mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
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:
parent
1b22ffdfbd
commit
090b50e549
1 changed files with 9 additions and 2 deletions
|
@ -244,12 +244,12 @@ gst_mf_audio_enc_process_output (GstMFAudioEnc * self)
|
||||||
{
|
{
|
||||||
GstMFAudioEncClass *klass = GST_MF_AUDIO_ENC_GET_CLASS (self);
|
GstMFAudioEncClass *klass = GST_MF_AUDIO_ENC_GET_CLASS (self);
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
BYTE *data;
|
BYTE *data = nullptr;
|
||||||
ComPtr < IMFMediaBuffer > media_buffer;
|
ComPtr < IMFMediaBuffer > media_buffer;
|
||||||
ComPtr < IMFSample > sample;
|
ComPtr < IMFSample > sample;
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
GstFlowReturn res = GST_FLOW_ERROR;
|
GstFlowReturn res = GST_FLOW_ERROR;
|
||||||
DWORD buffer_len;
|
DWORD buffer_len = 0;
|
||||||
|
|
||||||
res = gst_mf_transform_get_output (self->transform, sample.GetAddressOf ());
|
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))
|
if (!gst_mf_result (hr))
|
||||||
return GST_FLOW_ERROR;
|
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 = gst_audio_encoder_allocate_output_buffer (GST_AUDIO_ENCODER (self),
|
||||||
buffer_len);
|
buffer_len);
|
||||||
gst_buffer_fill (buffer, 0, data, buffer_len);
|
gst_buffer_fill (buffer, 0, data, buffer_len);
|
||||||
|
|
Loading…
Reference in a new issue