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

This commit is contained in:
Sebastian Dröge 2011-11-17 10:19:35 -08:00
parent 2408e0d33a
commit 7df465bfb3

View file

@ -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))