Add playback mute notifications for mmap tracks
Added the portId callback to the aaudio client which is registering it
with the AudioService similar to the AudioTrack clients logic.
MMap tracks have a different way of computing the volume. Some volume
components are computed in the aaudioservice. Note that AppOps mute,
client mute and volume shaper mute are not available for AAudio MMap tracks.
Test: dumpsys audio
Bug: 235521198
Change-Id: I05edaa6646cd21647f1602c1ce695be2233a08fc
diff --git a/media/libaaudio/src/client/AudioStreamInternal.cpp b/media/libaaudio/src/client/AudioStreamInternal.cpp
index 2de878d..07a96b7 100644
--- a/media/libaaudio/src/client/AudioStreamInternal.cpp
+++ b/media/libaaudio/src/client/AudioStreamInternal.cpp
@@ -647,6 +647,8 @@
if (getState() == AAUDIO_STREAM_STATE_STARTING) {
setState(AAUDIO_STREAM_STATE_STARTED);
}
+ mPlayerBase->triggerPortIdUpdate(static_cast<audio_port_handle_t>(
+ message->event.dataLong));
break;
case AAUDIO_SERVICE_EVENT_PAUSED:
ALOGD("%s - got AAUDIO_SERVICE_EVENT_PAUSED", __func__);
diff --git a/media/libaudioclient/PlayerBase.cpp b/media/libaudioclient/PlayerBase.cpp
index 446a58c..651255a 100644
--- a/media/libaudioclient/PlayerBase.cpp
+++ b/media/libaudioclient/PlayerBase.cpp
@@ -58,6 +58,20 @@
}
}
+void PlayerBase::triggerPortIdUpdate(audio_port_handle_t portId) const {
+ if (mAudioManager == nullptr) {
+ ALOGE("%s: no audio service, player %d will not update portId %d",
+ __func__,
+ mPIId,
+ portId);
+ return;
+ }
+
+ if (mPIId != PLAYER_PIID_INVALID && portId != AUDIO_PORT_HANDLE_NONE) {
+ mAudioManager->playerEvent(mPIId, android::PLAYER_UPDATE_PORT_ID, portId);
+ }
+}
+
void PlayerBase::baseDestroy() {
serviceReleasePlayer();
if (mAudioManager != 0) {
diff --git a/media/libaudioclient/include/media/PlayerBase.h b/media/libaudioclient/include/media/PlayerBase.h
index 23b6bfd..5475f76 100644
--- a/media/libaudioclient/include/media/PlayerBase.h
+++ b/media/libaudioclient/include/media/PlayerBase.h
@@ -53,6 +53,10 @@
void baseUpdateDeviceId(audio_port_handle_t deviceId);
+ /**
+ * Updates the mapping in the AudioService between portId and piid
+ */
+ void triggerPortIdUpdate(audio_port_handle_t portId) const;
protected:
void init(player_type_t playerType, audio_usage_t usage, audio_session_t sessionId);
@@ -74,7 +78,6 @@
// player interface ID, uniquely identifies the player in the system
// effectively const after PlayerBase::init().
audio_unique_id_t mPIId;
-
private:
// report events to AudioService
void servicePlayerEvent(player_state_t event, audio_port_handle_t deviceId);