Let the wanted sample size go down to 0

This commit is contained in:
Chris Robinson 2012-12-14 06:02:34 -08:00
parent 05c6483257
commit 7332ffb0f8

View file

@ -178,13 +178,10 @@ class MovieAudioDecoder : public MWSound::Sound_Decoder
int n = av_samples_get_buffer_size(NULL, is->audio_st->codec->channels, 1,
is->audio_st->codec->sample_fmt, 1);
int wanted_size = samples_size + ((int)(diff * is->audio_st->codec->sample_rate) * n);
int min_size = samples_size/n * (100-SAMPLE_CORRECTION_PERCENT_MAX) / 100 * n;
int max_size = samples_size/n * (100+SAMPLE_CORRECTION_PERCENT_MAX) / 100 * n;
if(wanted_size < min_size)
wanted_size = min_size;
else if (wanted_size > max_size)
wanted_size = max_size;
wanted_size = std::max(0, wanted_size);
wanted_size = std::min(wanted_size, max_size);
if(wanted_size < samples_size)
{