After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 740987 - Fixes to osxaudiosrc and osxaudiosink
Fixes to osxaudiosrc and osxaudiosink
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
unspecified
Other Mac OS
: Normal normal
: 1.5.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks: 711764
 
 
Reported: 2014-12-01 15:56 UTC by Arun Raghavan
Modified: 2014-12-15 05:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
osxaudio: Consolidate input and output code paths a bit (12.26 KB, patch)
2014-12-01 15:56 UTC, Arun Raghavan
accepted-commit_now Details | Review
osxaudio: Move device selection to ringbuffer->open_device() (6.19 KB, patch)
2014-12-01 15:56 UTC, Arun Raghavan
reviewed Details | Review
osxaudio: Make some debug code compile conditionally (1.46 KB, patch)
2014-12-01 15:56 UTC, Arun Raghavan
accepted-commit_now Details | Review
osxaudiosink: Move device caps probing to get_caps() (2.64 KB, patch)
2014-12-01 15:57 UTC, Arun Raghavan
reviewed Details | Review
osxaudio: Clean up a GstCoreAudio -> GstOsxAudioSrc/Sink reference (13.13 KB, patch)
2014-12-01 15:57 UTC, Arun Raghavan
needs-work Details | Review
osxaudio: Move osxaudiosrc-specific code out of the generic path (4.04 KB, patch)
2014-12-01 15:57 UTC, Arun Raghavan
accepted-commit_now Details | Review
osxaudiosink: Fix up caps querying a bit (2.42 KB, patch)
2014-12-01 15:57 UTC, Arun Raghavan
accepted-commit_now Details | Review
osxaudio: Bind audio device to audio unit early (2.04 KB, patch)
2014-12-01 15:57 UTC, Arun Raghavan
accepted-commit_now Details | Review
osxaudiosrc: Implement caps probing (7.23 KB, patch)
2014-12-01 15:57 UTC, Arun Raghavan
needs-work Details | Review
osxaudiosink: Only fix up channels/layout for PCM caps while probing (1.84 KB, patch)
2014-12-01 15:57 UTC, Arun Raghavan
accepted-commit_now Details | Review
osxaudiosrc: Probe channel layout too (9.77 KB, patch)
2014-12-01 15:58 UTC, Arun Raghavan
reviewed Details | Review
osxaudio: Consolidate input and output code paths a bit (12.26 KB, patch)
2014-12-12 09:28 UTC, Arun Raghavan
committed Details | Review
osxaudio: Move device selection to ringbuffer->open_device() (6.10 KB, patch)
2014-12-12 09:31 UTC, Arun Raghavan
committed Details | Review
osxaudio: Make some debug code compile conditionally (1.46 KB, patch)
2014-12-12 09:32 UTC, Arun Raghavan
committed Details | Review
osxaudiosink: Move device caps probing to get_caps() (2.96 KB, patch)
2014-12-12 09:32 UTC, Arun Raghavan
committed Details | Review
osxaudio: Clean up a GstCoreAudio -> GstOsxAudioSrc/Sink reference (13.58 KB, patch)
2014-12-12 09:32 UTC, Arun Raghavan
committed Details | Review
osxaudio: Move osxaudiosrc-specific code out of the generic path (4.04 KB, patch)
2014-12-12 09:32 UTC, Arun Raghavan
committed Details | Review
osxaudiosink: Fix up caps querying a bit (2.47 KB, patch)
2014-12-12 09:32 UTC, Arun Raghavan
needs-work Details | Review
osxaudio: Bind audio device to audio unit early (2.04 KB, patch)
2014-12-12 09:33 UTC, Arun Raghavan
committed Details | Review
osxaudiosrc: Implement caps probing (7.39 KB, patch)
2014-12-12 09:33 UTC, Arun Raghavan
needs-work Details | Review
osxaudiosink: Only fix up channels/layout for PCM caps while probing (1.84 KB, patch)
2014-12-12 09:33 UTC, Arun Raghavan
committed Details | Review
osxaudiosrc: Probe channel layout too (10.54 KB, patch)
2014-12-12 09:33 UTC, Arun Raghavan
committed Details | Review
osxaudio: Take lock around sink/source before accessing the ringbuffer (2.17 KB, patch)
2014-12-12 09:33 UTC, Arun Raghavan
needs-work Details | Review
osxaudiosink: Add some error handling around channel layout parsing (1.98 KB, patch)
2014-12-12 09:33 UTC, Arun Raghavan
committed Details | Review
osxaudiosink: Prefer filter caps order while getting caps (890 bytes, patch)
2014-12-15 05:55 UTC, Arun Raghavan
committed Details | Review
osxaudiosink: Add some error handling around channel layout parsing (1.98 KB, patch)
2014-12-15 05:55 UTC, Arun Raghavan
committed Details | Review

