From d44130339c7317faaa5cbab767eccc37347ffd25 Mon Sep 17 00:00:00 2001 From: Jean-Michel Trivi Date: Sun, 30 Sep 2012 11:08:06 -0700 Subject: bug 7253033 Add "exiting" state to remote audio submix module Support receiving a parameter that sets the remote audio submix module in a state where the audio pipe will unblock any current write operation and not block anymore. Change-Id: Ia3119cd79972afff0de24187dae627855a468ebf --- modules/audio_remote_submix/Android.mk | 1 + modules/audio_remote_submix/audio_hw.cpp | 31 +++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/modules/audio_remote_submix/Android.mk b/modules/audio_remote_submix/Android.mk index 735215e..5f54902 100644 --- a/modules/audio_remote_submix/Android.mk +++ b/modules/audio_remote_submix/Android.mk @@ -24,6 +24,7 @@ LOCAL_C_INCLUDES += \ frameworks/av/include/ \ frameworks/native/include/ LOCAL_SHARED_LIBRARIES := liblog libcutils libutils libnbaio +LOCAL_STATIC_LIBRARIES := libmedia_helper LOCAL_MODULE_TAGS := optional include $(BUILD_SHARED_LIBRARY) diff --git a/modules/audio_remote_submix/audio_hw.cpp b/modules/audio_remote_submix/audio_hw.cpp index 0f8adab..b24608f 100755 --- a/modules/audio_remote_submix/audio_hw.cpp +++ b/modules/audio_remote_submix/audio_hw.cpp @@ -31,12 +31,13 @@ #include #include -//#include -//#include #include #include #include +#include +#include + extern "C" { namespace android { @@ -175,6 +176,32 @@ static int out_dump(const struct audio_stream *stream, int fd) static int out_set_parameters(struct audio_stream *stream, const char *kvpairs) { + int exiting = -1; + AudioParameter parms = AudioParameter(String8(kvpairs)); + // FIXME this is using hard-coded strings but in the future, this functionality will be + // converted to use audio HAL extensions required to support tunneling + if ((parms.getInt(String8("exiting"), exiting) == NO_ERROR) && (exiting > 0)) { + const struct submix_stream_out *out = + reinterpret_cast(stream); + + pthread_mutex_lock(&out->dev->lock); + + MonoPipe* sink = out->dev->rsxSink.get(); + if (sink != NULL) { + sink->incStrong(out); + } else { + pthread_mutex_unlock(&out->dev->lock); + return 0; + } + + ALOGI("shutdown"); + sink->shutdown(true); + + sink->decStrong(out); + + pthread_mutex_unlock(&out->dev->lock); + } + return 0; } -- cgit v1.1