blob: 5e4da5d4d610d5ef6b7c6a977250949904988850 [file] [log] [blame]
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001/*
Alok Kediya601e9b52013-09-27 11:55:10 +05302 * Copyright (c) 2013, The Linux Foundation. All rights reserved.
3 * Not a Contribution.
4 *
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08005 * Copyright (C) 2009 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20#define LOG_TAG "IAudioFlingerClient"
21#include <utils/Log.h>
22
23#include <stdint.h>
24#include <sys/types.h>
25
Mathias Agopian75624082009-05-19 19:08:10 -070026#include <binder/Parcel.h>
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080027
28#include <media/IAudioFlingerClient.h>
Eric Laurentc2f1f072009-07-17 12:17:14 -070029#include <media/AudioSystem.h>
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080030
31namespace android {
32
33enum {
Eric Laurentc2f1f072009-07-17 12:17:14 -070034 IO_CONFIG_CHANGED = IBinder::FIRST_CALL_TRANSACTION
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080035};
36
37class BpAudioFlingerClient : public BpInterface<IAudioFlingerClient>
38{
39public:
40 BpAudioFlingerClient(const sp<IBinder>& impl)
41 : BpInterface<IAudioFlingerClient>(impl)
42 {
43 }
44
Glenn Kastenb81cc8c2012-03-01 09:14:51 -080045 void ioConfigChanged(int event, audio_io_handle_t ioHandle, const void *param2)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080046 {
47 Parcel data, reply;
48 data.writeInterfaceToken(IAudioFlingerClient::getInterfaceDescriptor());
Eric Laurentc2f1f072009-07-17 12:17:14 -070049 data.writeInt32(event);
Glenn Kasten72ef00d2012-01-17 11:09:42 -080050 data.writeInt32((int32_t) ioHandle);
Eric Laurentc2f1f072009-07-17 12:17:14 -070051 if (event == AudioSystem::STREAM_CONFIG_CHANGED) {
Glenn Kastenb81cc8c2012-03-01 09:14:51 -080052 uint32_t stream = *(const uint32_t *)param2;
Steve Block3856b092011-10-20 11:56:00 +010053 ALOGV("ioConfigChanged stream %d", stream);
Eric Laurentc2f1f072009-07-17 12:17:14 -070054 data.writeInt32(stream);
Alok Kediya601e9b52013-09-27 11:55:10 +053055 } else if (event != AudioSystem::OUTPUT_CLOSED && event != AudioSystem::INPUT_CLOSED &&
56 event != AudioSystem::EFFECT_CONFIG_CHANGED) {
57 const AudioSystem::OutputDescriptor *desc = (const AudioSystem::OutputDescriptor *)param2;
Eric Laurentc2f1f072009-07-17 12:17:14 -070058 data.writeInt32(desc->samplingRate);
59 data.writeInt32(desc->format);
Glenn Kastenfad226a2013-07-16 17:19:58 -070060 data.writeInt32(desc->channelMask);
Eric Laurentc2f1f072009-07-17 12:17:14 -070061 data.writeInt32(desc->frameCount);
62 data.writeInt32(desc->latency);
63 }
64 remote()->transact(IO_CONFIG_CHANGED, data, &reply, IBinder::FLAG_ONEWAY);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080065 }
66};
67
68IMPLEMENT_META_INTERFACE(AudioFlingerClient, "android.media.IAudioFlingerClient");
69
70// ----------------------------------------------------------------------
71
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080072status_t BnAudioFlingerClient::onTransact(
73 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
74{
Glenn Kastene53b9ea2012-03-12 16:29:55 -070075 switch (code) {
Eric Laurentc2f1f072009-07-17 12:17:14 -070076 case IO_CONFIG_CHANGED: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080077 CHECK_INTERFACE(IAudioFlingerClient, data, reply);
Eric Laurentc2f1f072009-07-17 12:17:14 -070078 int event = data.readInt32();
Glenn Kasten72ef00d2012-01-17 11:09:42 -080079 audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
Glenn Kastenb81cc8c2012-03-01 09:14:51 -080080 const void *param2 = NULL;
Eric Laurentc2f1f072009-07-17 12:17:14 -070081 AudioSystem::OutputDescriptor desc;
82 uint32_t stream;
Eric Laurentc2f1f072009-07-17 12:17:14 -070083 if (event == AudioSystem::STREAM_CONFIG_CHANGED) {
84 stream = data.readInt32();
85 param2 = &stream;
Steve Block3856b092011-10-20 11:56:00 +010086 ALOGV("STREAM_CONFIG_CHANGED stream %d", stream);
Eric Laurentc2f1f072009-07-17 12:17:14 -070087 } else if (event != AudioSystem::OUTPUT_CLOSED && event != AudioSystem::INPUT_CLOSED) {
88 desc.samplingRate = data.readInt32();
Glenn Kasteneced2da2013-07-16 17:17:28 -070089 desc.format = (audio_format_t) data.readInt32();
Glenn Kastenfad226a2013-07-16 17:19:58 -070090 desc.channelMask = (audio_channel_mask_t) data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -070091 desc.frameCount = data.readInt32();
92 desc.latency = data.readInt32();
93 param2 = &desc;
94 }
Eric Laurentfa2877b2009-07-28 08:44:33 -070095 ioConfigChanged(event, ioHandle, param2);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080096 return NO_ERROR;
97 } break;
98 default:
99 return BBinder::onTransact(code, data, reply, flags);
100 }
101}
102
103// ----------------------------------------------------------------------------
104
105}; // namespace android