aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder_control.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/decoder_control.h')
-rw-r--r--src/decoder_control.h38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/decoder_control.h b/src/decoder_control.h
index d03c7a805..38c4f0d83 100644
--- a/src/decoder_control.h
+++ b/src/decoder_control.h
@@ -72,14 +72,22 @@ struct decoder_control {
/** the format being sent to the music pipe */
struct audio_format out_audio_format;
- struct song *current_song;
- struct song *next_song;
+ /**
+ * 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;
+
float total_time;
/** the #music_chunk allocator */
struct music_buffer *buffer;
- /** the destination pipe for decoded chunks */
+ /**
+ * The destination pipe for decoded chunks. The caller thread
+ * owns this object, and is responsible for freeing it.
+ */
struct music_pipe *pipe;
};
@@ -132,16 +140,14 @@ decoder_signal(struct decoder_control *dc)
static inline bool
decoder_is_idle(const struct decoder_control *dc)
{
- return (dc->state == DECODE_STATE_STOP ||
- dc->state == DECODE_STATE_ERROR) &&
- dc->command != DECODE_COMMAND_START;
+ return dc->state == DECODE_STATE_STOP ||
+ dc->state == DECODE_STATE_ERROR;
}
static inline bool
decoder_is_starting(const struct decoder_control *dc)
{
- return dc->command == DECODE_COMMAND_START ||
- dc->state == DECODE_STATE_START;
+ return dc->state == DECODE_STATE_START;
}
static inline bool
@@ -198,7 +204,7 @@ decoder_current_song(const struct decoder_control *dc)
case DECODE_STATE_START:
case DECODE_STATE_DECODE:
- return dc->current_song;
+ return dc->song;
}
assert(false);
@@ -208,11 +214,17 @@ decoder_current_song(const struct decoder_control *dc)
void
dc_command_wait(struct decoder_control *dc);
+/**
+ * Start the decoder.
+ *
+ * @param the decoder
+ * @param song the song to be decoded
+ * @param pipe the pipe which receives the decoded chunks (owned by
+ * the caller)
+ */
void
-dc_start(struct decoder_control *dc, struct song *song);
-
-void
-dc_start_async(struct decoder_control *dc, struct song *song);
+dc_start(struct decoder_control *dc, struct song *song,
+ struct music_buffer *buffer, struct music_pipe *pipe);
void
dc_stop(struct decoder_control *dc);