1 /*
2  * Copyright 2008-2013 Various Authors
3  * Copyright 2004 Timo Hirvonen
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef CMUS_PLAYER_H
20 #define CMUS_PLAYER_H
21 
22 #include "locking.h"
23 #include "track_info.h"
24 
25 #include <pthread.h>
26 
27 enum {
28 	/* no error */
29 	PLAYER_ERROR_SUCCESS,
30 	/* system error (error code in errno) */
31 	PLAYER_ERROR_ERRNO,
32 	/* function not supported */
33 	PLAYER_ERROR_NOT_SUPPORTED
34 };
35 
36 extern const char * const player_status_names[];
37 enum player_status {
38 	PLAYER_STATUS_STOPPED,
39 	PLAYER_STATUS_PLAYING,
40 	PLAYER_STATUS_PAUSED,
41 	NR_PLAYER_STATUS
42 };
43 
44 enum replaygain {
45 	RG_DISABLED,
46 	RG_TRACK,
47 	RG_ALBUM,
48 	RG_TRACK_PREFERRED,
49 	RG_ALBUM_PREFERRED
50 };
51 
52 struct player_info {
53 	/* current track */
54 	struct track_info *ti;
55 
56 	/* status */
57 	enum player_status status;
58 	int pos;
59 	int current_bitrate;
60 
61 	int buffer_fill;
62 	int buffer_size;
63 
64 	/* display this if not NULL */
65 	char *error_msg;
66 
67 	unsigned int file_changed : 1;
68 	unsigned int metadata_changed : 1;
69 	unsigned int status_changed : 1;
70 	unsigned int position_changed : 1;
71 	unsigned int buffer_fill_changed : 1;
72 };
73 
74 extern char player_metadata[255 * 16 + 1];
75 extern struct player_info player_info;
76 extern int player_cont;
77 extern int player_cont_album;
78 extern int player_repeat_current;
79 extern enum replaygain replaygain;
80 extern int replaygain_limit;
81 extern double replaygain_preamp;
82 extern int soft_vol;
83 extern int soft_vol_l;
84 extern int soft_vol_r;
85 
86 void player_init(void);
87 void player_exit(void);
88 
89 /* set current file */
90 void player_set_file(struct track_info *ti);
91 
92 /* set current file and start playing */
93 void player_play_file(struct track_info *ti);
94 
95 /* update track info */
96 void player_file_changed(struct track_info *ti);
97 
98 void player_play(void);
99 void player_stop(void);
100 void player_pause(void);
101 void player_pause_playback(void);
102 void player_seek(double offset, int relative, int start_playing);
103 void player_set_op(const char *name);
104 void player_set_buffer_chunks(unsigned int nr_chunks);
105 int player_get_buffer_chunks(void);
106 void player_info_snapshot(void);
107 
108 void player_set_soft_volume(int l, int r);
109 void player_set_soft_vol(int soft);
110 void player_set_rg(enum replaygain rg);
111 void player_set_rg_limit(int limit);
112 void player_set_rg_preamp(double db);
113 
114 #define VF_RELATIVE	0x01
115 #define VF_PERCENTAGE	0x02
116 int player_set_vol(int l, int lf, int r, int rf);
117 
118 void player_metadata_lock(void);
119 void player_metadata_unlock(void);
120 
121 #endif
122