Add selectPresentation API to IAudioTrack
The Java AudioTrack interface has a setPresentation API. This
calls the setParameters API in IAudioTrack. However, this does
not eventuate into a call into the android.hardware.audio@4.0
IStreamOut selectPresentation API.
Add selectPresentation API to IAudioTrack and call down to the
android.hardware.audio@4.0 IStreamOut selectPresentation API.
Translate into calls to setParameters API for legacy HAL
interfaces.
Bug: 63901775
Test: compile
Change-Id: Id634a107f3f93ab18dc80d2bd0af67bda35e859f
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index b6b3815..1b20693 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -553,6 +553,7 @@
virtual void pause();
virtual status_t attachAuxEffect(int effectId);
virtual status_t setParameters(const String8& keyValuePairs);
+ virtual status_t selectPresentation(int presentationId, int programId);
virtual media::VolumeShaper::Status applyVolumeShaper(
const sp<media::VolumeShaper::Configuration>& configuration,
const sp<media::VolumeShaper::Operation>& operation) override;
diff --git a/services/audioflinger/PlaybackTracks.h b/services/audioflinger/PlaybackTracks.h
index 53ea9a4..971f6a5 100644
--- a/services/audioflinger/PlaybackTracks.h
+++ b/services/audioflinger/PlaybackTracks.h
@@ -67,6 +67,7 @@
bool isStatic() const { return mSharedBuffer.get() != nullptr; }
status_t setParameters(const String8& keyValuePairs);
+ status_t selectPresentation(int presentationId, int programId);
status_t attachAuxEffect(int EffectId);
void setAuxBuffer(int EffectId, int32_t *buffer);
int32_t *auxBuffer() const { return mAuxBuffer; }
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index f833cf7..cec0819 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -2413,6 +2413,14 @@
return String8();
}
+status_t AudioFlinger::DirectOutputThread::selectPresentation(int presentationId, int programId) {
+ Mutex::Autolock _l(mLock);
+ if (mOutput == nullptr || mOutput->stream == nullptr) {
+ return NO_INIT;
+ }
+ return mOutput->stream->selectPresentation(presentationId, programId);
+}
+
void AudioFlinger::PlaybackThread::ioConfigChanged(audio_io_config_event event, pid_t pid) {
sp<AudioIoDescriptor> desc = new AudioIoDescriptor();
ALOGV("PlaybackThread::ioConfigChanged, thread %p, event %d", this, event);
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index 49fc234..7f3ea0f 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -1199,6 +1199,8 @@
audio_io_handle_t id, audio_devices_t device, bool systemReady);
virtual ~DirectOutputThread();
+ status_t selectPresentation(int presentationId, int programId);
+
// Thread virtuals
virtual bool checkForNewParameter_l(const String8& keyValuePair,
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index f2617ae..91a3286 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -326,6 +326,10 @@
return mTrack->setParameters(keyValuePairs);
}
+status_t AudioFlinger::TrackHandle::selectPresentation(int presentationId, int programId) {
+ return mTrack->selectPresentation(presentationId, programId);
+}
+
VolumeShaper::Status AudioFlinger::TrackHandle::applyVolumeShaper(
const sp<VolumeShaper::Configuration>& configuration,
const sp<VolumeShaper::Operation>& operation) {
@@ -976,6 +980,19 @@
}
}
+status_t AudioFlinger::PlaybackThread::Track::selectPresentation(int presentationId,
+ int programId) {
+ sp<ThreadBase> thread = mThread.promote();
+ if (thread == 0) {
+ ALOGE("thread is dead");
+ return FAILED_TRANSACTION;
+ } else if ((thread->type() == ThreadBase::DIRECT) || (thread->type() == ThreadBase::OFFLOAD)) {
+ DirectOutputThread *directOutputThread = static_cast<DirectOutputThread*>(thread.get());
+ return directOutputThread->selectPresentation(presentationId, programId);
+ }
+ return INVALID_OPERATION;
+}
+
VolumeShaper::Status AudioFlinger::PlaybackThread::Track::applyVolumeShaper(
const sp<VolumeShaper::Configuration>& configuration,
const sp<VolumeShaper::Operation>& operation)