AudioFlinger: Control volume using Port ID
This CL migrates the volume management within AudioFlinger
from stream type to port ID.
It gives full power to AudioPolicy to compute the list of port
(so MmapThreads/Tracks) on which volume control is required.
It prevents from overwritting MUSIC stream type which is
the default for volume groups without associated stream type.
Bug: 317212590
Test: build & play audio
Test: atest audiopolicy_tests
Flag: com.android.media.audioserver.portid_volume_management
Change-Id: I4c9e8bb45660c9ceffcc0f4029b0617f9795ab3c
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index 654b841..ba5c09c 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -836,6 +836,12 @@
typename SortedVector<sp<T>>::iterator end() {
return mActiveTracks.end();
}
+ typename SortedVector<const sp<T>>::iterator begin() const {
+ return mActiveTracks.begin();
+ }
+ typename SortedVector<const sp<T>>::iterator end() const {
+ return mActiveTracks.end();
+ }
// Due to Binder recursion optimization, clear() and updatePowerState()
// cannot be called from a Binder thread because they may call back into
@@ -1011,6 +1017,7 @@
void setStreamVolume(audio_stream_type_t stream, float value) final EXCLUDES_ThreadBase_Mutex;
void setStreamMute(audio_stream_type_t stream, bool muted) final EXCLUDES_ThreadBase_Mutex;
float streamVolume(audio_stream_type_t stream) const final EXCLUDES_ThreadBase_Mutex;
+ sp<VolumePortInterface> getVolumePortInterface(audio_port_handle_t port) const;
void setVolumeForOutput_l(float left, float right) const final;
sp<IAfTrack> createTrack_l(
@@ -1035,7 +1042,8 @@
const sp<media::IAudioTrackCallback>& callback,
bool isSpatialized,
bool isBitPerfect,
- audio_output_flags_t* afTrackFlags) final
+ audio_output_flags_t* afTrackFlags,
+ float volume) final
REQUIRES(audio_utils::AudioFlinger_Mutex);
bool isTrackActive(const sp<IAfTrack>& track) const final {
@@ -2386,6 +2394,8 @@
void setStreamMute(audio_stream_type_t stream, bool muted) final EXCLUDES_ThreadBase_Mutex;
float streamVolume(audio_stream_type_t stream) const final EXCLUDES_ThreadBase_Mutex;
+ sp<VolumePortInterface> getVolumePortInterface(audio_port_handle_t port) const;
+
void setMasterMute_l(bool muted) REQUIRES(mutex()) { mMasterMute = muted; }
void invalidateTracks(audio_stream_type_t streamType) final EXCLUDES_ThreadBase_Mutex;