From 8129b1847a13be248098b8d8ec773f8bdf821df6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B6rg=20H=C3=B6hle?= Date: Tue, 9 Aug 2011 21:19:51 +0200 Subject: [PATCH] winealsa: Pulse knows handle_underrun only since 2010-07-09. --- dlls/winealsa.drv/mmdevdrv.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/dlls/winealsa.drv/mmdevdrv.c b/dlls/winealsa.drv/mmdevdrv.c index 01fe4fdb63e..ec75fec1b86 100644 --- a/dlls/winealsa.drv/mmdevdrv.c +++ b/dlls/winealsa.drv/mmdevdrv.c @@ -497,6 +497,7 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(const char *key, IMMDevice *dev, int err; snd_pcm_stream_t stream; snd_config_t *lconf; + static int handle_underrun = 1; TRACE("\"%s\" %p %d %p\n", key, dev, dataflow, out); @@ -520,27 +521,23 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(const char *key, IMMDevice *dev, return E_UNEXPECTED; } - lconf = make_handle_underrun_config(key); - This->dataflow = dataflow; - if(lconf){ - if((err = snd_pcm_open_lconf(&This->pcm_handle, key, stream, - SND_PCM_NONBLOCK, lconf)) < 0){ - snd_config_delete(lconf); - HeapFree(GetProcessHeap(), 0, This); - WARN("Unable to open PCM \"%s\": %d (%s)\n", key, err, - snd_strerror(err)); - return E_FAIL; - } + if(handle_underrun && ((lconf = make_handle_underrun_config(key)))){ + err = snd_pcm_open_lconf(&This->pcm_handle, key, stream, SND_PCM_NONBLOCK, lconf); + TRACE("Opening PCM device \"%s\" with handle_underrun: %d\n", key, err); snd_config_delete(lconf); - }else{ - if((err = snd_pcm_open(&This->pcm_handle, key, stream, - SND_PCM_NONBLOCK)) < 0){ - HeapFree(GetProcessHeap(), 0, This); - WARN("Unable to open PCM \"%s\": %d (%s)\n", key, err, - snd_strerror(err)); - return E_FAIL; - } + /* Pulse <= 2010 returns EINVAL, it does not know handle_underrun. */ + if(err == -EINVAL) + handle_underrun = 0; + }else + err = -EINVAL; + if(err == -EINVAL){ + err = snd_pcm_open(&This->pcm_handle, key, stream, SND_PCM_NONBLOCK); + } + if(err < 0){ + HeapFree(GetProcessHeap(), 0, This); + WARN("Unable to open PCM \"%s\": %d (%s)\n", key, err, snd_strerror(err)); + return E_FAIL; } This->hw_params = HeapAlloc(GetProcessHeap(), 0, -- 2.11.4.GIT