From de5bb99d1f604fe018d158d79c802b00cde45577 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 20 Jul 2015 17:33:21 -0700 Subject: [PATCH] ALSA: support mmap complex placement --- README.md | 5 ++--- src/alsa.cpp | 13 +++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 240a89c..4be80ae 100644 --- a/README.md +++ b/README.md @@ -152,8 +152,8 @@ or the server not running, or the platform is wrong, the next backend is tried. 0. PulseAudio 0. ALSA (Linux) 0. CoreAudio (OSX) - 0. ASIO (Windows) 0. WASAPI (Windows) + 0. ASIO (Windows) 0. Dummy If you don't like this order, you can use `soundio_connect_backend` to @@ -246,8 +246,6 @@ view `coverage/index.html` in a browser. 0. clean up API and improve documentation - make sure every function which can return an error documents which errors it can return - - consider doing the public/private struct thing and make `backend_data` a - union instead of a `void *` 0. use a documentation generator and host the docs somewhere 0. -fvisibility=hidden and then explicitly export stuff 0. Integrate into libgroove and test with Groove Basin @@ -259,6 +257,7 @@ view `coverage/index.html` in a browser. unused to a buffer for you. 0. add len arguments to APIs that have char * 0. custom allocator support + 0. ALSA: support devices that don't support mmap access ## Planned Uses for libsoundio diff --git a/src/alsa.cpp b/src/alsa.cpp index e5b638d..507c196 100644 --- a/src/alsa.cpp +++ b/src/alsa.cpp @@ -274,8 +274,11 @@ static int probe_open_device(SoundIoDevice *device, snd_pcm_t *handle, int resam return SoundIoErrorOpeningDevice; if ((err = snd_pcm_hw_params_set_access(handle, hwparams, SND_PCM_ACCESS_MMAP_INTERLEAVED)) < 0) { - if ((err = snd_pcm_hw_params_set_access(handle, hwparams, SND_PCM_ACCESS_MMAP_NONINTERLEAVED)) < 0) - return SoundIoErrorIncompatibleDevice; + if ((err = snd_pcm_hw_params_set_access(handle, hwparams, SND_PCM_ACCESS_MMAP_NONINTERLEAVED)) < 0) { + if ((err = snd_pcm_hw_params_set_access(handle, hwparams, SND_PCM_ACCESS_MMAP_COMPLEX)) < 0) { + return SoundIoErrorIncompatibleDevice; + } + } } unsigned int channel_count; @@ -965,8 +968,10 @@ static int outstream_open_alsa(SoundIoPrivate *si, SoundIoOutStreamPrivate *os) if ((err = snd_pcm_hw_params_set_access(osa->handle, hwparams, SND_PCM_ACCESS_MMAP_INTERLEAVED)) < 0) { if ((err = snd_pcm_hw_params_set_access(osa->handle, hwparams, SND_PCM_ACCESS_MMAP_NONINTERLEAVED)) < 0) { - outstream_destroy_alsa(si, os); - return SoundIoErrorIncompatibleDevice; + if ((err = snd_pcm_hw_params_set_access(osa->handle, hwparams, SND_PCM_ACCESS_MMAP_COMPLEX)) < 0) { + outstream_destroy_alsa(si, os); + return SoundIoErrorIncompatibleDevice; + } } }