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