osxaudio: Fix error handling when selecting/opening devices
authorNirbheek Chauhan <nirbheek@centricular.com>
Thu, 14 Jan 2016 22:26:49 +0000 (03:56 +0530)
committerTim-Philipp Müller <tim@centricular.com>
Thu, 14 Jan 2016 22:32:09 +0000 (22:32 +0000)
Post an element error when the CoreAudio device cannot be selected or opened.
Also ensure that we post a GST_ERROR with more detail.

sys/osxaudio/gstosxaudioringbuffer.c
sys/osxaudio/gstosxcoreaudiohal.c

index 2afcb56..4201e04 100644 (file)
@@ -48,6 +48,7 @@
 #endif
 
 #include <gst/gst.h>
+#include <gst/gst-i18n-plugin.h>
 #include <gst/audio/audio-channels.h>
 #include "gstosxaudioringbuffer.h"
 #include "gstosxaudiosink.h"
@@ -140,12 +141,22 @@ gst_osx_audio_ring_buffer_dispose (GObject * object)
 static gboolean
 gst_osx_audio_ring_buffer_open_device (GstAudioRingBuffer * buf)
 {
+  GstObject *osxel = GST_OBJECT_PARENT (buf);
   GstOsxAudioRingBuffer *osxbuf = GST_OSX_AUDIO_RING_BUFFER (buf);
 
-  if (!gst_core_audio_select_device (osxbuf->core_audio))
+  if (!gst_core_audio_select_device (osxbuf->core_audio)) {
+    GST_ELEMENT_ERROR (osxel, RESOURCE, NOT_FOUND,
+        (_("CoreAudio device not found")), (NULL));
     return FALSE;
+  }
 
-  return gst_core_audio_open (osxbuf->core_audio);
+  if (!gst_core_audio_open (osxbuf->core_audio)) {
+    GST_ELEMENT_ERROR (osxel, RESOURCE, OPEN_READ,
+        (_("CoreAudio device could not be opened")), (NULL));
+    return FALSE;
+  }
+
+  return TRUE;
 }
 
 static gboolean
index c1fefcc..36bd85e 100644 (file)
@@ -1238,7 +1238,7 @@ gst_core_audio_select_device_impl (GstCoreAudio * core_audio)
       device_id = default_device_id;
       res = TRUE;
     } else {
-      /* No device of required type available */
+      GST_ERROR ("No device of required type available");
       res = FALSE;
     }
   } else {