osxaudiosrc: no resampling on OS X
authorIlya Konstantinov <ilya.konstantinov@gmail.com>
Wed, 15 Apr 2015 17:13:27 +0000 (20:13 +0300)
committerArun Raghavan <git@arunraghavan.net>
Tue, 14 Jul 2015 12:19:50 +0000 (17:49 +0530)
Unlike Remote IO, AUHAL doesn't have built-in resampling
for sources -- confirmed by Core Audio engineer Doug Wyatt:
http://lists.apple.com/archives/coreaudio-api/2006/Sep/msg00088.html

https://bugzilla.gnome.org/show_bug.cgi?id=743758

sys/osxaudio/gstosxcoreaudio.c

index 9dd7532..d516e6d 100644 (file)
@@ -624,6 +624,21 @@ gst_core_audio_probe_caps (GstCoreAudio * core_audio, GstCaps * in_caps)
         gst_structure_remove_field (out_s, "channel-mask");
       }
 
+#ifndef HAVE_IOS
+      if (core_audio->is_src && got_outer_asbd
+          && outer_asbd.mSampleRate != kAudioStreamAnyRate) {
+        /* According to Core Audio engineer, AUHAL does not support sample rate conversion.
+         * on sources. Therefore, we fixate the sample rate.
+         *
+         * "You definitely cannot do rate conversion as part of getting input from AUHAL.
+         *  That's the most common cause of those "cannot do in current context" errors."
+         * http://lists.apple.com/archives/coreaudio-api/2006/Sep/msg00088.html
+         */
+        gst_structure_set (out_s, "rate", G_TYPE_INT,
+            (gint) outer_asbd.mSampleRate, NULL);
+      }
+#endif
+
       /* Special cases for upmixing and downmixing.
        * Other than that, the AUs don't upmix or downmix multi-channel audio,
        * e.g. if you push 5.1-surround audio to a stereo configuration,