mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 23:06:49 +00:00
omxaudioenc: Add hack for encoder components that don't allow empty EOS buffers
This commit is contained in:
parent
2cab5b5db5
commit
887d43c290
1 changed files with 105 additions and 65 deletions
|
@ -463,11 +463,23 @@ gst_omx_audio_enc_loop (GstOMXAudioEnc * self)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_assert (acq_return == GST_OMX_ACQUIRE_BUFFER_OK && buf != NULL);
|
g_assert (acq_return == GST_OMX_ACQUIRE_BUFFER_OK);
|
||||||
|
|
||||||
|
if (buf) {
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (self, "Handling buffer: 0x%08x %lu", buf->omx_buf->nFlags,
|
GST_DEBUG_OBJECT (self, "Handling buffer: 0x%08x %lu", buf->omx_buf->nFlags,
|
||||||
buf->omx_buf->nTimeStamp);
|
buf->omx_buf->nTimeStamp);
|
||||||
|
|
||||||
|
/* This prevents a deadlock between the srcpad stream
|
||||||
|
* lock and the videocodec stream lock, if ::reset()
|
||||||
|
* is called at the wrong time
|
||||||
|
*/
|
||||||
|
if (gst_omx_port_is_flushing (self->out_port)) {
|
||||||
|
GST_DEBUG_OBJECT (self, "Flushing");
|
||||||
|
gst_omx_port_release_buffer (self->out_port, buf);
|
||||||
|
goto flushing;
|
||||||
|
}
|
||||||
|
|
||||||
GST_AUDIO_ENCODER_STREAM_LOCK (self);
|
GST_AUDIO_ENCODER_STREAM_LOCK (self);
|
||||||
is_eos = ! !(buf->omx_buf->nFlags & OMX_BUFFERFLAG_EOS);
|
is_eos = ! !(buf->omx_buf->nFlags & OMX_BUFFERFLAG_EOS);
|
||||||
|
|
||||||
|
@ -482,7 +494,8 @@ gst_omx_audio_enc_loop (GstOMXAudioEnc * self)
|
||||||
buf->omx_buf->pBuffer + buf->omx_buf->nOffset,
|
buf->omx_buf->pBuffer + buf->omx_buf->nOffset,
|
||||||
buf->omx_buf->nFilledLen);
|
buf->omx_buf->nFilledLen);
|
||||||
|
|
||||||
gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, codec_data, NULL);
|
gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, codec_data,
|
||||||
|
NULL);
|
||||||
if (!gst_pad_set_caps (GST_AUDIO_ENCODER_SRC_PAD (self), caps)) {
|
if (!gst_pad_set_caps (GST_AUDIO_ENCODER_SRC_PAD (self), caps)) {
|
||||||
gst_caps_unref (caps);
|
gst_caps_unref (caps);
|
||||||
if (buf)
|
if (buf)
|
||||||
|
@ -538,12 +551,18 @@ gst_omx_audio_enc_loop (GstOMXAudioEnc * self)
|
||||||
}
|
}
|
||||||
g_mutex_unlock (self->drain_lock);
|
g_mutex_unlock (self->drain_lock);
|
||||||
} else {
|
} else {
|
||||||
GST_DEBUG_OBJECT (self, "Finished frame: %s", gst_flow_get_name (flow_ret));
|
GST_DEBUG_OBJECT (self, "Finished frame: %s",
|
||||||
|
gst_flow_get_name (flow_ret));
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_omx_port_release_buffer (port, buf);
|
gst_omx_port_release_buffer (port, buf);
|
||||||
|
|
||||||
self->downstream_flow_ret = flow_ret;
|
self->downstream_flow_ret = flow_ret;
|
||||||
|
} else {
|
||||||
|
g_assert ((klass->hacks & GST_OMX_HACK_NO_EMPTY_EOS_BUFFER));
|
||||||
|
GST_AUDIO_ENCODER_STREAM_LOCK (self);
|
||||||
|
flow_ret = GST_FLOW_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
if (flow_ret != GST_FLOW_OK)
|
if (flow_ret != GST_FLOW_OK)
|
||||||
goto flow_error;
|
goto flow_error;
|
||||||
|
@ -993,8 +1012,10 @@ static gboolean
|
||||||
gst_omx_audio_enc_event (GstAudioEncoder * encoder, GstEvent * event)
|
gst_omx_audio_enc_event (GstAudioEncoder * encoder, GstEvent * event)
|
||||||
{
|
{
|
||||||
GstOMXAudioEnc *self;
|
GstOMXAudioEnc *self;
|
||||||
|
GstOMXAudioEncClass *klass;
|
||||||
|
|
||||||
self = GST_OMX_AUDIO_ENC (encoder);
|
self = GST_OMX_AUDIO_ENC (encoder);
|
||||||
|
klass = GST_OMX_AUDIO_ENC_GET_CLASS (self);
|
||||||
|
|
||||||
if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
|
if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
|
||||||
GstOMXBuffer *buf;
|
GstOMXBuffer *buf;
|
||||||
|
@ -1009,6 +1030,17 @@ gst_omx_audio_enc_event (GstAudioEncoder * encoder, GstEvent * event)
|
||||||
}
|
}
|
||||||
self->eos = TRUE;
|
self->eos = TRUE;
|
||||||
|
|
||||||
|
if ((klass->hacks & GST_OMX_HACK_NO_EMPTY_EOS_BUFFER)) {
|
||||||
|
GST_WARNING_OBJECT (self, "Component does not support empty EOS buffers");
|
||||||
|
|
||||||
|
/* Insert a NULL into the queue to signal EOS */
|
||||||
|
g_mutex_lock (self->out_port->port_lock);
|
||||||
|
g_queue_push_tail (self->out_port->pending_buffers, NULL);
|
||||||
|
g_cond_broadcast (self->out_port->port_cond);
|
||||||
|
g_mutex_unlock (self->out_port->port_lock);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Make sure to release the base class stream lock, otherwise
|
/* Make sure to release the base class stream lock, otherwise
|
||||||
* _loop() can't call _finish_frame() and we might block forever
|
* _loop() can't call _finish_frame() and we might block forever
|
||||||
* because no input buffers are released */
|
* because no input buffers are released */
|
||||||
|
@ -1042,11 +1074,14 @@ gst_omx_audio_enc_event (GstAudioEncoder * encoder, GstEvent * event)
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_omx_audio_enc_drain (GstOMXAudioEnc * self)
|
gst_omx_audio_enc_drain (GstOMXAudioEnc * self)
|
||||||
{
|
{
|
||||||
|
GstOMXAudioEncClass *klass;
|
||||||
GstOMXBuffer *buf;
|
GstOMXBuffer *buf;
|
||||||
GstOMXAcquireBufferReturn acq_ret;
|
GstOMXAcquireBufferReturn acq_ret;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (self, "Draining component");
|
GST_DEBUG_OBJECT (self, "Draining component");
|
||||||
|
|
||||||
|
klass = GST_OMX_AUDIO_ENC_GET_CLASS (self);
|
||||||
|
|
||||||
if (!self->started) {
|
if (!self->started) {
|
||||||
GST_DEBUG_OBJECT (self, "Component not started yet");
|
GST_DEBUG_OBJECT (self, "Component not started yet");
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
@ -1059,6 +1094,11 @@ gst_omx_audio_enc_drain (GstOMXAudioEnc * self)
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((klass->hacks & GST_OMX_HACK_NO_EMPTY_EOS_BUFFER)) {
|
||||||
|
GST_WARNING_OBJECT (self, "Component does not support empty EOS buffers");
|
||||||
|
return GST_FLOW_OK;
|
||||||
|
}
|
||||||
|
|
||||||
/* Make sure to release the base class stream lock, otherwise
|
/* Make sure to release the base class stream lock, otherwise
|
||||||
* _loop() can't call _finish_frame() and we might block forever
|
* _loop() can't call _finish_frame() and we might block forever
|
||||||
* because no input buffers are released */
|
* because no input buffers are released */
|
||||||
|
|
Loading…
Reference in a new issue