ext/alsa/gstalsamixerelement.c: Make state change fail if the specified device can...
authorTim-Philipp Müller <tim@centricular.net>
Thu, 20 Jul 2006 16:57:29 +0000 (16:57 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Thu, 20 Jul 2006 16:57:29 +0000 (16:57 +0000)
Original commit message from CVS:
* ext/alsa/gstalsamixerelement.c:
(gst_alsa_mixer_element_change_state):
Make state change fail if the specified device can't be opened
for some reason.

ChangeLog
ext/alsa/gstalsamixerelement.c

index b272f76ef3693364cf7fa5fdae3ddd847964cb9a..fd92785eb8eeddace78c1ce027e80e7a7c02db8f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-07-20  Tim-Philipp Müller  <tim at centricular dot net>
+
+       * ext/alsa/gstalsamixerelement.c:
+       (gst_alsa_mixer_element_change_state):
+         Make state change fail if the specified device can't be opened
+         for some reason.
+
 2006-07-20  Wim Taymans  <wim@fluendo.com>
 
        * gst/playback/test.c: (gen_video_element), (gen_audio_element),
index 2fa5bec713bd86cd7b4723a556abcbdb2a4f88a6..4cefe781f9ad1ccdcb0016dc1ceb516591da0fe9 100644 (file)
@@ -208,10 +208,13 @@ gst_alsa_mixer_element_change_state (GstElement * element,
   switch (transition) {
     case GST_STATE_CHANGE_NULL_TO_READY:
       if (!this->mixer) {
-        if (!this->device) {
-          this->mixer = gst_alsa_mixer_new ("default", GST_ALSA_MIXER_ALL);
-        } else {
-          this->mixer = gst_alsa_mixer_new (this->device, GST_ALSA_MIXER_ALL);
+        const gchar *device = (this->device) ? this->device : "default";
+
+        this->mixer = gst_alsa_mixer_new (device, GST_ALSA_MIXER_ALL);
+        if (!this->mixer) {
+          GST_ELEMENT_ERROR (element, RESOURCE, OPEN_READ_WRITE, (NULL),
+              ("Failed to open alsa mixer device '%s'", device));
+          return GST_STATE_CHANGE_FAILURE;
         }
       }
       break;