diff options
author | Paul McLean <pmclean@google.com> | 2015-02-20 15:39:59 -0800 |
---|---|---|
committer | Paul McLean <pmclean@google.com> | 2015-02-20 15:39:59 -0800 |
commit | f55fdb2d555ae4047225238755209db02db40ebc (patch) | |
tree | def870cf0ad7a76fa7e43a479cd89dda1384e102 /modules | |
parent | 3546c8d66bc9391c3605fa63f1cd34080d1a0224 (diff) | |
download | hardware_libhardware-f55fdb2d555ae4047225238755209db02db40ebc.zip hardware_libhardware-f55fdb2d555ae4047225238755209db02db40ebc.tar.gz hardware_libhardware-f55fdb2d555ae4047225238755209db02db40ebc.tar.bz2 |
Back out locking order and (over) simplification in out_write(), in_read().
Change-Id: I96954f883798f8e10adce56d9c33b70574999d1c
Diffstat (limited to 'modules')
-rw-r--r-- | modules/usbaudio/audio_hal.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/modules/usbaudio/audio_hal.c b/modules/usbaudio/audio_hal.c index e583467..3163424 100644 --- a/modules/usbaudio/audio_hal.c +++ b/modules/usbaudio/audio_hal.c @@ -424,10 +424,12 @@ static ssize_t out_write(struct audio_stream_out *stream, const void* buffer, si if (out->standby) { ret = start_output_stream(out); if (ret != 0) { + pthread_mutex_unlock(&out->dev->lock); goto err; } out->standby = false; } + pthread_mutex_unlock(&out->dev->lock); alsa_device_proxy* proxy = &out->proxy; const void * write_buff = buffer; @@ -458,13 +460,11 @@ static ssize_t out_write(struct audio_stream_out *stream, const void* buffer, si } pthread_mutex_unlock(&out->lock); - pthread_mutex_unlock(&out->dev->lock); return bytes; err: pthread_mutex_unlock(&out->lock); - pthread_mutex_unlock(&out->dev->lock); if (ret != 0) { usleep(bytes * 1000000 / audio_stream_out_frame_size(stream) / out_get_sample_rate(&stream->common)); @@ -807,10 +807,12 @@ static ssize_t in_read(struct audio_stream_in *stream, void* buffer, size_t byte pthread_mutex_lock(&in->lock); if (in->standby) { if (start_input_stream(in) != 0) { + pthread_mutex_unlock(&in->dev->lock); goto err; } in->standby = false; } + pthread_mutex_unlock(&in->dev->lock); alsa_device_profile * profile = in->profile; @@ -896,7 +898,6 @@ static ssize_t in_read(struct audio_stream_in *stream, void* buffer, size_t byte err: pthread_mutex_unlock(&in->lock); - pthread_mutex_unlock(&in->dev->lock); return num_read_buff_bytes; } |