audio-converter: add API to determine passthrough mode
authorMathieu Duponchelle <mathieu@centricular.com>
Mon, 17 Dec 2018 12:33:56 +0000 (13:33 +0100)
committerMathieu Duponchelle <mduponchelle1@gmail.com>
Mon, 17 Dec 2018 14:23:49 +0000 (14:23 +0000)
audioconvert's passthrough status can no longer be determined
strictly from input / output caps equality, as a mix-matrix can
now be specified.

We now call gst_base_transform_set_passthrough dynamically, based
on the return from the new gst_audio_converter_is_passthrough()
API, which takes the mix matrix into account.

docs/libs/gst-plugins-base-libs-sections.txt
gst-libs/gst/audio/audio-converter.c
gst-libs/gst/audio/audio-converter.h
gst/audioconvert/gstaudioconvert.c

index 368a623..78606bb 100644 (file)
@@ -708,6 +708,7 @@ gst_audio_converter_update_config
 gst_audio_converter_get_config
 gst_audio_converter_reset
 gst_audio_converter_supports_inplace
+gst_audio_converter_is_passthrough
 <SUBSECTION Standard>
 gst_audio_converter_flags_get_type
 GST_TYPE_AUDIO_CONVERTER_FLAGS
index 1836a47..afaba7f 100644 (file)
@@ -111,6 +111,8 @@ struct _GstAudioConverter
 
   gboolean in_place;            /* the conversion can be done in place; returned by gst_audio_converter_supports_inplace() */
 
+  gboolean passthrough;
+
   /* unpack */
   gboolean in_default;
   gboolean unpack_ip;
@@ -1373,6 +1375,7 @@ gst_audio_converter_new (GstAudioConverterFlags flags, GstAudioInfo * in_info,
 
   convert->convert = converter_generic;
   convert->in_place = FALSE;
+  convert->passthrough = FALSE;
 
   /* optimize */
   if (convert->mix_passthrough) {
@@ -1383,6 +1386,7 @@ gst_audio_converter_new (GstAudioConverterFlags flags, GstAudioInfo * in_info,
               "passthrough mixing -> passthrough");
           convert->convert = converter_passthrough;
           convert->in_place = TRUE;
+          convert->passthrough = TRUE;
         }
       } else {
         if (is_intermediate_format (in_info->finfo->format)) {
@@ -1645,3 +1649,19 @@ gst_audio_converter_supports_inplace (GstAudioConverter * convert)
 {
   return convert->in_place;
 }
+
+/**
+ * gst_audio_converter_is_passthrough:
+ *
+ * Returns whether the audio converter will operate in passthrough mode.
+ * The return value would be typically input to gst_base_transform_set_passthrough()
+ *
+ * Returns: %TRUE when no conversion will actually occur.
+ *
+ * Since: 1.16
+ */
+gboolean
+gst_audio_converter_is_passthrough (GstAudioConverter * convert)
+{
+  return convert->passthrough;
+}
index 9e85898..b23646d 100644 (file)
@@ -160,6 +160,9 @@ GST_AUDIO_API
 gboolean             gst_audio_converter_supports_inplace (GstAudioConverter *convert);
 
 GST_AUDIO_API
+gboolean             gst_audio_converter_is_passthrough   (GstAudioConverter *convert);
+
+GST_AUDIO_API
 gboolean             gst_audio_converter_convert          (GstAudioConverter * convert,
                                                            GstAudioConverterFlags flags,
                                                            gpointer in, gsize in_size,
index cfb0836..2269e0a 100644 (file)
@@ -775,6 +775,9 @@ gst_audio_convert_set_caps (GstBaseTransform * base, GstCaps * incaps,
   in_place = gst_audio_converter_supports_inplace (this->convert);
   gst_base_transform_set_in_place (base, in_place);
 
+  gst_base_transform_set_passthrough (base,
+      gst_audio_converter_is_passthrough (this->convert));
+
   this->in_info = in_info;
   this->out_info = out_info;