| The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| Alok Kediya | 601e9b5 | 2013-09-27 11:55:10 +0530 | [diff] [blame^] | 2 | * Copyright (c) 2013, The Linux Foundation. All rights reserved. |
| 3 | * Not a Contribution. |
| 4 | * |
| The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5 | * 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 Agopian | 7562408 | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 26 | #include <binder/Parcel.h> |
| The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | |
| 28 | #include <media/IAudioFlingerClient.h> |
| Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 29 | #include <media/AudioSystem.h> |
| The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | |
| 31 | namespace android { |
| 32 | |
| 33 | enum { |
| Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 34 | IO_CONFIG_CHANGED = IBinder::FIRST_CALL_TRANSACTION |
| The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | class BpAudioFlingerClient : public BpInterface<IAudioFlingerClient> |
| 38 | { |
| 39 | public: |
| 40 | BpAudioFlingerClient(const sp<IBinder>& impl) |
| 41 | : BpInterface<IAudioFlingerClient>(impl) |
| 42 | { |
| 43 | } |
| 44 | |
| Glenn Kasten | b81cc8c | 2012-03-01 09:14:51 -0800 | [diff] [blame] | 45 | void ioConfigChanged(int event, audio_io_handle_t ioHandle, const void *param2) |
| The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 46 | { |
| 47 | Parcel data, reply; |
| 48 | data.writeInterfaceToken(IAudioFlingerClient::getInterfaceDescriptor()); |
| Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 49 | data.writeInt32(event); |
| Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 50 | data.writeInt32((int32_t) ioHandle); |
| Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 51 | if (event == AudioSystem::STREAM_CONFIG_CHANGED) { |
| Glenn Kasten | b81cc8c | 2012-03-01 09:14:51 -0800 | [diff] [blame] | 52 | uint32_t stream = *(const uint32_t *)param2; |
| Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 53 | ALOGV("ioConfigChanged stream %d", stream); |
| Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 54 | data.writeInt32(stream); |
| Alok Kediya | 601e9b5 | 2013-09-27 11:55:10 +0530 | [diff] [blame^] | 55 | } 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 Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 58 | data.writeInt32(desc->samplingRate); |
| 59 | data.writeInt32(desc->format); |
| Glenn Kasten | fad226a | 2013-07-16 17:19:58 -0700 | [diff] [blame] | 60 | data.writeInt32(desc->channelMask); |
| Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 61 | 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 Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 65 | } |
| 66 | }; |
| 67 | |
| 68 | IMPLEMENT_META_INTERFACE(AudioFlingerClient, "android.media.IAudioFlingerClient"); |
| 69 | |
| 70 | // ---------------------------------------------------------------------- |
| 71 | |
| The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 72 | status_t BnAudioFlingerClient::onTransact( |
| 73 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 74 | { |
| Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 75 | switch (code) { |
| Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 76 | case IO_CONFIG_CHANGED: { |
| The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 77 | CHECK_INTERFACE(IAudioFlingerClient, data, reply); |
| Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 78 | int event = data.readInt32(); |
| Glenn Kasten | 72ef00d | 2012-01-17 11:09:42 -0800 | [diff] [blame] | 79 | audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32(); |
| Glenn Kasten | b81cc8c | 2012-03-01 09:14:51 -0800 | [diff] [blame] | 80 | const void *param2 = NULL; |
| Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 81 | AudioSystem::OutputDescriptor desc; |
| 82 | uint32_t stream; |
| Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 83 | if (event == AudioSystem::STREAM_CONFIG_CHANGED) { |
| 84 | stream = data.readInt32(); |
| 85 | param2 = &stream; |
| Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 86 | ALOGV("STREAM_CONFIG_CHANGED stream %d", stream); |
| Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 87 | } else if (event != AudioSystem::OUTPUT_CLOSED && event != AudioSystem::INPUT_CLOSED) { |
| 88 | desc.samplingRate = data.readInt32(); |
| Glenn Kasten | eced2da | 2013-07-16 17:17:28 -0700 | [diff] [blame] | 89 | desc.format = (audio_format_t) data.readInt32(); |
| Glenn Kasten | fad226a | 2013-07-16 17:19:58 -0700 | [diff] [blame] | 90 | desc.channelMask = (audio_channel_mask_t) data.readInt32(); |
| Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 91 | desc.frameCount = data.readInt32(); |
| 92 | desc.latency = data.readInt32(); |
| 93 | param2 = &desc; |
| 94 | } |
| Eric Laurent | fa2877b | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 95 | ioConfigChanged(event, ioHandle, param2); |
| The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 96 | return NO_ERROR; |
| 97 | } break; |
| 98 | default: |
| 99 | return BBinder::onTransact(code, data, reply, flags); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | // ---------------------------------------------------------------------------- |
| 104 | |
| 105 | }; // namespace android |