IAudioFlingerClient.cpp revision b7056fc8525e0515c6f46676e3307088f8b64cdc
1/* 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 <binder/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, IBinder::FLAG_ONEWAY); 47 } 48}; 49 50IMPLEMENT_META_INTERFACE(AudioFlingerClient, "android.media.IAudioFlingerClient"); 51 52// ---------------------------------------------------------------------- 53 54status_t BnAudioFlingerClient::onTransact( 55 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) 56{ 57 switch(code) { 58 case AUDIO_OUTPUT_CHANGED: { 59 CHECK_INTERFACE(IAudioFlingerClient, data, reply); 60 bool enabled = (bool)data.readInt32(); 61 a2dpEnabledChanged(enabled); 62 return NO_ERROR; 63 } break; 64 default: 65 return BBinder::onTransact(code, data, reply, flags); 66 } 67} 68 69// ---------------------------------------------------------------------------- 70 71}; // namespace android 72