IAudioRecord.cpp revision b7056fc8525e0515c6f46676e3307088f8b64cdc
157f4b77c89bafedf9468f9a636561c0c193405c9Mårten Kongstad/* 257f4b77c89bafedf9468f9a636561c0c193405c9Mårten Kongstad** 357f4b77c89bafedf9468f9a636561c0c193405c9Mårten Kongstad** Copyright 2007, The Android Open Source Project 457f4b77c89bafedf9468f9a636561c0c193405c9Mårten Kongstad** 557f4b77c89bafedf9468f9a636561c0c193405c9Mårten Kongstad** Licensed under the Apache License, Version 2.0 (the "License"); 657f4b77c89bafedf9468f9a636561c0c193405c9Mårten Kongstad** you may not use this file except in compliance with the License. 757f4b77c89bafedf9468f9a636561c0c193405c9Mårten Kongstad** You may obtain a copy of the License at 8ad6ed950dbfa152c193dd7e49c369d9e831f1591Mårten Kongstad** 9ad6ed950dbfa152c193dd7e49c369d9e831f1591Mårten Kongstad** http://www.apache.org/licenses/LICENSE-2.0 10ad6ed950dbfa152c193dd7e49c369d9e831f1591Mårten Kongstad** 11ad6ed950dbfa152c193dd7e49c369d9e831f1591Mårten Kongstad** Unless required by applicable law or agreed to in writing, software 1257f4b77c89bafedf9468f9a636561c0c193405c9Mårten Kongstad** distributed under the License is distributed on an "AS IS" BASIS, 1357f4b77c89bafedf9468f9a636561c0c193405c9Mårten Kongstad** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1457f4b77c89bafedf9468f9a636561c0c193405c9Mårten Kongstad** See the License for the specific language governing permissions and 15** limitations under the License. 16*/ 17 18#include <stdint.h> 19#include <sys/types.h> 20 21#include <binder/Parcel.h> 22 23#include <media/IAudioRecord.h> 24 25namespace android { 26 27enum { 28 GET_CBLK = IBinder::FIRST_CALL_TRANSACTION, 29 START, 30 STOP 31}; 32 33class BpAudioRecord : public BpInterface<IAudioRecord> 34{ 35public: 36 BpAudioRecord(const sp<IBinder>& impl) 37 : BpInterface<IAudioRecord>(impl) 38 { 39 } 40 41 virtual status_t start() 42 { 43 Parcel data, reply; 44 data.writeInterfaceToken(IAudioRecord::getInterfaceDescriptor()); 45 remote()->transact(START, data, &reply); 46 return reply.readInt32(); 47 } 48 49 virtual void stop() 50 { 51 Parcel data, reply; 52 data.writeInterfaceToken(IAudioRecord::getInterfaceDescriptor()); 53 remote()->transact(STOP, data, &reply); 54 } 55 56 virtual sp<IMemory> getCblk() const 57 { 58 Parcel data, reply; 59 data.writeInterfaceToken(IAudioRecord::getInterfaceDescriptor()); 60 remote()->transact(GET_CBLK, data, &reply); 61 return interface_cast<IMemory>(reply.readStrongBinder()); 62 } 63}; 64 65IMPLEMENT_META_INTERFACE(AudioRecord, "android.media.IAudioRecord"); 66 67// ---------------------------------------------------------------------- 68 69status_t BnAudioRecord::onTransact( 70 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) 71{ 72 switch(code) { 73 case GET_CBLK: { 74 CHECK_INTERFACE(IAudioRecord, data, reply); 75 reply->writeStrongBinder(getCblk()->asBinder()); 76 return NO_ERROR; 77 } break; 78 case START: { 79 CHECK_INTERFACE(IAudioRecord, data, reply); 80 reply->writeInt32(start()); 81 return NO_ERROR; 82 } break; 83 case STOP: { 84 CHECK_INTERFACE(IAudioRecord, data, reply); 85 stop(); 86 return NO_ERROR; 87 } break; 88 default: 89 return BBinder::onTransact(code, data, reply, flags); 90 } 91} 92 93}; // namespace android 94 95