diff options
author | android-build-prod (mdb) <android-build-team-robot@google.com> | 2020-03-30 21:47:30 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-03-30 21:47:30 +0000 |
commit | d06e549b9d3452b20fe292521f25b2ef109760c9 (patch) | |
tree | 21b05a2f10714d7cff7a9cf2f2d39642f9f67d8f | |
parent | 430e5762d82e6bcf8030b985ffb729b507e2cec7 (diff) | |
parent | 4a0697d97fc59de3ae538a62eae4d59494addca2 (diff) | |
download | libhardware-d06e549b9d3452b20fe292521f25b2ef109760c9.tar.gz |
Merge "Snap for 6348162 from 8705f278a3206328161db44772d1402e6954816f to sdk-release" into sdk-releaseplatform-tools-30.0.0
-rw-r--r-- | modules/audio_remote_submix/audio_hw.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/modules/audio_remote_submix/audio_hw.cpp b/modules/audio_remote_submix/audio_hw.cpp index dda0d0ef..30b96eea 100644 --- a/modules/audio_remote_submix/audio_hw.cpp +++ b/modules/audio_remote_submix/audio_hw.cpp @@ -821,12 +821,21 @@ static ssize_t out_write(struct audio_stream_out *stream, const void* buffer, return 0; } - // If the write to the sink would block when no input stream is present, flush enough frames + // If the write to the sink would block, flush enough frames // from the pipe to make space to write the most recent data. + // We DO NOT block if: + // - no peer input stream is present + // - the peer input is in standby AFTER having been active. + // We DO block if: + // - the input was never activated to avoid discarding first frames + // in the pipe in case capture start was delayed { const size_t availableToWrite = sink->availableToWrite(); sp<MonoPipeReader> source = rsxadev->routes[out->route_handle].rsxSource; - if (rsxadev->routes[out->route_handle].input == NULL && availableToWrite < frames) { + const struct submix_stream_in *in = rsxadev->routes[out->route_handle].input; + const bool dont_block = (in == NULL) + || (in->input_standby && (in->read_counter_frames != 0)); + if (dont_block && availableToWrite < frames) { static uint8_t flush_buffer[64]; const size_t flushBufferSizeFrames = sizeof(flush_buffer) / frame_size; size_t frames_to_flush_from_source = frames - availableToWrite; |