blob: a622241e0d7ca0a1505aa0ba6ddf4b13babcc1ed [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
Mathias Agopian75624082009-05-19 19:08:10 -070023#include <binder/Parcel.h>
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080024
25#include <media/IAudioFlingerClient.h>
Eric Laurentc2f1f072009-07-17 12:17:14 -070026#include <media/AudioSystem.h>
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080027
28namespace android {
29
30enum {
Eric Laurentc2f1f072009-07-17 12:17:14 -070031 IO_CONFIG_CHANGED = IBinder::FIRST_CALL_TRANSACTION
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080032};
33
34class BpAudioFlingerClient : public BpInterface<IAudioFlingerClient>
35{
36public:
37 BpAudioFlingerClient(const sp<IBinder>& impl)
38 : BpInterface<IAudioFlingerClient>(impl)
39 {
40 }
41
Eric Laurent73e26b62015-04-27 16:55:58 -070042 void ioConfigChanged(audio_io_config_event event, const sp<AudioIoDescriptor>& ioDesc)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080043 {
44 Parcel data, reply;
45 data.writeInterfaceToken(IAudioFlingerClient::getInterfaceDescriptor());
Eric Laurentc2f1f072009-07-17 12:17:14 -070046 data.writeInt32(event);
Eric Laurent73e26b62015-04-27 16:55:58 -070047 data.writeInt32((int32_t)ioDesc->mIoHandle);
48 data.writeInt32(ioDesc->mSamplingRate);
49 data.writeInt32(ioDesc->mFormat);
50 data.writeInt32(ioDesc->mChannelMask);
51 data.writeInt64(ioDesc->mFrameCount);
52 data.writeInt32(ioDesc->mLatency);
Eric Laurentc2f1f072009-07-17 12:17:14 -070053 remote()->transact(IO_CONFIG_CHANGED, data, &reply, IBinder::FLAG_ONEWAY);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080054 }
55};
56
57IMPLEMENT_META_INTERFACE(AudioFlingerClient, "android.media.IAudioFlingerClient");
58
59// ----------------------------------------------------------------------
60
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080061status_t BnAudioFlingerClient::onTransact(
62 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
63{
Glenn Kastene53b9ea2012-03-12 16:29:55 -070064 switch (code) {
Eric Laurentc2f1f072009-07-17 12:17:14 -070065 case IO_CONFIG_CHANGED: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080066 CHECK_INTERFACE(IAudioFlingerClient, data, reply);
Eric Laurent73e26b62015-04-27 16:55:58 -070067 audio_io_config_event event = (audio_io_config_event)data.readInt32();
68 sp<AudioIoDescriptor> ioDesc = new AudioIoDescriptor();
69 ioDesc->mIoHandle = (audio_io_handle_t) data.readInt32();
70 ioDesc->mSamplingRate = data.readInt32();
71 ioDesc->mFormat = (audio_format_t) data.readInt32();
72 ioDesc->mChannelMask = (audio_channel_mask_t) data.readInt32();
73 ioDesc->mFrameCount = data.readInt64();
74 ioDesc->mLatency = data.readInt32();
75 ioConfigChanged(event, ioDesc);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080076 return NO_ERROR;
77 } break;
78 default:
79 return BBinder::onTransact(code, data, reply, flags);
80 }
81}
82
83// ----------------------------------------------------------------------------
84
Glenn Kasten40bc9062015-03-20 09:09:33 -070085} // namespace android