Description Arun Raghavan 2014-12-01 15:56:33 UTC
This is a patchset to consolidate some of the code paths in osxaudiosrc and
osxaudiosink, and an implementation of proper caps querying for osxaudiosrc.

This has been tested on OS X (10.10) but not iOS.
Comment 1 Arun Raghavan 2014-12-01 15:56:41 UTC
Created attachment 291920 [details] [review]
osxaudio: Consolidate input and output code paths a bit
Comment 2 Arun Raghavan 2014-12-01 15:56:48 UTC
Created attachment 291921 [details] [review]
osxaudio: Move device selection to ringbuffer->open_device()

This is conceptually the right thing to do, and allows us to correctly
catch errors in device selection as well, which we could not do while
creating the ringbuffer.
Comment 3 Arun Raghavan 2014-12-01 15:56:54 UTC
Created attachment 291922 [details] [review]
osxaudio: Make some debug code compile conditionally
Comment 4 Arun Raghavan 2014-12-01 15:57:01 UTC
Created attachment 291923 [details] [review]
osxaudiosink: Move device caps probing to get_caps()

This should be preferred to running the probe at device open time.
Comment 5 Arun Raghavan 2014-12-01 15:57:15 UTC
Created attachment 291924 [details] [review]
osxaudio: Clean up a GstCoreAudio -> GstOsxAudioSrc/Sink reference

Now that device selection has no sink/source-specific bits, we can have
generic device selection for this path. We do need to now track state
changes so we can look up the final device_id once the device is open,
though.
Comment 6 Arun Raghavan 2014-12-01 15:57:23 UTC
Created attachment 291925 [details] [review]
osxaudio: Move osxaudiosrc-specific code out of the generic path

Avoids one layering violation (GstCoreAudio referring to
GstOsxAudioSrc).
Comment 7 Arun Raghavan 2014-12-01 15:57:31 UTC
Created attachment 291926 [details] [review]
osxaudiosink: Fix up caps querying a bit

This should make caps queries correct in PAUSED and higher as well.
Comment 8 Arun Raghavan 2014-12-01 15:57:39 UTC
Created attachment 291927 [details] [review]
osxaudio: Bind audio device to audio unit early

We want to bind the device during open so that subsequent format queries
on the audio unit are as specific as possible from that point onwards.
Comment 9 Arun Raghavan 2014-12-01 15:57:47 UTC
Created attachment 291928 [details] [review]
osxaudiosrc: Implement caps probing
Comment 10 Arun Raghavan 2014-12-01 15:57:56 UTC
Created attachment 291929 [details] [review]
osxaudiosink: Only fix up channels/layout for PCM caps while probing

It's unlikely that setting a channel layout will do much for AC3/DTS
streams. If we find at some point that it does make sense, we can
perform the structure copying unconditionally (i.e., the current code is
wrong, since AC3/DTS will get two structures now - one with the channel
layout, one without).
Comment 11 Arun Raghavan 2014-12-01 15:58:03 UTC
Created attachment 291930 [details] [review]
osxaudiosrc: Probe channel layout too
Comment 12 Arun Raghavan 2014-12-01 16:42:58 UTC
Just for completeness, I've tested the code on a USB webcam mic, a USB headset, and a BT headset, so a few different sample rates and mono and stereo input.
Comment 13 Sebastian Dröge (slomo) 2014-12-03 10:41:52 UTC
Review of attachment 291920 [details] [review]:

Good to push after this trivial change:

::: sys/osxaudio/gstosxaudiosrc.c
@@ +333,1 @@
 gst_osx_audio_src_select_device (GstOsxAudioSrc * osxsrc)

Why not static anymore? Also why is this a separate function anyway that only calls a single other function? :)
Comment 14 Sebastian Dröge (slomo) 2014-12-03 10:44:06 UTC
Review of attachment 291921 [details] [review]:

::: sys/osxaudio/gstosxaudiosink.c
@@ +449,3 @@
   ringbuffer->core_audio->is_src = FALSE;
 
+  gst_osx_audio_sink_set_volume (osxsink);

Setting volume without having selected the device yet? Shouldn't this move to select_device()?
Comment 15 Sebastian Dröge (slomo) 2014-12-03 10:46:35 UTC
Review of attachment 291923 [details] [review]:

