From: Mike Brady Date: Mon, 19 Nov 2018 15:35:04 +0000 (+0000) Subject: Use pthread_cleanup to unlock alsa handle mutex. X-Git-Tag: 3.3RC0~171 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ad0b15ec07a395b3892aad0722e667ec1bcadde;p=thirdparty%2Fshairport-sync.git Use pthread_cleanup to unlock alsa handle mutex. --- diff --git a/audio_alsa.c b/audio_alsa.c index 48f6a650..9e28dd47 100644 --- a/audio_alsa.c +++ b/audio_alsa.c @@ -489,8 +489,7 @@ static int init(int argc, char **argv) { } close_mixer(); } - debug_mutex_unlock(&alsa_mutex, 3); - pthread_cleanup_pop(0); // release the mutex + pthread_cleanup_pop(1); // release the mutex } else { // debug(1, "Has no mixer and thus no hardware mute."); } @@ -920,8 +919,8 @@ int delay(long *the_delay) { } } } - debug_mutex_unlock(&alsa_mutex, 3); - pthread_cleanup_pop(0); + // debug_mutex_unlock(&alsa_mutex, 3); + pthread_cleanup_pop(1); // here, occasionally pretend there's a problem with pcm_get_delay() // if ((random() % 100000) < 3) // keep it pretty rare // reply = -EIO; // pretend something bad has happened @@ -955,8 +954,8 @@ static int play(void *buf, int samples) { do_mute(0); } - debug_mutex_unlock(&alsa_mutex, 3); - pthread_cleanup_pop(0); // release the mutex + // debug_mutex_unlock(&alsa_mutex, 3); + pthread_cleanup_pop(1); // release the mutex } if (ret == 0) { pthread_cleanup_debug_mutex_lock(&alsa_mutex, 10000, 1); @@ -1041,8 +1040,8 @@ static int play(void *buf, int samples) { frame_index = 0; measurement_data_is_valid = 0; } - debug_mutex_unlock(&alsa_mutex, 3); - pthread_cleanup_pop(0); // release the mutex + // debug_mutex_unlock(&alsa_mutex, 3); + pthread_cleanup_pop(1); // release the mutex } return ret; } @@ -1068,8 +1067,8 @@ static void flush(void) { measurement_data_is_valid = 0; alsa_handle = NULL; } - debug_mutex_unlock(&alsa_mutex, 3); - pthread_cleanup_pop(0); // release the mutex + // debug_mutex_unlock(&alsa_mutex, 3); + pthread_cleanup_pop(1); // release the mutex } static void stop(void) { @@ -1125,8 +1124,8 @@ void volume(double vol) { pthread_cleanup_debug_mutex_lock(&alsa_mutex, 1000, 1); volume_set_request = 1; // an external request has been made to set the volume do_volume(vol); - debug_mutex_unlock(&alsa_mutex, 3); - pthread_cleanup_pop(0); // release the mutex + // debug_mutex_unlock(&alsa_mutex, 3); + pthread_cleanup_pop(1); // release the mutex } /* @@ -1153,8 +1152,8 @@ static void mute(int mute_state_requested) { mute_request_pending = 1; overriding_mute_state_requested = mute_state_requested; do_mute(mute_state_requested); - debug_mutex_unlock(&alsa_mutex, 3); - pthread_cleanup_pop(0); // release the mutex + // debug_mutex_unlock(&alsa_mutex, 3); + pthread_cleanup_pop(1); // release the mutex } void do_mute(int mute_state_requested) {