2 * Copyright (C) 2009 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #define LOG_TAG "IAudioFlingerClient"
18 #include <utils/Log.h>
21 #include <sys/types.h>
23 #include <utils/Parcel.h>
25 #include <media/IAudioFlingerClient.h>
30 AUDIO_OUTPUT_CHANGED = IBinder::FIRST_CALL_TRANSACTION
33 class BpAudioFlingerClient : public BpInterface<IAudioFlingerClient>
36 BpAudioFlingerClient(const sp<IBinder>& impl)
37 : BpInterface<IAudioFlingerClient>(impl)
41 void a2dpEnabledChanged(bool enabled)
44 data.writeInterfaceToken(IAudioFlingerClient::getInterfaceDescriptor());
45 data.writeInt32((int)enabled);
46 remote()->transact(AUDIO_OUTPUT_CHANGED, data, &reply, IBinder::FLAG_ONEWAY);
50 IMPLEMENT_META_INTERFACE(AudioFlingerClient, "android.media.IAudioFlingerClient");
52 // ----------------------------------------------------------------------
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; \
60 status_t BnAudioFlingerClient::onTransact(
61 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
64 case AUDIO_OUTPUT_CHANGED: {
65 CHECK_INTERFACE(IAudioFlingerClient, data, reply);
66 bool enabled = (bool)data.readInt32();
67 a2dpEnabledChanged(enabled);
71 return BBinder::onTransact(code, data, reply, flags);
75 // ----------------------------------------------------------------------------
77 }; // namespace android