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