IAudioPolicyService.cpp revision d7086030fcf731e4bcef6c033cc6418cd04e6b91
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,
58db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent    SET_EFFECT_ENABLED
59c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent};
60c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
61c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentclass BpAudioPolicyService : public BpInterface<IAudioPolicyService>
62c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{
63c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentpublic:
64c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    BpAudioPolicyService(const sp<IBinder>& impl)
65c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        : BpInterface<IAudioPolicyService>(impl)
66c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
67c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
68c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
69c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t setDeviceConnectionState(
70fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                    audio_devices_t device,
71fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                    audio_policy_dev_state_t state,
72c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    const char *device_address)
73c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
74c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
75c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
76c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(device));
77c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(state));
78c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeCString(device_address);
79c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_DEVICE_CONNECTION_STATE, data, &reply);
80c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
81c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
82c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
83fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual audio_policy_dev_state_t getDeviceConnectionState(
84fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                    audio_devices_t device,
85c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    const char *device_address)
86c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
87c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
88c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
89c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(device));
90c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeCString(device_address);
91c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_DEVICE_CONNECTION_STATE, data, &reply);
92fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin        return static_cast <audio_policy_dev_state_t>(reply.readInt32());
93c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
94c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
95f78aee70d15daf4690de7e7b4983ee68b0d1381dGlenn Kasten    virtual status_t setPhoneState(audio_mode_t state)
96c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
97c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
98c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
99c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(state);
100c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_PHONE_STATE, data, &reply);
101c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
102c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
103c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
104fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config)
105c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
106c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
107c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
108c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(usage));
109c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(config));
110c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_FORCE_USE, data, &reply);
111c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
112c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
113c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
114fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage)
115c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
116c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
117c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
118c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(usage));
119c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_FORCE_USE, data, &reply);
120fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin        return static_cast <audio_policy_forced_cfg_t> (reply.readInt32());
121c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
122c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
123c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual audio_io_handle_t getOutput(
124fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                        audio_stream_type_t stream,
125c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                        uint32_t samplingRate,
12658f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten                                        audio_format_t format,
127254af180475346b6186b49c297f340c9c4817511Glenn Kasten                                        audio_channel_mask_t channelMask,
1280ca3cf94c0dfc173ad7886ae162c4b67067539f6Eric Laurent                                        audio_output_flags_t flags)
129c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
130c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
131c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
132c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
133c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(samplingRate);
134c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(format));
135254af180475346b6186b49c297f340c9c4817511Glenn Kasten        data.writeInt32(channelMask);
136c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(flags));
137c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_OUTPUT, data, &reply);
138fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        return static_cast <audio_io_handle_t> (reply.readInt32());
139c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
140c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
141de070137f11d346fba77605bd76a44c040a618fcEric Laurent    virtual status_t startOutput(audio_io_handle_t output,
142fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                 audio_stream_type_t stream,
143de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                 int session)
144c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
145c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
146c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
147fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(output);
148fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten        data.writeInt32((int32_t) stream);
149de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(session);
150c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(START_OUTPUT, data, &reply);
151c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
152c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
153c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
154de070137f11d346fba77605bd76a44c040a618fcEric Laurent    virtual status_t stopOutput(audio_io_handle_t output,
155fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                audio_stream_type_t stream,
156de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                int session)
157c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
158c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
159c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
160fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(output);
161fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten        data.writeInt32((int32_t) stream);
162de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(session);
163c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(STOP_OUTPUT, data, &reply);
164c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
165c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
166c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
167c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual void releaseOutput(audio_io_handle_t output)
168c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
169c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
170c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
171fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(output);
172c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(RELEASE_OUTPUT, data, &reply);
173c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
174c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
175c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual audio_io_handle_t getInput(
176eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten                                    audio_source_t inputSource,
177c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    uint32_t samplingRate,
17858f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten                                    audio_format_t format,
179254af180475346b6186b49c297f340c9c4817511Glenn Kasten                                    audio_channel_mask_t channelMask,
1807c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent                                    int audioSession)
181c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
182c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
183c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
184eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten        data.writeInt32((int32_t) inputSource);
185c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(samplingRate);
186c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(format));
187254af180475346b6186b49c297f340c9c4817511Glenn Kasten        data.writeInt32(channelMask);
1887c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent        data.writeInt32(audioSession);
189c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_INPUT, data, &reply);
190fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        return static_cast <audio_io_handle_t> (reply.readInt32());
191c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
192c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
193c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t startInput(audio_io_handle_t input)
194c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
195c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
196c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
197fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(input);
198c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(START_INPUT, data, &reply);
199c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
200c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
201c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
202c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t stopInput(audio_io_handle_t input)
203c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
204c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
205c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
206fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(input);
207c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(STOP_INPUT, data, &reply);
208c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
209c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
210c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
211c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual void releaseInput(audio_io_handle_t input)
212c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
213c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
214c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
215fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(input);
216c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(RELEASE_INPUT, data, &reply);
217c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
218c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
219fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual status_t initStreamVolume(audio_stream_type_t stream,
220c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    int indexMin,
221c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    int indexMax)
222c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
223c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
224c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
225c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
226c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(indexMin);
227c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(indexMax);
228c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(INIT_STREAM_VOLUME, data, &reply);
229c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
230c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
231c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
23283844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent    virtual status_t setStreamVolumeIndex(audio_stream_type_t stream,
23383844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent                                          int index,
23483844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent                                          audio_devices_t device)
235c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
236c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
237c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
238c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
239c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(index);
24083844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent        data.writeInt32(static_cast <uint32_t>(device));
241c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_STREAM_VOLUME, data, &reply);
242c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
243c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
244c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
24583844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent    virtual status_t getStreamVolumeIndex(audio_stream_type_t stream,
24683844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent                                          int *index,
24783844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent                                          audio_devices_t device)
248c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
249c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
250c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
251c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
25283844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent        data.writeInt32(static_cast <uint32_t>(device));
25383844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent
254c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_STREAM_VOLUME, data, &reply);
255c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        int lIndex = reply.readInt32();
256c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        if (index) *index = lIndex;
257c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
258c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
259de070137f11d346fba77605bd76a44c040a618fcEric Laurent
260fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual uint32_t getStrategyForStream(audio_stream_type_t stream)
261de070137f11d346fba77605bd76a44c040a618fcEric Laurent    {
262de070137f11d346fba77605bd76a44c040a618fcEric Laurent        Parcel data, reply;
263de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
264de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
265de070137f11d346fba77605bd76a44c040a618fcEric Laurent        remote()->transact(GET_STRATEGY_FOR_STREAM, data, &reply);
266de070137f11d346fba77605bd76a44c040a618fcEric Laurent        return reply.readInt32();
267de070137f11d346fba77605bd76a44c040a618fcEric Laurent    }
268de070137f11d346fba77605bd76a44c040a618fcEric Laurent
2696374252107fd6539397598195ea6defd5870fafbEric Laurent    virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream)
2706b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten    {
2716b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten        Parcel data, reply;
2726b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
2736b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten        data.writeInt32(static_cast <uint32_t>(stream));
2746b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten        remote()->transact(GET_DEVICES_FOR_STREAM, data, &reply);
2756374252107fd6539397598195ea6defd5870fafbEric Laurent        return (audio_devices_t) reply.readInt32();
2766b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten    }
2776b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten
27858e5aa34f01d663654d8bafad65db1dda42161ffGlenn Kasten    virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc)
279de070137f11d346fba77605bd76a44c040a618fcEric Laurent    {
280de070137f11d346fba77605bd76a44c040a618fcEric Laurent        Parcel data, reply;
281de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
282de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.write(desc, sizeof(effect_descriptor_t));
283de070137f11d346fba77605bd76a44c040a618fcEric Laurent        remote()->transact(GET_OUTPUT_FOR_EFFECT, data, &reply);
284de070137f11d346fba77605bd76a44c040a618fcEric Laurent        return static_cast <audio_io_handle_t> (reply.readInt32());
285de070137f11d346fba77605bd76a44c040a618fcEric Laurent    }
286de070137f11d346fba77605bd76a44c040a618fcEric Laurent
28758e5aa34f01d663654d8bafad65db1dda42161ffGlenn Kasten    virtual status_t registerEffect(const effect_descriptor_t *desc,
2887c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent                                        audio_io_handle_t io,
289de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                        uint32_t strategy,
290de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                        int session,
291de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                        int id)
292de070137f11d346fba77605bd76a44c040a618fcEric Laurent    {
293de070137f11d346fba77605bd76a44c040a618fcEric Laurent        Parcel data, reply;
294de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
295de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.write(desc, sizeof(effect_descriptor_t));
2967c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent        data.writeInt32(io);
297de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(strategy);
298de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(session);
299de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(id);
300de070137f11d346fba77605bd76a44c040a618fcEric Laurent        remote()->transact(REGISTER_EFFECT, data, &reply);
301de070137f11d346fba77605bd76a44c040a618fcEric Laurent        return static_cast <status_t> (reply.readInt32());
302de070137f11d346fba77605bd76a44c040a618fcEric Laurent    }
303de070137f11d346fba77605bd76a44c040a618fcEric Laurent
304de070137f11d346fba77605bd76a44c040a618fcEric Laurent    virtual status_t unregisterEffect(int id)
305de070137f11d346fba77605bd76a44c040a618fcEric Laurent    {
306de070137f11d346fba77605bd76a44c040a618fcEric Laurent        Parcel data, reply;
307de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
308de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(id);
309de070137f11d346fba77605bd76a44c040a618fcEric Laurent        remote()->transact(UNREGISTER_EFFECT, data, &reply);
310de070137f11d346fba77605bd76a44c040a618fcEric Laurent        return static_cast <status_t> (reply.readInt32());
311de070137f11d346fba77605bd76a44c040a618fcEric Laurent    }
312de070137f11d346fba77605bd76a44c040a618fcEric Laurent
313db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent    virtual status_t setEffectEnabled(int id, bool enabled)
314db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent    {
315db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        Parcel data, reply;
316db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
317db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        data.writeInt32(id);
318db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        data.writeInt32(enabled);
319db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        remote()->transact(SET_EFFECT_ENABLED, data, &reply);
320db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        return static_cast <status_t> (reply.readInt32());
321db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent    }
322db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent
323fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten    virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs) const
324eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent    {
325eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        Parcel data, reply;
326eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
327fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten        data.writeInt32((int32_t) stream);
328eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        data.writeInt32(inPastMs);
329eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        remote()->transact(IS_STREAM_ACTIVE, data, &reply);
330eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        return reply.readInt32();
331eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent    }
33257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent
333d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi    virtual bool isSourceActive(audio_source_t source) const
334d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi    {
335d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi        Parcel data, reply;
336d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
337d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi        data.writeInt32((int32_t) source);
338d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi        remote()->transact(IS_SOURCE_ACTIVE, data, &reply);
339d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi        return reply.readInt32();
340d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi    }
341d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi
34257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent    virtual status_t queryDefaultPreProcessing(int audioSession,
34357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                                               effect_descriptor_t *descriptors,
34457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                                               uint32_t *count)
34557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent    {
34657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        if (descriptors == NULL || count == NULL) {
34757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            return BAD_VALUE;
34857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        }
34957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        Parcel data, reply;
35057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
35157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        data.writeInt32(audioSession);
35257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        data.writeInt32(*count);
35357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        status_t status = remote()->transact(QUERY_DEFAULT_PRE_PROCESSING, data, &reply);
35457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        if (status != NO_ERROR) {
35557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            return status;
35657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        }
35757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        status = static_cast <status_t> (reply.readInt32());
35857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        uint32_t retCount = reply.readInt32();
35957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        if (retCount != 0) {
36057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            uint32_t numDesc = (retCount < *count) ? retCount : *count;
36157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            reply.read(descriptors, sizeof(effect_descriptor_t) * numDesc);
36257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        }
36357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        *count = retCount;
36457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        return status;
36557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent    }
366c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent};
367c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
368c2f1f07084818942352c6bbfb36af9b6b330eb4eEric LaurentIMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService");
369c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
370c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ----------------------------------------------------------------------
371c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
372c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
373c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentstatus_t BnAudioPolicyService::onTransact(
374c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
375c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{
376e53b9ead781c36e96d6b6f012ddffc93a3d80f0dGlenn Kasten    switch (code) {
377c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case SET_DEVICE_CONNECTION_STATE: {
378c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
379fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_devices_t device =
380fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_devices_t>(data.readInt32());
381fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_policy_dev_state_t state =
382fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_policy_dev_state_t>(data.readInt32());
383c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            const char *device_address = data.readCString();
384de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast<uint32_t> (setDeviceConnectionState(device,
385de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                              state,
386de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                              device_address)));
387c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
388c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
389c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
390c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_DEVICE_CONNECTION_STATE: {
391c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
392fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_devices_t device =
393fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast<audio_devices_t> (data.readInt32());
394c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            const char *device_address = data.readCString();
395de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast<uint32_t> (getDeviceConnectionState(device,
396de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                              device_address)));
397c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
398c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
399c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
400c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case SET_PHONE_STATE: {
401c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
402f78aee70d15daf4690de7e7b4983ee68b0d1381dGlenn Kasten            reply->writeInt32(static_cast <uint32_t>(setPhoneState((audio_mode_t) data.readInt32())));
403c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
404c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
405c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
406c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case SET_FORCE_USE: {
407c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
408fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>(data.readInt32());
409fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_policy_forced_cfg_t config =
410fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_policy_forced_cfg_t>(data.readInt32());
411c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(setForceUse(usage, config)));
412c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
413c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
414c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
415c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_FORCE_USE: {
416c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
417fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_policy_force_use_t usage = static_cast <audio_policy_force_use_t>(data.readInt32());
418c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(getForceUse(usage)));
419c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
420c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
421c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
422c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_OUTPUT: {
423c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
424fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_stream_type_t stream =
425fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_stream_type_t>(data.readInt32());
426c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t samplingRate = data.readInt32();
42758f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten            audio_format_t format = (audio_format_t) data.readInt32();
428254af180475346b6186b49c297f340c9c4817511Glenn Kasten            audio_channel_mask_t channelMask = data.readInt32();
4290ca3cf94c0dfc173ad7886ae162c4b67067539f6Eric Laurent            audio_output_flags_t flags =
4300ca3cf94c0dfc173ad7886ae162c4b67067539f6Eric Laurent                    static_cast <audio_output_flags_t>(data.readInt32());
431c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
432c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            audio_io_handle_t output = getOutput(stream,
433c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                                 samplingRate,
434c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                                 format,
435254af180475346b6186b49c297f340c9c4817511Glenn Kasten                                                 channelMask,
436c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                                 flags);
437fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            reply->writeInt32(static_cast <int>(output));
438c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
439c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
440c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
441c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case START_OUTPUT: {
442c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
443fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32());
444c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t stream = data.readInt32();
445de070137f11d346fba77605bd76a44c040a618fcEric Laurent            int session = data.readInt32();
446de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast <uint32_t>(startOutput(output,
447fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                                                 (audio_stream_type_t)stream,
448de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                 session)));
449c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
450c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
451c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
452c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case STOP_OUTPUT: {
453c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
454fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32());
455c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t stream = data.readInt32();
456de070137f11d346fba77605bd76a44c040a618fcEric Laurent            int session = data.readInt32();
457de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast <uint32_t>(stopOutput(output,
458fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                                                (audio_stream_type_t)stream,
459de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                session)));
460c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
461c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
462c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
463c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case RELEASE_OUTPUT: {
464c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
465fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32());
466c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            releaseOutput(output);
467c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
468c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
469c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
470c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_INPUT: {
471c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
472eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten            audio_source_t inputSource = (audio_source_t) data.readInt32();
473c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t samplingRate = data.readInt32();
47458f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten            audio_format_t format = (audio_format_t) data.readInt32();
475254af180475346b6186b49c297f340c9c4817511Glenn Kasten            audio_channel_mask_t channelMask = data.readInt32();
4767c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent            int audioSession = data.readInt32();
477c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            audio_io_handle_t input = getInput(inputSource,
478c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                               samplingRate,
479c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                               format,
480254af180475346b6186b49c297f340c9c4817511Glenn Kasten                                               channelMask,
4817c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent                                               audioSession);
482fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            reply->writeInt32(static_cast <int>(input));
483c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
484c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
485c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
486c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case START_INPUT: {
487c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
488fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32());
489c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(startInput(input)));
490c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
491c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
492c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
493c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case STOP_INPUT: {
494c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
495fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32());
496c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(stopInput(input)));
497c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
498c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
499c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
500c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case RELEASE_INPUT: {
501c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
502fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32());
503c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            releaseInput(input);
504c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
505c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
506c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
507c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case INIT_STREAM_VOLUME: {
508c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
509fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_stream_type_t stream =
510fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_stream_type_t>(data.readInt32());
511c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            int indexMin = data.readInt32();
512c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            int indexMax = data.readInt32();
513c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(initStreamVolume(stream, indexMin,indexMax)));
514c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
515c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
516c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
517c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case SET_STREAM_VOLUME: {
518c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
519fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_stream_type_t stream =
520fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_stream_type_t>(data.readInt32());
521c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            int index = data.readInt32();
52283844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent            audio_devices_t device = static_cast <audio_devices_t>(data.readInt32());
52383844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent            reply->writeInt32(static_cast <uint32_t>(setStreamVolumeIndex(stream,
52483844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent                                                                          index,
52583844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent                                                                          device)));
526c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
527c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
528c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
529c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_STREAM_VOLUME: {
530c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
531fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_stream_type_t stream =
532fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_stream_type_t>(data.readInt32());
53383844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent            audio_devices_t device = static_cast <audio_devices_t>(data.readInt32());
534c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            int index;
53583844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent            status_t status = getStreamVolumeIndex(stream, &index, device);
536c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(index);
537c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(status));
538c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
539c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
540c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
541de070137f11d346fba77605bd76a44c040a618fcEric Laurent        case GET_STRATEGY_FOR_STREAM: {
542de070137f11d346fba77605bd76a44c040a618fcEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
543fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_stream_type_t stream =
544fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_stream_type_t>(data.readInt32());
545de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(getStrategyForStream(stream));
546de070137f11d346fba77605bd76a44c040a618fcEric Laurent            return NO_ERROR;
547de070137f11d346fba77605bd76a44c040a618fcEric Laurent        } break;
548de070137f11d346fba77605bd76a44c040a618fcEric Laurent
5496b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten        case GET_DEVICES_FOR_STREAM: {
5506b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten            CHECK_INTERFACE(IAudioPolicyService, data, reply);
551fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin            audio_stream_type_t stream =
552fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                    static_cast <audio_stream_type_t>(data.readInt32());
5536b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten            reply->writeInt32(static_cast <int>(getDevicesForStream(stream)));
5546b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten            return NO_ERROR;
5556b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten        } break;
5566b2718c67aa7b1a8e3b0f25a73a0d5f72c59ffc3Glenn Kasten
557de070137f11d346fba77605bd76a44c040a618fcEric Laurent        case GET_OUTPUT_FOR_EFFECT: {
558de070137f11d346fba77605bd76a44c040a618fcEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
559de070137f11d346fba77605bd76a44c040a618fcEric Laurent            effect_descriptor_t desc;
560de070137f11d346fba77605bd76a44c040a618fcEric Laurent            data.read(&desc, sizeof(effect_descriptor_t));
561de070137f11d346fba77605bd76a44c040a618fcEric Laurent            audio_io_handle_t output = getOutputForEffect(&desc);
562de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast <int>(output));
563de070137f11d346fba77605bd76a44c040a618fcEric Laurent            return NO_ERROR;
564de070137f11d346fba77605bd76a44c040a618fcEric Laurent        } break;
565de070137f11d346fba77605bd76a44c040a618fcEric Laurent
566de070137f11d346fba77605bd76a44c040a618fcEric Laurent        case REGISTER_EFFECT: {
567de070137f11d346fba77605bd76a44c040a618fcEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
568de070137f11d346fba77605bd76a44c040a618fcEric Laurent            effect_descriptor_t desc;
569de070137f11d346fba77605bd76a44c040a618fcEric Laurent            data.read(&desc, sizeof(effect_descriptor_t));
5707c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent            audio_io_handle_t io = data.readInt32();
571de070137f11d346fba77605bd76a44c040a618fcEric Laurent            uint32_t strategy = data.readInt32();
572de070137f11d346fba77605bd76a44c040a618fcEric Laurent            int session = data.readInt32();
573de070137f11d346fba77605bd76a44c040a618fcEric Laurent            int id = data.readInt32();
574de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast <int32_t>(registerEffect(&desc,
5757c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent                                                                   io,
576de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                   strategy,
577de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                   session,
578de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                   id)));
579de070137f11d346fba77605bd76a44c040a618fcEric Laurent            return NO_ERROR;
580de070137f11d346fba77605bd76a44c040a618fcEric Laurent        } break;
581de070137f11d346fba77605bd76a44c040a618fcEric Laurent
582de070137f11d346fba77605bd76a44c040a618fcEric Laurent        case UNREGISTER_EFFECT: {
583de070137f11d346fba77605bd76a44c040a618fcEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
584de070137f11d346fba77605bd76a44c040a618fcEric Laurent            int id = data.readInt32();
585de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast <int32_t>(unregisterEffect(id)));
586de070137f11d346fba77605bd76a44c040a618fcEric Laurent            return NO_ERROR;
587de070137f11d346fba77605bd76a44c040a618fcEric Laurent        } break;
588de070137f11d346fba77605bd76a44c040a618fcEric Laurent
589db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        case SET_EFFECT_ENABLED: {
590db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
591db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent            int id = data.readInt32();
592db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent            bool enabled = static_cast <bool>(data.readInt32());
593db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent            reply->writeInt32(static_cast <int32_t>(setEffectEnabled(id, enabled)));
594db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent            return NO_ERROR;
595db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent        } break;
596db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent
597eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        case IS_STREAM_ACTIVE: {
598eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
599fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten            audio_stream_type_t stream = (audio_stream_type_t) data.readInt32();
600eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent            uint32_t inPastMs = (uint32_t)data.readInt32();
601fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten            reply->writeInt32( isStreamActive((audio_stream_type_t) stream, inPastMs) );
602eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent            return NO_ERROR;
603eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent        } break;
604eda6c364c253ba97ee45a3adeb8c2b45db1f81dbEric Laurent
605d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi        case IS_SOURCE_ACTIVE: {
606d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi            CHECK_INTERFACE(IAudioPolicyService, data, reply);
607d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi            audio_source_t source = (audio_source_t) data.readInt32();
608d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi            reply->writeInt32( isSourceActive(source));
609d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi            return NO_ERROR;
610d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi        }
611d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi
61257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        case QUERY_DEFAULT_PRE_PROCESSING: {
61357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
61457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            int audioSession = data.readInt32();
61557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            uint32_t count = data.readInt32();
61657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            uint32_t retCount = count;
61757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            effect_descriptor_t *descriptors =
61857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                    (effect_descriptor_t *)new char[count * sizeof(effect_descriptor_t)];
61957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            status_t status = queryDefaultPreProcessing(audioSession, descriptors, &retCount);
62057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            reply->writeInt32(status);
62157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            if (status != NO_ERROR && status != NO_MEMORY) {
62257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                retCount = 0;
62357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            }
62457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            reply->writeInt32(retCount);
62557dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            if (retCount) {
62657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                if (retCount < count) {
62757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                    count = retCount;
62857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                }
62957dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                reply->write(descriptors, sizeof(effect_descriptor_t) * count);
63057dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            }
63157dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            delete[] descriptors;
63257dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent            return status;
63357dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent        }
63457dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent
635c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        default:
636c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return BBinder::onTransact(code, data, reply, flags);
637c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
638c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}
639c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
640c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ----------------------------------------------------------------------------
641c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
642c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; // namespace android
643