зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1400674 - P1: fix the algorithm of filling audio gaps with silence. r=jya
MozReview-Commit-ID: Hjsboq6PdlN --HG-- extra : rebase_source : 639e1f4fcb96b6080133fced25ed304152e515af
This commit is contained in:
Родитель
5668671730
Коммит
3705c2d6bb
|
@ -424,28 +424,21 @@ AudioSink::NotifyAudioNeeded()
|
|||
missingFrames = std::min<int64_t>(INT32_MAX, missingFrames.value());
|
||||
mFramesParsed += missingFrames.value();
|
||||
|
||||
// We need to calculate how many frames are missing at the output rate.
|
||||
missingFrames =
|
||||
SaferMultDiv(missingFrames.value(), mOutputRate, data->mRate);
|
||||
if (!missingFrames.isValid()) {
|
||||
NS_WARNING("Int overflow in AudioSink");
|
||||
mErrored = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// We need to insert silence, first use drained frames if any.
|
||||
missingFrames -= DrainConverter(missingFrames.value());
|
||||
// Insert silence if still needed.
|
||||
if (missingFrames.value()) {
|
||||
AlignedAudioBuffer silenceData(missingFrames.value() * mOutputChannels);
|
||||
if (!silenceData) {
|
||||
NS_WARNING("OOM in AudioSink");
|
||||
mErrored = true;
|
||||
return;
|
||||
}
|
||||
RefPtr<AudioData> silence = CreateAudioFromBuffer(Move(silenceData), data);
|
||||
PushProcessedAudio(silence);
|
||||
RefPtr<AudioData> silenceData;
|
||||
AlignedAudioBuffer silenceBuffer(missingFrames.value() * data->mChannels);
|
||||
if (!silenceBuffer) {
|
||||
NS_WARNING("OOM in AudioSink");
|
||||
mErrored = true;
|
||||
return;
|
||||
}
|
||||
if (mConverter->InputConfig() != mConverter->OutputConfig()) {
|
||||
AlignedAudioBuffer convertedData =
|
||||
mConverter->Process(AudioSampleBuffer(Move(silenceBuffer))).Forget();
|
||||
silenceData = CreateAudioFromBuffer(Move(convertedData), data);
|
||||
} else {
|
||||
silenceData = CreateAudioFromBuffer(Move(silenceBuffer), data);
|
||||
}
|
||||
PushProcessedAudio(silenceData);
|
||||
}
|
||||
|
||||
mLastEndTime = data->GetEndTime();
|
||||
|
@ -486,7 +479,7 @@ AudioSink::PushProcessedAudio(AudioData* aData)
|
|||
|
||||
already_AddRefed<AudioData>
|
||||
AudioSink::CreateAudioFromBuffer(AlignedAudioBuffer&& aBuffer,
|
||||
AudioData* aReference)
|
||||
AudioData* aReference)
|
||||
{
|
||||
uint32_t frames = aBuffer.Length() / mOutputChannels;
|
||||
if (!frames) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче