From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Sat, 29 Jun 2024 18:59:28 +0000 (+0100) Subject: prevent cancellation while performing ao-related operations. X-Git-Tag: 4.3.4~1^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e23ad3f899ec2f12fa22f2d1ca0c4fd73edb788;p=thirdparty%2Fshairport-sync.git prevent cancellation while performing ao-related operations. --- diff --git a/audio_ao.c b/audio_ao.c index 61746487..b53eedc7 100644 --- a/audio_ao.c +++ b/audio_ao.c @@ -69,6 +69,8 @@ static void help(void) { } static int init(int argc, char **argv) { + int oldState; + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldState); // make this un-cancellable ao_initialize(); driver = ao_default_driver_id(); if (driver == -1) { @@ -133,14 +135,18 @@ static int init(int argc, char **argv) { fmt.byte_format = AO_FMT_NATIVE; fmt.matrix = strdup("L,R"); } + pthread_setcancelstate(oldState, NULL); return 0; } static void deinit(void) { + int oldState; + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldState); // make this un-cancellable if (dev != NULL) ao_close(dev); dev = NULL; ao_shutdown(); + pthread_setcancelstate(oldState, NULL); } static void start(__attribute__((unused)) int sample_rate, @@ -166,10 +172,13 @@ static int play(void *buf, int samples, __attribute__((unused)) int sample_type, static void stop(void) { // debug(1,"libao stop"); + int oldState; + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldState); // make this un-cancellable if (dev != NULL) { ao_close(dev); dev = NULL; } + pthread_setcancelstate(oldState, NULL); } audio_output audio_ao = {.name = "ao",