1c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent/*
2c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent**
3c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** Copyright 2009, The Android Open Source Project
4c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent**
5c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** Licensed under the Apache License, Version 2.0 (the "License");
6c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** you may not use this file except in compliance with the License.
7c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** You may obtain a copy of the License at
8c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent**
9c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent**     http://www.apache.org/licenses/LICENSE-2.0
10c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent**
11c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** Unless required by applicable law or agreed to in writing, software
12c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** distributed under the License is distributed on an "AS IS" BASIS,
13c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** See the License for the specific language governing permissions and
15c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent** limitations under the License.
16c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent*/
17c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
18c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#define LOG_TAG "IAudioPolicyService"
19c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <utils/Log.h>
20c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
21c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <stdint.h>
22c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <sys/types.h>
23c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
24c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <binder/Parcel.h>
25c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
2674adca9ad30b7f8a70d40c5237bade0d16c4ea58Eric Laurent#include <media/AudioEffect.h>
27c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <media/IAudioPolicyService.h>
28c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
2964760240f931714858a59c1579f07264d7182ba2Dima Zavin#include <system/audio.h>
30fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin
31c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentnamespace android {
32c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
33c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentenum {
34c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    SET_DEVICE_CONNECTION_STATE = IBinder::FIRST_CALL_TRANSACTION,
35c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    GET_DEVICE_CONNECTION_STATE,
36c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    SET_PHONE_STATE,
370b07b8085d7b837b4dd5f09e0c8c39408f6bdbf7Glenn Kasten    SET_RINGER_MODE,    // reserved, no longer used
38c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    SET_FORCE_USE,
39c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    GET_FORCE_USE,
40c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    GET_OUTPUT,
41c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    START_OUTPUT,
42c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    STOP_OUTPUT,
43c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    RELEASE_OUTPUT,
44caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent    GET_INPUT_FOR_ATTR,
45c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    START_INPUT,
46c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    STOP_INPUT,
47c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    RELEASE_INPUT,
48c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    INIT_STREAM_VOLUME,
49c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    SET_STREAM_VOLUME,
50de070137f11d346fba77605bd76a44c040a618fcEric Laurent    GET_STREAM_VOLUME,
51de070137f11d346fba77605bd76a44c040a618fcEric Laurent    GET_STRATEGY_FOR_STREAM,
52de070137f11d346fba77605bd76a44c040a618fcEric Laurent    GET_OUTPUT_FOR_EFFECT,
53de070137f11d346fba77605bd76a44c040a618fcEric Laurent    REGISTER_EFFECT,
54eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent    UNREGISTER_EFFECT,
556b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten    IS_STREAM_ACTIVE,
56d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi    IS_SOURCE_ACTIVE,
576b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten    GET_DEVICES_FOR_STREAM,
58db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent    QUERY_DEFAULT_PRE_PROCESSING,
59272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi    SET_EFFECT_ENABLED,
60ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald    IS_STREAM_ACTIVE_REMOTELY,
61203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    IS_OFFLOAD_SUPPORTED,
62203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    LIST_AUDIO_PORTS,
63203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    GET_AUDIO_PORT,
64203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    CREATE_AUDIO_PATCH,
65203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    RELEASE_AUDIO_PATCH,
66203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    LIST_AUDIO_PATCHES,
67b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent    SET_AUDIO_PORT_CONFIG,
685bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi    REGISTER_CLIENT,
69df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent    GET_OUTPUT_FOR_ATTR,
70df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent    ACQUIRE_SOUNDTRIGGER_SESSION,
71bb6c9a05840d924b502ce0f1868fca4881ada1edEric Laurent    RELEASE_SOUNDTRIGGER_SESSION,
72baac183f3808d7b68f184647a97bd381620415feEric Laurent    GET_PHONE_STATE,
73baac183f3808d7b68f184647a97bd381620415feEric Laurent    REGISTER_POLICY_MIXES,
74c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent};
75c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
766dc6c38b63b0ec5a72bd956c4821b9d00d3ab123Eric Laurent#define MAX_ITEMS_PER_LIST 1024
776dc6c38b63b0ec5a72bd956c4821b9d00d3ab123Eric Laurent
78c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentclass BpAudioPolicyService : public BpInterface<IAudioPolicyService>
79c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{
80c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentpublic:
81c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    BpAudioPolicyService(const sp<IBinder>& impl)
82c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        : BpInterface<IAudioPolicyService>(impl)
83c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
84c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
85c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
86c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t setDeviceConnectionState(
87fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                    audio_devices_t device,
88fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                    audio_policy_dev_state_t state,
89c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    const char *device_address)
90c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
91c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
92c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
93c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(device));
94c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(state));
95c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeCString(device_address);
96c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_DEVICE_CONNECTION_STATE, data, &reply);
97c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
98c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
99c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
100fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual audio_policy_dev_state_t getDeviceConnectionState(
101fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                    audio_devices_t device,
102c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    const char *device_address)
103c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
104c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
105c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
106c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(device));
107c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeCString(device_address);
108c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_DEVICE_CONNECTION_STATE, data, &reply);
109fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin        return static_cast <audio_policy_dev_state_t>(reply.readInt32());
110c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
111c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
112f78aee70d15daf4690de7e7b4983ee68b0d1381dGlenn Kasten    virtual status_t setPhoneState(audio_mode_t state)
113c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
114c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
115c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
116c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(state);
117c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_PHONE_STATE, data, &reply);
118c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
119c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
120c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
121fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config)
122c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
123c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
124c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
125c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(usage));
126c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(config));
127c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_FORCE_USE, data, &reply);
128c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
129c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
130c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
131fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage)
132c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
133c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
134c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
135c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(usage));
136c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_FORCE_USE, data, &reply);
137fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin        return static_cast <audio_policy_forced_cfg_t> (reply.readInt32());
138c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
139c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
140c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual audio_io_handle_t getOutput(
141fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                        audio_stream_type_t stream,
142c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                        uint32_t samplingRate,
14358f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten                                        audio_format_t format,
144254af180475346b6186b49c297f340c9c4817511Glenn Kasten                                        audio_channel_mask_t channelMask,
145ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald                                        audio_output_flags_t flags,
146ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald                                        const audio_offload_info_t *offloadInfo)
147c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
148c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
149c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
150c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
151c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(samplingRate);
152c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(format));
153254af180475346b6186b49c297f340c9c4817511Glenn Kasten        data.writeInt32(channelMask);
154c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(flags));
1552301acc6a9c7a3af4ad01f3d1d0f76f13eca7350Glenn Kasten        // hasOffloadInfo
156b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald        if (offloadInfo == NULL) {
157b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald            data.writeInt32(0);
158b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald        } else {
159b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald            data.writeInt32(1);
160b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald            data.write(offloadInfo, sizeof(audio_offload_info_t));
161b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald        }
162c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_OUTPUT, data, &reply);
163fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        return static_cast <audio_io_handle_t> (reply.readInt32());
164c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
165c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
166e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent    virtual status_t getOutputForAttr(const audio_attributes_t *attr,
167e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                                        audio_io_handle_t *output,
168e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                                        audio_session_t session,
169e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                                        audio_stream_type_t *stream,
170e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                                        uint32_t samplingRate,
171e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                                        audio_format_t format,
172e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                                        audio_channel_mask_t channelMask,
173e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                                        audio_output_flags_t flags,
174e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                                        const audio_offload_info_t *offloadInfo)
1755bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi        {
1765bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi            Parcel data, reply;
1775bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi            data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
1785bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi            if (attr == NULL) {
179e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                if (stream == NULL) {
180e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                    ALOGE("getOutputForAttr(): NULL audio attributes and stream type");
181e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                    return BAD_VALUE;
182e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                }
183e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                if (*stream == AUDIO_STREAM_DEFAULT) {
184e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                    ALOGE("getOutputForAttr unspecified stream type");
185e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                    return BAD_VALUE;
186e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                }
187e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent            }
188e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent            if (output == NULL) {
189e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                ALOGE("getOutputForAttr NULL output - shouldn't happen");
190e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                return BAD_VALUE;
191e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent            }
192e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent            if (attr == NULL) {
193e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                data.writeInt32(0);
194e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent            } else {
195e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                data.writeInt32(1);
196e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                data.write(attr, sizeof(audio_attributes_t));
197e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent            }
198e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent            data.writeInt32(session);
199e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent            if (stream == NULL) {
200e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                data.writeInt32(0);
201e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent            } else {
202e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                data.writeInt32(1);
203e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                data.writeInt32(*stream);
2045bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi            }
2055bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi            data.writeInt32(samplingRate);
2065bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi            data.writeInt32(static_cast <uint32_t>(format));
2075bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi            data.writeInt32(channelMask);
2085bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi            data.writeInt32(static_cast <uint32_t>(flags));
2095bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi            // hasOffloadInfo
2105bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi            if (offloadInfo == NULL) {
2115bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi                data.writeInt32(0);
2125bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi            } else {
2135bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi                data.writeInt32(1);
2145bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi                data.write(offloadInfo, sizeof(audio_offload_info_t));
2155bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi            }
216e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent            status_t status = remote()->transact(GET_OUTPUT_FOR_ATTR, data, &reply);
217e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent            if (status != NO_ERROR) {
218e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                return status;
219e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent            }
220e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent            status = (status_t)reply.readInt32();
221e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent            if (status != NO_ERROR) {
222e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                return status;
223e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent            }
224e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent            *output = (audio_io_handle_t)reply.readInt32();
225e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent            if (stream != NULL) {
226e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                *stream = (audio_stream_type_t)reply.readInt32();
227e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent            }
228e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent            return status;
2295bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi        }
2305bd3f38638acab633d181359cc9ec27b80f84d43Jean-Michel Trivi
231de070137f11d346fba77605bd76a44c040a618fcEric Laurent    virtual status_t startOutput(audio_io_handle_t output,
232fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                 audio_stream_type_t stream,
233e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                                 audio_session_t session)
234c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
235c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
236c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
237fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(output);
238fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten        data.writeInt32((int32_t) stream);
239e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent        data.writeInt32((int32_t)session);
240c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(START_OUTPUT, data, &reply);
241c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
242c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
243c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
244de070137f11d346fba77605bd76a44c040a618fcEric Laurent    virtual status_t stopOutput(audio_io_handle_t output,
245fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                audio_stream_type_t stream,
246e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                                audio_session_t session)
247c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
248c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
249c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
250fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(output);
251fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten        data.writeInt32((int32_t) stream);
252e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent        data.writeInt32((int32_t)session);
253c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(STOP_OUTPUT, data, &reply);
254c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
255c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
256c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
257e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent    virtual void releaseOutput(audio_io_handle_t output,
258e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                               audio_stream_type_t stream,
259e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent                               audio_session_t session)
260c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
261c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
262c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
263fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(output);
264e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent        data.writeInt32((int32_t)stream);
265e83b55dc29ca16092ba02f36f55fa6e0e37fd78cEric Laurent        data.writeInt32((int32_t)session);
266c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(RELEASE_OUTPUT, data, &reply);
267c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
268c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
269caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent    virtual status_t getInputForAttr(const audio_attributes_t *attr,
270caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent                                     audio_io_handle_t *input,
271caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent                                     audio_session_t session,
272caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent                                     uint32_t samplingRate,
273caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent                                     audio_format_t format,
274caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent                                     audio_channel_mask_t channelMask,
275caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent                                     audio_input_flags_t flags)
276c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
277c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
278c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
279caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent        if (attr == NULL) {
280caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent            ALOGE("getInputForAttr NULL attr - shouldn't happen");
281caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent            return BAD_VALUE;
282caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent        }
283caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent        if (input == NULL) {
284caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent            ALOGE("getInputForAttr NULL input - shouldn't happen");
285caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent            return BAD_VALUE;
286caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent        }
287caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent        data.write(attr, sizeof(audio_attributes_t));
288caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent        data.writeInt32(session);
289c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(samplingRate);
290c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(format));
291254af180475346b6186b49c297f340c9c4817511Glenn Kasten        data.writeInt32(channelMask);
292b3b1660ecb67f61f9da54efced8677fa3a6f4863Glenn Kasten        data.writeInt32(flags);
293caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent        status_t status = remote()->transact(GET_INPUT_FOR_ATTR, data, &reply);
294caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent        if (status != NO_ERROR) {
295caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent            return status;
296caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent        }
297caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent        status = reply.readInt32();
298caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent        if (status != NO_ERROR) {
299caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent            return status;
300caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent        }
301caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent        *input = (audio_io_handle_t)reply.readInt32();
302caf7f48a0ef558689d39aafd187c1571ff4128b4Eric Laurent        return NO_ERROR;
303c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
304c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
3054dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent    virtual status_t startInput(audio_io_handle_t input,
3064dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent                                audio_session_t session)
307c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
308c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
309c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
310fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(input);
3114dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent        data.writeInt32(session);
312c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(START_INPUT, data, &reply);
313c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
314c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
315c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
3164dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent    virtual status_t stopInput(audio_io_handle_t input,
3174dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent                               audio_session_t session)
318c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
319c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
320c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
321fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(input);
3224dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent        data.writeInt32(session);
323c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(STOP_INPUT, data, &reply);
324c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
325c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
326c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
3274dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent    virtual void releaseInput(audio_io_handle_t input,
3284dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent                              audio_session_t session)
329c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
330c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
331c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
332fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(input);
3334dc680607181e6a76f4e91a39366c4f5dfb7b03eEric Laurent        data.writeInt32(session);
334c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(RELEASE_INPUT, data, &reply);
335c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
336c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
337fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual status_t initStreamVolume(audio_stream_type_t stream,
338c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    int indexMin,
339c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    int indexMax)
340c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
341c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
342c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
343c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
344c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(indexMin);
345c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(indexMax);
346c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(INIT_STREAM_VOLUME, data, &reply);
347c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
348c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
349c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
35083844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent    virtual status_t setStreamVolumeIndex(audio_stream_type_t stream,
35183844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent                                          int index,
35283844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent                                          audio_devices_t device)
353c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
354c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
355c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
356c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
357c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(index);
35883844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent        data.writeInt32(static_cast <uint32_t>(device));
359c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_STREAM_VOLUME, data, &reply);
360c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
361c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
362c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
36383844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent    virtual status_t getStreamVolumeIndex(audio_stream_type_t stream,
36483844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent                                          int *index,
36583844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent                                          audio_devices_t device)
366c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
367c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
368c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
369c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
37083844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent        data.writeInt32(static_cast <uint32_t>(device));
37183844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent
372c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_STREAM_VOLUME, data, &reply);
373c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        int lIndex = reply.readInt32();
374c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        if (index) *index = lIndex;
375c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
376c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
377de070137f11d346fba77605bd76a44c040a618fcEric Laurent
378fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual uint32_t getStrategyForStream(audio_stream_type_t stream)
379de070137f11d346fba77605bd76a44c040a618fcEric Laurent    {
380de070137f11d346fba77605bd76a44c040a618fcEric Laurent        Parcel data, reply;
381de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
382de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
383de070137f11d346fba77605bd76a44c040a618fcEric Laurent        remote()->transact(GET_STRATEGY_FOR_STREAM, data, &reply);
384de070137f11d346fba77605bd76a44c040a618fcEric Laurent        return reply.readInt32();
385de070137f11d346fba77605bd76a44c040a618fcEric Laurent    }
386de070137f11d346fba77605bd76a44c040a618fcEric Laurent
3876374252107fd6539397598195ea6defd5870fafbEric Laurent    virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream)
3886b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten    {
3896b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten        Parcel data, reply;
3906b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
3916b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten        data.writeInt32(static_cast <uint32_t>(stream));
3926b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten        remote()->transact(GET_DEVICES_FOR_STREAM, data, &reply);
3936374252107fd6539397598195ea6defd5870fafbEric Laurent        return (audio_devices_t) reply.readInt32();
3946b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten    }
3956b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten
39658e5aa34f01d663654d8bafad65db1dda42161ffGlenn Kasten    virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc)
397de070137f11d346fba77605bd76a44c040a618fcEric Laurent    {
398de070137f11d346fba77605bd76a44c040a618fcEric Laurent        Parcel data, reply;
399de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
400de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.write(desc, sizeof(effect_descriptor_t));
401de070137f11d346fba77605bd76a44c040a618fcEric Laurent        remote()->transact(GET_OUTPUT_FOR_EFFECT, data, &reply);
402de070137f11d346fba77605bd76a44c040a618fcEric Laurent        return static_cast <audio_io_handle_t> (reply.readInt32());
403de070137f11d346fba77605bd76a44c040a618fcEric Laurent    }
404de070137f11d346fba77605bd76a44c040a618fcEric Laurent
40558e5aa34f01d663654d8bafad65db1dda42161ffGlenn Kasten    virtual status_t registerEffect(const effect_descriptor_t *desc,
4067c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent                                        audio_io_handle_t io,
407de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                        uint32_t strategy,
408de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                        int session,
409de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                        int id)
410de070137f11d346fba77605bd76a44c040a618fcEric Laurent    {
411de070137f11d346fba77605bd76a44c040a618fcEric Laurent        Parcel data, reply;
412de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
413de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.write(desc, sizeof(effect_descriptor_t));
4147c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent        data.writeInt32(io);
415de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(strategy);
416de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(session);
417de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(id);
418de070137f11d346fba77605bd76a44c040a618fcEric Laurent        remote()->transact(REGISTER_EFFECT, data, &reply);
419de070137f11d346fba77605bd76a44c040a618fcEric Laurent        return static_cast <status_t> (reply.readInt32());
420de070137f11d346fba77605bd76a44c040a618fcEric Laurent    }
421de070137f11d346fba77605bd76a44c040a618fcEric Laurent
422de070137f11d346fba77605bd76a44c040a618fcEric Laurent    virtual status_t unregisterEffect(int id)
423de070137f11d346fba77605bd76a44c040a618fcEric Laurent    {
424de070137f11d346fba77605bd76a44c040a618fcEric Laurent        Parcel data, reply;
425de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
426de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(id);
427de070137f11d346fba77605bd76a44c040a618fcEric Laurent        remote()->transact(UNREGISTER_EFFECT, data, &reply);
428de070137f11d346fba77605bd76a44c040a618fcEric Laurent        return static_cast <status_t> (reply.readInt32());
429de070137f11d346fba77605bd76a44c040a618fcEric Laurent    }
430de070137f11d346fba77605bd76a44c040a618fcEric Laurent
431db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent    virtual status_t setEffectEnabled(int id, bool enabled)
432db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent    {
433db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        Parcel data, reply;
434db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
435db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        data.writeInt32(id);
436db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        data.writeInt32(enabled);
437db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        remote()->transact(SET_EFFECT_ENABLED, data, &reply);
438db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        return static_cast <status_t> (reply.readInt32());
439db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent    }
440db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent
441fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten    virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs) const
442eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent    {
443eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        Parcel data, reply;
444eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
445fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten        data.writeInt32((int32_t) stream);
446eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        data.writeInt32(inPastMs);
447eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        remote()->transact(IS_STREAM_ACTIVE, data, &reply);
448eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        return reply.readInt32();
449eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent    }
45057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent
451272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi    virtual bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs) const
452272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi    {
453272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi        Parcel data, reply;
454272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
455272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi        data.writeInt32((int32_t) stream);
456272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi        data.writeInt32(inPastMs);
457272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi        remote()->transact(IS_STREAM_ACTIVE_REMOTELY, data, &reply);
458272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi        return reply.readInt32();
459272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi    }
460272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi
461d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi    virtual bool isSourceActive(audio_source_t source) const
462d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi    {
463d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi        Parcel data, reply;
464d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
465d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi        data.writeInt32((int32_t) source);
466d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi        remote()->transact(IS_SOURCE_ACTIVE, data, &reply);
467d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi        return reply.readInt32();
468d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi    }
469d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi
47057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent    virtual status_t queryDefaultPreProcessing(int audioSession,
47157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                                               effect_descriptor_t *descriptors,
47257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                                               uint32_t *count)
47357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent    {
47457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        if (descriptors == NULL || count == NULL) {
47557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            return BAD_VALUE;
47657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        }
47757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        Parcel data, reply;
47857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
47957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        data.writeInt32(audioSession);
48057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        data.writeInt32(*count);
48157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        status_t status = remote()->transact(QUERY_DEFAULT_PRE_PROCESSING, data, &reply);
48257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        if (status != NO_ERROR) {
48357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            return status;
48457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        }
48557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        status = static_cast <status_t> (reply.readInt32());
48657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        uint32_t retCount = reply.readInt32();
48757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        if (retCount != 0) {
48857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            uint32_t numDesc = (retCount < *count) ? retCount : *count;
48957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            reply.read(descriptors, sizeof(effect_descriptor_t) * numDesc);
49057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        }
49157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        *count = retCount;
49257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        return status;
49357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent    }
494ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald
495ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald    virtual bool isOffloadSupported(const audio_offload_info_t& info)
496ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald    {
497b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald        Parcel data, reply;
498b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
499b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald        data.write(&info, sizeof(audio_offload_info_t));
500b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald        remote()->transact(IS_OFFLOAD_SUPPORTED, data, &reply);
501203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        return reply.readInt32();
502203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    }
503203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent
504203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    virtual status_t listAudioPorts(audio_port_role_t role,
505203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                                    audio_port_type_t type,
506203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                                    unsigned int *num_ports,
507203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                                    struct audio_port *ports,
508203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                                    unsigned int *generation)
509203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    {
510203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        if (num_ports == NULL || (*num_ports != 0 && ports == NULL) ||
511203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                generation == NULL) {
512203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent            return BAD_VALUE;
513203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        }
514203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        Parcel data, reply;
515203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
516203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        unsigned int numPortsReq = (ports == NULL) ? 0 : *num_ports;
517203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        data.writeInt32(role);
518203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        data.writeInt32(type);
519203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        data.writeInt32(numPortsReq);
520203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        status_t status = remote()->transact(LIST_AUDIO_PORTS, data, &reply);
521203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        if (status == NO_ERROR) {
522203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent            status = (status_t)reply.readInt32();
523203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent            *num_ports = (unsigned int)reply.readInt32();
524203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        }
525203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        if (status == NO_ERROR) {
526203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent            if (numPortsReq > *num_ports) {
527203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                numPortsReq = *num_ports;
528203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent            }
529203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent            if (numPortsReq > 0) {
530203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                reply.read(ports, numPortsReq * sizeof(struct audio_port));
531203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent            }
532203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent            *generation = reply.readInt32();
533203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        }
534203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        return status;
535203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    }
536203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent
537203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    virtual status_t getAudioPort(struct audio_port *port)
538203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    {
539203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        if (port == NULL) {
540203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent            return BAD_VALUE;
541203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        }
542203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        Parcel data, reply;
543203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
544203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        data.write(port, sizeof(struct audio_port));
545203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        status_t status = remote()->transact(GET_AUDIO_PORT, data, &reply);
546203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        if (status != NO_ERROR ||
547203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                (status = (status_t)reply.readInt32()) != NO_ERROR) {
548203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent            return status;
549203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        }
550203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        reply.read(port, sizeof(struct audio_port));
551203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        return status;
552203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    }
553203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent
554203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    virtual status_t createAudioPatch(const struct audio_patch *patch,
555203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                                       audio_patch_handle_t *handle)
556203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    {
557203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        if (patch == NULL || handle == NULL) {
558203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent            return BAD_VALUE;
559203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        }
560203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        Parcel data, reply;
561203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
562203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        data.write(patch, sizeof(struct audio_patch));
563203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        data.write(handle, sizeof(audio_patch_handle_t));
564203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        status_t status = remote()->transact(CREATE_AUDIO_PATCH, data, &reply);
565203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        if (status != NO_ERROR ||
566203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                (status = (status_t)reply.readInt32()) != NO_ERROR) {
567203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent            return status;
568203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        }
569203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        reply.read(handle, sizeof(audio_patch_handle_t));
570203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        return status;
571203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    }
572203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent
573203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    virtual status_t releaseAudioPatch(audio_patch_handle_t handle)
574203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    {
575203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        Parcel data, reply;
576203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
577203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        data.write(&handle, sizeof(audio_patch_handle_t));
578203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        status_t status = remote()->transact(RELEASE_AUDIO_PATCH, data, &reply);
579203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        if (status != NO_ERROR) {
580203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent            status = (status_t)reply.readInt32();
581203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        }
582203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        return status;
583203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    }
584203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent
585203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    virtual status_t listAudioPatches(unsigned int *num_patches,
586203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                                      struct audio_patch *patches,
587203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                                      unsigned int *generation)
588203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    {
589203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        if (num_patches == NULL || (*num_patches != 0 && patches == NULL) ||
590203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                generation == NULL) {
591203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent            return BAD_VALUE;
592203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        }
593203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        Parcel data, reply;
594203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
595203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        unsigned int numPatchesReq = (patches == NULL) ? 0 : *num_patches;
596203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        data.writeInt32(numPatchesReq);
597203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        status_t status = remote()->transact(LIST_AUDIO_PATCHES, data, &reply);
598203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        if (status == NO_ERROR) {
599203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent            status = (status_t)reply.readInt32();
600203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent            *num_patches = (unsigned int)reply.readInt32();
601203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        }
602203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        if (status == NO_ERROR) {
603203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent            if (numPatchesReq > *num_patches) {
604203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                numPatchesReq = *num_patches;
605203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent            }
606203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent            if (numPatchesReq > 0) {
607203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                reply.read(patches, numPatchesReq * sizeof(struct audio_patch));
608203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent            }
609203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent            *generation = reply.readInt32();
610203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        }
611203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        return status;
612203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    }
613203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent
614203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    virtual status_t setAudioPortConfig(const struct audio_port_config *config)
615203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    {
616203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        if (config == NULL) {
617203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent            return BAD_VALUE;
618203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        }
619203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        Parcel data, reply;
620203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
621203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        data.write(config, sizeof(struct audio_port_config));
622203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        status_t status = remote()->transact(SET_AUDIO_PORT_CONFIG, data, &reply);
623203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        if (status != NO_ERROR) {
624203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent            status = (status_t)reply.readInt32();
625203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        }
626203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent        return status;
627203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    }
628df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent
629b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent    virtual void registerClient(const sp<IAudioPolicyServiceClient>& client)
630b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent    {
631b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent        Parcel data, reply;
632b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
633b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent        data.writeStrongBinder(client->asBinder());
634b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent        remote()->transact(REGISTER_CLIENT, data, &reply);
635b52c152d553556b2d227ffc943489de0c60b4b02Eric Laurent    }
636df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent
637df3dc7e2fe6c639529b70e3f3a7d2bf0f4c6e871Eric Laurent    virtual status_t acquireSoundTriggerSession(audio_session_t *session,
638