aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-08-19 20:26:12 +0200
committerMax Kellermann <max@duempel.org>2014-08-19 20:44:29 +0200
commite88524f274093d594978297ff28999daf1d19416 (patch)
tree59fbc703a281f72f89def84f8d83db35c8dee4ca /src
parent7a929fcd2738c27455286b170f7ef058622ef39d (diff)
downloadmpd-e88524f274093d594978297ff28999daf1d19416.tar.gz
mpd-e88524f274093d594978297ff28999daf1d19416.tar.xz
mpd-e88524f274093d594978297ff28999daf1d19416.zip
decoder/faad: check InputStream::KnownSize()
Replace the bogus GetSize() check and call GetSize() only when necessary.
Diffstat (limited to 'src')
-rw-r--r--src/decoder/plugins/FaadDecoderPlugin.cxx8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/decoder/plugins/FaadDecoderPlugin.cxx b/src/decoder/plugins/FaadDecoderPlugin.cxx
index af63553eb..21351f2ba 100644
--- a/src/decoder/plugins/FaadDecoderPlugin.cxx
+++ b/src/decoder/plugins/FaadDecoderPlugin.cxx
@@ -112,8 +112,7 @@ adts_song_duration(DecoderBuffer *buffer)
{
const InputStream &is = decoder_buffer_get_stream(buffer);
const bool estimate = !is.CheapSeeking();
- const auto file_size = is.GetSize();
- if (estimate && file_size <= 0)
+ if (estimate && !is.KnownSize())
return -1;
unsigned sample_rate = 0;
@@ -149,6 +148,7 @@ adts_song_duration(DecoderBuffer *buffer)
if (offset <= 0)
return -1;
+ const auto file_size = is.GetSize();
frames = (frames * file_size) / offset;
break;
}
@@ -202,6 +202,10 @@ faad_song_duration(DecoderBuffer *buffer, InputStream &is)
return song_length;
} else if (data.size >= 5 && memcmp(data.data, "ADIF", 4) == 0) {
/* obtain the duration from the ADIF header */
+
+ if (!is.KnownSize())
+ return -1;
+
size_t skip_size = (data.data[4] & 0x80) ? 9 : 0;
if (8 + skip_size > data.size)