From 7df465bfb38406880a635fe4f787498b66b04269 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 17 Nov 2011 10:19:35 -0800 Subject: [PATCH] omxaudioenc: Shutdown component in PAUSED->READY and deallocate buffers --- omx/gstomxaudioenc.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/omx/gstomxaudioenc.c b/omx/gstomxaudioenc.c index 5062407..940774d 100644 --- a/omx/gstomxaudioenc.c +++ b/omx/gstomxaudioenc.c @@ -285,11 +285,14 @@ gst_omx_audio_enc_open (GstOMXAudioEnc * self) return TRUE; } + static gboolean -gst_omx_audio_enc_close (GstOMXAudioEnc * self) +gst_omx_audio_enc_shutdown (GstOMXAudioEnc * self) { OMX_STATETYPE state; + GST_DEBUG_OBJECT (self, "Shutting down encoder"); + state = gst_omx_component_get_state (self->component, 0); if (state > OMX_StateLoaded || state == OMX_StateInvalid) { if (state > OMX_StateIdle) { @@ -303,6 +306,17 @@ gst_omx_audio_enc_close (GstOMXAudioEnc * self) gst_omx_component_get_state (self->component, 5 * GST_SECOND); } + return TRUE; +} + +static gboolean +gst_omx_audio_enc_close (GstOMXAudioEnc * self) +{ + GST_DEBUG_OBJECT (self, "Closing encoder"); + + if (!gst_omx_audio_enc_shutdown (self)) + return FALSE; + self->in_port = NULL; self->out_port = NULL; if (self->component) @@ -379,6 +393,9 @@ gst_omx_audio_enc_change_state (GstElement * element, GstStateChange transition) case GST_STATE_CHANGE_PAUSED_TO_READY: self->downstream_flow_ret = GST_FLOW_WRONG_STATE; self->started = FALSE; + + if (!gst_omx_audio_enc_shutdown (self)) + ret = GST_STATE_CHANGE_FAILURE; break; case GST_STATE_CHANGE_READY_TO_NULL: if (!gst_omx_audio_enc_close (self)) -- 2.7.4