| 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: | 
| Chih-Hung Hsieh | 090ef60 | 2016-04-27 10:39:54 -0700 | [diff] [blame] | 37 | explicit BpAudioFlingerClient(const sp<IBinder>& impl) | 
| The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | : BpInterface<IAudioFlingerClient>(impl) | 
|  | 39 | { | 
|  | 40 | } | 
|  | 41 |  | 
| Eric Laurent | 73e26b6 | 2015-04-27 16:55:58 -0700 | [diff] [blame] | 42 | void ioConfigChanged(audio_io_config_event event, const sp<AudioIoDescriptor>& ioDesc) | 
| 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); | 
| Eric Laurent | 73e26b6 | 2015-04-27 16:55:58 -0700 | [diff] [blame] | 47 | data.writeInt32((int32_t)ioDesc->mIoHandle); | 
| Eric Laurent | 296fb13 | 2015-05-01 11:38:42 -0700 | [diff] [blame] | 48 | data.write(&ioDesc->mPatch, sizeof(struct audio_patch)); | 
| Eric Laurent | 73e26b6 | 2015-04-27 16:55:58 -0700 | [diff] [blame] | 49 | data.writeInt32(ioDesc->mSamplingRate); | 
|  | 50 | data.writeInt32(ioDesc->mFormat); | 
|  | 51 | data.writeInt32(ioDesc->mChannelMask); | 
|  | 52 | data.writeInt64(ioDesc->mFrameCount); | 
| Glenn Kasten | 4a8308b | 2016-04-18 14:10:01 -0700 | [diff] [blame] | 53 | data.writeInt64(ioDesc->mFrameCountHAL); | 
| Eric Laurent | 73e26b6 | 2015-04-27 16:55:58 -0700 | [diff] [blame] | 54 | data.writeInt32(ioDesc->mLatency); | 
| Eric Laurent | 09f1ed2 | 2019-04-24 17:45:17 -0700 | [diff] [blame] | 55 | data.writeInt32(ioDesc->mPortId); | 
| Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 56 | 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] | 57 | } | 
|  | 58 | }; | 
|  | 59 |  | 
|  | 60 | IMPLEMENT_META_INTERFACE(AudioFlingerClient, "android.media.IAudioFlingerClient"); | 
|  | 61 |  | 
|  | 62 | // ---------------------------------------------------------------------- | 
|  | 63 |  | 
| The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 64 | status_t BnAudioFlingerClient::onTransact( | 
|  | 65 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) | 
|  | 66 | { | 
| Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 67 | switch (code) { | 
| Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 68 | case IO_CONFIG_CHANGED: { | 
| The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 69 | CHECK_INTERFACE(IAudioFlingerClient, data, reply); | 
| Eric Laurent | 73e26b6 | 2015-04-27 16:55:58 -0700 | [diff] [blame] | 70 | audio_io_config_event event = (audio_io_config_event)data.readInt32(); | 
|  | 71 | sp<AudioIoDescriptor> ioDesc = new AudioIoDescriptor(); | 
|  | 72 | ioDesc->mIoHandle = (audio_io_handle_t) data.readInt32(); | 
| Eric Laurent | 296fb13 | 2015-05-01 11:38:42 -0700 | [diff] [blame] | 73 | data.read(&ioDesc->mPatch, sizeof(struct audio_patch)); | 
| Eric Laurent | 73e26b6 | 2015-04-27 16:55:58 -0700 | [diff] [blame] | 74 | ioDesc->mSamplingRate = data.readInt32(); | 
|  | 75 | ioDesc->mFormat = (audio_format_t) data.readInt32(); | 
|  | 76 | ioDesc->mChannelMask = (audio_channel_mask_t) data.readInt32(); | 
|  | 77 | ioDesc->mFrameCount = data.readInt64(); | 
| Glenn Kasten | 4a8308b | 2016-04-18 14:10:01 -0700 | [diff] [blame] | 78 | ioDesc->mFrameCountHAL = data.readInt64(); | 
| Eric Laurent | 73e26b6 | 2015-04-27 16:55:58 -0700 | [diff] [blame] | 79 | ioDesc->mLatency = data.readInt32(); | 
| Eric Laurent | 09f1ed2 | 2019-04-24 17:45:17 -0700 | [diff] [blame] | 80 | ioDesc->mPortId = data.readInt32(); | 
| Eric Laurent | 73e26b6 | 2015-04-27 16:55:58 -0700 | [diff] [blame] | 81 | ioConfigChanged(event, ioDesc); | 
| The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 82 | return NO_ERROR; | 
|  | 83 | } break; | 
|  | 84 | default: | 
|  | 85 | return BBinder::onTransact(code, data, reply, flags); | 
|  | 86 | } | 
|  | 87 | } | 
|  | 88 |  | 
|  | 89 | // ---------------------------------------------------------------------------- | 
|  | 90 |  | 
| Glenn Kasten | 40bc906 | 2015-03-20 09:09:33 -0700 | [diff] [blame] | 91 | } // namespace android |