Bug 996853: handle AUDIO_FORMAT_SILENCE in MediaPipeline and AudioSegment::WriteTo r=roc

This commit is contained in:
Randell Jesup 2014-04-17 17:45:25 -04:00
Родитель 86f7e1e45e
Коммит dd18e038e2
2 изменённых файлов: 5 добавлений и 4 удалений

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

@ -175,7 +175,7 @@ AudioSegment::WriteTo(uint64_t aID, AudioStream* aOutput, AudioMixer* aMixer)
// To avoid overbuffering in the AudioStream, we simply drop the silence,
// here. The stream will underrun and output silence anyways.
if (c.mBuffer || aOutput->GetWritten()) {
if (c.mBuffer) {
if (c.mBuffer && c.mBufferFormat != AUDIO_FORMAT_SILENCE) {
channelData.SetLength(c.mChannelData.Length());
for (uint32_t i = 0; i < channelData.Length(); ++i) {
channelData[i] = c.mChannelData[i];

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

@ -1010,6 +1010,9 @@ void MediaPipelineTransmit::PipelineListener::ProcessAudioChunk(
ConvertAudioSamplesWithScale(buf, samples, chunk.mDuration, chunk.mVolume);
}
break;
case AUDIO_FORMAT_SILENCE:
memset(samples, 0, chunk.mDuration * sizeof(samples[0]));
break;
default:
MOZ_ASSERT(PR_FALSE);
return;
@ -1017,9 +1020,7 @@ void MediaPipelineTransmit::PipelineListener::ProcessAudioChunk(
}
} else {
// This means silence.
for (uint32_t i = 0; i < chunk.mDuration; ++i) {
samples[i] = 0;
}
memset(samples, 0, chunk.mDuration * sizeof(samples[0]));
}
MOZ_ASSERT(!(rate%100)); // rate should be a multiple of 100