summaryrefslogtreecommitdiffstats
path: root/modules/audio_remote_submix
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2014-12-09 20:20:15 -0800
committerJean-Michel Trivi <jmtrivi@google.com>2014-12-09 20:27:11 -0800
commit257fde6eb533b890776c8c45be8b61c48ab04945 (patch)
tree0935faf841d0d19d5699ee462cf2b69f86df8c17 /modules/audio_remote_submix
parent285fed09639f66923529289d71cc633ad738c96c (diff)
downloadhardware_libhardware-257fde6eb533b890776c8c45be8b61c48ab04945.zip
hardware_libhardware-257fde6eb533b890776c8c45be8b61c48ab04945.tar.gz
hardware_libhardware-257fde6eb533b890776c8c45be8b61c48ab04945.tar.bz2
Reroute submix HAL: fix race condition on output state
When reading from a pipe, the output may have been previously closed, therefore the output state should only be read if it is still available. This fixes a race condition observed between in_read() (which accesses the output stream) and adev_close_output_stream() (which sets the output reference to NULL). No issue with out_write() which checks the input reference. Bug 16009464 Change-Id: I979bc12c8fe91fad9b6f6c9e0be107c1bacae360
Diffstat (limited to 'modules/audio_remote_submix')
-rw-r--r--modules/audio_remote_submix/audio_hw.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/modules/audio_remote_submix/audio_hw.cpp b/modules/audio_remote_submix/audio_hw.cpp
index bd50246..b9dcf7a 100644
--- a/modules/audio_remote_submix/audio_hw.cpp
+++ b/modules/audio_remote_submix/audio_hw.cpp
@@ -1036,9 +1036,10 @@ static ssize_t in_read(struct audio_stream_in *stream, void* buffer,
SUBMIX_ALOGV("in_read bytes=%zu", bytes);
pthread_mutex_lock(&rsxadev->lock);
- const bool output_standby_transition =
- (in->output_standby_rec_thr != rsxadev->routes[in->route_handle].output->output_standby);
- in->output_standby_rec_thr = rsxadev->routes[in->route_handle].output->output_standby;
+ const bool output_standby = rsxadev->routes[in->route_handle].output == NULL
+ ? true : rsxadev->routes[in->route_handle].output->output_standby;
+ const bool output_standby_transition = (in->output_standby_rec_thr != output_standby);
+ in->output_standby_rec_thr = output_standby;
if (in->input_standby || output_standby_transition) {
in->input_standby = false;