blob: 65cc7d6fd62983905c09e4916d7922cfd9d59095 [file] [log] [blame]
Eric Laurentb52c1522014-05-20 11:27:36 -07001/*
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
28namespace android {
29
30enum {
31 PORT_LIST_UPDATE = IBinder::FIRST_CALL_TRANSACTION,
Jean-Michel Trivide801052015-04-14 19:10:14 -070032 PATCH_LIST_UPDATE,
33 MIX_STATE_UPDATE
Eric Laurentb52c1522014-05-20 11:27:36 -070034};
35
36class BpAudioPolicyServiceClient : public BpInterface<IAudioPolicyServiceClient>
37{
38public:
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 Trivide801052015-04-14 19:10:14 -070057
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 Laurentb52c1522014-05-20 11:27:36 -070066};
67
68IMPLEMENT_META_INTERFACE(AudioPolicyServiceClient, "android.media.IAudioPolicyServiceClient");
69
70// ----------------------------------------------------------------------
71
72status_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 Trivide801052015-04-14 19:10:14 -070086 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 Laurentb52c1522014-05-20 11:27:36 -070093 default:
94 return BBinder::onTransact(code, data, reply, flags);
95 }
96}
97
98// ----------------------------------------------------------------------------
99
Glenn Kasten40bc9062015-03-20 09:09:33 -0700100} // namespace android