diff options
-rw-r--r-- | gstreamer_ti/ti_build/ticodecplugin/src/gsttiauddec.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/gstreamer_ti/ti_build/ticodecplugin/src/gsttiauddec.c b/gstreamer_ti/ti_build/ticodecplugin/src/gsttiauddec.c index dd5d1ed..3e33c29 100644 --- a/gstreamer_ti/ti_build/ticodecplugin/src/gsttiauddec.c +++ b/gstreamer_ti/ti_build/ticodecplugin/src/gsttiauddec.c @@ -246,6 +246,19 @@ gst_ti_auddec_codec_open (GstTIAuddec * auddec) AUDDEC1_DynamicParams dynParams = Adec1_DynamicParams_DEFAULT; Buffer_Attrs bAttrs = Buffer_Attrs_DEFAULT; + /* Make sure we know what codec we're using */ + if (!auddec->engineName) { + GST_ELEMENT_ERROR (auddec, RESOURCE, FAILED, + ("engine name not specified"), (NULL)); + goto fail; + } + + if (!auddec->codecName) { + GST_ELEMENT_ERROR (auddec, RESOURCE, FAILED, + ("codec name not specified"), (NULL)); + goto fail; + } + auddec->hEngine = Engine_open ((Char *) auddec->engineName, NULL, NULL); GST_LOG_OBJECT (auddec, "opened codec engine [%s] -> %p", auddec->engineName, auddec->hEngine); @@ -418,7 +431,10 @@ gst_ti_auddec_set_format (GstAudioDecoder * dec, GstCaps * caps) gst_ti_auddec_codec_close (auddec); - ret = gst_ti_auddec_codec_open (auddec); + /* ok if we made it here, will open codec later on. + * Not so clean, but it allows not needing input caps and setting + * codec properties manually */ + ret = TRUE; exit: return ret; @@ -438,6 +454,11 @@ gst_ti_auddec_parse (GstAudioDecoder * dec, GstAdapter * adapter, auddec = GST_TI_AUDDEC (dec); + if (G_UNLIKELY (!auddec->hAd)) { + if (!gst_ti_auddec_codec_open (auddec)) + return GST_FLOW_ERROR; + } + again: av = gst_adapter_available (adapter); data = gst_adapter_peek (adapter, av); @@ -551,6 +572,12 @@ gst_ti_auddec_check_caps_reset (GstTIAuddec * auddec) return GST_FLOW_NOT_NEGOTIATED; } + if (G_UNLIKELY (!nchannels)) { + nchannels = 2; + GST_WARNING_OBJECT (auddec, "unable to determine channel count, " + "defaulting to %d", nchannels); + } + /* only set caps if they weren't already set for this continuous stream */ if (rate != auddec->rate || !GST_PAD_CAPS (GST_AUDIO_DECODER_SRC_PAD (auddec))) { @@ -582,7 +609,7 @@ gst_ti_auddec_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer) auddec = GST_TI_AUDDEC (dec); /* no fancy draining */ - if (G_UNLIKELY (!buffer)) + if (G_UNLIKELY (!buffer) || !auddec->hAd) return GST_FLOW_OK; /* arrange for initial caps before pushing data, |