summaryrefslogtreecommitdiffstats
path: root/modules/audio_remote_submix
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2012-10-31 14:03:30 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-10-31 14:03:30 -0700
commit76e678cdde9630e6daa364e156ebd6d53a5768ad (patch)
tree46a056a53b3964bd05682d122132868a5a43a439 /modules/audio_remote_submix
parentb0acad33a7891d38100aa84c673280bbd8c1a90d (diff)
parent413f693c90c0f7191c27c70b192ca92a68aa77c7 (diff)
downloadhardware_libhardware-76e678cdde9630e6daa364e156ebd6d53a5768ad.zip
hardware_libhardware-76e678cdde9630e6daa364e156ebd6d53a5768ad.tar.gz
hardware_libhardware-76e678cdde9630e6daa364e156ebd6d53a5768ad.tar.bz2
am 413f693c: am 90b0fbd1: Shutdown audio pipe when closing input stream
* commit '413f693c90c0f7191c27c70b192ca92a68aa77c7': Shutdown audio pipe when closing input stream
Diffstat (limited to 'modules/audio_remote_submix')
-rwxr-xr-xmodules/audio_remote_submix/audio_hw.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/modules/audio_remote_submix/audio_hw.cpp b/modules/audio_remote_submix/audio_hw.cpp
index b24608f..3756274 100755
--- a/modules/audio_remote_submix/audio_hw.cpp
+++ b/modules/audio_remote_submix/audio_hw.cpp
@@ -233,12 +233,22 @@ static ssize_t out_write(struct audio_stream_out *stream, const void* buffer,
ssize_t written_frames = 0;
struct submix_stream_out *out = reinterpret_cast<struct submix_stream_out *>(stream);
+ const size_t frame_size = audio_stream_frame_size(&stream->common);
+ const size_t frames = bytes / frame_size;
+
pthread_mutex_lock(&out->dev->lock);
out->dev->output_standby = false;
MonoPipe* sink = out->dev->rsxSink.get();
if (sink != NULL) {
+ if (sink->isShutdown()) {
+ pthread_mutex_unlock(&out->dev->lock);
+ // the pipe has already been shutdown, this buffer will be lost but we must
+ // simulate timing so we don't drain the output faster than realtime
+ usleep(frames * 1000000 / out_get_sample_rate(&stream->common));
+ return bytes;
+ }
sink->incStrong(buffer);
} else {
pthread_mutex_unlock(&out->dev->lock);
@@ -249,8 +259,6 @@ static ssize_t out_write(struct audio_stream_out *stream, const void* buffer,
pthread_mutex_unlock(&out->dev->lock);
- const size_t frame_size = audio_stream_frame_size(&stream->common);
- const size_t frames = bytes / frame_size;
written_frames = sink->write(buffer, frames);
if (written_frames < 0) {
if (written_frames == (ssize_t)NEGOTIATE) {
@@ -741,6 +749,12 @@ static void adev_close_input_stream(struct audio_hw_device *dev,
pthread_mutex_lock(&rsxadev->lock);
+ MonoPipe* sink = rsxadev->rsxSink.get();
+ if (sink != NULL) {
+ ALOGI("shutdown");
+ sink->shutdown(true);
+ }
+
free(stream);
pthread_mutex_unlock(&rsxadev->lock);