Add flag DIRECT to track flags for track running on DirectOutputThread
If the playback thread is DirectOutputThread, add
AUDIO_OUTPUT_FLAG_DIRECT to the track's flags. This allows HAL to
receive `Flush`, as well as many other control signals, when client
sends the commands.
Bug: 111196161
Test: On device
Change-Id: I48fae1e05cfb7aabf53a050c72ec78d18e478b0a
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 850a8b3..90b59b3 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -2356,10 +2356,20 @@
}
}
+ // Set DIRECT flag if current thread is DirectOutputThread. This can
+ // happen when the playback is rerouted to direct output thread by
+ // dynamic audio policy.
+ // Do NOT report the flag changes back to client, since the client
+ // doesn't explicitly request a direct flag.
+ audio_output_flags_t trackFlags = *flags;
+ if (mType == DIRECT) {
+ trackFlags = static_cast<audio_output_flags_t>(trackFlags | AUDIO_OUTPUT_FLAG_DIRECT);
+ }
+
track = new Track(this, client, streamType, attr, sampleRate, format,
channelMask, frameCount,
nullptr /* buffer */, (size_t)0 /* bufferSize */, sharedBuffer,
- sessionId, creatorPid, uid, *flags, TrackBase::TYPE_DEFAULT, portId);
+ sessionId, creatorPid, uid, trackFlags, TrackBase::TYPE_DEFAULT, portId);
lStatus = track != 0 ? track->initCheck() : (status_t) NO_MEMORY;
if (lStatus != NO_ERROR) {