From: Mike Brady Date: Tue, 13 Jun 2017 06:58:17 +0000 (+0100) Subject: Stop generating multiple PA sound applications -- now, just generate one. X-Git-Tag: 3.1~10^2~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5ad994257a78480c2582bd80d14dcd6b8ddb4b9;p=thirdparty%2Fshairport-sync.git Stop generating multiple PA sound applications -- now, just generate one. --- diff --git a/audio_pa.c b/audio_pa.c index 96f34892..969886b1 100644 --- a/audio_pa.c +++ b/audio_pa.c @@ -53,18 +53,7 @@ static int init(int argc, char **argv) { audio_toq = audio_eoq = audio_lmb; audio_umb = audio_lmb + audio_size; audio_occupancy = 0; - - return 0; -} - -static void deinit(void) {} - -static void start(int sample_rate, int sample_format) { - - - uint32_t buffer_size_in_bytes = (uint32_t)2 * 2 * RATE * 0.1; // hard wired in here - // debug(1, "pa_buffer size is %u bytes.", buffer_size_in_bytes); - + // Get a mainloop and its context mainloop = pa_threaded_mainloop_new(); assert(mainloop); @@ -91,6 +80,24 @@ static void start(int sample_rate, int sample_format) { pa_threaded_mainloop_wait(mainloop); } + pa_threaded_mainloop_unlock(mainloop); + + return 0; +} + +static void deinit(void) { + // debug(1, "pa deinit start"); + pa_threaded_mainloop_stop(mainloop); + pa_threaded_mainloop_free(mainloop); + // debug(1, "pa deinit done"); +} + +static void start(int sample_rate, int sample_format) { + + uint32_t buffer_size_in_bytes = (uint32_t)2 * 2 * RATE * 0.1; // hard wired in here + // debug(1, "pa_buffer size is %u bytes.", buffer_size_in_bytes); + + pa_threaded_mainloop_lock(mainloop); // Create a playback stream pa_sample_spec sample_specifications; sample_specifications.format = FORMAT; @@ -212,11 +219,8 @@ static void stop(void) { audio_umb = audio_lmb + audio_size; audio_occupancy = 0; - // debug(1, "pa deinit start"); + // debug(1, "finish with stream"); pa_stream_disconnect(stream); - pa_threaded_mainloop_stop(mainloop); - pa_threaded_mainloop_free(mainloop); - // debug(1, "pa deinit done"); } static void help(void) {