diff options
Diffstat (limited to 'src/decoder_control.h')
-rw-r--r-- | src/decoder_control.h | 246 |
1 files changed, 123 insertions, 123 deletions
diff --git a/src/decoder_control.h b/src/decoder_control.h index 963e73ea..8f3fc948 100644 --- a/src/decoder_control.h +++ b/src/decoder_control.h @@ -28,96 +28,96 @@ #include <assert.h> enum decoder_state { - DECODE_STATE_STOP = 0, - DECODE_STATE_START, - DECODE_STATE_DECODE, - - /** - * The last "START" command failed, because there was an I/O - * error or because no decoder was able to decode the file. - * This state will only come after START; once the state has - * turned to DECODE, by definition no such error can occur. - */ - DECODE_STATE_ERROR, + DECODE_STATE_STOP = 0, + DECODE_STATE_START, + DECODE_STATE_DECODE, + + /** + * The last "START" command failed, because there was an I/O + * error or because no decoder was able to decode the file. + * This state will only come after START; once the state has + * turned to DECODE, by definition no such error can occur. + */ + DECODE_STATE_ERROR, }; struct decoder_control { - /** the handle of the decoder thread, or NULL if the decoder - thread isn't running */ - GThread *thread; - - /** - * This lock protects #state and #command. - */ - GMutex *mutex; - - /** - * Trigger this object after you have modified #command. This - * is also used by the decoder thread to notify the caller - * when it has finished a command. - */ - GCond *cond; - - /** - * The trigger of this object's client. It is signalled - * whenever an event occurs. - */ - GCond *client_cond; - - enum decoder_state state; - enum decoder_command command; - - bool quit; - bool seek_error; - bool seekable; - double seek_where; - - /** the format of the song file */ - struct audio_format in_audio_format; - - /** the format being sent to the music pipe */ - struct audio_format out_audio_format; - - /** - * The song currently being decoded. This attribute is set by - * the player thread, when it sends the #DECODE_COMMAND_START - * command. - */ - const struct song *song; - - /** - * The initial seek position (in milliseconds), e.g. to the - * start of a sub-track described by a CUE file. - * - * This attribute is set by dc_start(). - */ - unsigned start_ms; - - /** - * The decoder will stop when it reaches this position (in - * milliseconds). 0 means don't stop before the end of the - * file. - * - * This attribute is set by dc_start(). - */ - unsigned end_ms; - - float total_time; - - /** maximum number of samples to keep buffered */ - int buffer_samples; - - /** - * The destination pipe for decoded chunks. The caller thread - * owns this object, and is responsible for freeing it. - */ - struct music_pipe *pipe; - - float replay_gain_db; - float replay_gain_prev_db; - char *mixramp_start; - char *mixramp_end; - char *mixramp_prev_end; + /** the handle of the decoder thread, or NULL if the decoder + thread isn't running */ + GThread *thread; + + /** + * This lock protects #state and #command. + */ + GMutex *mutex; + + /** + * Trigger this object after you have modified #command. This + * is also used by the decoder thread to notify the caller + * when it has finished a command. + */ + GCond *cond; + + /** + * The trigger of this object's client. It is signalled + * whenever an event occurs. + */ + GCond *client_cond; + + enum decoder_state state; + enum decoder_command command; + + bool quit; + bool seek_error; + bool seekable; + double seek_where; + + /** the format of the song file */ + struct audio_format in_audio_format; + + /** the format being sent to the music pipe */ + struct audio_format out_audio_format; + + /** + * The song currently being decoded. This attribute is set by + * the player thread, when it sends the #DECODE_COMMAND_START + * command. + */ + const struct song *song; + + /** + * The initial seek position (in milliseconds), e.g. to the + * start of a sub-track described by a CUE file. + * + * This attribute is set by dc_start(). + */ + unsigned start_ms; + + /** + * The decoder will stop when it reaches this position (in + * milliseconds). 0 means don't stop before the end of the + * file. + * + * This attribute is set by dc_start(). + */ + unsigned end_ms; + + float total_time; + + /** maximum number of samples to keep buffered */ + int buffer_samples; + + /** + * The destination pipe for decoded chunks. The caller thread + * owns this object, and is responsible for freeing it. + */ + struct music_pipe *pipe; + + float replay_gain_db; + float replay_gain_prev_db; + char *mixramp_start; + char *mixramp_end; + char *mixramp_prev_end; }; G_GNUC_MALLOC @@ -133,7 +133,7 @@ dc_free(struct decoder_control *dc); static inline void decoder_lock(struct decoder_control *dc) { - g_mutex_lock(dc->mutex); + g_mutex_lock(dc->mutex); } /** @@ -142,7 +142,7 @@ decoder_lock(struct decoder_control *dc) static inline void decoder_unlock(struct decoder_control *dc) { - g_mutex_unlock(dc->mutex); + g_mutex_unlock(dc->mutex); } /** @@ -153,7 +153,7 @@ decoder_unlock(struct decoder_control *dc) static inline void decoder_wait(struct decoder_control *dc) { - g_cond_wait(dc->cond, dc->mutex); + g_cond_wait(dc->cond, dc->mutex); } /** @@ -164,81 +164,81 @@ decoder_wait(struct decoder_control *dc) static inline void decoder_signal(struct decoder_control *dc) { - g_cond_signal(dc->cond); + g_cond_signal(dc->cond); } static inline bool decoder_is_idle(const struct decoder_control *dc) { - return dc->state == DECODE_STATE_STOP || - dc->state == DECODE_STATE_ERROR; + return dc->state == DECODE_STATE_STOP || + dc->state == DECODE_STATE_ERROR; } static inline bool decoder_is_starting(const struct decoder_control *dc) { - return dc->state == DECODE_STATE_START; + return dc->state == DECODE_STATE_START; } static inline bool decoder_has_failed(const struct decoder_control *dc) { - assert(dc->command == DECODE_COMMAND_NONE); + assert(dc->command == DECODE_COMMAND_NONE); - return dc->state == DECODE_STATE_ERROR; + return dc->state == DECODE_STATE_ERROR; } static inline bool decoder_lock_is_idle(struct decoder_control *dc) { - bool ret; + bool ret; - decoder_lock(dc); - ret = decoder_is_idle(dc); - decoder_unlock(dc); + decoder_lock(dc); + ret = decoder_is_idle(dc); + decoder_unlock(dc); - return ret; + return ret; } static inline bool decoder_lock_is_starting(struct decoder_control *dc) { - bool ret; + bool ret; - decoder_lock(dc); - ret = decoder_is_starting(dc); - decoder_unlock(dc); + decoder_lock(dc); + ret = decoder_is_starting(dc); + decoder_unlock(dc); - return ret; + return ret; } static inline bool decoder_lock_has_failed(struct decoder_control *dc) { - bool ret; + bool ret; - decoder_lock(dc); - ret = decoder_has_failed(dc); - decoder_unlock(dc); + decoder_lock(dc); + ret = decoder_has_failed(dc); + decoder_unlock(dc); - return ret; + return ret; } static inline const struct song * decoder_current_song(const struct decoder_control *dc) { - switch (dc->state) { - case DECODE_STATE_STOP: - case DECODE_STATE_ERROR: - return NULL; - - case DECODE_STATE_START: - case DECODE_STATE_DECODE: - return dc->song; - } - - assert(false); - return NULL; + switch (dc->state) { + case DECODE_STATE_STOP: + case DECODE_STATE_ERROR: + return NULL; + + case DECODE_STATE_START: + case DECODE_STATE_DECODE: + return dc->song; + } + + assert(false); + return NULL; } /** |