::: sys/osxaudio/gstosxaudiosink.c
@@ +310,3 @@
 {
   GstOsxAudioSink *sink = GST_OSX_AUDIO_SINK (base);
+  GstAudioRingBuffer *buf = GST_AUDIO_BASE_SINK (sink)->ringbuffer;

This might also need to be protected by a mutex, not sure

@@ +324,1 @@
   if (sink->cached_caps) {

Probing is protected by the mutex... but sink->cached_caps not?
Comment 16 Sebastian Dröge (slomo) 2014-12-03 10:54:14 UTC
Review of attachment 291924 [details] [review]:

::: sys/osxaudio/gstosxaudiosink.c
@@ +276,3 @@
+      ringbuffer =
+          GST_OSX_AUDIO_RING_BUFFER (GST_AUDIO_BASE_SINK (osxsink)->ringbuffer);
+      osxsink->device_id = ringbuffer->core_audio->device_id;

g_object_notify() for the property maybe

::: sys/osxaudio/gstosxaudiosrc.c
@@ +233,3 @@
+      ringbuffer =
+          GST_OSX_AUDIO_RING_BUFFER (GST_AUDIO_BASE_SRC (osxsrc)->ringbuffer);
+      osxsrc->device_id = ringbuffer->core_audio->device_id;

g_object_notify() too
Comment 17 Sebastian Dröge (slomo) 2014-12-03 10:57:18 UTC
Review of attachment 291926 [details] [review]:

::: sys/osxaudio/gstosxaudiosink.c
@@ +361,3 @@
+    if (buf->acquired) {
+      /* Caps are fixed, use what we have */
+      ret = gst_pad_get_current_caps (GST_BASE_SINK_PAD (sink));

Maybe add an assertion/warning here if ret==NULL
Comment 18 Sebastian Dröge (slomo) 2014-12-03 10:57:58 UTC
Comment on attachment 291927 [details] [review]
osxaudio: Bind audio device to audio unit early

Also relevant for remoteio? Did you check if the remoteio bits still compile btw?
Comment 19 Sebastian Dröge (slomo) 2014-12-03 11:00:24 UTC
Review of attachment 291928 [details] [review]:

::: sys/osxaudio/gstosxaudiosrc.c
@@ +301,3 @@
+      /* Caps are fixed, use what we have */
+      ret = gst_pad_get_current_caps (GST_BASE_SINK_PAD (src));
+

Assertion/warning here maybe

::: sys/osxaudio/gstosxcoreaudio.c
@@ +239,3 @@
+
+      ret = gst_caps_new_simple ("audio/x-raw",
+          "format", G_TYPE_STRING, format,

You might want to use a GstAudioInfo here that is filled from the stuff above, and then just convert that to caps. E.g. you're currently missing the "layout" field :) Probably the same in the sink specific code?
Comment 20 Sebastian Dröge (slomo) 2014-12-03 11:02:34 UTC
Review of attachment 291930 [details] [review]:

Looks good but are we handling channel reordering correctly in sink and src? We have a fixed channel order given by the bit position of a channel in the mask, which might be different than the order expected by coreaudio
Comment 21 Arun Raghavan 2014-12-11 04:33:48 UTC
I've update patches with all the comments so far at: http://cgit.freedesktop.org/~arun/gst-plugins-good

Now tested on iOS as well. Will push out soon unless there are comments/concerns. One pending item is verifying that cached_caps are cleaned up at the correct point in src and sink -- will look at this before pushing.
Comment 22 Arun Raghavan 2014-12-12 09:28:19 UTC
Created attachment 292592 [details] [review]
osxaudio: Consolidate input and output code paths a bit

Incorporated review comments (mostly squashed, 2 new patches).
Comment 23 Arun Raghavan 2014-12-12 09:31:48 UTC
Created attachment 292593 [details] [review]
osxaudio: Move device selection to ringbuffer->open_device()

This is conceptually the right thing to do, and allows us to correctly
catch errors in device selection as well, which we could not do while
creating the ringbuffer.
Comment 24 Arun Raghavan 2014-12-12 09:32:02 UTC
Created attachment 292594 [details] [review]
osxaudio: Make some debug code compile conditionally
Comment 25 Arun Raghavan 2014-12-12 09:32:12 UTC
Created attachment 292595 [details] [review]
osxaudiosink: Move device caps probing to get_caps()

This should be preferred to running the probe at device open time.
Comment 26 Arun Raghavan 2014-12-12 09:32:24 UTC
Created attachment 292596 [details] [review]
osxaudio: Clean up a GstCoreAudio -> GstOsxAudioSrc/Sink reference

Now that device selection has no sink/source-specific bits, we can have
generic device selection for this path. We do need to now track state
changes so we can look up the final device_id once the device is open,
though.
Comment 27 Arun Raghavan 2014-12-12 09:32:36 UTC
Created attachment 292597 [details] [review]
osxaudio: Move osxaudiosrc-specific code out of the generic path

Avoids one layering violation (GstCoreAudio referring to
GstOsxAudioSrc).
Comment 28 Arun Raghavan 2014-12-12 09:32:50 UTC
Created attachment 292598 [details] [review]
osxaudiosink: Fix up caps querying a bit

This should make caps queries correct in PAUSED and higher as well.
Comment 29 Arun Raghavan 2014-12-12 09:33:01 UTC
Created attachment 292599 [details] [review]
osxaudio: Bind audio device to audio unit early

We want to bind the device during open so that subsequent format queries
on the audio unit are as specific as possible from that point onwards.
Comment 30 Arun Raghavan 2014-12-12 09:33:12 UTC
Created attachment 292600 [details] [review]
osxaudiosrc: Implement caps probing
Comment 31 Arun Raghavan 2014-12-12 09:33:22 UTC
Created attachment 292601 [details] [review]
osxaudiosink: Only fix up channels/layout for PCM caps while probing

It's unlikely that setting a channel layout will do much for AC3/DTS
streams. If we find at some point that it does make sense, we can
perform the structure copying unconditionally (i.e., the current code is
wrong, since AC3/DTS will get two structures now - one with the channel
layout, one without).
Comment 32 Arun Raghavan 2014-12-12 09:33:31 UTC
Created attachment 292602 [details] [review]
osxaudiosrc: Probe channel layout too
Comment 33 Arun Raghavan 2014-12-12 09:33:43 UTC
Created attachment 292603 [details] [review]
osxaudio: Take lock around sink/source before accessing the ringbuffer
Comment 34 Arun Raghavan 2014-12-12 09:33:56 UTC
Created attachment 292604 [details] [review]
osxaudiosink: Add some error handling around channel layout parsing

For now we just spit a warning and ignore the channel layout if we can't
support it.
Comment 35 Sebastian Dröge (slomo) 2014-12-12 10:17:07 UTC
Review of attachment 292598 [details] [review]:

::: sys/osxaudio/gstosxaudiosink.c
@@ +367,3 @@
+      /* Caps are fixed, use what we have */
+      ret = gst_pad_get_current_caps (GST_BASE_SINK_PAD (sink));
+      g_return_val_if_fail (ret, NULL);

This would forget to unlock the mutex
Comment 36 Sebastian Dröge (slomo) 2014-12-12 10:20:35 UTC
Review of attachment 292600 [details] [review]:

::: sys/osxaudio/gstosxaudiosrc.c
@@ +301,3 @@
+      /* Caps are fixed, use what we have */
+      ret = gst_pad_get_current_caps (GST_BASE_SINK_PAD (src));
+      g_return_val_if_fail (ret, NULL);

Forget to unlock

@@ +316,3 @@
+  if (filter) {
+    GstCaps *tmp;
+    tmp = gst_caps_intersect_full (ret, filter, GST_CAPS_INTERSECT_FIRST);

We usually have the filter first here as we ideally output what the other elements want
Comment 37 Sebastian Dröge (slomo) 2014-12-12 10:22:19 UTC
Review of attachment 292603 [details] [review]:

Contains a change in common
Comment 38 Arun Raghavan 2014-12-15 05:52:46 UTC
The following fixes have been pushed:
db91486 osxaudiosink: Prefer filter caps order while getting caps
f573f02 osxaudiosink: Add some error handling around channel layout parsing
d18a6b0 osxaudio: Take lock around sink/source before accessing the ringbuffer
4a58ebf osxaudiosrc: Probe channel layout too
df610a7 osxaudiosink: Only fix up channels/layout for PCM caps while probing
bd15028 osxaudiosrc: Implement caps probing
48872db osxaudio: Bind audio device to audio unit early
2d0391c osxaudiosink: Fix up caps querying a bit
f967f07 osxaudio: Move osxaudiosrc-specific code out of the generic path
ffcb157 osxaudio: Clean up a GstCoreAudio -> GstOsxAudioSrc/Sink reference
5c2f041 osxaudiosink: Move device caps probing to get_caps()
945aaa0 osxaudio: Make some debug code compile conditionally
b06ae28 osxaudio: Move device selection to ringbuffer->open_device()
199461b osxaudio: Consolidate input and output code paths a bit
Comment 39 Arun Raghavan 2014-12-15 05:55:09 UTC
Created attachment 292732 [details] [review]
osxaudiosink: Prefer filter caps order while getting caps
Comment 40 Arun Raghavan 2014-12-15 05:55:21 UTC
Created attachment 292733 [details] [review]
osxaudiosink: Add some error handling around channel layout parsing

For now we just spit a warning and ignore the channel layout if we can't
support it.