Concurrent playback behavior when bit-perfect client is active.
1. Mute system sound on bit-perfect output thread. System sound such as
touch sound can be triggered often. To provide better bit-perfect
playback experience, mute system sound on bit-perfect output thread.
2. Mute bit-perfect track when there are other clients playing. When
there are other clients, such as notification, playing, the
bit-perfect client can no longer be played bit-perfectly. As the
bit-perfect client can turn out to be noise if it cannot be played
bit-perfectly, mute bit-perfect client when there are other clients
playing.
3. Do not allow creating bit-perfect client if there is any other high
priority use case, such as ringtone, alarm, active. The reason is
that the high priority clients will always take the audio focus for
the playback and there is no need for those clients to be played over
bit-perfect path.
Bug: 339515899
Test: atest audiopolicy_tests
Test: Manually
Change-Id: I8483d08085fd4076fa64ed4de278e45e6f6c0af0
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index d5d778f..46c85af 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -4915,6 +4915,23 @@
return mPatchPanel->getAudioMixPort_l(devicePort, mixPort);
}
+status_t AudioFlinger::setTracksInternalMute(
+ const std::vector<media::TrackInternalMuteInfo>& tracksInternalMute) {
+ audio_utils::lock_guard _l(mutex());
+ ALOGV("%s", __func__);
+
+ std::map<audio_port_handle_t, bool> tracksInternalMuteMap;
+ for (const auto& trackInternalMute : tracksInternalMute) {
+ audio_port_handle_t portId = VALUE_OR_RETURN_STATUS(
+ aidl2legacy_int32_t_audio_port_handle_t(trackInternalMute.portId));
+ tracksInternalMuteMap.emplace(portId, trackInternalMute.muted);
+ }
+ for (size_t i = 0; i < mPlaybackThreads.size() && !tracksInternalMuteMap.empty(); i++) {
+ mPlaybackThreads.valueAt(i)->setTracksInternalMute(&tracksInternalMuteMap);
+ }
+ return NO_ERROR;
+}
+
// ----------------------------------------------------------------------------
status_t AudioFlinger::onTransactWrapper(TransactionCode code,
@@ -4949,6 +4966,7 @@
case TransactionCode::INVALIDATE_TRACKS:
case TransactionCode::GET_AUDIO_POLICY_CONFIG:
case TransactionCode::GET_AUDIO_MIX_PORT:
+ case TransactionCode::SET_TRACKS_INTERNAL_MUTE:
ALOGW("%s: transaction %d received from PID %d",
__func__, static_cast<int>(code), IPCThreadState::self()->getCallingPid());
// return status only for non void methods