From 75e0792b8fe2c6c90c4ab9a1793f8ba845e9fa4d Mon Sep 17 00:00:00 2001 From: Simon Wilson Date: Thu, 6 Oct 2011 15:33:55 -0700 Subject: audio: add locks, only tear down PCMs when needed for WB AMR Change-Id: I03ba325b613aef21dba8d16187aaccca08d2a328 --- audio/audio_hw.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'audio') diff --git a/audio/audio_hw.c b/audio/audio_hw.c index e70f767..e954fbe 100755 --- a/audio/audio_hw.c +++ b/audio/audio_hw.c @@ -623,13 +623,18 @@ static void end_call(struct tuna_audio_device *adev) void audio_set_wb_amr_callback(void *data, int enable) { struct tuna_audio_device *adev = (struct tuna_audio_device *)data; - adev->wb_amr = enable; - /* reopen the modem PCMs at the new rate */ - if (adev->in_call) { - end_call(adev); - start_call(adev); + pthread_mutex_lock(&adev->lock); + if (adev->wb_amr != enable) { + adev->wb_amr = enable; + + /* reopen the modem PCMs at the new rate */ + if (adev->in_call) { + end_call(adev); + start_call(adev); + } } + pthread_mutex_unlock(&adev->lock); } static void set_incall_device(struct tuna_audio_device *adev) -- cgit v1.1