blob: 5feb11fb10bbe33ff610f40128c516b2a1973aab [file] [log] [blame]
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "IAudioFlingerClient"
18#include <utils/Log.h>
19
20#include <stdint.h>
21#include <sys/types.h>
22
23#include <utils/Parcel.h>
24
25#include <media/IAudioFlingerClient.h>
26
27namespace android {
28
29enum {
30 AUDIO_OUTPUT_CHANGED = IBinder::FIRST_CALL_TRANSACTION
31};
32
33class BpAudioFlingerClient : public BpInterface<IAudioFlingerClient>
34{
35public:
36 BpAudioFlingerClient(const sp<IBinder>& impl)
37 : BpInterface<IAudioFlingerClient>(impl)
38 {
39 }
40
41 void a2dpEnabledChanged(bool enabled)
42 {
43 Parcel data, reply;
44 data.writeInterfaceToken(IAudioFlingerClient::getInterfaceDescriptor());
45 data.writeInt32((int)enabled);
46 remote()->transact(AUDIO_OUTPUT_CHANGED, data, &reply);
47 }
48};
49
50IMPLEMENT_META_INTERFACE(AudioFlingerClient, "android.media.IAudioFlingerClient");
51
52// ----------------------------------------------------------------------
53
54#define CHECK_INTERFACE(interface, data, reply) \
55 do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \
56 LOGW("Call incorrectly routed to " #interface); \
57 return PERMISSION_DENIED; \
58 } } while (0)
59
60status_t BnAudioFlingerClient::onTransact(
61 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
62{
63 switch(code) {
64 case AUDIO_OUTPUT_CHANGED: {
65 CHECK_INTERFACE(IAudioFlingerClient, data, reply);
66 bool enabled = (bool)data.readInt32();
67 a2dpEnabledChanged(enabled);
68 return NO_ERROR;
69 } break;
70 default:
71 return BBinder::onTransact(code, data, reply, flags);
72 }
73}
74
75// ----------------------------------------------------------------------------
76
77}; // namespace android