mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 23:06:49 +00:00
omx: Refactor code flow a bit if output port settings have changed
This commit is contained in:
parent
b12610efd7
commit
e42faae652
3 changed files with 130 additions and 122 deletions
|
@ -295,54 +295,39 @@ gst_omx_audio_enc_loop (GstOMXAudioEnc * self)
|
|||
goto component_error;
|
||||
} else if (acq_return == GST_OMX_ACQUIRE_BUFFER_FLUSHING) {
|
||||
goto flushing;
|
||||
} else if (acq_return == GST_OMX_ACQUIRE_BUFFER_RECONFIGURE) {
|
||||
OMX_ERRORTYPE err;
|
||||
|
||||
/* Reallocate all buffers */
|
||||
err = gst_omx_port_set_enabled (port, FALSE);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_wait_buffers_released (port, 5 * GST_SECOND);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_deallocate_buffers (port);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_wait_enabled (port, 1 * GST_SECOND);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_set_enabled (port, TRUE);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_allocate_buffers (port);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_wait_enabled (port, 5 * GST_SECOND);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_mark_reconfigured (port);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
/* Update caps below */
|
||||
}
|
||||
|
||||
GST_AUDIO_ENCODER_STREAM_LOCK (self);
|
||||
if (!gst_pad_has_current_caps (GST_AUDIO_ENCODER_SRC_PAD (self))
|
||||
|| acq_return == GST_OMX_ACQUIRE_BUFFER_RECONFIGURE) {
|
||||
GstAudioInfo *info =
|
||||
gst_audio_encoder_get_audio_info (GST_AUDIO_ENCODER (self));
|
||||
GstCaps *caps;
|
||||
OMX_ERRORTYPE err;
|
||||
|
||||
GST_DEBUG_OBJECT (self, "Port settings have changed, updating caps");
|
||||
|
||||
/* Reallocate all buffers */
|
||||
if (acq_return == GST_OMX_ACQUIRE_BUFFER_RECONFIGURE) {
|
||||
err = gst_omx_port_set_enabled (port, FALSE);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_wait_buffers_released (port, 5 * GST_SECOND);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_deallocate_buffers (port);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_wait_enabled (port, 1 * GST_SECOND);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
}
|
||||
|
||||
GST_AUDIO_ENCODER_STREAM_LOCK (self);
|
||||
|
||||
caps = klass->get_caps (self, self->enc_out_port, info);
|
||||
if (!caps) {
|
||||
if (buf)
|
||||
|
@ -362,13 +347,31 @@ gst_omx_audio_enc_loop (GstOMXAudioEnc * self)
|
|||
}
|
||||
gst_caps_unref (caps);
|
||||
|
||||
GST_AUDIO_ENCODER_STREAM_UNLOCK (self);
|
||||
|
||||
if (acq_return == GST_OMX_ACQUIRE_BUFFER_RECONFIGURE) {
|
||||
err = gst_omx_port_set_enabled (port, TRUE);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_allocate_buffers (port);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_wait_enabled (port, 5 * GST_SECOND);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_mark_reconfigured (port);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
}
|
||||
|
||||
/* Now get a buffer */
|
||||
if (acq_return != GST_OMX_ACQUIRE_BUFFER_OK) {
|
||||
GST_AUDIO_ENCODER_STREAM_UNLOCK (self);
|
||||
return;
|
||||
}
|
||||
}
|
||||
GST_AUDIO_ENCODER_STREAM_UNLOCK (self);
|
||||
|
||||
g_assert (acq_return == GST_OMX_ACQUIRE_BUFFER_OK);
|
||||
|
||||
|
|
|
@ -564,54 +564,39 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self)
|
|||
goto component_error;
|
||||
} else if (acq_return == GST_OMX_ACQUIRE_BUFFER_FLUSHING) {
|
||||
goto flushing;
|
||||
} else if (acq_return == GST_OMX_ACQUIRE_BUFFER_RECONFIGURE) {
|
||||
OMX_ERRORTYPE err;
|
||||
|
||||
/* Reallocate all buffers */
|
||||
err = gst_omx_port_set_enabled (port, FALSE);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_wait_buffers_released (port, 5 * GST_SECOND);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_deallocate_buffers (port);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_wait_enabled (port, 1 * GST_SECOND);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_set_enabled (port, TRUE);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_allocate_buffers (port);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_wait_enabled (port, 5 * GST_SECOND);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_mark_reconfigured (port);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
/* Update caps below */
|
||||
}
|
||||
|
||||
GST_VIDEO_DECODER_STREAM_LOCK (self);
|
||||
if (!gst_pad_has_current_caps (GST_VIDEO_DECODER_SRC_PAD (self))
|
||||
|| acq_return == GST_OMX_ACQUIRE_BUFFER_RECONFIGURE) {
|
||||
if (!gst_pad_has_current_caps (GST_VIDEO_DECODER_SRC_PAD (self)) ||
|
||||
acq_return == GST_OMX_ACQUIRE_BUFFER_RECONFIGURE) {
|
||||
OMX_ERRORTYPE err;
|
||||
GstVideoCodecState *state;
|
||||
OMX_PARAM_PORTDEFINITIONTYPE port_def;
|
||||
GstVideoFormat format;
|
||||
|
||||
GST_DEBUG_OBJECT (self, "Port settings have changed, updating caps");
|
||||
|
||||
/* Reallocate all buffers */
|
||||
if (acq_return == GST_OMX_ACQUIRE_BUFFER_RECONFIGURE) {
|
||||
err = gst_omx_port_set_enabled (port, FALSE);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_wait_buffers_released (port, 5 * GST_SECOND);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_deallocate_buffers (port);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_wait_enabled (port, 1 * GST_SECOND);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
}
|
||||
|
||||
GST_VIDEO_DECODER_STREAM_LOCK (self);
|
||||
|
||||
|
||||
gst_omx_port_get_port_definition (port, &port_def);
|
||||
g_assert (port_def.format.video.eCompressionFormat ==
|
||||
OMX_VIDEO_CodingUnused);
|
||||
|
@ -658,13 +643,31 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self)
|
|||
|
||||
gst_video_codec_state_unref (state);
|
||||
|
||||
GST_VIDEO_DECODER_STREAM_UNLOCK (self);
|
||||
|
||||
if (acq_return == GST_OMX_ACQUIRE_BUFFER_RECONFIGURE) {
|
||||
err = gst_omx_port_set_enabled (port, TRUE);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_allocate_buffers (port);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_wait_enabled (port, 5 * GST_SECOND);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_mark_reconfigured (port);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
}
|
||||
|
||||
/* Now get a buffer */
|
||||
if (acq_return != GST_OMX_ACQUIRE_BUFFER_OK) {
|
||||
GST_VIDEO_DECODER_STREAM_UNLOCK (self);
|
||||
return;
|
||||
}
|
||||
}
|
||||
GST_VIDEO_DECODER_STREAM_UNLOCK (self);
|
||||
|
||||
g_assert (acq_return == GST_OMX_ACQUIRE_BUFFER_OK);
|
||||
|
||||
|
|
|
@ -746,53 +746,37 @@ gst_omx_video_enc_loop (GstOMXVideoEnc * self)
|
|||
goto component_error;
|
||||
} else if (acq_return == GST_OMX_ACQUIRE_BUFFER_FLUSHING) {
|
||||
goto flushing;
|
||||
} else if (acq_return == GST_OMX_ACQUIRE_BUFFER_RECONFIGURE) {
|
||||
OMX_ERRORTYPE err;
|
||||
|
||||
/* Reallocate all buffers */
|
||||
err = gst_omx_port_set_enabled (port, FALSE);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_wait_buffers_released (port, 5 * GST_SECOND);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_deallocate_buffers (port);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_wait_enabled (port, 1 * GST_SECOND);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_set_enabled (port, TRUE);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_allocate_buffers (port);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_wait_enabled (port, 5 * GST_SECOND);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_mark_reconfigured (port);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
/* Update caps below */
|
||||
}
|
||||
|
||||
GST_VIDEO_ENCODER_STREAM_LOCK (self);
|
||||
if (!gst_pad_has_current_caps (GST_VIDEO_ENCODER_SRC_PAD (self))
|
||||
|| acq_return == GST_OMX_ACQUIRE_BUFFER_RECONFIGURE) {
|
||||
GstCaps *caps;
|
||||
GstVideoCodecState *state;
|
||||
OMX_ERRORTYPE err;
|
||||
|
||||
GST_DEBUG_OBJECT (self, "Port settings have changed, updating caps");
|
||||
|
||||
if (acq_return == GST_OMX_ACQUIRE_BUFFER_RECONFIGURE) {
|
||||
/* Reallocate all buffers */
|
||||
err = gst_omx_port_set_enabled (port, FALSE);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_wait_buffers_released (port, 5 * GST_SECOND);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_deallocate_buffers (port);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_wait_enabled (port, 1 * GST_SECOND);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
}
|
||||
|
||||
GST_VIDEO_ENCODER_STREAM_LOCK (self);
|
||||
|
||||
caps = klass->get_caps (self, self->enc_out_port, self->input_state);
|
||||
if (!caps) {
|
||||
if (buf)
|
||||
|
@ -815,13 +799,31 @@ gst_omx_video_enc_loop (GstOMXVideoEnc * self)
|
|||
goto caps_failed;
|
||||
}
|
||||
|
||||
GST_VIDEO_ENCODER_STREAM_UNLOCK (self);
|
||||
|
||||
if (acq_return == GST_OMX_ACQUIRE_BUFFER_RECONFIGURE) {
|
||||
err = gst_omx_port_set_enabled (port, TRUE);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_allocate_buffers (port);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_wait_enabled (port, 5 * GST_SECOND);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
|
||||
err = gst_omx_port_mark_reconfigured (port);
|
||||
if (err != OMX_ErrorNone)
|
||||
goto reconfigure_error;
|
||||
}
|
||||
|
||||
/* Now get a buffer */
|
||||
if (acq_return != GST_OMX_ACQUIRE_BUFFER_OK) {
|
||||
GST_VIDEO_ENCODER_STREAM_UNLOCK (self);
|
||||
return;
|
||||
}
|
||||
}
|
||||
GST_VIDEO_ENCODER_STREAM_UNLOCK (self);
|
||||
|
||||
g_assert (acq_return == GST_OMX_ACQUIRE_BUFFER_OK);
|
||||
|
||||
|
|
Loading…
Reference in a new issue