From d974bd3937a1115473c89b1f084a12a4ecf3f988 Mon Sep 17 00:00:00 2001 From: Simon Wilson Date: Mon, 25 Jul 2011 16:56:43 -0700 Subject: audio: add missing locks The device lock must be held when using the mixer because mixer_* calls are not thread safe. This fixes a bug where some mixer controls including the earpiece volume were not being set at boot. Bug: 5073076 Change-Id: Ide060ccad49e7276b7555428d2ff3ab399a5ce40 --- audio/audio_hw.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'audio') diff --git a/audio/audio_hw.c b/audio/audio_hw.c index a9a5be7..4eac118 100644 --- a/audio/audio_hw.c +++ b/audio/audio_hw.c @@ -730,6 +730,7 @@ static int start_input_stream(struct tuna_stream_in *in) * Also check how capture is possible during voice calls or if both use cases are mutually * exclusive. */ + pthread_mutex_lock(&adev->lock); if (in->port == PORT_VX) set_route_by_array(adev->mixer, vx_ul_amic, 1); else @@ -737,6 +738,7 @@ static int start_input_stream(struct tuna_stream_in *in) mixer_ctl_set_enum_by_string(adev->mixer_ctls.left_capture, MIXER_MAIN_MIC); + pthread_mutex_unlock(&adev->lock); /* this assumes routing is done previously */ in->pcm = pcm_open(0, in->port, PCM_IN, &in->config); @@ -1265,6 +1267,7 @@ static int adev_open(const hw_module_t* module, const char* name, } /* Set the default route before the PCM stream is opened */ + pthread_mutex_lock(&adev->lock); set_route_by_array(adev->mixer, defaults, 1); adev->mode = AUDIO_MODE_NORMAL; adev->out_device = AUDIO_DEVICE_OUT_SPEAKER; @@ -1276,6 +1279,7 @@ static int adev_open(const hw_module_t* module, const char* name, /* RIL */ ril_open(&adev->ril); + pthread_mutex_unlock(&adev->lock); *device = &adev->device.common; -- cgit v1.1