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/media/libaudioclient/Android.bp b/media/libaudioclient/Android.bp
index 04a8a45..e667964 100644
--- a/media/libaudioclient/Android.bp
+++ b/media/libaudioclient/Android.bp
@@ -315,6 +315,7 @@
"aidl/android/media/DeviceConnectedState.aidl",
"aidl/android/media/EffectDescriptor.aidl",
"aidl/android/media/SurroundSoundConfig.aidl",
+ "aidl/android/media/TrackInternalMuteInfo.aidl",
"aidl/android/media/TrackSecondaryOutputInfo.aidl",
],
defaults: [
diff --git a/media/libaudioclient/IAudioFlinger.cpp b/media/libaudioclient/IAudioFlinger.cpp
index aa5c840..cf3b43a 100644
--- a/media/libaudioclient/IAudioFlinger.cpp
+++ b/media/libaudioclient/IAudioFlinger.cpp
@@ -918,6 +918,11 @@
return OK;
}
+status_t AudioFlingerClientAdapter::setTracksInternalMute(
+ const std::vector<media::TrackInternalMuteInfo>& tracksInternalMuted) {
+ return statusTFromBinderStatus(mDelegate->setTracksInternalMute(tracksInternalMuted));
+}
+
////////////////////////////////////////////////////////////////////////////////////////////////////
// AudioFlingerServerAdapter
AudioFlingerServerAdapter::AudioFlingerServerAdapter(
@@ -1477,4 +1482,9 @@
return Status::ok();
}
+Status AudioFlingerServerAdapter::setTracksInternalMute(
+ const std::vector<media::TrackInternalMuteInfo>& tracksInternalMute) {
+ return Status::fromStatusT(mDelegate->setTracksInternalMute(tracksInternalMute));
+}
+
} // namespace android
diff --git a/media/libaudioclient/aidl/android/media/IAudioFlingerService.aidl b/media/libaudioclient/aidl/android/media/IAudioFlingerService.aidl
index 31d3af5..e8fcf77 100644
--- a/media/libaudioclient/aidl/android/media/IAudioFlingerService.aidl
+++ b/media/libaudioclient/aidl/android/media/IAudioFlingerService.aidl
@@ -41,6 +41,7 @@
import android.media.ISoundDoseCallback;
import android.media.MicrophoneInfoFw;
import android.media.RenderPosition;
+import android.media.TrackInternalMuteInfo;
import android.media.TrackSecondaryOutputInfo;
import android.media.audio.common.AudioChannelLayout;
import android.media.audio.common.AudioFormatDescription;
@@ -293,6 +294,11 @@
*/
AudioPortFw getAudioMixPort(in AudioPortFw devicePort, in AudioPortFw mixPort);
+ /**
+ * Set internal mute for a list of tracks.
+ */
+ void setTracksInternalMute(in TrackInternalMuteInfo[] tracksInternalMute);
+
// When adding a new method, please review and update
// IAudioFlinger.h AudioFlingerServerAdapter::Delegate::TransactionCode
// AudioFlinger.cpp AudioFlinger::onTransactWrapper()
diff --git a/media/libaudioclient/aidl/android/media/TrackInternalMuteInfo.aidl b/media/libaudioclient/aidl/android/media/TrackInternalMuteInfo.aidl
new file mode 100644
index 0000000..05b1fa4
--- /dev/null
+++ b/media/libaudioclient/aidl/android/media/TrackInternalMuteInfo.aidl
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media;
+
+parcelable TrackInternalMuteInfo {
+ /* Interpreted as audio_port_handle_t. */
+ int portId;
+ boolean muted;
+}
diff --git a/media/libaudioclient/include/media/IAudioFlinger.h b/media/libaudioclient/include/media/IAudioFlinger.h
index 5a1e037..860a0bc 100644
--- a/media/libaudioclient/include/media/IAudioFlinger.h
+++ b/media/libaudioclient/include/media/IAudioFlinger.h
@@ -60,6 +60,7 @@
#include "android/media/OpenInputResponse.h"
#include "android/media/OpenOutputRequest.h"
#include "android/media/OpenOutputResponse.h"
+#include "android/media/TrackInternalMuteInfo.h"
#include "android/media/TrackSecondaryOutputInfo.h"
namespace android {
@@ -388,6 +389,9 @@
virtual status_t getAudioMixPort(const struct audio_port_v7 *devicePort,
struct audio_port_v7 *mixPort) const = 0;
+
+ virtual status_t setTracksInternalMute(
+ const std::vector<media::TrackInternalMuteInfo>& tracksInternalMute) = 0;
};
/**
@@ -504,6 +508,8 @@
status_t getAudioPolicyConfig(media::AudioPolicyConfig* output) override;
status_t getAudioMixPort(const struct audio_port_v7 *devicePort,
struct audio_port_v7 *mixPort) const override;
+ status_t setTracksInternalMute(
+ const std::vector<media::TrackInternalMuteInfo>& tracksInternalMute) override;
private:
const sp<media::IAudioFlingerService> mDelegate;
@@ -606,6 +612,7 @@
GET_AUDIO_POLICY_CONFIG =
media::BnAudioFlingerService::TRANSACTION_getAudioPolicyConfig,
GET_AUDIO_MIX_PORT = media::BnAudioFlingerService::TRANSACTION_getAudioMixPort,
+ SET_TRACKS_INTERNAL_MUTE = media::BnAudioFlingerService::TRANSACTION_setTracksInternalMute,
};
protected:
@@ -742,6 +749,8 @@
Status getAudioMixPort(const media::AudioPortFw& devicePort,
const media::AudioPortFw& mixPort,
media::AudioPortFw* _aidl_return) override;
+ Status setTracksInternalMute(
+ const std::vector<media::TrackInternalMuteInfo>& tracksInternalMute) override;
private:
const sp<AudioFlingerServerAdapter::Delegate> mDelegate;
};