Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [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 "IAudioPolicyServiceClient" |
| 18 | #include <utils/Log.h> |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | |
| 23 | #include <binder/Parcel.h> |
| 24 | |
| 25 | #include <media/IAudioPolicyServiceClient.h> |
| 26 | #include <media/AudioSystem.h> |
| 27 | |
| 28 | namespace android { |
| 29 | |
| 30 | enum { |
| 31 | PORT_LIST_UPDATE = IBinder::FIRST_CALL_TRANSACTION, |
Jean-Michel Trivi | de80105 | 2015-04-14 19:10:14 -0700 | [diff] [blame^] | 32 | PATCH_LIST_UPDATE, |
| 33 | MIX_STATE_UPDATE |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | class BpAudioPolicyServiceClient : public BpInterface<IAudioPolicyServiceClient> |
| 37 | { |
| 38 | public: |
| 39 | BpAudioPolicyServiceClient(const sp<IBinder>& impl) |
| 40 | : BpInterface<IAudioPolicyServiceClient>(impl) |
| 41 | { |
| 42 | } |
| 43 | |
| 44 | void onAudioPortListUpdate() |
| 45 | { |
| 46 | Parcel data, reply; |
| 47 | data.writeInterfaceToken(IAudioPolicyServiceClient::getInterfaceDescriptor()); |
| 48 | remote()->transact(PORT_LIST_UPDATE, data, &reply, IBinder::FLAG_ONEWAY); |
| 49 | } |
| 50 | |
| 51 | void onAudioPatchListUpdate() |
| 52 | { |
| 53 | Parcel data, reply; |
| 54 | data.writeInterfaceToken(IAudioPolicyServiceClient::getInterfaceDescriptor()); |
| 55 | remote()->transact(PATCH_LIST_UPDATE, data, &reply, IBinder::FLAG_ONEWAY); |
| 56 | } |
Jean-Michel Trivi | de80105 | 2015-04-14 19:10:14 -0700 | [diff] [blame^] | 57 | |
| 58 | void onDynamicPolicyMixStateUpdate(String8 regId, int32_t state) |
| 59 | { |
| 60 | Parcel data, reply; |
| 61 | data.writeInterfaceToken(IAudioPolicyServiceClient::getInterfaceDescriptor()); |
| 62 | data.writeString8(regId); |
| 63 | data.writeInt32(state); |
| 64 | remote()->transact(MIX_STATE_UPDATE, data, &reply, IBinder::FLAG_ONEWAY); |
| 65 | } |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | IMPLEMENT_META_INTERFACE(AudioPolicyServiceClient, "android.media.IAudioPolicyServiceClient"); |
| 69 | |
| 70 | // ---------------------------------------------------------------------- |
| 71 | |
| 72 | status_t BnAudioPolicyServiceClient::onTransact( |
| 73 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 74 | { |
| 75 | switch (code) { |
| 76 | case PORT_LIST_UPDATE: { |
| 77 | CHECK_INTERFACE(IAudioPolicyServiceClient, data, reply); |
| 78 | onAudioPortListUpdate(); |
| 79 | return NO_ERROR; |
| 80 | } break; |
| 81 | case PATCH_LIST_UPDATE: { |
| 82 | CHECK_INTERFACE(IAudioPolicyServiceClient, data, reply); |
| 83 | onAudioPatchListUpdate(); |
| 84 | return NO_ERROR; |
| 85 | } break; |
Jean-Michel Trivi | de80105 | 2015-04-14 19:10:14 -0700 | [diff] [blame^] | 86 | case MIX_STATE_UPDATE: { |
| 87 | CHECK_INTERFACE(IAudioPolicyServiceClient, data, reply); |
| 88 | String8 regId = data.readString8(); |
| 89 | int32_t state = data.readInt32(); |
| 90 | onDynamicPolicyMixStateUpdate(regId, state); |
| 91 | return NO_ERROR; |
| 92 | } |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 93 | default: |
| 94 | return BBinder::onTransact(code, data, reply, flags); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | // ---------------------------------------------------------------------------- |
| 99 | |
Glenn Kasten | 40bc906 | 2015-03-20 09:09:33 -0700 | [diff] [blame] | 100 | } // namespace android |