omxvideoenc: Shutdown component in PAUSED->READY and deallocate buffers

This commit is contained in:
Sebastian Dröge 2011-11-17 10:19:30 -08:00
parent 30610a746e
commit 2408e0d33a

View file

@ -450,10 +450,12 @@ gst_omx_video_enc_open (GstOMXVideoEnc * self)
} }
static gboolean static gboolean
gst_omx_video_enc_close (GstOMXVideoEnc * self) gst_omx_video_enc_shutdown (GstOMXVideoEnc * self)
{ {
OMX_STATETYPE state; OMX_STATETYPE state;
GST_DEBUG_OBJECT (self, "Shutting down encoder");
state = gst_omx_component_get_state (self->component, 0); state = gst_omx_component_get_state (self->component, 0);
if (state > OMX_StateLoaded || state == OMX_StateInvalid) { if (state > OMX_StateLoaded || state == OMX_StateInvalid) {
if (state > OMX_StateIdle) { if (state > OMX_StateIdle) {
@ -467,6 +469,17 @@ gst_omx_video_enc_close (GstOMXVideoEnc * self)
gst_omx_component_get_state (self->component, 5 * GST_SECOND); gst_omx_component_get_state (self->component, 5 * GST_SECOND);
} }
return TRUE;
}
static gboolean
gst_omx_video_enc_close (GstOMXVideoEnc * self)
{
GST_DEBUG_OBJECT (self, "Closing encoder");
if (!gst_omx_video_enc_shutdown (self))
return FALSE;
self->in_port = NULL; self->in_port = NULL;
self->out_port = NULL; self->out_port = NULL;
if (self->component) if (self->component)
@ -614,6 +627,9 @@ gst_omx_video_enc_change_state (GstElement * element, GstStateChange transition)
case GST_STATE_CHANGE_PAUSED_TO_READY: case GST_STATE_CHANGE_PAUSED_TO_READY:
self->downstream_flow_ret = GST_FLOW_WRONG_STATE; self->downstream_flow_ret = GST_FLOW_WRONG_STATE;
self->started = FALSE; self->started = FALSE;
if (!gst_omx_video_enc_shutdown (self))
ret = GST_STATE_CHANGE_FAILURE;
break; break;
case GST_STATE_CHANGE_READY_TO_NULL: case GST_STATE_CHANGE_READY_TO_NULL:
if (!gst_omx_video_enc_close (self)) if (!gst_omx_video_enc_close (self))