[mythtv] [patch] Crash in AudioOutputALSA::Reconfigure

Jesper Sörensen jesper at datapartner.se
Mon Jul 19 14:32:24 EDT 2004


I've discovered a bug in AudioOutputALSA when the audio format changes. 
In the Reconfigure method, it seems like snd_pcm_hw_free() is called on 
an invalid handle - it crashes with an assertion error in ALSA. Setting 
pcm_handle to NULL after it is closed in KillAudio() fixes the problem 
but maybe there is a better fix?


void AudioOutputALSA::Reconfigure(int laudio_bits, int laudio_channels,
                                  int laudio_samplerate)
{
    snd_pcm_t *new_pcm_handle;
    snd_pcm_format_t format;
    unsigned int buffer_time = 500000, period_time = 100000;

    int err;

    if (laudio_bits == audio_bits && laudio_channels == audio_channels &&
        laudio_samplerate == audio_samplerate)
    {
        return;
    }

    KillAudio();
    
    new_pcm_handle = pcm_handle;
    pcm_handle = NULL;

    if (new_pcm_handle)
        snd_pcm_hw_free(new_pcm_handle); // CRASH!!!

...
-------------- next part --------------
Index: libs/libmyth/audiooutputalsa.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/audiooutputalsa.cpp,v
retrieving revision 1.8
diff -u -r1.8 audiooutputalsa.cpp
--- libs/libmyth/audiooutputalsa.cpp	13 Jul 2004 21:10:02 -0000	1.8
+++ libs/libmyth/audiooutputalsa.cpp	19 Jul 2004 17:23:44 -0000
@@ -204,7 +204,10 @@
     }
 
     if (pcm_handle != NULL)
+    {
 	snd_pcm_close(pcm_handle);
+	pcm_handle = NULL;
+    }
 
     killAudioLock.unlock();
 }


More information about the mythtv-dev mailing list