[mythtv] [patch] handle ALSA OpenDevice failures

Daniel Thor Kristjansson danielk at mrl.nyu.edu
Wed Mar 2 18:23:37 UTC 2005


Trivial fix that gets rid of repeated "getSpaceOnSoundcard()
called with pcm_handle == NULL!" messages when the audio output
is busy when you start MythTV. The problem was that we did not
return false from OpenDevice() when we couldn't open the
device. This patch explicitly closes the device if pcm_handle
is set, and adds the missing "return false;".

I've also added an error message if SetParameters() fails,
instead of just returning false. This is a good thing to have
since NVP just looks for an error message to determine whether
to show the audio error dialog.

-- Daniel
-------------- next part --------------
Index: libs/libmyth/audiooutputalsa.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/audiooutputalsa.cpp,v
retrieving revision 1.17
diff -u -r1.17 audiooutputalsa.cpp
--- libs/libmyth/audiooutputalsa.cpp	15 Feb 2005 00:03:43 -0000	1.17
+++ libs/libmyth/audiooutputalsa.cpp	2 Mar 2005 18:15:21 -0000
@@ -49,6 +49,9 @@
     { 
         Error(QString("snd_pcm_open(%1): %2")
               .arg(audiodevice).arg(snd_strerror(err)));
+        if (pcm_handle)
+            CloseDevice();
+        return false;
     }
 
     /* the audio fragment size was computed by using the next lower power of 2
@@ -91,6 +94,7 @@
                         period_time);
     if (err < 0) 
     {
+        Error("Unable to set ALSA parameters");
         CloseDevice();
         return false;
     }    


More information about the mythtv-dev mailing list