decoder/faad: check InputStream::KnownSize()
Replace the bogus GetSize() check and call GetSize() only when necessary.
This commit is contained in:
parent
7a929fcd27
commit
e88524f274
@ -112,8 +112,7 @@ adts_song_duration(DecoderBuffer *buffer)
|
|||||||
{
|
{
|
||||||
const InputStream &is = decoder_buffer_get_stream(buffer);
|
const InputStream &is = decoder_buffer_get_stream(buffer);
|
||||||
const bool estimate = !is.CheapSeeking();
|
const bool estimate = !is.CheapSeeking();
|
||||||
const auto file_size = is.GetSize();
|
if (estimate && !is.KnownSize())
|
||||||
if (estimate && file_size <= 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
unsigned sample_rate = 0;
|
unsigned sample_rate = 0;
|
||||||
@ -149,6 +148,7 @@ adts_song_duration(DecoderBuffer *buffer)
|
|||||||
if (offset <= 0)
|
if (offset <= 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
const auto file_size = is.GetSize();
|
||||||
frames = (frames * file_size) / offset;
|
frames = (frames * file_size) / offset;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -202,6 +202,10 @@ faad_song_duration(DecoderBuffer *buffer, InputStream &is)
|
|||||||
return song_length;
|
return song_length;
|
||||||
} else if (data.size >= 5 && memcmp(data.data, "ADIF", 4) == 0) {
|
} else if (data.size >= 5 && memcmp(data.data, "ADIF", 4) == 0) {
|
||||||
/* obtain the duration from the ADIF header */
|
/* obtain the duration from the ADIF header */
|
||||||
|
|
||||||
|
if (!is.KnownSize())
|
||||||
|
return -1;
|
||||||
|
|
||||||
size_t skip_size = (data.data[4] & 0x80) ? 9 : 0;
|
size_t skip_size = (data.data[4] & 0x80) ? 9 : 0;
|
||||||
|
|
||||||
if (8 + skip_size > data.size)
|
if (8 + skip_size > data.size)
|
||||||
|
Loading…
Reference in New Issue
Block a user