From f6684a0585fe92fe29a8c6e669a49c28d5d8256f Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 21 Jul 2015 17:43:41 -0700 Subject: [PATCH] PulseAudio: implement pausing input streams --- README.md | 2 +- src/pulseaudio.cpp | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 818178d..b4b888b 100644 --- a/README.md +++ b/README.md @@ -238,9 +238,9 @@ view `coverage/index.html` in a browser. ## Roadmap + 0. ALSA: poll instead of callback 0. ALSA: support devices that don't support mmap access (test with pulseaudio alsa default) 0. implement ALSA (Linux) backend, get examples working - 0. ALSA: poll instead of callback 0. pipe record to playback example working with dummy linux, osx, windows 0. pipe record to playback example working with pulseaudio linux 0. implement CoreAudio (OSX) backend, get examples working diff --git a/src/pulseaudio.cpp b/src/pulseaudio.cpp index 581266b..2a0b864 100644 --- a/src/pulseaudio.cpp +++ b/src/pulseaudio.cpp @@ -969,7 +969,21 @@ static void instream_clear_buffer_pa(SoundIoPrivate *si, SoundIoInStreamPrivate } static int instream_pause_pa(SoundIoPrivate *si, SoundIoInStreamPrivate *is, bool pause) { - soundio_panic("TODO"); + SoundIoInStreamPulseAudio *ispa = (SoundIoInStreamPulseAudio *)is->backend_data; + SoundIoPulseAudio *sipa = (SoundIoPulseAudio *)si->backend_data; + + pa_threaded_mainloop_lock(sipa->main_loop); + + if (pause != !pa_stream_is_corked(ispa->stream)) { + pa_operation *op = pa_stream_cork(ispa->stream, pause, NULL, NULL); + if (!op) + return SoundIoErrorStreaming; + pa_operation_unref(op); + } + + pa_threaded_mainloop_unlock(sipa->main_loop); + + return 0; } int soundio_pulseaudio_init(SoundIoPrivate *si) {