decoder/audiofile: use audiofile_get_duration() in _stream_decode()

This commit is contained in:
Max Kellermann 2014-07-10 08:35:24 +02:00
parent 2e1347aba4
commit 1d214b4aed

View File

@ -186,10 +186,9 @@ static void
audiofile_stream_decode(Decoder &decoder, InputStream &is) audiofile_stream_decode(Decoder &decoder, InputStream &is)
{ {
AFvirtualfile *vf; AFvirtualfile *vf;
int fs, frame_count; int fs;
AFfilehandle af_fp; AFfilehandle af_fp;
AudioFormat audio_format; AudioFormat audio_format;
float total_time;
uint16_t bit_rate; uint16_t bit_rate;
int ret; int ret;
char chunk[CHUNK_SIZE]; char chunk[CHUNK_SIZE];
@ -219,9 +218,7 @@ audiofile_stream_decode(Decoder &decoder, InputStream &is)
return; return;
} }
frame_count = afGetFrameCount(af_fp, AF_DEFAULT_TRACK); const double total_time = audiofile_get_duration(af_fp);
total_time = ((float)frame_count / (float)audio_format.sample_rate);
bit_rate = (uint16_t)(is.GetSize() * 8.0 / total_time / 1000.0 + 0.5); bit_rate = (uint16_t)(is.GetSize() * 8.0 / total_time / 1000.0 + 0.5);