IAudioPolicyService.cpp revision 2301acc6a9c7a3af4ad01f3d1d0f76f13eca7350
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
26c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <media/IAudioPolicyService.h>
27c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
2864760240f931714858a59c1579f07264d7182ba2Dima Zavin#include <system/audio.h>
29fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin
30c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentnamespace android {
31c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
32c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentenum {
33c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    SET_DEVICE_CONNECTION_STATE = IBinder::FIRST_CALL_TRANSACTION,
34c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    GET_DEVICE_CONNECTION_STATE,
35c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    SET_PHONE_STATE,
360b07b8085d7b837b4dd5f09e0c8c39408f6bdbf7Glenn Kasten    SET_RINGER_MODE,    // reserved, no longer used
37c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    SET_FORCE_USE,
38c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    GET_FORCE_USE,
39c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    GET_OUTPUT,
40c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    START_OUTPUT,
41c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    STOP_OUTPUT,
42c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    RELEASE_OUTPUT,
43c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    GET_INPUT,
44c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    START_INPUT,
45c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    STOP_INPUT,
46c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    RELEASE_INPUT,
47c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    INIT_STREAM_VOLUME,
48c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    SET_STREAM_VOLUME,
49de070137f11d346fba77605bd76a44c040a618fcEric Laurent    GET_STREAM_VOLUME,
50de070137f11d346fba77605bd76a44c040a618fcEric Laurent    GET_STRATEGY_FOR_STREAM,
51de070137f11d346fba77605bd76a44c040a618fcEric Laurent    GET_OUTPUT_FOR_EFFECT,
52de070137f11d346fba77605bd76a44c040a618fcEric Laurent    REGISTER_EFFECT,
53eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent    UNREGISTER_EFFECT,
546b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten    IS_STREAM_ACTIVE,
55d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi    IS_SOURCE_ACTIVE,
566b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten    GET_DEVICES_FOR_STREAM,
57db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent    QUERY_DEFAULT_PRE_PROCESSING,
58272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi    SET_EFFECT_ENABLED,
59ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald    IS_STREAM_ACTIVE_REMOTELY,
60ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald    IS_OFFLOAD_SUPPORTED
61c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent};
62c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
63c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentclass BpAudioPolicyService : public BpInterface<IAudioPolicyService>
64c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{
65c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentpublic:
66c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    BpAudioPolicyService(const sp<IBinder>& impl)
67c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        : BpInterface<IAudioPolicyService>(impl)
68c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
69c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
70c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
71c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t setDeviceConnectionState(
72fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                    audio_devices_t device,
73fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                    audio_policy_dev_state_t state,
74c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    const char *device_address)
75c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
76c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
77c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
78c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(device));
79c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(state));
80c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeCString(device_address);
81c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_DEVICE_CONNECTION_STATE, data, &reply);
82c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
83c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
84c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
85fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual audio_policy_dev_state_t getDeviceConnectionState(
86fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                    audio_devices_t device,
87c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    const char *device_address)
88c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
89c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
90c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
91c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(device));
92c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeCString(device_address);
93c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_DEVICE_CONNECTION_STATE, data, &reply);
94fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin        return static_cast <audio_policy_dev_state_t>(reply.readInt32());
95c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
96c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
97f78aee70d15daf4690de7e7b4983ee68b0d1381dGlenn Kasten    virtual status_t setPhoneState(audio_mode_t state)
98c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
99c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
100c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
101c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(state);
102c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_PHONE_STATE, data, &reply);
103c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
104c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
105c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
106fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config)
107c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
108c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
109c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
110c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(usage));
111c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(config));
112c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_FORCE_USE, data, &reply);
113c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
114c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
115c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
116fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage)
117c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
118c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
119c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
120c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(usage));
121c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_FORCE_USE, data, &reply);
122fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin        return static_cast <audio_policy_forced_cfg_t> (reply.readInt32());
123c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
124c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
125c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual audio_io_handle_t getOutput(
126fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                        audio_stream_type_t stream,
127c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                        uint32_t samplingRate,
12858f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten                                        audio_format_t format,
129254af180475346b6186b49c297f340c9c4817511Glenn Kasten                                        audio_channel_mask_t channelMask,
130ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald                                        audio_output_flags_t flags,
131ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald                                        const audio_offload_info_t *offloadInfo)
132c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
133c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
134c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
135c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
136c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(samplingRate);
137c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(format));
138254af180475346b6186b49c297f340c9c4817511Glenn Kasten        data.writeInt32(channelMask);
139c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(flags));
1402301acc6a9c7a3af4ad01f3d1d0f76f13eca7350Glenn Kasten        // hasOffloadInfo
141b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald        if (offloadInfo == NULL) {
142b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald            data.writeInt32(0);
143b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald        } else {
144b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald            data.writeInt32(1);
145b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald            data.write(offloadInfo, sizeof(audio_offload_info_t));
146b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald        }
147c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_OUTPUT, data, &reply);
148fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        return static_cast <audio_io_handle_t> (reply.readInt32());
149c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
150c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
151de070137f11d346fba77605bd76a44c040a618fcEric Laurent    virtual status_t startOutput(audio_io_handle_t output,
152fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                 audio_stream_type_t stream,
153de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                 int session)
154c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
155c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
156c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
157fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(output);
158fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten        data.writeInt32((int32_t) stream);
159de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(session);
160c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(START_OUTPUT, data, &reply);
161c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
162c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
163c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
164de070137f11d346fba77605bd76a44c040a618fcEric Laurent    virtual status_t stopOutput(audio_io_handle_t output,
165fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                audio_stream_type_t stream,
166de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                int session)
167c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
168c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
169c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
170fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(output);
171fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten        data.writeInt32((int32_t) stream);
172de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(session);
173c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(STOP_OUTPUT, data, &reply);
174c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
175c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
176c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
177c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual void releaseOutput(audio_io_handle_t output)
178c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
179c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
180c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
181fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(output);
182c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(RELEASE_OUTPUT, data, &reply);
183c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
184c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
185c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual audio_io_handle_t getInput(
186eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten                                    audio_source_t inputSource,
187c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    uint32_t samplingRate,
18858f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten                                    audio_format_t format,
189254af180475346b6186b49c297f340c9c4817511Glenn Kasten                                    audio_channel_mask_t channelMask,
1907c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent                                    int audioSession)
191c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
192c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
193c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
194eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten        data.writeInt32((int32_t) inputSource);
195c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(samplingRate);
196c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(format));
197254af180475346b6186b49c297f340c9c4817511Glenn Kasten        data.writeInt32(channelMask);
1987c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent        data.writeInt32(audioSession);
199c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_INPUT, data, &reply);
200fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        return static_cast <audio_io_handle_t> (reply.readInt32());
201c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
202c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
203c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t startInput(audio_io_handle_t input)
204c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
205c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
206c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
207fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(input);
208c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(START_INPUT, data, &reply);
209c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
210c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
211c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
212c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t stopInput(audio_io_handle_t input)
213c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
214c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
215c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
216fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(input);
217c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(STOP_INPUT, data, &reply);
218c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
219c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
220c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
221c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual void releaseInput(audio_io_handle_t input)
222c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
223c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
224c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
225fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(input);
226c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(RELEASE_INPUT, data, &reply);
227c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
228c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
229fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual status_t initStreamVolume(audio_stream_type_t stream,
230c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    int indexMin,
231c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    int indexMax)
232c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
233c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
234c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
235c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
236c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(indexMin);
237c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(indexMax);
238c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(INIT_STREAM_VOLUME, data, &reply);
239c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
240c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
241c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
24283844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent    virtual status_t setStreamVolumeIndex(audio_stream_type_t stream,
24383844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent                                          int index,
24483844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent                                          audio_devices_t device)
245c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
246c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
247c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
248c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
249c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(index);
25083844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent        data.writeInt32(static_cast <uint32_t>(device));
251c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_STREAM_VOLUME, data, &reply);
252c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
253c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
254c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
25583844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent    virtual status_t getStreamVolumeIndex(audio_stream_type_t stream,
25683844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent                                          int *index,
25783844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent                                          audio_devices_t device)
258c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
259c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
260c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
261c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
26283844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent        data.writeInt32(static_cast <uint32_t>(device));
26383844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent
264c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_STREAM_VOLUME, data, &reply);
265c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        int lIndex = reply.readInt32();
266c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        if (index) *index = lIndex;
267c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
268c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
269de070137f11d346fba77605bd76a44c040a618fcEric Laurent
270fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual uint32_t getStrategyForStream(audio_stream_type_t stream)
271de070137f11d346fba77605bd76a44c040a618fcEric Laurent    {
272de070137f11d346fba77605bd76a44c040a618fcEric Laurent        Parcel data, reply;
273de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
274de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
275de070137f11d346fba77605bd76a44c040a618fcEric Laurent        remote()->transact(GET_STRATEGY_FOR_STREAM, data, &reply);
276de070137f11d346fba77605bd76a44c040a618fcEric Laurent        return reply.readInt32();
277de070137f11d346fba77605bd76a44c040a618fcEric Laurent    }
278de070137f11d346fba77605bd76a44c040a618fcEric Laurent
2796374252107fd6539397598195ea6defd5870fafbEric Laurent    virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream)
2806b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten    {
2816b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten        Parcel data, reply;
2826b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
2836b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten        data.writeInt32(static_cast <uint32_t>(stream));
2846b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten        remote()->transact(GET_DEVICES_FOR_STREAM, data, &reply);
2856374252107fd6539397598195ea6defd5870fafbEric Laurent        return (audio_devices_t) reply.readInt32();
2866b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten    }
2876b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten
28858e5aa34f01d663654d8bafad65db1dda42161ffGlenn Kasten    virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc)
289de070137f11d346fba77605bd76a44c040a618fcEric Laurent    {
290de070137f11d346fba77605bd76a44c040a618fcEric Laurent        Parcel data, reply;
291de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
292de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.write(desc, sizeof(effect_descriptor_t));
293de070137f11d346fba77605bd76a44c040a618fcEric Laurent        remote()->transact(GET_OUTPUT_FOR_EFFECT, data, &reply);
294de070137f11d346fba77605bd76a44c040a618fcEric Laurent        return static_cast <audio_io_handle_t> (reply.readInt32());
295de070137f11d346fba77605bd76a44c040a618fcEric Laurent    }
296de070137f11d346fba77605bd76a44c040a618fcEric Laurent
29758e5aa34f01d663654d8bafad65db1dda42161ffGlenn Kasten    virtual status_t registerEffect(const effect_descriptor_t *desc,
2987c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent                                        audio_io_handle_t io,
299de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                        uint32_t strategy,
300de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                        int session,
301de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                        int id)
302de070137f11d346fba77605bd76a44c040a618fcEric Laurent    {
303de070137f11d346fba77605bd76a44c040a618fcEric Laurent        Parcel data, reply;
304de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
305de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.write(desc, sizeof(effect_descriptor_t));
3067c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent        data.writeInt32(io);
307de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(strategy);
308de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(session);
309de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(id);
310de070137f11d346fba77605bd76a44c040a618fcEric Laurent        remote()->transact(REGISTER_EFFECT, data, &reply);
311de070137f11d346fba77605bd76a44c040a618fcEric Laurent        return static_cast <status_t> (reply.readInt32());
312de070137f11d346fba77605bd76a44c040a618fcEric Laurent    }
313de070137f11d346fba77605bd76a44c040a618fcEric Laurent
314de070137f11d346fba77605bd76a44c040a618fcEric Laurent    virtual status_t unregisterEffect(int id)
315de070137f11d346fba77605bd76a44c040a618fcEric Laurent    {
316de070137f11d346fba77605bd76a44c040a618fcEric Laurent        Parcel data, reply;
317de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
318de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(id);
319de070137f11d346fba77605bd76a44c040a618fcEric Laurent        remote()->transact(UNREGISTER_EFFECT, data, &reply);
320de070137f11d346fba77605bd76a44c040a618fcEric Laurent        return static_cast <status_t> (reply.readInt32());
321de070137f11d346fba77605bd76a44c040a618fcEric Laurent    }
322de070137f11d346fba77605bd76a44c040a618fcEric Laurent
323db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent    virtual status_t setEffectEnabled(int id, bool enabled)
324db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent    {
325db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        Parcel data, reply;
326db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
327db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        data.writeInt32(id);
328db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        data.writeInt32(enabled);
329db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        remote()->transact(SET_EFFECT_ENABLED, data, &reply);
330db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        return static_cast <status_t> (reply.readInt32());
331db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent    }
332db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent
333fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten    virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs) const
334eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent    {
335eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        Parcel data, reply;
336eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
337fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten        data.writeInt32((int32_t) stream);
338eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        data.writeInt32(inPastMs);
339eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        remote()->transact(IS_STREAM_ACTIVE, data, &reply);
340eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        return reply.readInt32();
341eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent    }
34257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent
343272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi    virtual bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs) const
344272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi    {
345272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi        Parcel data, reply;
346272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
347272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi        data.writeInt32((int32_t) stream);
348272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi        data.writeInt32(inPastMs);
349272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi        remote()->transact(IS_STREAM_ACTIVE_REMOTELY, data, &reply);
350272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi        return reply.readInt32();
351272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi    }
352272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi
353d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi    virtual bool isSourceActive(audio_source_t source) const
354d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi    {
355d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi        Parcel data, reply;
356d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
357d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi        data.writeInt32((int32_t) source);
358d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi        remote()->transact(IS_SOURCE_ACTIVE, data, &reply);
359d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi        return reply.readInt32();
360d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi    }
361d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi
36257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent    virtual status_t queryDefaultPreProcessing(int audioSession,
36357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                                               effect_descriptor_t *descriptors,
36457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                                               uint32_t *count)
36557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent    {
36657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        if (descriptors == NULL || count == NULL) {
36757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            return BAD_VALUE;
36857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        }
36957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        Parcel data, reply;
37057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
37157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        data.writeInt32(audioSession);
37257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        data.writeInt32(*count);
37357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        status_t status = remote()->transact(QUERY_DEFAULT_PRE_PROCESSING, data, &reply);
37457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        if (status != NO_ERROR) {
37557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            return status;
37657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        }
37757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        status = static_cast <status_t> (reply.readInt32());
37857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        uint32_t retCount = reply.readInt32();
37957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        if (retCount != 0) {
38057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            uint32_t numDesc = (retCount < *count) ? retCount : *count;
38157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            reply.read(descriptors, sizeof(effect_descriptor_t) * numDesc);
38257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        }
38357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        *count = retCount;
38457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        return status;
38557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent    }
386ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald
387ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald    virtual bool isOffloadSupported(const audio_offload_info_t& info)
388ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald    {
389b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald        Parcel data, reply;
390b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
391b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald        data.write(&info, sizeof(audio_offload_info_t));
392b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald        remote()->transact(IS_OFFLOAD_SUPPORTED, data, &reply);
393b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald        return reply.readInt32();    }
394c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent};
395c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
396c2f1f07084818942352c6bbfb36af9b6b330eb4eEric LaurentIMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService");
397c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
398c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ----------------------------------------------------------------------
399c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
400c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
401c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentstatus_t BnAudioPolicyService::onTransact(
402c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
403c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{
404e53b9ead781c36e96d6b6f012ddffc93a3d80f0dGlenn Kasten    switch (code) {
405c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case SET_DEVICE_CONNECTION_STATE: {
406c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
407fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_devices_t device =
408fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_devices_t>(data.readInt32());
409fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_policy_dev_state_t state =
410fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_policy_dev_state_t>(data.readInt32());
411c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            const char *device_address = data.readCString();
412de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast<uint32_t> (setDeviceConnectionState(device,
413de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                              state,
414de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                              device_address)));
415c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
416c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
417c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
418c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_DEVICE_CONNECTION_STATE: {
419c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
420fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_devices_t device =
421fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast<audio_devices_t> (data.readInt32());
422c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            const char *device_address = data.readCString();
423de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast<uint32_t> (getDeviceConnectionState(device,
424de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                              device_address)));
425c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
426c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
427c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
428c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case SET_PHONE_STATE: {
429c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
43085ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten            reply->writeInt32(static_cast <uint32_t>(setPhoneState(
43185ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten                    (audio_mode_t) data.readInt32())));
432c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
433c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
434c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
435c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case SET_FORCE_USE: {
436c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
43785ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten            audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>(
43885ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten                    data.readInt32());
439fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_policy_forced_cfg_t config =
440fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_policy_forced_cfg_t>(data.readInt32());
441c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(setForceUse(usage, config)));
442c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
443c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
444c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
445c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_FORCE_USE: {
446c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
44785ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten            audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>(
44885ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten                    data.readInt32());
449c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(getForceUse(usage)));
450c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
451c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
452c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
453c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_OUTPUT: {
454c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
455fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_stream_type_t stream =
456fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_stream_type_t>(data.readInt32());
457c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t samplingRate = data.readInt32();
45858f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten            audio_format_t format = (audio_format_t) data.readInt32();
459254af180475346b6186b49c297f340c9c4817511Glenn Kasten            audio_channel_mask_t channelMask = data.readInt32();
4600ca3cf94c0dfc173ad7886ae162c4b67067539f6Eric Laurent            audio_output_flags_t flags =
4610ca3cf94c0dfc173ad7886ae162c4b67067539f6Eric Laurent                    static_cast <audio_output_flags_t>(data.readInt32());
462b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald            bool hasOffloadInfo = data.readInt32() != 0;
463b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald            audio_offload_info_t offloadInfo;
464b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald            if (hasOffloadInfo) {
465b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald                data.read(&offloadInfo, sizeof(audio_offload_info_t));
466b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald            }
467c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            audio_io_handle_t output = getOutput(stream,
468c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                                 samplingRate,
469c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                                 format,
470254af180475346b6186b49c297f340c9c4817511Glenn Kasten                                                 channelMask,
471b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald                                                 flags,
472b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald                                                 hasOffloadInfo ? &offloadInfo : NULL);
473fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            reply->writeInt32(static_cast <int>(output));
474c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
475c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
476c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
477c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case START_OUTPUT: {
478c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
479fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32());
480ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent            audio_stream_type_t stream =
481ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent                                static_cast <audio_stream_type_t>(data.readInt32());
482de070137f11d346fba77605bd76a44c040a618fcEric Laurent            int session = data.readInt32();
483de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast <uint32_t>(startOutput(output,
484ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent                                                                 stream,
485de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                 session)));
486c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
487c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
488c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
489c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case STOP_OUTPUT: {
490c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
491fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32());
492ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent            audio_stream_type_t stream =
493ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent                                static_cast <audio_stream_type_t>(data.readInt32());
494de070137f11d346fba77605bd76a44c040a618fcEric Laurent            int session = data.readInt32();
495de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast <uint32_t>(stopOutput(output,
496ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent                                                                stream,
497de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                session)));
498c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
499c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
500c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
501c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case RELEASE_OUTPUT: {
502c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
503fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32());
504c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            releaseOutput(output);
505c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
506c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
507c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
508c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_INPUT: {
509c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
510eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten            audio_source_t inputSource = (audio_source_t) data.readInt32();
511c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t samplingRate = data.readInt32();
51258f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten            audio_format_t format = (audio_format_t) data.readInt32();
513254af180475346b6186b49c297f340c9c4817511Glenn Kasten            audio_channel_mask_t channelMask = data.readInt32();
5147c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent            int audioSession = data.readInt32();
515c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            audio_io_handle_t input = getInput(inputSource,
516c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                               samplingRate,
517c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                               format,
518254af180475346b6186b49c297f340c9c4817511Glenn Kasten                                               channelMask,
5197c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent                                               audioSession);
520fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            reply->writeInt32(static_cast <int>(input));
521c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
522c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
523c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
524c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case START_INPUT: {
525c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
526fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32());
527c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(startInput(input)));
528c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
529c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
530c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
531c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case STOP_INPUT: {
532c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
533fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32());
534c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(stopInput(input)));
535c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
536c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
537c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
538c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case RELEASE_INPUT: {
539c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
540fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32());
541c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            releaseInput(input);
542c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
543c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
544c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
545c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case INIT_STREAM_VOLUME: {
546c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
547fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_stream_type_t stream =
548fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_stream_type_t>(data.readInt32());
549c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            int indexMin = data.readInt32();
550c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            int indexMax = data.readInt32();
551c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(initStreamVolume(stream, indexMin,indexMax)));
552c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
553c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
554c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
555c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case SET_STREAM_VOLUME: {
556c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
557fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_stream_type_t stream =
558fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_stream_type_t>(data.readInt32());
559c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            int index = data.readInt32();
56083844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent            audio_devices_t device = static_cast <audio_devices_t>(data.readInt32());
56183844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent            reply->writeInt32(static_cast <uint32_t>(setStreamVolumeIndex(stream,
56283844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent                                                                          index,
56383844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent                                                                          device)));
564c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
565c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
566c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
567c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_STREAM_VOLUME: {
568c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
569fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_stream_type_t stream =
570fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_stream_type_t>(data.readInt32());
57183844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent            audio_devices_t device = static_cast <audio_devices_t>(data.readInt32());
572c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            int index;
57383844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent            status_t status = getStreamVolumeIndex(stream, &index, device);
574c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(index);
575c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(status));
576c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
577c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
578c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
579de070137f11d346fba77605bd76a44c040a618fcEric Laurent        case GET_STRATEGY_FOR_STREAM: {
580de070137f11d346fba77605bd76a44c040a618fcEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
581fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_stream_type_t stream =
582fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_stream_type_t>(data.readInt32());
583de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(getStrategyForStream(stream));
584de070137f11d346fba77605bd76a44c040a618fcEric Laurent            return NO_ERROR;
585de070137f11d346fba77605bd76a44c040a618fcEric Laurent        } break;
586de070137f11d346fba77605bd76a44c040a618fcEric Laurent
5876b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten        case GET_DEVICES_FOR_STREAM: {
5886b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten            CHECK_INTERFACE(IAudioPolicyService, data, reply);
589fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_stream_type_t stream =
590fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_stream_type_t>(data.readInt32());
5916b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten            reply->writeInt32(static_cast <int>(getDevicesForStream(stream)));
5926b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten            return NO_ERROR;
5936b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten        } break;
5946b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten
595de070137f11d346fba77605bd76a44c040a618fcEric Laurent        case GET_OUTPUT_FOR_EFFECT: {
596de070137f11d346fba77605bd76a44c040a618fcEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
597de070137f11d346fba77605bd76a44c040a618fcEric Laurent            effect_descriptor_t desc;
598de070137f11d346fba77605bd76a44c040a618fcEric Laurent            data.read(&desc, sizeof(effect_descriptor_t));
599de070137f11d346fba77605bd76a44c040a618fcEric Laurent            audio_io_handle_t output = getOutputForEffect(&desc);
600de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast <int>(output));
601de070137f11d346fba77605bd76a44c040a618fcEric Laurent            return NO_ERROR;
602de070137f11d346fba77605bd76a44c040a618fcEric Laurent        } break;
603de070137f11d346fba77605bd76a44c040a618fcEric Laurent
604de070137f11d346fba77605bd76a44c040a618fcEric Laurent        case REGISTER_EFFECT: {
605de070137f11d346fba77605bd76a44c040a618fcEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
606de070137f11d346fba77605bd76a44c040a618fcEric Laurent            effect_descriptor_t desc;
607de070137f11d346fba77605bd76a44c040a618fcEric Laurent            data.read(&desc, sizeof(effect_descriptor_t));
6087c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent            audio_io_handle_t io = data.readInt32();
609de070137f11d346fba77605bd76a44c040a618fcEric Laurent            uint32_t strategy = data.readInt32();
610de070137f11d346fba77605bd76a44c040a618fcEric Laurent            int session = data.readInt32();
611de070137f11d346fba77605bd76a44c040a618fcEric Laurent            int id = data.readInt32();
612de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast <int32_t>(registerEffect(&desc,
6137c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent                                                                   io,
614de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                   strategy,
615de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                   session,
616de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                   id)));
617de070137f11d346fba77605bd76a44c040a618fcEric Laurent            return NO_ERROR;
618de070137f11d346fba77605bd76a44c040a618fcEric Laurent        } break;
619de070137f11d346fba77605bd76a44c040a618fcEric Laurent
620de070137f11d346fba77605bd76a44c040a618fcEric Laurent        case UNREGISTER_EFFECT: {
621de070137f11d346fba77605bd76a44c040a618fcEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
622de070137f11d346fba77605bd76a44c040a618fcEric Laurent            int id = data.readInt32();
623de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast <int32_t>(unregisterEffect(id)));
624de070137f11d346fba77605bd76a44c040a618fcEric Laurent            return NO_ERROR;
625de070137f11d346fba77605bd76a44c040a618fcEric Laurent        } break;
626de070137f11d346fba77605bd76a44c040a618fcEric Laurent
627db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        case SET_EFFECT_ENABLED: {
628db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
629db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent            int id = data.readInt32();
630db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent            bool enabled = static_cast <bool>(data.readInt32());
631db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent            reply->writeInt32(static_cast <int32_t>(setEffectEnabled(id, enabled)));
632db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent            return NO_ERROR;
633db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        } break;
634db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent
635eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        case IS_STREAM_ACTIVE: {
636eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
637fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten            audio_stream_type_t stream = (audio_stream_type_t) data.readInt32();
638eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent            uint32_t inPastMs = (uint32_t)data.readInt32();
639ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent            reply->writeInt32( isStreamActive(stream, inPastMs) );
640eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent            return NO_ERROR;
641eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        } break;
642eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent
643272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi        case IS_STREAM_ACTIVE_REMOTELY: {
644272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi            CHECK_INTERFACE(IAudioPolicyService, data, reply);
645272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi            audio_stream_type_t stream = (audio_stream_type_t) data.readInt32();
646272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi            uint32_t inPastMs = (uint32_t)data.readInt32();
647ebcb254adb7402ab89ae97c4d9d16d886790dcb3Eric Laurent            reply->writeInt32( isStreamActiveRemotely(stream, inPastMs) );
648272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi            return NO_ERROR;
649272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi        } break;
650272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi
651d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi        case IS_SOURCE_ACTIVE: {
652d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi            CHECK_INTERFACE(IAudioPolicyService, data, reply);
653d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi            audio_source_t source = (audio_source_t) data.readInt32();
654d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi            reply->writeInt32( isSourceActive(source));
655d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi            return NO_ERROR;
656d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi        }
657d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi
65857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        case QUERY_DEFAULT_PRE_PROCESSING: {
65957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
66057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            int audioSession = data.readInt32();
66157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            uint32_t count = data.readInt32();
66257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            uint32_t retCount = count;
66357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            effect_descriptor_t *descriptors =
66457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                    (effect_descriptor_t *)new char[count * sizeof(effect_descriptor_t)];
66557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            status_t status = queryDefaultPreProcessing(audioSession, descriptors, &retCount);
66657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            reply->writeInt32(status);
66757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            if (status != NO_ERROR && status != NO_MEMORY) {
66857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                retCount = 0;
66957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            }
67057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            reply->writeInt32(retCount);
67157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            if (retCount) {
67257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                if (retCount < count) {
67357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                    count = retCount;
67457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                }
67557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                reply->write(descriptors, sizeof(effect_descriptor_t) * count);
67657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            }
67757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            delete[] descriptors;
67857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            return status;
67957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        }
68057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent
681b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald        case IS_OFFLOAD_SUPPORTED: {
682b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald            CHECK_INTERFACE(IAudioPolicyService, data, reply);
683b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald            audio_offload_info_t info;
684b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald            data.read(&info, sizeof(audio_offload_info_t));
685b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald            bool isSupported = isOffloadSupported(info);
686b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald            reply->writeInt32(isSupported);
687b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald            return NO_ERROR;
688b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald        }
689b1a270d1e926fb9a01b4265a7675ed0c2c8f4868Richard Fitzgerald
690c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        default:
691c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return BBinder::onTransact(code, data, reply, flags);
692c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
693c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}
694c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
695c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ----------------------------------------------------------------------------
696c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
697c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; // namespace android
698