Add unique audio port IDs to AudioTrack and AudioRecord
This will allow to track activity at the track level instead of
at audio session level as only possible with current implementation.
AudioTracks and AudioRecords will receive a unique audio port ID the
first time they register to audio policy with
getOutputForAttr()/getInputForAttr() and keep this ID for their
lifetime.
This CL is the first partial change and just updates the
audio policy and audio flinger APIs used at track creation time.
Test: basic regression test of audio playback and capture use cases
Change-Id: I8d612e67738e120494f61e3f7c60bfd0b2c6a329
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index e8e27e4..9746075 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -75,7 +75,8 @@
uid_t clientUid,
bool isOut,
alloc_type alloc,
- track_type type)
+ track_type type,
+ audio_port_handle_t portId)
: RefBase(),
mThread(thread),
mClient(client),
@@ -96,7 +97,8 @@
mId(android_atomic_inc(&nextTrackId)),
mTerminated(false),
mType(type),
- mThreadIoHandle(thread->id())
+ mThreadIoHandle(thread->id()),
+ mPortId(portId)
{
const uid_t callingUid = IPCThreadState::self()->getCallingUid();
if (!isTrustedCallingUid(callingUid) || clientUid == AUDIO_UID_INVALID) {
@@ -343,12 +345,13 @@
audio_session_t sessionId,
uid_t uid,
audio_output_flags_t flags,
- track_type type)
+ track_type type,
+ audio_port_handle_t portId)
: TrackBase(thread, client, sampleRate, format, channelMask, frameCount,
(sharedBuffer != 0) ? sharedBuffer->pointer() : buffer,
sessionId, uid, true /*isOut*/,
(type == TYPE_PATCH) ? ( buffer == NULL ? ALLOC_LOCAL : ALLOC_NONE) : ALLOC_CBLK,
- type),
+ type, portId),
mFillingUpStatus(FS_INVALID),
// mRetryCount initialized later when needed
mSharedBuffer(sharedBuffer),
@@ -1477,13 +1480,14 @@
audio_session_t sessionId,
uid_t uid,
audio_input_flags_t flags,
- track_type type)
+ track_type type,
+ audio_port_handle_t portId)
: TrackBase(thread, client, sampleRate, format,
channelMask, frameCount, buffer, sessionId, uid, false /*isOut*/,
(type == TYPE_DEFAULT) ?
((flags & AUDIO_INPUT_FLAG_FAST) ? ALLOC_PIPE : ALLOC_CBLK) :
((buffer == NULL) ? ALLOC_LOCAL : ALLOC_NONE),
- type),
+ type, portId),
mOverflow(false),
mFramesToDrop(0),
mResamplerBufferProvider(NULL), // initialize in case of early constructor exit