From 68f77e4163db78bbc3740555591b95aad824d82c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 11 Nov 2009 08:14:37 +0100 Subject: oggflac: rewind stream after FLAC detection The oggflac plugin has been completely broken for quite a while and nobody has noticed - maybe we should remove it? --- src/decoder/oggflac_plugin.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/decoder') diff --git a/src/decoder/oggflac_plugin.c b/src/decoder/oggflac_plugin.c index fedfdcb48..c0e7e35e1 100644 --- a/src/decoder/oggflac_plugin.c +++ b/src/decoder/oggflac_plugin.c @@ -272,6 +272,10 @@ oggflac_tag_dup(const char *file) return NULL; } + /* rewind the stream, because ogg_stream_type_detect() has + moved it */ + input_stream_seek(&input_stream, 0, SEEK_SET); + flac_data_init(&data, NULL, &input_stream); data.tag = tag_new(); @@ -300,6 +304,10 @@ oggflac_decode(struct decoder * mpd_decoder, struct input_stream *input_stream) if (ogg_stream_type_detect(input_stream) != FLAC) return; + /* rewind the stream, because ogg_stream_type_detect() has + moved it */ + input_stream_seek(input_stream, 0, SEEK_SET); + flac_data_init(&data, mpd_decoder, input_stream); if (!(decoder = full_decoder_init_and_read_metadata(&data, 0))) { -- cgit v1.2.3 From dca4d9cf83849877206379a20a1e478ed1b5dc55 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 11 Nov 2009 08:55:55 +0100 Subject: decoder/flac: fixed CUE seeking range check If flac_container_decode() gets a seek destination which is out of range, it ignores the SEEK command (never finishes it). This leads to MPD lockup, because the player thread waits for completion. --- src/decoder/flac_plugin.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'src/decoder') diff --git a/src/decoder/flac_plugin.c b/src/decoder/flac_plugin.c index 1d5d48d09..0c0d994b7 100644 --- a/src/decoder/flac_plugin.c +++ b/src/decoder/flac_plugin.c @@ -629,21 +629,15 @@ flac_container_decode(struct decoder* decoder, FLAC__uint64 seek_sample = t_start + (decoder_seek_where(decoder) * data.audio_format.sample_rate); - //if (seek_sample >= t_start && seek_sample <= t_end && data.total_time > 30) - if (seek_sample >= t_start && seek_sample <= t_end) - { - if (flac_seek_absolute(flac_dec, (FLAC__uint64)seek_sample)) - { - data.time = (float)(seek_sample - t_start) / - data.audio_format.sample_rate; - data.position = 0; + if (seek_sample >= t_start && seek_sample <= t_end && + flac_seek_absolute(flac_dec, (FLAC__uint64)seek_sample)) { + data.time = (float)(seek_sample - t_start) / + data.audio_format.sample_rate; + data.position = 0; - decoder_command_finished(decoder); - } - else - decoder_seek_error(decoder); - //decoder_command_finished(decoder); - } + decoder_command_finished(decoder); + } else + decoder_seek_error(decoder); } else if (flac_get_state(flac_dec) == flac_decoder_eof) break; -- cgit v1.2.3