mfaudioenc: Handle empty IMFMediaBuffer

IMFMediaBuffer may not hold encoded data, which seems to happen
while draining.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1679>
This commit is contained in:
Seungha Yang 2022-02-10 01:48:23 +09:00
parent 1b22ffdfbd
commit 090b50e549

View file

@ -244,12 +244,12 @@ gst_mf_audio_enc_process_output (GstMFAudioEnc * self)
{
GstMFAudioEncClass *klass = GST_MF_AUDIO_ENC_GET_CLASS (self);
HRESULT hr;
BYTE *data;
BYTE *data = nullptr;
ComPtr < IMFMediaBuffer > media_buffer;
ComPtr < IMFSample > sample;
GstBuffer *buffer;
GstFlowReturn res = GST_FLOW_ERROR;
DWORD buffer_len;
DWORD buffer_len = 0;
res = gst_mf_transform_get_output (self->transform, sample.GetAddressOf ());
@ -264,6 +264,13 @@ gst_mf_audio_enc_process_output (GstMFAudioEnc * self)
if (!gst_mf_result (hr))
return GST_FLOW_ERROR;
/* Can happen while draining */
if (buffer_len == 0 || !data) {
GST_DEBUG_OBJECT (self, "Empty media buffer");
media_buffer->Unlock ();
return GST_FLOW_OK;
}
buffer = gst_audio_encoder_allocate_output_buffer (GST_AUDIO_ENCODER (self),
buffer_len);
gst_buffer_fill (buffer, 0, data, buffer_len);