summaryrefslogtreecommitdiff
path: root/audio
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2012-08-29 18:51:31 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-08-30 10:39:36 -0700
commitbd222dc20ef4e512393ace3d031012ea44c7e666 (patch)
tree8456b932c8b3dbc1a8cfd7a438de0ac2daf0b39d /audio
parent2f7c07158e8fdaaedaace5980dbb1a253c352b15 (diff)
audio: fix crash when starting capture
When starting capture, we check if a playback stream is active with an incompatible sampling rate and if yes force this stream in standby. The output stream lock is acquired while requesting standby. The problem is that this stream is referenced by adev->active_out which is cleared by do_output_standby() and a crash occurs when releasing the lock. The same problem is present when starting a playback stream and a capture stream is active. Change-Id: I72ce058308371199655e3b2e1cfc0529328555ec
Diffstat (limited to 'audio')
-rw-r--r--audio/audio_hw.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
index 3182c00..5159cb5 100644
--- a/audio/audio_hw.c
+++ b/audio/audio_hw.c
@@ -281,13 +281,14 @@ static int start_output_stream(struct stream_out *out)
* the most common rate, but group 2 is required for SCO.
*/
if (adev->active_in) {
- pthread_mutex_lock(&adev->active_in->lock);
+ struct stream_in *in = adev->active_in;
+ pthread_mutex_lock(&in->lock);
if (((out->pcm_config->rate % 8000 == 0) &&
- (adev->active_in->pcm_config->rate % 8000) != 0) ||
+ (in->pcm_config->rate % 8000) != 0) ||
((out->pcm_config->rate % 11025 == 0) &&
- (adev->active_in->pcm_config->rate % 11025) != 0))
- do_in_standby(adev->active_in);
- pthread_mutex_unlock(&adev->active_in->lock);
+ (in->pcm_config->rate % 11025) != 0))
+ do_in_standby(in);
+ pthread_mutex_unlock(&in->lock);
}
out->pcm = pcm_open(PCM_CARD, device, PCM_OUT | PCM_NORESTART, out->pcm_config);
@@ -348,13 +349,14 @@ static int start_input_stream(struct stream_in *in)
* the most common rate, but group 2 is required for SCO.
*/
if (adev->active_out) {
- pthread_mutex_lock(&adev->active_out->lock);
+ struct stream_out *out = adev->active_out;
+ pthread_mutex_lock(&out->lock);
if (((in->pcm_config->rate % 8000 == 0) &&
- (adev->active_out->pcm_config->rate % 8000) != 0) ||
+ (out->pcm_config->rate % 8000) != 0) ||
((in->pcm_config->rate % 11025 == 0) &&
- (adev->active_out->pcm_config->rate % 11025) != 0))
- do_out_standby(adev->active_out);
- pthread_mutex_unlock(&adev->active_out->lock);
+ (out->pcm_config->rate % 11025) != 0))
+ do_out_standby(out);
+ pthread_mutex_unlock(&out->lock);
}
in->pcm = pcm_open(PCM_CARD, device, PCM_IN, in->pcm_config);