Add audio attributes info when starting aaudio tracks on MMAP mix.
In aaudio, when adding tracks to mixed stream, it is needed to update
audio attributes to HAL whenever the tracks are added or removed.
Currently, only the audio attributes used to open the stream will be
sent to the HAL. In that case, adding audio attributes of the clients
when starting the stream can help solve the problem. In audio flinger,
the client's audio attributes will be used to create MmapTrack.
Test: play multiple aaudio tracks, add log
Bug: 77279923
Change-Id: Ic1c536049e194a2bb7513425ee4828d52769d27f
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 40519b0..5c20a2d 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -681,7 +681,8 @@
struct audio_mmap_buffer_info *info);
virtual status_t getMmapPosition(struct audio_mmap_position *position);
virtual status_t start(const AudioClient& client,
- audio_port_handle_t *handle);
+ const audio_attributes_t *attr,
+ audio_port_handle_t *handle);
virtual status_t stop(audio_port_handle_t handle);
virtual status_t standby();
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index d8d4d35..105fa14 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -8633,10 +8633,10 @@
}
status_t AudioFlinger::MmapThreadHandle::start(const AudioClient& client,
- audio_port_handle_t *handle)
+ const audio_attributes_t *attr, audio_port_handle_t *handle)
{
- return mThread->start(client, handle);
+ return mThread->start(client, attr, handle);
}
status_t AudioFlinger::MmapThreadHandle::stop(audio_port_handle_t handle)
@@ -8741,6 +8741,7 @@
}
status_t AudioFlinger::MmapThread::start(const AudioClient& client,
+ const audio_attributes_t *attr,
audio_port_handle_t *handle)
{
ALOGV("%s clientUid %d mStandby %d mPortId %d *handle %d", __FUNCTION__,
@@ -8831,9 +8832,10 @@
}
// Given that MmapThread::mAttr is mutable, should a MmapTrack have attributes ?
- sp<MmapTrack> track = new MmapTrack(this, mAttr, mSampleRate, mFormat, mChannelMask, mSessionId,
- isOutput(), client.clientUid, client.clientPid,
- IPCThreadState::self()->getCallingPid(), portId);
+ sp<MmapTrack> track = new MmapTrack(this, attr == nullptr ? mAttr : *attr, mSampleRate, mFormat,
+ mChannelMask, mSessionId, isOutput(), client.clientUid,
+ client.clientPid, IPCThreadState::self()->getCallingPid(),
+ portId);
if (isOutput()) {
// force volume update when a new track is added
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index 8149e95..e5a6196 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -1776,7 +1776,9 @@
status_t createMmapBuffer(int32_t minSizeFrames,
struct audio_mmap_buffer_info *info);
status_t getMmapPosition(struct audio_mmap_position *position);
- status_t start(const AudioClient& client, audio_port_handle_t *handle);
+ status_t start(const AudioClient& client,
+ const audio_attributes_t *attr,
+ audio_port_handle_t *handle);
status_t stop(audio_port_handle_t handle);
status_t standby();