audio: refactor update metadata process
The meta data isn't updated when stream volume was changed on MMAP
playback thread.
- Move readAndClearHasChanged() and
setMetadataHasChanged() from Track to TrackBase and changes of meta
data is able to be noticed for all types of track.
- Added the flow to check every track's status on
ActiveTracks<T>::readAndClearHasChanged().
- Added isStreamInitialized() in ThreadBase to simplify the processed
flow for each thread.
Bug: 187769565
Test: mmap playback/deep-buffer/offload/low-latency
Signed-off-by: Jasmine Cha <chajasmine@google.com>
Change-Id: I949772cf38c77de4e41d4d699231c1edecf70f76
Merged-In: I949772cf38c77de4e41d4d699231c1edecf70f76
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index 65db986..17acb16 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -527,6 +527,8 @@
}
}
+ virtual bool isStreamInitialized() = 0;
+
protected:
// entry describing an effect being suspended in mSuspendedSessions keyed vector
@@ -741,7 +743,9 @@
void updatePowerState(sp<ThreadBase> thread, bool force = false);
/** @return true if one or move active tracks was added or removed since the
- * last time this function was called or the vector was created. */
+ * last time this function was called or the vector was created.
+ * true if volume of one of active tracks was changed.
+ */
bool readAndClearHasChanged();
private:
@@ -993,6 +997,10 @@
&& outDeviceTypes().count(mTimestampCorrectedDevice) != 0;
}
+ virtual bool isStreamInitialized() {
+ return !(mOutput == nullptr || mOutput->stream == nullptr);
+ }
+
audio_channel_mask_t hapticChannelMask() const override {
return mHapticChannelMask;
}
@@ -1780,6 +1788,10 @@
audio_session_t sharedSessionId = AUDIO_SESSION_NONE,
int64_t sharedAudioStartMs = -1);
+ virtual bool isStreamInitialized() {
+ return !(mInput == nullptr || mInput->stream == nullptr);
+ }
+
protected:
void dumpInternals_l(int fd, const Vector<String16>& args) override;
void dumpTracks_l(int fd, const Vector<String16>& args) override;
@@ -1949,6 +1961,8 @@
virtual void setRecordSilenced(audio_port_handle_t portId __unused,
bool silenced __unused) {}
+ virtual bool isStreamInitialized() { return false; }
+
protected:
void dumpInternals_l(int fd, const Vector<String16>& args) override;
void dumpTracks_l(int fd, const Vector<String16>& args) override;
@@ -2011,6 +2025,10 @@
status_t getExternalPosition(uint64_t *position, int64_t *timeNanos) override;
+ virtual bool isStreamInitialized() {
+ return !(mOutput == nullptr || mOutput->stream == nullptr);
+ }
+
protected:
void dumpInternals_l(int fd, const Vector<String16>& args) override;
@@ -2043,6 +2061,10 @@
status_t getExternalPosition(uint64_t *position, int64_t *timeNanos) override;
+ virtual bool isStreamInitialized() {
+ return !(mInput == nullptr || mInput->stream == nullptr);
+ }
+
protected:
AudioStreamIn* mInput;