b=938450 process all input samples in decodeAudioData r=padenot

--HG--
extra : transplant_source : %01%B2%FE%DA%BE%2CcX%B9%A7%60%15%FB%08%C5%2AS%99%B28
This commit is contained in:
Karl Tomlinson 2013-12-03 12:09:01 +13:00
Родитель 3d689d137a
Коммит b56423c2be
1 изменённых файлов: 7 добавлений и 9 удалений

Просмотреть файл

@ -346,15 +346,11 @@ MediaDecodeTask::Decode()
(audioData->mAudioBuffer->Data());
if (sampleRate != destSampleRate) {
const uint32_t expectedOutSamples = static_cast<uint32_t>(
static_cast<uint64_t>(destSampleRate) *
static_cast<uint64_t>(audioData->mFrames) /
static_cast<uint64_t>(sampleRate)
);
const uint32_t maxOutSamples = resampledFrames - mDecodeJob.mWriteIndex;
for (uint32_t i = 0; i < audioData->mChannels; ++i) {
uint32_t inSamples = audioData->mFrames;
uint32_t outSamples = expectedOutSamples;
uint32_t outSamples = maxOutSamples;
WebAudioUtils::SpeexResamplerProcess(
resampler, i, &bufferData[i * audioData->mFrames], &inSamples,
@ -364,6 +360,7 @@ MediaDecodeTask::Decode()
if (i == audioData->mChannels - 1) {
mDecodeJob.mWriteIndex += outSamples;
MOZ_ASSERT(mDecodeJob.mWriteIndex <= resampledFrames);
MOZ_ASSERT(inSamples == audioData->mFrames);
}
}
} else {
@ -380,11 +377,11 @@ MediaDecodeTask::Decode()
}
if (sampleRate != destSampleRate) {
int inputLatency = speex_resampler_get_input_latency(resampler);
int outputLatency = speex_resampler_get_output_latency(resampler);
uint32_t inputLatency = speex_resampler_get_input_latency(resampler);
const uint32_t maxOutSamples = resampledFrames - mDecodeJob.mWriteIndex;
for (uint32_t i = 0; i < channelCount; ++i) {
uint32_t inSamples = inputLatency;
uint32_t outSamples = outputLatency;
uint32_t outSamples = maxOutSamples;
WebAudioUtils::SpeexResamplerProcess(
resampler, i, (AudioDataValue*)nullptr, &inSamples,
@ -394,6 +391,7 @@ MediaDecodeTask::Decode()
if (i == channelCount - 1) {
mDecodeJob.mWriteIndex += outSamples;
MOZ_ASSERT(mDecodeJob.mWriteIndex <= resampledFrames);
MOZ_ASSERT(inSamples == inputLatency);
}
}
}