From 0347f0eff05734a223367cc6c1b3ad09979ef985 Mon Sep 17 00:00:00 2001 From: Shunkai Yao Date: Tue, 12 Dec 2023 22:55:55 +0000 Subject: [PATCH] Revert "audio: Fix remote submix behavior with multiple inputs" Revert submission 2862771-cuttlefish_aidl_audio-2 Reason for revert: b/316027906 Reverted changes: /q/submissionid:2862771-cuttlefish_aidl_audio-2 Change-Id: I68932be8dad4b4fd4214d0ae6fc01202727f1658 --- audio/aidl/default/Configuration.cpp | 4 ++-- audio/aidl/default/r_submix/ModuleRemoteSubmix.cpp | 2 +- audio/aidl/default/r_submix/StreamRemoteSubmix.cpp | 6 ++++-- audio/aidl/default/r_submix/SubmixRoute.cpp | 6 ++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/audio/aidl/default/Configuration.cpp b/audio/aidl/default/Configuration.cpp index 2a8e58f843..d63e353462 100644 --- a/audio/aidl/default/Configuration.cpp +++ b/audio/aidl/default/Configuration.cpp @@ -321,9 +321,9 @@ std::unique_ptr getPrimaryConfiguration() { // // Mix ports: // * "r_submix output", maximum 10 opened streams, maximum 10 active streams -// - profile PCM 16-bit; STEREO; 8000, 11025, 16000, 32000, 44100, 48000 +// - profile PCM 16-bit; MONO, STEREO; 8000, 11025, 16000, 32000, 44100, 48000 // * "r_submix input", maximum 10 opened streams, maximum 10 active streams -// - profile PCM 16-bit; STEREO; 8000, 11025, 16000, 32000, 44100, 48000 +// - profile PCM 16-bit; MONO, STEREO; 8000, 11025, 16000, 32000, 44100, 48000 // // Routes: // "r_submix output" -> "Remote Submix Out" diff --git a/audio/aidl/default/r_submix/ModuleRemoteSubmix.cpp b/audio/aidl/default/r_submix/ModuleRemoteSubmix.cpp index 2f4288976f..3e8dd7cb39 100644 --- a/audio/aidl/default/r_submix/ModuleRemoteSubmix.cpp +++ b/audio/aidl/default/r_submix/ModuleRemoteSubmix.cpp @@ -112,7 +112,7 @@ int32_t ModuleRemoteSubmix::getNominalLatencyMs(const AudioPortConfig&) { static constexpr int32_t kMaxLatencyMs = (r_submix::kDefaultPipeSizeInFrames * 1000) / r_submix::kDefaultSampleRateHz; static constexpr int32_t kMinLatencyMs = kMaxLatencyMs / r_submix::kDefaultPipePeriodCount; - return kMinLatencyMs; + return (kMaxLatencyMs + kMinLatencyMs) / 2; } } // namespace aidl::android::hardware::audio::core diff --git a/audio/aidl/default/r_submix/StreamRemoteSubmix.cpp b/audio/aidl/default/r_submix/StreamRemoteSubmix.cpp index d238aa42b3..6258c938b0 100644 --- a/audio/aidl/default/r_submix/StreamRemoteSubmix.cpp +++ b/audio/aidl/default/r_submix/StreamRemoteSubmix.cpp @@ -73,8 +73,10 @@ std::map> StreamRemoteSubmix::s LOG(ERROR) << __func__ << ": nullptr sink when opening stream"; return ::android::NO_INIT; } - if ((!mIsInput || mCurrentRoute->isStreamInOpen()) && sink->isShutdown()) { - LOG(DEBUG) << __func__ << ": Shut down sink when opening stream"; + // If the sink has been shutdown or pipe recreation is forced, delete the pipe and + // recreate it. + if (sink->isShutdown()) { + LOG(DEBUG) << __func__ << ": Non-nullptr shut down sink when opening stream"; if (::android::OK != mCurrentRoute->resetPipe()) { LOG(ERROR) << __func__ << ": reset pipe failed"; return ::android::NO_INIT; diff --git a/audio/aidl/default/r_submix/SubmixRoute.cpp b/audio/aidl/default/r_submix/SubmixRoute.cpp index 235c9a3f32..f04e607283 100644 --- a/audio/aidl/default/r_submix/SubmixRoute.cpp +++ b/audio/aidl/default/r_submix/SubmixRoute.cpp @@ -98,9 +98,6 @@ void SubmixRoute::openStream(bool isInput) { } mStreamInStandby = true; mReadCounterFrames = 0; - if (mSink != nullptr) { - mSink->shutdown(false); - } } else { mStreamOutOpen = true; } @@ -109,7 +106,8 @@ void SubmixRoute::openStream(bool isInput) { void SubmixRoute::closeStream(bool isInput) { std::lock_guard guard(mLock); if (isInput) { - if (--mInputRefCount == 0) { + mInputRefCount--; + if (mInputRefCount == 0) { mStreamInOpen = false; if (mSink != nullptr) { mSink->shutdown(true);