Generate the IPlayer interface with AIDL.
This removes the manually rolled IPlayer implementation and instead uses
an aidl generated implementation. The IPlayer aidl file is moved from
frameworks/base/.
Test: run cts --module CtsMediaTestCases
Bug: 64223827
Change-Id: Ia609f7ba1cc6f71ce919d6174dd8b5e0e1b05575
diff --git a/media/libaudioclient/Android.bp b/media/libaudioclient/Android.bp
index a02311b..98e8d95 100644
--- a/media/libaudioclient/Android.bp
+++ b/media/libaudioclient/Android.bp
@@ -20,6 +20,7 @@
// The headers for these interfaces will be available to any modules that
// include libaudioclient, at the path "aidl/package/path/BnFoo.h"
"aidl/android/media/IAudioRecord.aidl",
+ "aidl/android/media/IPlayer.aidl",
"AudioEffect.cpp",
"AudioPolicy.cpp",
@@ -49,7 +50,7 @@
],
export_shared_lib_headers: ["libbinder"],
- local_include_dirs: ["include/media"],
+ local_include_dirs: ["include/media", "aidl"],
header_libs: ["libaudioclient_headers"],
export_header_lib_headers: ["libaudioclient_headers"],
diff --git a/media/libaudioclient/AudioTrack.cpp b/media/libaudioclient/AudioTrack.cpp
index 31e1e2b..07875ac 100644
--- a/media/libaudioclient/AudioTrack.cpp
+++ b/media/libaudioclient/AudioTrack.cpp
@@ -39,6 +39,8 @@
namespace android {
// ---------------------------------------------------------------------------
+using media::VolumeShaper;
+
// TODO: Move to a separate .h
template <typename T>
@@ -553,7 +555,7 @@
mFramesWritten = 0;
mFramesWrittenServerOffset = 0;
mFramesWrittenAtRestore = -1; // -1 is a unique initializer.
- mVolumeHandler = new VolumeHandler();
+ mVolumeHandler = new media::VolumeHandler();
return NO_ERROR;
}
diff --git a/media/libaudioclient/IAudioTrack.cpp b/media/libaudioclient/IAudioTrack.cpp
index 79e864d..adff057 100644
--- a/media/libaudioclient/IAudioTrack.cpp
+++ b/media/libaudioclient/IAudioTrack.cpp
@@ -28,6 +28,8 @@
namespace android {
+using media::VolumeShaper;
+
enum {
GET_CBLK = IBinder::FIRST_CALL_TRANSACTION,
START,
@@ -185,7 +187,7 @@
return nullptr;
}
sp<VolumeShaper::State> state = new VolumeShaper::State;
- status = state->readFromParcel(reply);
+ status = state->readFromParcel(&reply);
if (status != NO_ERROR) {
return nullptr;
}
@@ -263,12 +265,12 @@
status_t status = data.readInt32(&present);
if (status == NO_ERROR && present != 0) {
configuration = new VolumeShaper::Configuration();
- status = configuration->readFromParcel(data);
+ status = configuration->readFromParcel(&data);
}
status = status ?: data.readInt32(&present);
if (status == NO_ERROR && present != 0) {
operation = new VolumeShaper::Operation();
- status = operation->readFromParcel(data);
+ status = operation->readFromParcel(&data);
}
if (status == NO_ERROR) {
status = (status_t)applyVolumeShaper(configuration, operation);
diff --git a/media/libaudioclient/PlayerBase.cpp b/media/libaudioclient/PlayerBase.cpp
index 7868318..b0c68e5 100644
--- a/media/libaudioclient/PlayerBase.cpp
+++ b/media/libaudioclient/PlayerBase.cpp
@@ -22,6 +22,8 @@
namespace android {
+using media::VolumeShaper;
+
//--------------------------------------------------------------------------------------------------
PlayerBase::PlayerBase() : BnPlayer(),
mPanMultiplierL(1.0f), mPanMultiplierR(1.0f),
@@ -117,23 +119,26 @@
//------------------------------------------------------------------------------
// Implementation of IPlayer
-void PlayerBase::start() {
+binder::Status PlayerBase::start() {
ALOGD("PlayerBase::start() from IPlayer");
(void)startWithStatus();
+ return binder::Status::ok();
}
-void PlayerBase::pause() {
+binder::Status PlayerBase::pause() {
ALOGD("PlayerBase::pause() from IPlayer");
(void)pauseWithStatus();
+ return binder::Status::ok();
}
-void PlayerBase::stop() {
+binder::Status PlayerBase::stop() {
ALOGD("PlayerBase::stop() from IPlayer");
(void)stopWithStatus();
+ return binder::Status::ok();
}
-void PlayerBase::setVolume(float vol) {
+binder::Status PlayerBase::setVolume(float vol) {
ALOGD("PlayerBase::setVolume() from IPlayer");
{
Mutex::Autolock _l(mSettingsLock);
@@ -144,9 +149,10 @@
if (status != NO_ERROR) {
ALOGW("PlayerBase::setVolume() error %d", status);
}
+ return binder::Status::fromStatusT(status);
}
-void PlayerBase::setPan(float pan) {
+binder::Status PlayerBase::setPan(float pan) {
ALOGD("PlayerBase::setPan() from IPlayer");
{
Mutex::Autolock _l(mSettingsLock);
@@ -163,22 +169,19 @@
if (status != NO_ERROR) {
ALOGW("PlayerBase::setPan() error %d", status);
}
+ return binder::Status::fromStatusT(status);
}
-void PlayerBase::setStartDelayMs(int32_t delayMs __unused) {
+binder::Status PlayerBase::setStartDelayMs(int32_t delayMs __unused) {
ALOGW("setStartDelay() is not supported");
+ return binder::Status::ok();
}
-void PlayerBase::applyVolumeShaper(
- const sp<VolumeShaper::Configuration>& configuration __unused,
- const sp<VolumeShaper::Operation>& operation __unused) {
+binder::Status PlayerBase::applyVolumeShaper(
+ const VolumeShaper::Configuration& configuration __unused,
+ const VolumeShaper::Operation& operation __unused) {
ALOGW("applyVolumeShaper() is not supported");
-}
-
-status_t PlayerBase::onTransact(
- uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
-{
- return BnPlayer::onTransact(code, data, reply, flags);
+ return binder::Status::ok();
}
} // namespace android
diff --git a/media/libaudioclient/TrackPlayerBase.cpp b/media/libaudioclient/TrackPlayerBase.cpp
index 48cd803..0a914fc 100644
--- a/media/libaudioclient/TrackPlayerBase.cpp
+++ b/media/libaudioclient/TrackPlayerBase.cpp
@@ -18,6 +18,8 @@
namespace android {
+using media::VolumeShaper;
+
//--------------------------------------------------------------------------------------------------
TrackPlayerBase::TrackPlayerBase() : PlayerBase(),
mPlayerVolumeL(1.0f), mPlayerVolumeR(1.0f)
@@ -103,18 +105,24 @@
}
-void TrackPlayerBase::applyVolumeShaper(
- const sp<VolumeShaper::Configuration>& configuration,
- const sp<VolumeShaper::Operation>& operation) {
+binder::Status TrackPlayerBase::applyVolumeShaper(
+ const VolumeShaper::Configuration& configuration,
+ const VolumeShaper::Operation& operation) {
+
+ sp<VolumeShaper::Configuration> spConfiguration = new VolumeShaper::Configuration(configuration);
+ sp<VolumeShaper::Operation> spOperation = new VolumeShaper::Operation(operation);
+
if (mAudioTrack != 0) {
ALOGD("TrackPlayerBase::applyVolumeShaper() from IPlayer");
- VolumeShaper::Status status = mAudioTrack->applyVolumeShaper(configuration, operation);
+ VolumeShaper::Status status = mAudioTrack->applyVolumeShaper(spConfiguration, spOperation);
if (status < 0) { // a non-negative value is the volume shaper id.
ALOGE("TrackPlayerBase::applyVolumeShaper() failed with status %d", status);
}
+ return binder::Status::fromStatusT(status);
} else {
ALOGD("TrackPlayerBase::applyVolumeShaper()"
- " no AudioTrack for volume control from IPlayer");
+ " no AudioTrack for volume control from IPlayer");
+ return binder::Status::ok();
}
}
diff --git a/media/libaudioclient/aidl/android/media/IPlayer.aidl b/media/libaudioclient/aidl/android/media/IPlayer.aidl
new file mode 100644
index 0000000..a90fcdd
--- /dev/null
+++ b/media/libaudioclient/aidl/android/media/IPlayer.aidl
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media;
+
+import android.media.VolumeShaper.Configuration;
+import android.media.VolumeShaper.Operation;
+
+/**
+ * @hide
+ */
+interface IPlayer {
+ oneway void start();
+ oneway void pause();
+ oneway void stop();
+ oneway void setVolume(float vol);
+ oneway void setPan(float pan);
+ oneway void setStartDelayMs(int delayMs);
+ oneway void applyVolumeShaper(in Configuration configuration,
+ in Operation operation);
+}
diff --git a/media/libaudioclient/aidl/android/media/VolumeShaper/Configuration.aidl b/media/libaudioclient/aidl/android/media/VolumeShaper/Configuration.aidl
new file mode 100644
index 0000000..fd0e60f
--- /dev/null
+++ b/media/libaudioclient/aidl/android/media/VolumeShaper/Configuration.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.VolumeShaper;
+
+parcelable Configuration cpp_header "media/VolumeShaper.h";
diff --git a/media/libaudioclient/aidl/android/media/VolumeShaper/Operation.aidl b/media/libaudioclient/aidl/android/media/VolumeShaper/Operation.aidl
new file mode 100644
index 0000000..4290d9d
--- /dev/null
+++ b/media/libaudioclient/aidl/android/media/VolumeShaper/Operation.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.VolumeShaper;
+
+parcelable Operation cpp_header "media/VolumeShaper.h";
diff --git a/media/libaudioclient/aidl/android/media/VolumeShaper/State.aidl b/media/libaudioclient/aidl/android/media/VolumeShaper/State.aidl
new file mode 100644
index 0000000..f6a22b8
--- /dev/null
+++ b/media/libaudioclient/aidl/android/media/VolumeShaper/State.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.VolumeShaper;
+
+parcelable State cpp_header "media/VolumeShaper.h";
diff --git a/media/libaudioclient/include/media/AudioTrack.h b/media/libaudioclient/include/media/AudioTrack.h
index b168fc9..014df20 100644
--- a/media/libaudioclient/include/media/AudioTrack.h
+++ b/media/libaudioclient/include/media/AudioTrack.h
@@ -744,12 +744,12 @@
status_t setParameters(const String8& keyValuePairs);
/* Sets the volume shaper object */
- VolumeShaper::Status applyVolumeShaper(
- const sp<VolumeShaper::Configuration>& configuration,
- const sp<VolumeShaper::Operation>& operation);
+ media::VolumeShaper::Status applyVolumeShaper(
+ const sp<media::VolumeShaper::Configuration>& configuration,
+ const sp<media::VolumeShaper::Operation>& operation);
/* Gets the volume shaper state */
- sp<VolumeShaper::State> getVolumeShaperState(int id);
+ sp<media::VolumeShaper::State> getVolumeShaperState(int id);
/* Get parameters */
String8 getParameters(const String8& keys);
@@ -1146,7 +1146,7 @@
// May not match the app selection depending on other
// activity and connected devices.
- sp<VolumeHandler> mVolumeHandler;
+ sp<media::VolumeHandler> mVolumeHandler;
private:
class DeathNotifier : public IBinder::DeathRecipient {
diff --git a/media/libaudioclient/include/media/IAudioTrack.h b/media/libaudioclient/include/media/IAudioTrack.h
index 27a62d6..94afe3c 100644
--- a/media/libaudioclient/include/media/IAudioTrack.h
+++ b/media/libaudioclient/include/media/IAudioTrack.h
@@ -77,12 +77,12 @@
virtual void signal() = 0;
/* Sets the volume shaper */
- virtual VolumeShaper::Status applyVolumeShaper(
- const sp<VolumeShaper::Configuration>& configuration,
- const sp<VolumeShaper::Operation>& operation) = 0;
+ virtual media::VolumeShaper::Status applyVolumeShaper(
+ const sp<media::VolumeShaper::Configuration>& configuration,
+ const sp<media::VolumeShaper::Operation>& operation) = 0;
/* gets the volume shaper state */
- virtual sp<VolumeShaper::State> getVolumeShaperState(int id) = 0;
+ virtual sp<media::VolumeShaper::State> getVolumeShaperState(int id) = 0;
};
// ----------------------------------------------------------------------------
diff --git a/media/libaudioclient/include/media/PlayerBase.h b/media/libaudioclient/include/media/PlayerBase.h
index e63090b..e7a8abc 100644
--- a/media/libaudioclient/include/media/PlayerBase.h
+++ b/media/libaudioclient/include/media/PlayerBase.h
@@ -17,35 +17,31 @@
#ifndef __ANDROID_PLAYER_BASE_H__
#define __ANDROID_PLAYER_BASE_H__
-#include <audiomanager/IPlayer.h>
#include <audiomanager/AudioManager.h>
#include <audiomanager/IAudioManager.h>
+#include "android/media/BnPlayer.h"
namespace android {
-class PlayerBase : public BnPlayer
+class PlayerBase : public ::android::media::BnPlayer
{
public:
explicit PlayerBase();
- virtual ~PlayerBase();
+ virtual ~PlayerBase() override;
virtual void destroy() = 0;
//IPlayer implementation
- virtual void start();
- virtual void pause();
- virtual void stop();
- virtual void setVolume(float vol);
- virtual void setPan(float pan);
- virtual void setStartDelayMs(int32_t delayMs);
- virtual void applyVolumeShaper(
- const sp<VolumeShaper::Configuration>& configuration,
- const sp<VolumeShaper::Operation>& operation) override;
-
- virtual status_t onTransact(
- uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags);
-
+ virtual binder::Status start() override;
+ virtual binder::Status pause() override;
+ virtual binder::Status stop() override;
+ virtual binder::Status setVolume(float vol) override;
+ virtual binder::Status setPan(float pan) override;
+ virtual binder::Status setStartDelayMs(int32_t delayMs) override;
+ virtual binder::Status applyVolumeShaper(
+ const media::VolumeShaper::Configuration& configuration,
+ const media::VolumeShaper::Operation& operation) override;
status_t startWithStatus();
status_t pauseWithStatus();
diff --git a/media/libaudioclient/include/media/TrackPlayerBase.h b/media/libaudioclient/include/media/TrackPlayerBase.h
index 2d113c0..66e9b3b 100644
--- a/media/libaudioclient/include/media/TrackPlayerBase.h
+++ b/media/libaudioclient/include/media/TrackPlayerBase.h
@@ -32,9 +32,9 @@
virtual void destroy();
//IPlayer implementation
- virtual void applyVolumeShaper(
- const sp<VolumeShaper::Configuration>& configuration,
- const sp<VolumeShaper::Operation>& operation);
+ virtual binder::Status applyVolumeShaper(
+ const media::VolumeShaper::Configuration& configuration,
+ const media::VolumeShaper::Operation& operation);
//FIXME move to protected field, so far made public to minimize changes to AudioTrack logic
sp<AudioTrack> mAudioTrack;