From d3cf8f02db34c2ab1fb2fe2d5c42cb6145fce298 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 29 Jul 2015 13:12:04 -0700 Subject: [PATCH] PulseAudio: fix using 100% CPU soundio_wait_events wasn't blocking but now it is. --- README.md | 3 +-- src/pulseaudio.cpp | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 582477b..a652c6c 100644 --- a/README.md +++ b/README.md @@ -245,8 +245,7 @@ view `coverage/index.html` in a browser. 0. implement CoreAudio (OSX) backend, get examples working 0. implement WASAPI (Windows) backend, get examples working 0. implement ASIO (Windows) backend, get examples working - 0. JACK: implement prebuffering - 0. why does pulseaudio microphone use up all the CPU? + 0. JACK: implement prebuffering ...or delete prebuffering as a concept 0. Avoid calling `soundio_panic` in PulseAudio. 0. Figure out a way to test prebuf. I suspect prebuf not working for ALSA which is why we have to pre-fill the ring buffer with silence for diff --git a/src/pulseaudio.cpp b/src/pulseaudio.cpp index 1503232..7dca8fb 100644 --- a/src/pulseaudio.cpp +++ b/src/pulseaudio.cpp @@ -460,7 +460,9 @@ static void flush_events(SoundIoPrivate *si) { static void wait_events(SoundIoPrivate *si) { SoundIoPulseAudio *sipa = &si->backend_data.pulseaudio; flush_events(si); + pa_threaded_mainloop_lock(sipa->main_loop); pa_threaded_mainloop_wait(sipa->main_loop); + pa_threaded_mainloop_unlock(sipa->main_loop); } static void wakeup(SoundIoPrivate *si) {