1d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent/* 2d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent** 3d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent** Copyright 2010, The Android Open Source Project 4d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent** 5d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent** Licensed under the Apache License, Version 2.0 (the "License"); 6d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent** you may not use this file except in compliance with the License. 7d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent** You may obtain a copy of the License at 8d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent** 9d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent** http://www.apache.org/licenses/LICENSE-2.0 10d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent** 11d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent** Unless required by applicable law or agreed to in writing, software 12d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent** distributed under the License is distributed on an "AS IS" BASIS, 13d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent** See the License for the specific language governing permissions and 15d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent** limitations under the License. 16d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent*/ 17d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent 18d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent//#define LOG_NDEBUG 0 19d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent#define LOG_TAG "IEffectClient" 20d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent#include <utils/Log.h> 21d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent#include <stdint.h> 22d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent#include <sys/types.h> 23d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent#include <media/IEffectClient.h> 24d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent 25d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurentnamespace android { 26d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent 27d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurentenum { 28d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent CONTROL_STATUS_CHANGED = IBinder::FIRST_CALL_TRANSACTION, 29d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent ENABLE_STATUS_CHANGED, 30d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent COMMAND_EXECUTED 31d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent}; 32d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent 33d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurentclass BpEffectClient: public BpInterface<IEffectClient> 34d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent{ 35d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurentpublic: 36d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent BpEffectClient(const sp<IBinder>& impl) 37d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent : BpInterface<IEffectClient>(impl) 38d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent { 39d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent } 40d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent 41d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent void controlStatusChanged(bool controlGranted) 42d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent { 433856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("controlStatusChanged"); 44d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent Parcel data, reply; 45d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent data.writeInterfaceToken(IEffectClient::getInterfaceDescriptor()); 46d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent data.writeInt32((uint32_t)controlGranted); 47d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent remote()->transact(CONTROL_STATUS_CHANGED, data, &reply, IBinder::FLAG_ONEWAY); 48d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent } 49d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent 50d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent void enableStatusChanged(bool enabled) 51d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent { 523856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("enableStatusChanged"); 53d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent Parcel data, reply; 54d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent data.writeInterfaceToken(IEffectClient::getInterfaceDescriptor()); 55d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent data.writeInt32((uint32_t)enabled); 56d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent remote()->transact(ENABLE_STATUS_CHANGED, data, &reply, IBinder::FLAG_ONEWAY); 57d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent } 58d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent 5925f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent void commandExecuted(uint32_t cmdCode, 6025f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent uint32_t cmdSize, 6125f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent void *pCmdData, 6225f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent uint32_t replySize, 6325f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent void *pReplyData) 64d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent { 653856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("commandExecuted"); 66d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent Parcel data, reply; 67d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent data.writeInterfaceToken(IEffectClient::getInterfaceDescriptor()); 68d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent data.writeInt32(cmdCode); 69d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent int size = cmdSize; 70d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent if (pCmdData == NULL) { 71d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent size = 0; 72d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent } 73d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent data.writeInt32(size); 74d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent if (size) { 75d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent data.write(pCmdData, size); 76d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent } 77d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent size = replySize; 78d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent if (pReplyData == NULL) { 79d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent size = 0; 80d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent } 81d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent data.writeInt32(size); 82d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent if (size) { 83d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent data.write(pReplyData, size); 84d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent } 85d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent remote()->transact(COMMAND_EXECUTED, data, &reply, IBinder::FLAG_ONEWAY); 86d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent } 87d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent 88d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent}; 89d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent 90d71a1be83ff31cdb6599c351f9832cefc8d447baEric LaurentIMPLEMENT_META_INTERFACE(EffectClient, "android.media.IEffectClient"); 91d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent 92d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent// ---------------------------------------------------------------------- 93d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent 94d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurentstatus_t BnEffectClient::onTransact( 95d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) 96d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent{ 97e53b9ead781c36e96d6b6f012ddffc93a3d80f0dGlenn Kasten switch (code) { 98d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent case CONTROL_STATUS_CHANGED: { 993856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("CONTROL_STATUS_CHANGED"); 100d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent CHECK_INTERFACE(IEffectClient, data, reply); 101d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent bool hasControl = (bool)data.readInt32(); 102d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent controlStatusChanged(hasControl); 103d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent return NO_ERROR; 104d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent } break; 105d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent case ENABLE_STATUS_CHANGED: { 1063856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("ENABLE_STATUS_CHANGED"); 107d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent CHECK_INTERFACE(IEffectClient, data, reply); 108d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent bool enabled = (bool)data.readInt32(); 109d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent enableStatusChanged(enabled); 110d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent return NO_ERROR; 111d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent } break; 112d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent case COMMAND_EXECUTED: { 1133856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("COMMAND_EXECUTED"); 114d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent CHECK_INTERFACE(IEffectClient, data, reply); 11525f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent uint32_t cmdCode = data.readInt32(); 11625f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent uint32_t cmdSize = data.readInt32(); 117d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent char *cmd = NULL; 118d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent if (cmdSize) { 119d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent cmd = (char *)malloc(cmdSize); 120d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent data.read(cmd, cmdSize); 121d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent } 12225f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent uint32_t replySize = data.readInt32(); 123d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent char *resp = NULL; 124d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent if (replySize) { 125d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent resp = (char *)malloc(replySize); 126d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent data.read(resp, replySize); 127d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent } 128d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent commandExecuted(cmdCode, cmdSize, cmd, replySize, resp); 129d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent if (cmd) { 130d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent free(cmd); 131d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent } 132d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent if (resp) { 133d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent free(resp); 134d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent } 135d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent return NO_ERROR; 136d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent } break; 137d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent default: 138d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent return BBinder::onTransact(code, data, reply, flags); 139d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent } 140d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent} 141d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent 142d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent// ---------------------------------------------------------------------------- 143d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent 144d71a1be83ff31cdb6599c351f9832cefc8d447baEric Laurent}; // namespace android 145