summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorSimon Wilson <simonwilson@google.com>2011-07-25 16:56:43 -0700
committerSimon Wilson <simonwilson@google.com>2011-07-25 16:56:43 -0700
commitd974bd3937a1115473c89b1f084a12a4ecf3f988 (patch)
tree902ec205aab288840f1fd6fbec2d9b7e4ec48896 /audio
parent759e6a2aafca4618224698efb2ddd4d43e3eba3e (diff)
downloaddevice_samsung_tuna-d974bd3937a1115473c89b1f084a12a4ecf3f988.zip
device_samsung_tuna-d974bd3937a1115473c89b1f084a12a4ecf3f988.tar.gz
device_samsung_tuna-d974bd3937a1115473c89b1f084a12a4ecf3f988.tar.bz2
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
Diffstat (limited to 'audio')
-rw-r--r--audio/audio_hw.c4
1 files changed, 4 insertions, 0 deletions
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;