diff --git a/media/gpu/windows/mf_audio_encoder.cc b/media/gpu/windows/mf_audio_encoder.cc --- a/media/gpu/windows/mf_audio_encoder.cc +++ b/media/gpu/windows/mf_audio_encoder.cc @@ -327,11 +327,15 @@ HRESULT GetSampleBuffer(const DWORD required_size, DWORD buffer_capacity; RETURN_IF_FAILED(buffer->GetMaxLength(&buffer_capacity)); - if (buffer_capacity < required_size) + if (buffer_capacity < required_size) { need_buffer_allocation = true; + // Replace, don't append: drop the too-small buffer(s) so the sample + // contains exactly one buffer that the MFT writes into and we read from. + RETURN_IF_FAILED(sample->RemoveAllBuffers()); + } } if (need_buffer_allocation) { RETURN_IF_FAILED( MFCreateAlignedMemoryBuffer(required_size, buffer_alignment, &buffer)); RETURN_IF_FAILED(sample->AddBuffer(buffer.Get())); }