45
46
thread isn't running */
50
volatile enum decoder_state state;
51
volatile enum decoder_command command;
50
* This lock protects #state and #command.
55
* Trigger this object after you have modified #command. This
56
* is also used by the decoder thread to notify the caller
57
* when it has finished a command.
61
enum decoder_state state;
62
enum decoder_command command;
55
volatile double seek_where;
57
69
/** the format of the song file */
58
70
struct audio_format in_audio_format;
60
72
/** the format being sent to the music pipe */
61
73
struct audio_format out_audio_format;
63
struct song *current_song;
64
struct song *next_song;
76
* The song currently being decoded. This attribute is set by
77
* the player thread, when it sends the #DECODE_COMMAND_START
80
const struct song *song;
67
84
/** the #music_chunk allocator */
68
85
struct music_buffer *buffer;
70
/** the destination pipe for decoded chunks */
88
* The destination pipe for decoded chunks. The caller thread
89
* owns this object, and is responsible for freeing it.
71
91
struct music_pipe *pipe;
94
float replay_gain_prev_db;
97
char *mixramp_prev_end;
74
extern struct decoder_control dc;
80
static inline bool decoder_is_idle(void)
82
return (dc.state == DECODE_STATE_STOP ||
83
dc.state == DECODE_STATE_ERROR) &&
84
dc.command != DECODE_COMMAND_START;
87
static inline bool decoder_is_starting(void)
89
return dc.command == DECODE_COMMAND_START ||
90
dc.state == DECODE_STATE_START;
93
static inline bool decoder_has_failed(void)
95
assert(dc.command == DECODE_COMMAND_NONE);
97
return dc.state == DECODE_STATE_ERROR;
100
static inline struct song *
101
decoder_current_song(void)
101
dc_init(struct decoder_control *dc);
104
dc_deinit(struct decoder_control *dc);
107
* Locks the #decoder_control object.
110
decoder_lock(struct decoder_control *dc)
112
g_mutex_lock(dc->mutex);
116
* Unlocks the #decoder_control object.
119
decoder_unlock(struct decoder_control *dc)
121
g_mutex_unlock(dc->mutex);
125
* Waits for a signal on the #decoder_control object. This function
126
* is only valid in the decoder thread. The object must be locked
127
* prior to calling this function.
130
decoder_wait(struct decoder_control *dc)
132
g_cond_wait(dc->cond, dc->mutex);
136
* Signals the #decoder_control object. This function is only valid
137
* in the player thread. The object should be locked prior to calling
141
decoder_signal(struct decoder_control *dc)
143
g_cond_signal(dc->cond);
147
decoder_is_idle(const struct decoder_control *dc)
149
return dc->state == DECODE_STATE_STOP ||
150
dc->state == DECODE_STATE_ERROR;
154
decoder_is_starting(const struct decoder_control *dc)
156
return dc->state == DECODE_STATE_START;
160
decoder_has_failed(const struct decoder_control *dc)
162
assert(dc->command == DECODE_COMMAND_NONE);
164
return dc->state == DECODE_STATE_ERROR;
168
decoder_lock_is_idle(struct decoder_control *dc)
173
ret = decoder_is_idle(dc);
180
decoder_lock_is_starting(struct decoder_control *dc)
185
ret = decoder_is_starting(dc);
192
decoder_lock_has_failed(struct decoder_control *dc)
197
ret = decoder_has_failed(dc);
203
static inline const struct song *
204
decoder_current_song(const struct decoder_control *dc)
104
207
case DECODE_STATE_STOP:
105
208
case DECODE_STATE_ERROR:
108
211
case DECODE_STATE_START:
109
212
case DECODE_STATE_DECODE:
110
return dc.current_song;
118
dc_command_wait(struct notify *notify);
121
dc_start(struct notify *notify, struct song *song, struct music_pipe *pipe);
124
dc_start_async(struct song *song, struct music_pipe *pipe);
127
dc_stop(struct notify *notify);
221
dc_command_wait(struct decoder_control *dc);
227
* @param song the song to be decoded
228
* @param pipe the pipe which receives the decoded chunks (owned by
232
dc_start(struct decoder_control *dc, struct song *song,
233
struct music_buffer *buffer, struct music_pipe *pipe);
236
dc_stop(struct decoder_control *dc);
130
dc_seek(struct notify *notify, double where);
239
dc_seek(struct decoder_control *dc, double where);
242
dc_quit(struct decoder_control *dc);
245
dc_mixramp_start(struct decoder_control *dc, char *mixramp_start);
248
dc_mixramp_end(struct decoder_control *dc, char *mixramp_end);
251
dc_mixramp_prev_end(struct decoder_control *dc, char *mixramp_prev_end);