summaryrefslogtreecommitdiffstats
path: root/media/libmedia/IEffectClient.cpp
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2010-05-21 07:47:50 -0700
committerEric Laurent <elaurent@google.com>2010-05-24 23:33:42 -0700
commitd71a1be83ff31cdb6599c351f9832cefc8d447ba (patch)
treee4bd66e6f5f7386067622eafa8c8cea56c6f4797 /media/libmedia/IEffectClient.cpp
parent9bca89d50d0c51d8e3f3e74d610b7d9a2dc98ed3 (diff)
downloadframeworks_av-d71a1be83ff31cdb6599c351f9832cefc8d447ba.zip
frameworks_av-d71a1be83ff31cdb6599c351f9832cefc8d447ba.tar.gz
frameworks_av-d71a1be83ff31cdb6599c351f9832cefc8d447ba.tar.bz2
Fix issue 2667797: [Audio Effect Framework] new base class and binder interfaces for effect control.
Added IEffect and IEffectClient binder interfaces to exchange effect module control and status information between application and media server processes. Change-Id: I10e8e894898e52ed9956a765d0ef7075eb2593af
Diffstat (limited to 'media/libmedia/IEffectClient.cpp')
-rw-r--r--media/libmedia/IEffectClient.cpp141
1 files changed, 141 insertions, 0 deletions
diff --git a/media/libmedia/IEffectClient.cpp b/media/libmedia/IEffectClient.cpp
new file mode 100644
index 0000000..e7659ae
--- /dev/null
+++ b/media/libmedia/IEffectClient.cpp
@@ -0,0 +1,141 @@
+/*
+**
+** Copyright 2010, 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.
+*/
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "IEffectClient"
+#include <utils/Log.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <media/IEffectClient.h>
+
+namespace android {
+
+enum {
+ CONTROL_STATUS_CHANGED = IBinder::FIRST_CALL_TRANSACTION,
+ ENABLE_STATUS_CHANGED,
+ COMMAND_EXECUTED
+};
+
+class BpEffectClient: public BpInterface<IEffectClient>
+{
+public:
+ BpEffectClient(const sp<IBinder>& impl)
+ : BpInterface<IEffectClient>(impl)
+ {
+ }
+
+ void controlStatusChanged(bool controlGranted)
+ {
+ LOGV("controlStatusChanged");
+ Parcel data, reply;
+ data.writeInterfaceToken(IEffectClient::getInterfaceDescriptor());
+ data.writeInt32((uint32_t)controlGranted);
+ remote()->transact(CONTROL_STATUS_CHANGED, data, &reply, IBinder::FLAG_ONEWAY);
+ }
+
+ void enableStatusChanged(bool enabled)
+ {
+ LOGV("enableStatusChanged");
+ Parcel data, reply;
+ data.writeInterfaceToken(IEffectClient::getInterfaceDescriptor());
+ data.writeInt32((uint32_t)enabled);
+ remote()->transact(ENABLE_STATUS_CHANGED, data, &reply, IBinder::FLAG_ONEWAY);
+ }
+
+ void commandExecuted(int cmdCode, int cmdSize, void *pCmdData, int replySize, void *pReplyData)
+ {
+ LOGV("commandExecuted");
+ Parcel data, reply;
+ data.writeInterfaceToken(IEffectClient::getInterfaceDescriptor());
+ data.writeInt32(cmdCode);
+ int size = cmdSize;
+ if (pCmdData == NULL) {
+ size = 0;
+ }
+ data.writeInt32(size);
+ if (size) {
+ data.write(pCmdData, size);
+ }
+ size = replySize;
+ if (pReplyData == NULL) {
+ size = 0;
+ }
+ data.writeInt32(size);
+ if (size) {
+ data.write(pReplyData, size);
+ }
+ remote()->transact(COMMAND_EXECUTED, data, &reply, IBinder::FLAG_ONEWAY);
+ }
+
+};
+
+IMPLEMENT_META_INTERFACE(EffectClient, "android.media.IEffectClient");
+
+// ----------------------------------------------------------------------
+
+status_t BnEffectClient::onTransact(
+ uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
+{
+ switch(code) {
+ case CONTROL_STATUS_CHANGED: {
+ LOGV("CONTROL_STATUS_CHANGED");
+ CHECK_INTERFACE(IEffectClient, data, reply);
+ bool hasControl = (bool)data.readInt32();
+ controlStatusChanged(hasControl);
+ return NO_ERROR;
+ } break;
+ case ENABLE_STATUS_CHANGED: {
+ LOGV("ENABLE_STATUS_CHANGED");
+ CHECK_INTERFACE(IEffectClient, data, reply);
+ bool enabled = (bool)data.readInt32();
+ enableStatusChanged(enabled);
+ return NO_ERROR;
+ } break;
+ case COMMAND_EXECUTED: {
+ LOGV("COMMAND_EXECUTED");
+ CHECK_INTERFACE(IEffectClient, data, reply);
+ int cmdCode = data.readInt32();
+ int cmdSize = data.readInt32();
+ char *cmd = NULL;
+ if (cmdSize) {
+ cmd = (char *)malloc(cmdSize);
+ data.read(cmd, cmdSize);
+ }
+ int replySize = data.readInt32();
+ char *resp = NULL;
+ if (replySize) {
+ resp = (char *)malloc(replySize);
+ data.read(resp, replySize);
+ }
+ commandExecuted(cmdCode, cmdSize, cmd, replySize, resp);
+ if (cmd) {
+ free(cmd);
+ }
+ if (resp) {
+ free(resp);
+ }
+ return NO_ERROR;
+ } break;
+ default:
+ return BBinder::onTransact(code, data, reply, flags);
+ }
+}
+
+// ----------------------------------------------------------------------------
+
+}; // namespace android
+