IAudioPolicyService.cpp revision f78aee70d15daf4690de7e7b4983ee68b0d1381d
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,
36c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    SET_RINGER_MODE,
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,
556b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten    GET_DEVICES_FOR_STREAM,
56db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent    QUERY_DEFAULT_PRE_PROCESSING,
57db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent    SET_EFFECT_ENABLED
58c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent};
59c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
60c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentclass BpAudioPolicyService : public BpInterface<IAudioPolicyService>
61c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{
62c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentpublic:
63c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    BpAudioPolicyService(const sp<IBinder>& impl)
64c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        : BpInterface<IAudioPolicyService>(impl)
65c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
66c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
67c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
68c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t setDeviceConnectionState(
69fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                    audio_devices_t device,
70fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                    audio_policy_dev_state_t state,
71c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    const char *device_address)
72c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
73c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
74c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
75c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(device));
76c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(state));
77c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeCString(device_address);
78c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_DEVICE_CONNECTION_STATE, data, &reply);
79c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
80c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
81c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
82fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual audio_policy_dev_state_t getDeviceConnectionState(
83fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                    audio_devices_t device,
84c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    const char *device_address)
85c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
86c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
87c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
88c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(device));
89c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeCString(device_address);
90c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_DEVICE_CONNECTION_STATE, data, &reply);
91fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin        return static_cast <audio_policy_dev_state_t>(reply.readInt32());
92c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
93c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
94f78aee70d15daf4690de7e7b4983ee68b0d1381dGlenn Kasten    virtual status_t setPhoneState(audio_mode_t state)
95c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
96c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
97c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
98c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(state);
99c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_PHONE_STATE, data, &reply);
100c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
101c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
102c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
103c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t setRingerMode(uint32_t mode, uint32_t mask)
104c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
105c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
106c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
107c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(mode);
108c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(mask);
109c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_RINGER_MODE, data, &reply);
110c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
111c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
112c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
113fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config)
114c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
115c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
116c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
117c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(usage));
118c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(config));
119c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_FORCE_USE, data, &reply);
120c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
121c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
122c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
123fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage)
124c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
125c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
126c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
127c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(usage));
128c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_FORCE_USE, data, &reply);
129fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin        return static_cast <audio_policy_forced_cfg_t> (reply.readInt32());
130c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
131c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
132c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual audio_io_handle_t getOutput(
133fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                        audio_stream_type_t stream,
134c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                        uint32_t samplingRate,
135c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                        uint32_t format,
136c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                        uint32_t channels,
137fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                        audio_policy_output_flags_t flags)
138c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
139c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
140c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
141c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
142c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(samplingRate);
143c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(format));
144c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(channels);
145c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(flags));
146c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_OUTPUT, data, &reply);
147fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        return static_cast <audio_io_handle_t> (reply.readInt32());
148c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
149c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
150de070137f11d346fba77605bd76a44c040a618fcEric Laurent    virtual status_t startOutput(audio_io_handle_t output,
151fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                 audio_stream_type_t stream,
152de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                 int session)
153c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
154c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
155c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
156fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(output);
157c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(stream);
158de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(session);
159c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(START_OUTPUT, data, &reply);
160c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
161c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
162c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
163de070137f11d346fba77605bd76a44c040a618fcEric Laurent    virtual status_t stopOutput(audio_io_handle_t output,
164fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                audio_stream_type_t stream,
165de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                int session)
166c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
167c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
168c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
169fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(output);
170c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(stream);
171de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(session);
172c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(STOP_OUTPUT, data, &reply);
173c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
174c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
175c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
176c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual void releaseOutput(audio_io_handle_t output)
177c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
178c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
179c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
180fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(output);
181c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(RELEASE_OUTPUT, data, &reply);
182c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
183c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
184c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual audio_io_handle_t getInput(
185c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    int inputSource,
186c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    uint32_t samplingRate,
187c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    uint32_t format,
188c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    uint32_t channels,
1897c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent                                    audio_in_acoustics_t acoustics,
1907c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent                                    int audioSession)
191c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
192c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
193c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
194c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(inputSource);
195c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(samplingRate);
196c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(format));
197c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(channels);
198c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(acoustics));
1997c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent        data.writeInt32(audioSession);
200c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_INPUT, data, &reply);
201fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        return static_cast <audio_io_handle_t> (reply.readInt32());
202c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
203c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
204c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t startInput(audio_io_handle_t input)
205c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
206c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
207c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
208fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(input);
209c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(START_INPUT, data, &reply);
210c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
211c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
212c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
213c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t stopInput(audio_io_handle_t input)
214c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
215c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
216c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
217fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(input);
218c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(STOP_INPUT, data, &reply);
219c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
220c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
221c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
222c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual void releaseInput(audio_io_handle_t input)
223c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
224c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
225c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
226fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(input);
227c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(RELEASE_INPUT, data, &reply);
228c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
229c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
230fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual status_t initStreamVolume(audio_stream_type_t stream,
231c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    int indexMin,
232c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    int indexMax)
233c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
234c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
235c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
236c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
237c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(indexMin);
238c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(indexMax);
239c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(INIT_STREAM_VOLUME, data, &reply);
240c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
241c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
242c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
243fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, int index)
244c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
245c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
246c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
247c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
248c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(index);
249c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_STREAM_VOLUME, data, &reply);
250c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
251c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
252c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
253fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, int *index)
254c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
255c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
256c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
257c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
258c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_STREAM_VOLUME, data, &reply);
259c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        int lIndex = reply.readInt32();
260c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        if (index) *index = lIndex;
261c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
262c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
263de070137f11d346fba77605bd76a44c040a618fcEric Laurent
264fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual uint32_t getStrategyForStream(audio_stream_type_t stream)
265de070137f11d346fba77605bd76a44c040a618fcEric Laurent    {
266de070137f11d346fba77605bd76a44c040a618fcEric Laurent        Parcel data, reply;
267de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
268de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
269de070137f11d346fba77605bd76a44c040a618fcEric Laurent        remote()->transact(GET_STRATEGY_FOR_STREAM, data, &reply);
270de070137f11d346fba77605bd76a44c040a618fcEric Laurent        return reply.readInt32();
271de070137f11d346fba77605bd76a44c040a618fcEric Laurent    }
272de070137f11d346fba77605bd76a44c040a618fcEric Laurent
273fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual uint32_t getDevicesForStream(audio_stream_type_t stream)
2746b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten    {
2756b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten        Parcel data, reply;
2766b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
2776b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten        data.writeInt32(static_cast <uint32_t>(stream));
2786b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten        remote()->transact(GET_DEVICES_FOR_STREAM, data, &reply);
2796b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten        return (uint32_t) reply.readInt32();
2806b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten    }
2816b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten
282de070137f11d346fba77605bd76a44c040a618fcEric Laurent    virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc)
283de070137f11d346fba77605bd76a44c040a618fcEric Laurent    {
284de070137f11d346fba77605bd76a44c040a618fcEric Laurent        Parcel data, reply;
285de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
286de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.write(desc, sizeof(effect_descriptor_t));
287de070137f11d346fba77605bd76a44c040a618fcEric Laurent        remote()->transact(GET_OUTPUT_FOR_EFFECT, data, &reply);
288de070137f11d346fba77605bd76a44c040a618fcEric Laurent        return static_cast <audio_io_handle_t> (reply.readInt32());
289de070137f11d346fba77605bd76a44c040a618fcEric Laurent    }
290de070137f11d346fba77605bd76a44c040a618fcEric Laurent
291de070137f11d346fba77605bd76a44c040a618fcEric Laurent    virtual status_t registerEffect(effect_descriptor_t *desc,
2927c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent                                        audio_io_handle_t io,
293de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                        uint32_t strategy,
294de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                        int session,
295de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                        int id)
296de070137f11d346fba77605bd76a44c040a618fcEric Laurent    {
297de070137f11d346fba77605bd76a44c040a618fcEric Laurent        Parcel data, reply;
298de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
299de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.write(desc, sizeof(effect_descriptor_t));
3007c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent        data.writeInt32(io);
301de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(strategy);
302de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(session);
303de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(id);
304de070137f11d346fba77605bd76a44c040a618fcEric Laurent        remote()->transact(REGISTER_EFFECT, data, &reply);
305de070137f11d346fba77605bd76a44c040a618fcEric Laurent        return static_cast <status_t> (reply.readInt32());
306de070137f11d346fba77605bd76a44c040a618fcEric Laurent    }
307de070137f11d346fba77605bd76a44c040a618fcEric Laurent
308de070137f11d346fba77605bd76a44c040a618fcEric Laurent    virtual status_t unregisterEffect(int id)
309de070137f11d346fba77605bd76a44c040a618fcEric Laurent    {
310de070137f11d346fba77605bd76a44c040a618fcEric Laurent        Parcel data, reply;
311de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
312de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(id);
313de070137f11d346fba77605bd76a44c040a618fcEric Laurent        remote()->transact(UNREGISTER_EFFECT, data, &reply);
314de070137f11d346fba77605bd76a44c040a618fcEric Laurent        return static_cast <status_t> (reply.readInt32());
315de070137f11d346fba77605bd76a44c040a618fcEric Laurent    }
316de070137f11d346fba77605bd76a44c040a618fcEric Laurent
317db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent    virtual status_t setEffectEnabled(int id, bool enabled)
318db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent    {
319db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        Parcel data, reply;
320db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
321db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        data.writeInt32(id);
322db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        data.writeInt32(enabled);
323db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        remote()->transact(SET_EFFECT_ENABLED, data, &reply);
324db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        return static_cast <status_t> (reply.readInt32());
325db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent    }
326db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent
327eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent    virtual bool isStreamActive(int stream, uint32_t inPastMs) const
328eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent    {
329eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        Parcel data, reply;
330eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
331eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        data.writeInt32(stream);
332eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        data.writeInt32(inPastMs);
333eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        remote()->transact(IS_STREAM_ACTIVE, data, &reply);
334eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        return reply.readInt32();
335eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent    }
33657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent
33757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent    virtual status_t queryDefaultPreProcessing(int audioSession,
33857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                                               effect_descriptor_t *descriptors,
33957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                                               uint32_t *count)
34057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent    {
34157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        if (descriptors == NULL || count == NULL) {
34257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            return BAD_VALUE;
34357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        }
34457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        Parcel data, reply;
34557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
34657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        data.writeInt32(audioSession);
34757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        data.writeInt32(*count);
34857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        status_t status = remote()->transact(QUERY_DEFAULT_PRE_PROCESSING, data, &reply);
34957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        if (status != NO_ERROR) {
35057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            return status;
35157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        }
35257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        status = static_cast <status_t> (reply.readInt32());
35357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        uint32_t retCount = reply.readInt32();
35457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        if (retCount != 0) {
35557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            uint32_t numDesc = (retCount < *count) ? retCount : *count;
35657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            reply.read(descriptors, sizeof(effect_descriptor_t) * numDesc);
35757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        }
35857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        *count = retCount;
35957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        return status;
36057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent    }
361c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent};
362c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
363c2f1f07084818942352c6bbfb36af9b6b330eb4eEric LaurentIMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService");
364c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
365c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ----------------------------------------------------------------------
366c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
367c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
368c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentstatus_t BnAudioPolicyService::onTransact(
369c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
370c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{
371c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    switch(code) {
372c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case SET_DEVICE_CONNECTION_STATE: {
373c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
374fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_devices_t device =
375fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_devices_t>(data.readInt32());
376fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_policy_dev_state_t state =
377fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_policy_dev_state_t>(data.readInt32());
378c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            const char *device_address = data.readCString();
379de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast<uint32_t> (setDeviceConnectionState(device,
380de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                              state,
381de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                              device_address)));
382c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
383c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
384c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
385c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_DEVICE_CONNECTION_STATE: {
386c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
387fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_devices_t device =
388fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast<audio_devices_t> (data.readInt32());
389c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            const char *device_address = data.readCString();
390de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast<uint32_t> (getDeviceConnectionState(device,
391de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                              device_address)));
392c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
393c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
394c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
395c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case SET_PHONE_STATE: {
396c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
397f78aee70d15daf4690de7e7b4983ee68b0d1381dGlenn Kasten            reply->writeInt32(static_cast <uint32_t>(setPhoneState((audio_mode_t) data.readInt32())));
398c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
399c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
400c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
401c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case SET_RINGER_MODE: {
402c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
403c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t mode = data.readInt32();
404c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t mask = data.readInt32();
405c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(setRingerMode(mode, mask)));
406c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
407c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
408c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
409c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case SET_FORCE_USE: {
410c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
411fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>(data.readInt32());
412fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_policy_forced_cfg_t config =
413fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_policy_forced_cfg_t>(data.readInt32());
414c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(setForceUse(usage, config)));
415c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
416c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
417c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
418c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_FORCE_USE: {
419c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
420fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>(data.readInt32());
421c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(getForceUse(usage)));
422c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
423c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
424c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
425c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_OUTPUT: {
426c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
427fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_stream_type_t stream =
428fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_stream_type_t>(data.readInt32());
429c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t samplingRate = data.readInt32();
430c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t format = data.readInt32();
431c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t channels = data.readInt32();
432fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_policy_output_flags_t flags =
433fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_policy_output_flags_t>(data.readInt32());
434c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
435c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            audio_io_handle_t output = getOutput(stream,
436c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                                 samplingRate,
437c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                                 format,
438c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                                 channels,
439c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                                 flags);
440fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            reply->writeInt32(static_cast <int>(output));
441c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
442c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
443c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
444c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case START_OUTPUT: {
445c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
446fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32());
447c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t stream = data.readInt32();
448de070137f11d346fba77605bd76a44c040a618fcEric Laurent            int session = data.readInt32();
449de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast <uint32_t>(startOutput(output,
450fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                                                 (audio_stream_type_t)stream,
451de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                 session)));
452c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
453c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
454c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
455c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case STOP_OUTPUT: {
456c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
457fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32());
458c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t stream = data.readInt32();
459de070137f11d346fba77605bd76a44c040a618fcEric Laurent            int session = data.readInt32();
460de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast <uint32_t>(stopOutput(output,
461fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                                                (audio_stream_type_t)stream,
462de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                session)));
463c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
464c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
465c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
466c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case RELEASE_OUTPUT: {
467c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
468fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32());
469c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            releaseOutput(output);
470c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
471c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
472c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
473c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_INPUT: {
474c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
475c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            int inputSource = data.readInt32();
476c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t samplingRate = data.readInt32();
477c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t format = data.readInt32();
478c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t channels = data.readInt32();
479fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_in_acoustics_t acoustics =
480fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_in_acoustics_t>(data.readInt32());
4817c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent            int audioSession = data.readInt32();
482c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            audio_io_handle_t input = getInput(inputSource,
483c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                               samplingRate,
484c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                               format,
485c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                               channels,
4867c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent                                               acoustics,
4877c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent                                               audioSession);
488fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            reply->writeInt32(static_cast <int>(input));
489c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
490c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
491c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
492c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case START_INPUT: {
493c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
494fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32());
495c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(startInput(input)));
496c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
497c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
498c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
499c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case STOP_INPUT: {
500c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
501fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32());
502c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(stopInput(input)));
503c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
504c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
505c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
506c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case RELEASE_INPUT: {
507c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
508fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32());
509c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            releaseInput(input);
510c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
511c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
512c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
513c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case INIT_STREAM_VOLUME: {
514c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
515fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_stream_type_t stream =
516fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_stream_type_t>(data.readInt32());
517c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            int indexMin = data.readInt32();
518c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            int indexMax = data.readInt32();
519c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(initStreamVolume(stream, indexMin,indexMax)));
520c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
521c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
522c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
523c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case SET_STREAM_VOLUME: {
524c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
525fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_stream_type_t stream =
526fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_stream_type_t>(data.readInt32());
527c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            int index = data.readInt32();
528c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(setStreamVolumeIndex(stream, index)));
529c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
530c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
531c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
532c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_STREAM_VOLUME: {
533c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
534fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_stream_type_t stream =
535fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_stream_type_t>(data.readInt32());
536c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            int index;
537c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            status_t status = getStreamVolumeIndex(stream, &index);
538c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(index);
539c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(status));
540c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
541c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
542c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
543de070137f11d346fba77605bd76a44c040a618fcEric Laurent        case GET_STRATEGY_FOR_STREAM: {
544de070137f11d346fba77605bd76a44c040a618fcEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
545fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_stream_type_t stream =
546fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_stream_type_t>(data.readInt32());
547de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(getStrategyForStream(stream));
548de070137f11d346fba77605bd76a44c040a618fcEric Laurent            return NO_ERROR;
549de070137f11d346fba77605bd76a44c040a618fcEric Laurent        } break;
550de070137f11d346fba77605bd76a44c040a618fcEric Laurent
5516b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten        case GET_DEVICES_FOR_STREAM: {
5526b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten            CHECK_INTERFACE(IAudioPolicyService, data, reply);
553fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_stream_type_t stream =
554fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_stream_type_t>(data.readInt32());
5556b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten            reply->writeInt32(static_cast <int>(getDevicesForStream(stream)));
5566b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten            return NO_ERROR;
5576b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten        } break;
5586b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten
559de070137f11d346fba77605bd76a44c040a618fcEric Laurent        case GET_OUTPUT_FOR_EFFECT: {
560de070137f11d346fba77605bd76a44c040a618fcEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
561de070137f11d346fba77605bd76a44c040a618fcEric Laurent            effect_descriptor_t desc;
562de070137f11d346fba77605bd76a44c040a618fcEric Laurent            data.read(&desc, sizeof(effect_descriptor_t));
563de070137f11d346fba77605bd76a44c040a618fcEric Laurent            audio_io_handle_t output = getOutputForEffect(&desc);
564de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast <int>(output));
565de070137f11d346fba77605bd76a44c040a618fcEric Laurent            return NO_ERROR;
566de070137f11d346fba77605bd76a44c040a618fcEric Laurent        } break;
567de070137f11d346fba77605bd76a44c040a618fcEric Laurent
568de070137f11d346fba77605bd76a44c040a618fcEric Laurent        case REGISTER_EFFECT: {
569de070137f11d346fba77605bd76a44c040a618fcEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
570de070137f11d346fba77605bd76a44c040a618fcEric Laurent            effect_descriptor_t desc;
571de070137f11d346fba77605bd76a44c040a618fcEric Laurent            data.read(&desc, sizeof(effect_descriptor_t));
5727c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent            audio_io_handle_t io = data.readInt32();
573de070137f11d346fba77605bd76a44c040a618fcEric Laurent            uint32_t strategy = data.readInt32();
574de070137f11d346fba77605bd76a44c040a618fcEric Laurent            int session = data.readInt32();
575de070137f11d346fba77605bd76a44c040a618fcEric Laurent            int id = data.readInt32();
576de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast <int32_t>(registerEffect(&desc,
5777c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent                                                                   io,
578de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                   strategy,
579de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                   session,
580de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                   id)));
581de070137f11d346fba77605bd76a44c040a618fcEric Laurent            return NO_ERROR;
582de070137f11d346fba77605bd76a44c040a618fcEric Laurent        } break;
583de070137f11d346fba77605bd76a44c040a618fcEric Laurent
584de070137f11d346fba77605bd76a44c040a618fcEric Laurent        case UNREGISTER_EFFECT: {
585de070137f11d346fba77605bd76a44c040a618fcEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
586de070137f11d346fba77605bd76a44c040a618fcEric Laurent            int id = data.readInt32();
587de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast <int32_t>(unregisterEffect(id)));
588de070137f11d346fba77605bd76a44c040a618fcEric Laurent            return NO_ERROR;
589de070137f11d346fba77605bd76a44c040a618fcEric Laurent        } break;
590de070137f11d346fba77605bd76a44c040a618fcEric Laurent
591db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        case SET_EFFECT_ENABLED: {
592db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
593db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent            int id = data.readInt32();
594db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent            bool enabled = static_cast <bool>(data.readInt32());
595db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent            reply->writeInt32(static_cast <int32_t>(setEffectEnabled(id, enabled)));
596db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent            return NO_ERROR;
597db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        } break;
598db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent
599eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        case IS_STREAM_ACTIVE: {
600eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
601eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent            int stream = data.readInt32();
602eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent            uint32_t inPastMs = (uint32_t)data.readInt32();
603eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent            reply->writeInt32( isStreamActive(stream, inPastMs) );
604eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent            return NO_ERROR;
605eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        } break;
606eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent
60757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        case QUERY_DEFAULT_PRE_PROCESSING: {
60857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
60957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            int audioSession = data.readInt32();
61057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            uint32_t count = data.readInt32();
61157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            uint32_t retCount = count;
61257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            effect_descriptor_t *descriptors =
61357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                    (effect_descriptor_t *)new char[count * sizeof(effect_descriptor_t)];
61457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            status_t status = queryDefaultPreProcessing(audioSession, descriptors, &retCount);
61557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            reply->writeInt32(status);
61657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            if (status != NO_ERROR && status != NO_MEMORY) {
61757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                retCount = 0;
61857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            }
61957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            reply->writeInt32(retCount);
62057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            if (retCount) {
62157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                if (retCount < count) {
62257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                    count = retCount;
62357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                }
62457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                reply->write(descriptors, sizeof(effect_descriptor_t) * count);
62557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            }
62657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            delete[] descriptors;
62757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            return status;
62857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        }
62957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent
630c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        default:
631c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return BBinder::onTransact(code, data, reply, flags);
632c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
633c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}
634c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
635c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ----------------------------------------------------------------------------
636c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
637c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; // namespace android
638