1
/*
2
 * Copyright 2008-2011 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 _PLAYER_H
20
#define _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_callbacks {
53
	int (*get_next)(struct track_info **ti);
54
};
55
56
struct player_info {
57
	pthread_mutex_t mutex;
58
59
	/* current track */
60
	struct track_info *ti;
61
62
	/* stream metadata */
63
	char metadata[255 * 16 + 1];
64
65
	/* status */
66
	enum player_status status;
67
	int pos;
68
	int current_bitrate;
69
70
	int buffer_fill;
71
	int buffer_size;
72
73
	/* display this if not NULL */
74
	char *error_msg;
75
76
	unsigned int file_changed : 1;
77
	unsigned int metadata_changed : 1;
78
	unsigned int status_changed : 1;
79
	unsigned int position_changed : 1;
80
	unsigned int buffer_fill_changed : 1;
81
};
82
83
extern struct player_info player_info;
84
extern int player_cont;
85
extern int player_repeat_current;
86
extern enum replaygain replaygain;
87
extern int replaygain_limit;
88
extern double replaygain_preamp;
89
extern int soft_vol;
90
extern int soft_vol_l;
91
extern int soft_vol_r;
92
93
void player_init(const struct player_callbacks *callbacks);
94
void player_exit(void);
95
96
/* set current file */
97
void player_set_file(struct track_info *ti);
98
99
/* set current file and start playing */
100
void player_play_file(struct track_info *ti);
101
102
/* update track info */
103
void player_file_changed(struct track_info *ti);
104
105
void player_play(void);
106
void player_stop(void);
107
void player_pause(void);
108
void player_seek(double offset, int relative, int start_playing);
109
void player_set_op(const char *name);
110
void player_set_buffer_chunks(unsigned int nr_chunks);
111
int player_get_buffer_chunks(void);
112
113
void player_set_soft_volume(int l, int r);
114
void player_set_soft_vol(int soft);
115
void player_set_rg(enum replaygain rg);
116
void player_set_rg_limit(int limit);
117
void player_set_rg_preamp(double db);
118
119
#define player_info_lock() cmus_mutex_lock(&player_info.mutex)
120
#define player_info_unlock() cmus_mutex_unlock(&player_info.mutex)
121
122
#endif