From f185b35088cc5b1025c3e60b5f72030627e79878 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 4 Oct 2011 22:07:01 +0200 Subject: decoder_api: clear initial_seek_running on error Fixes possible assertion failure. --- src/decoder_api.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/decoder_api.c') diff --git a/src/decoder_api.c b/src/decoder_api.c index 99c02db87..f0ba3b01f 100644 --- a/src/decoder_api.c +++ b/src/decoder_api.c @@ -180,10 +180,12 @@ void decoder_seek_error(struct decoder * decoder) assert(dc->pipe != NULL); - if (decoder->initial_seek_running) + if (decoder->initial_seek_running) { /* d'oh, we can't seek to the sub-song start position, what now? - no idea, ignoring the problem for now. */ + decoder->initial_seek_running = false; return; + } assert(dc->command == DECODE_COMMAND_SEEK); -- cgit v1.2.3 From 99d4ae0c1ae5522202d71381b40f55418e7d531a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 5 Oct 2011 22:53:36 +0200 Subject: decoder_api: don't copy tag to pipe during initial seek Fixes one more assertion failure. --- src/decoder_api.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/decoder_api.c') diff --git a/src/decoder_api.c b/src/decoder_api.c index f0ba3b01f..bbe93eef0 100644 --- a/src/decoder_api.c +++ b/src/decoder_api.c @@ -438,6 +438,14 @@ decoder_tag(G_GNUC_UNUSED struct decoder *decoder, struct input_stream *is, update_stream_tag(decoder, is); + /* check if we're seeking */ + + if (decoder->initial_seek_pending) + /* during initial seek, no music chunk must be created + until seeking is finished; skip the rest of the + function here */ + return DECODE_COMMAND_SEEK; + /* send tag to music pipe */ if (decoder->stream_tag != NULL) { @@ -451,9 +459,6 @@ decoder_tag(G_GNUC_UNUSED struct decoder *decoder, struct input_stream *is, /* send only the decoder tag */ cmd = do_send_tag(decoder, is, tag); - if (cmd == DECODE_COMMAND_NONE) - cmd = decoder_get_virtual_command(decoder); - return cmd; } -- cgit v1.2.3 From 64b0ba6da7975fdde774f188b1647ab6c9024cfa Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 5 Oct 2011 22:37:59 +0200 Subject: decoder_control: add attributes start_ms, end_ms Don't read song.start_ms and song.end_ms, let the player thread manage this logic instead. --- src/decoder_api.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/decoder_api.c') diff --git a/src/decoder_api.c b/src/decoder_api.c index bbe93eef0..bec271179 100644 --- a/src/decoder_api.c +++ b/src/decoder_api.c @@ -132,7 +132,7 @@ decoder_command_finished(struct decoder *decoder) assert(music_pipe_empty(dc->pipe)); decoder->initial_seek_running = false; - decoder->timestamp = dc->song->start_ms / 1000.; + decoder->timestamp = dc->start_ms / 1000.; decoder_unlock(dc); return; } @@ -165,7 +165,7 @@ double decoder_seek_where(G_GNUC_UNUSED struct decoder * decoder) assert(dc->pipe != NULL); if (decoder->initial_seek_running) - return dc->song->start_ms / 1000.; + return dc->start_ms / 1000.; assert(dc->command == DECODE_COMMAND_SEEK); @@ -407,8 +407,8 @@ decoder_data(struct decoder *decoder, decoder->timestamp += (double)nbytes / audio_format_time_to_size(&dc->out_audio_format); - if (dc->song->end_ms > 0 && - decoder->timestamp >= dc->song->end_ms / 1000.0) + if (dc->end_ms > 0 && + decoder->timestamp >= dc->end_ms / 1000.0) /* the end of this range has been reached: stop decoding */ return DECODE_COMMAND_STOP; -- cgit v1.2.3 From e07073ff286ed22d4859aba3584285586c7781c8 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 6 Oct 2011 00:25:44 +0200 Subject: decoder_api: move code to _prepare_initial_seek() .. and add a few code comments. --- src/decoder_api.c | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'src/decoder_api.c') diff --git a/src/decoder_api.c b/src/decoder_api.c index bec271179..3e4917508 100644 --- a/src/decoder_api.c +++ b/src/decoder_api.c @@ -79,30 +79,54 @@ decoder_initialized(struct decoder *decoder, } /** - * Returns the current decoder command. May return a "virtual" - * synthesized command, e.g. to seek to the beginning of the CUE - * track. + * Checks if we need an "initial seek". If so, then the initial seek + * is prepared, and the function returns true. */ G_GNUC_PURE -static enum decoder_command -decoder_get_virtual_command(struct decoder *decoder) +static bool +decoder_prepare_initial_seek(struct decoder *decoder) { const struct decoder_control *dc = decoder->dc; assert(dc->pipe != NULL); if (decoder->initial_seek_running) - return DECODE_COMMAND_SEEK; + /* initial seek has already begun - override any other + command */ + return true; if (decoder->initial_seek_pending) { if (dc->command == DECODE_COMMAND_NONE) { + /* begin initial seek */ + decoder->initial_seek_pending = false; decoder->initial_seek_running = true; - return DECODE_COMMAND_SEEK; + return true; } + /* skip initial seek when there's another command + (e.g. STOP) */ + decoder->initial_seek_pending = false; } + return false; +} + +/** + * Returns the current decoder command. May return a "virtual" + * synthesized command, e.g. to seek to the beginning of the CUE + * track. + */ +G_GNUC_PURE +static enum decoder_command +decoder_get_virtual_command(struct decoder *decoder) +{ + const struct decoder_control *dc = decoder->dc; + assert(dc->pipe != NULL); + + if (decoder_prepare_initial_seek(decoder)) + return DECODE_COMMAND_SEEK; + return dc->command; } -- cgit v1.2.3 From f67136df1951031a0561383b4421afc0328031d0 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 6 Oct 2011 00:35:45 +0200 Subject: decoder_api: call _prepare_initial_seek() in decoder_tag() This checks both conditions: pending and running. Fixes yet another assertion failure! --- src/decoder_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/decoder_api.c') diff --git a/src/decoder_api.c b/src/decoder_api.c index 3e4917508..6dcca32c2 100644 --- a/src/decoder_api.c +++ b/src/decoder_api.c @@ -464,7 +464,7 @@ decoder_tag(G_GNUC_UNUSED struct decoder *decoder, struct input_stream *is, /* check if we're seeking */ - if (decoder->initial_seek_pending) + if (decoder_prepare_initial_seek(decoder)) /* during initial seek, no music chunk must be created until seeking is finished; skip the rest of the function here */ -- cgit v1.2.3