AudioFlinger: Extract TeePatch
Test: atest audiorecord_tests audiotrack_tests audiorouting_tests trackplayerbase_tests audiosystem_tests
Test: atest AAudioTests AudioTrackOffloadTest
Test: atest AudioTrackTest AudioRecordTest
Test: YouTube Camera
Bug: 288339104
Merged-In: I88576005a266fd6beeabec873a2d531a65dcf9fd
Change-Id: I88576005a266fd6beeabec873a2d531a65dcf9fd
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 4ad2e58..5c6fc9c 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -3999,7 +3999,7 @@
patchTrack->setPeerProxy(patchRecord, true /* holdReference */);
patchRecord->setPeerProxy(patchTrack, false /* holdReference */);
}
- track->setTeePatchesToUpdate_l(&teePatches); // TODO(b/288339104) void* to std::move()
+ track->setTeePatchesToUpdate_l(std::move(teePatches));
}
sp<audioflinger::SyncEvent> AudioFlinger::createSyncEvent(AudioSystem::sync_event_t type,
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 85bb746..d18300b 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -583,13 +583,6 @@
// Requests media.log to start merging log buffers
void requestLogMerge();
- // TODO(b/288339104) replace these forward declaration classes with interfaces.
-private:
- struct TeePatch;
-public:
- using TeePatches = std::vector<TeePatch>;
-private:
-
// Find io handle by session id.
// Preference is given to an io handle with a matching effect chain to session id.
// If none found, AUDIO_IO_HANDLE_NONE is returned.
@@ -723,11 +716,6 @@
audio_io_handle_t upStream, const String8& keyValuePairs,
const std::function<bool(const sp<IAfPlaybackThread>&)>& useThread = nullptr);
- struct TeePatch {
- sp<IAfPatchRecord> patchRecord;
- sp<IAfPatchTrack> patchTrack;
- };
-
// for mAudioSessionRefs only
struct AudioSessionRef {
AudioSessionRef(audio_session_t sessionid, pid_t pid, uid_t uid) :
diff --git a/services/audioflinger/IAfTrack.h b/services/audioflinger/IAfTrack.h
index 9ca13ca..cac8e40 100644
--- a/services/audioflinger/IAfTrack.h
+++ b/services/audioflinger/IAfTrack.h
@@ -19,10 +19,19 @@
namespace android {
class IAfDuplicatingThread;
+class IAfPatchRecord;
+class IAfPatchTrack;
class IAfPlaybackThread;
class IAfRecordThread;
class IAfThreadBase;
+struct TeePatch {
+ sp<IAfPatchRecord> patchRecord;
+ sp<IAfPatchTrack> patchTrack;
+};
+
+using TeePatches = std::vector<TeePatch>;
+
// Common interface to all Playback and Record tracks.
class IAfTrackBase : public virtual RefBase {
public:
@@ -325,9 +334,8 @@
// This function should be called with holding thread lock.
virtual void updateTeePatches_l() = 0;
- // TODO(b/288339104) type
- virtual void setTeePatchesToUpdate_l(
- const void* teePatchesToUpdate /* TeePatches& teePatchesToUpdate */) = 0;
+ // Argument teePatchesToUpdate is by value, use std::move to optimize.
+ virtual void setTeePatchesToUpdate_l(TeePatches teePatchesToUpdate) = 0;
static bool checkServerLatencySupported(audio_format_t format, audio_output_flags_t flags) {
return audio_is_linear_pcm(format) && (flags & AUDIO_OUTPUT_FLAG_HW_AV_SYNC) == 0;
diff --git a/services/audioflinger/PlaybackTracks.h b/services/audioflinger/PlaybackTracks.h
index 6a2887d..308a691 100644
--- a/services/audioflinger/PlaybackTracks.h
+++ b/services/audioflinger/PlaybackTracks.h
@@ -189,11 +189,7 @@
// This function should be called with holding thread lock.
void updateTeePatches_l() final;
- void setTeePatchesToUpdate_l(const void* teePatchesToUpdate) final {
- setTeePatchesToUpdate_l( // TODO(b/288339104) void*
- *reinterpret_cast<const AudioFlinger::TeePatches*>(teePatchesToUpdate));
- }
- void setTeePatchesToUpdate_l(AudioFlinger::TeePatches teePatchesToUpdate);
+ void setTeePatchesToUpdate_l(TeePatches teePatchesToUpdate) final;
void tallyUnderrunFrames(size_t frames) final {
if (isOut()) { // we expect this from output tracks only
@@ -389,8 +385,8 @@
bool mFlushHwPending; // track requests for thread flush
bool mPauseHwPending = false; // direct/offload track request for thread pause
audio_output_flags_t mFlags;
- AudioFlinger::TeePatches mTeePatches;
- std::optional<AudioFlinger::TeePatches> mTeePatchesToUpdate;
+ TeePatches mTeePatches;
+ std::optional<TeePatches> mTeePatchesToUpdate;
const float mSpeed;
const bool mIsSpatialized;
const bool mIsBitPerfect;
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index 2a59315..7989410 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -1615,7 +1615,7 @@
}
}
-void Track::setTeePatchesToUpdate_l(AudioFlinger::TeePatches teePatchesToUpdate) {
+void Track::setTeePatchesToUpdate_l(TeePatches teePatchesToUpdate) {
ALOGW_IF(mTeePatchesToUpdate.has_value(),
"%s, existing tee patches to update will be ignored", __func__);
mTeePatchesToUpdate = std::move(teePatchesToUpdate);