3 ** Copyright 2010, The Android Open Source Project
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
9 ** http://www.apache.org/licenses/LICENSE-2.0
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
18 //#define LOG_NDEBUG 0
19 #define LOG_TAG "IEffectClient"
20 #include <utils/Log.h>
22 #include <sys/types.h>
23 #include <media/IEffectClient.h>
28 CONTROL_STATUS_CHANGED = IBinder::FIRST_CALL_TRANSACTION,
29 ENABLE_STATUS_CHANGED,
33 class BpEffectClient: public BpInterface<IEffectClient>
36 BpEffectClient(const sp<IBinder>& impl)
37 : BpInterface<IEffectClient>(impl)
41 void controlStatusChanged(bool controlGranted)
43 LOGV("controlStatusChanged");
45 data.writeInterfaceToken(IEffectClient::getInterfaceDescriptor());
46 data.writeInt32((uint32_t)controlGranted);
47 remote()->transact(CONTROL_STATUS_CHANGED, data, &reply, IBinder::FLAG_ONEWAY);
50 void enableStatusChanged(bool enabled)
52 LOGV("enableStatusChanged");
54 data.writeInterfaceToken(IEffectClient::getInterfaceDescriptor());
55 data.writeInt32((uint32_t)enabled);
56 remote()->transact(ENABLE_STATUS_CHANGED, data, &reply, IBinder::FLAG_ONEWAY);
59 void commandExecuted(uint32_t cmdCode,
65 LOGV("commandExecuted");
67 data.writeInterfaceToken(IEffectClient::getInterfaceDescriptor());
68 data.writeInt32(cmdCode);
70 if (pCmdData == NULL) {
73 data.writeInt32(size);
75 data.write(pCmdData, size);
78 if (pReplyData == NULL) {
81 data.writeInt32(size);
83 data.write(pReplyData, size);
85 remote()->transact(COMMAND_EXECUTED, data, &reply, IBinder::FLAG_ONEWAY);
90 IMPLEMENT_META_INTERFACE(EffectClient, "android.media.IEffectClient");
92 // ----------------------------------------------------------------------
94 status_t BnEffectClient::onTransact(
95 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
98 case CONTROL_STATUS_CHANGED: {
99 LOGV("CONTROL_STATUS_CHANGED");
100 CHECK_INTERFACE(IEffectClient, data, reply);
101 bool hasControl = (bool)data.readInt32();
102 controlStatusChanged(hasControl);
105 case ENABLE_STATUS_CHANGED: {
106 LOGV("ENABLE_STATUS_CHANGED");
107 CHECK_INTERFACE(IEffectClient, data, reply);
108 bool enabled = (bool)data.readInt32();
109 enableStatusChanged(enabled);
112 case COMMAND_EXECUTED: {
113 LOGV("COMMAND_EXECUTED");
114 CHECK_INTERFACE(IEffectClient, data, reply);
115 uint32_t cmdCode = data.readInt32();
116 uint32_t cmdSize = data.readInt32();
119 cmd = (char *)malloc(cmdSize);
120 data.read(cmd, cmdSize);
122 uint32_t replySize = data.readInt32();
125 resp = (char *)malloc(replySize);
126 data.read(resp, replySize);
128 commandExecuted(cmdCode, cmdSize, cmd, replySize, resp);
138 return BBinder::onTransact(code, data, reply, flags);
142 // ----------------------------------------------------------------------------
144 }; // namespace android