omxaudioenc: Only enable the output port after we know the output format
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Fri, 1 Mar 2013 10:25:04 +0000 (11:25 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Fri, 1 Mar 2013 10:25:04 +0000 (11:25 +0100)
omx/gstomxaudioenc.c

index 250ef39..547d0cd 100644 (file)
@@ -654,11 +654,6 @@ gst_omx_audio_enc_set_format (GstAudioEncoder * encoder, GstAudioInfo * info)
           &port_def) != OMX_ErrorNone)
     return FALSE;
 
-  GST_DEBUG_OBJECT (self, "Setting outport port definition");
-  if (gst_omx_port_update_port_definition (self->enc_out_port,
-          NULL) != OMX_ErrorNone)
-    return FALSE;
-
   GST_OMX_INIT_STRUCT (&pcm_param);
   pcm_param.nPortIndex = self->enc_in_port->index;
   pcm_param.nChannels = info->channels;
@@ -729,6 +724,11 @@ gst_omx_audio_enc_set_format (GstAudioEncoder * encoder, GstAudioInfo * info)
     }
   }
 
+  GST_DEBUG_OBJECT (self, "Updating outport port definition");
+  if (gst_omx_port_update_port_definition (self->enc_out_port,
+          NULL) != OMX_ErrorNone)
+    return FALSE;
+
   GST_DEBUG_OBJECT (self, "Enabling component");
   if (needs_disable) {
     if (gst_omx_port_set_enabled (self->enc_in_port, TRUE) != OMX_ErrorNone)
@@ -747,7 +747,13 @@ gst_omx_audio_enc_set_format (GstAudioEncoder * encoder, GstAudioInfo * info)
     /* Need to allocate buffers to reach Idle state */
     if (gst_omx_port_allocate_buffers (self->enc_in_port, -1) != OMX_ErrorNone)
       return FALSE;
-    if (gst_omx_port_allocate_buffers (self->enc_out_port, -1) != OMX_ErrorNone)
+
+    /* And disable output port */
+    if (gst_omx_port_set_enabled (self->enc_out_port, FALSE) != OMX_ErrorNone)
+      return FALSE;
+
+    if (gst_omx_port_wait_enabled (self->enc_out_port,
+            1 * GST_SECOND) != OMX_ErrorNone)
       return FALSE;
 
     if (gst_omx_component_get_state (self->enc,