IAudioPolicyService.cpp revision de070137f11d346fba77605bd76a44c040a618fc
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
28c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentnamespace android {
29c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
30c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentenum {
31c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    SET_DEVICE_CONNECTION_STATE = IBinder::FIRST_CALL_TRANSACTION,
32c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    GET_DEVICE_CONNECTION_STATE,
33c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    SET_PHONE_STATE,
34c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    SET_RINGER_MODE,
35c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    SET_FORCE_USE,
36c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    GET_FORCE_USE,
37c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    GET_OUTPUT,
38c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    START_OUTPUT,
39c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    STOP_OUTPUT,
40c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    RELEASE_OUTPUT,
41c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    GET_INPUT,
42c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    START_INPUT,
43c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    STOP_INPUT,
44c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    RELEASE_INPUT,
45c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    INIT_STREAM_VOLUME,
46c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    SET_STREAM_VOLUME,
47de070137f11d346fba77605bd76a44c040a618fcEric Laurent    GET_STREAM_VOLUME,
48de070137f11d346fba77605bd76a44c040a618fcEric Laurent    GET_STRATEGY_FOR_STREAM,
49de070137f11d346fba77605bd76a44c040a618fcEric Laurent    GET_OUTPUT_FOR_EFFECT,
50de070137f11d346fba77605bd76a44c040a618fcEric Laurent    REGISTER_EFFECT,
51de070137f11d346fba77605bd76a44c040a618fcEric Laurent    UNREGISTER_EFFECT
52c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent};
53c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
54c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentclass BpAudioPolicyService : public BpInterface<IAudioPolicyService>
55c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{
56c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentpublic:
57c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    BpAudioPolicyService(const sp<IBinder>& impl)
58c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        : BpInterface<IAudioPolicyService>(impl)
59c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
60c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
61c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
62c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t setDeviceConnectionState(
63c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    AudioSystem::audio_devices device,
64c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    AudioSystem::device_connection_state state,
65c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    const char *device_address)
66c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
67c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
68c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
69c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(device));
70c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(state));
71c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeCString(device_address);
72c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_DEVICE_CONNECTION_STATE, data, &reply);
73c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
74c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
75c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
76c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual AudioSystem::device_connection_state getDeviceConnectionState(
77c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    AudioSystem::audio_devices device,
78c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    const char *device_address)
79c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
80c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
81c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
82c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(device));
83c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeCString(device_address);
84c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_DEVICE_CONNECTION_STATE, data, &reply);
85c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <AudioSystem::device_connection_state>(reply.readInt32());
86c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
87c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
88c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t setPhoneState(int state)
89c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
90c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
91c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
92c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(state);
93c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_PHONE_STATE, data, &reply);
94c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
95c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
96c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
97c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t setRingerMode(uint32_t mode, uint32_t mask)
98c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
99c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
100c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
101c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(mode);
102c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(mask);
103c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_RINGER_MODE, data, &reply);
104c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
105c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
106c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
107c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t setForceUse(AudioSystem::force_use usage, AudioSystem::forced_config config)
108c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
109c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
110c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
111c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(usage));
112c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(config));
113c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_FORCE_USE, data, &reply);
114c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
115c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
116c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
117c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual AudioSystem::forced_config getForceUse(AudioSystem::force_use usage)
118c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
119c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
120c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
121c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(usage));
122c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_FORCE_USE, data, &reply);
123c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <AudioSystem::forced_config> (reply.readInt32());
124c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
125c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
126c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual audio_io_handle_t getOutput(
127c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                        AudioSystem::stream_type stream,
128c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                        uint32_t samplingRate,
129c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                        uint32_t format,
130c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                        uint32_t channels,
131c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                        AudioSystem::output_flags flags)
132c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
133c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
134c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
135c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
136c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(samplingRate);
137c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(format));
138c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(channels);
139c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(flags));
140c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_OUTPUT, data, &reply);
141fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        return static_cast <audio_io_handle_t> (reply.readInt32());
142c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
143c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
144de070137f11d346fba77605bd76a44c040a618fcEric Laurent    virtual status_t startOutput(audio_io_handle_t output,
145de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                 AudioSystem::stream_type stream,
146de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                 int session)
147c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
148c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
149c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
150fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(output);
151c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(stream);
152de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(session);
153c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(START_OUTPUT, data, &reply);
154c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
155c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
156c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
157de070137f11d346fba77605bd76a44c040a618fcEric Laurent    virtual status_t stopOutput(audio_io_handle_t output,
158de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                AudioSystem::stream_type stream,
159de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                int session)
160c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
161c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
162c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
163fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(output);
164c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(stream);
165de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(session);
166c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(STOP_OUTPUT, data, &reply);
167c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
168c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
169c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
170c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual void releaseOutput(audio_io_handle_t output)
171c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
172c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
173c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
174fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(output);
175c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(RELEASE_OUTPUT, data, &reply);
176c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
177c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
178c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual audio_io_handle_t getInput(
179c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    int inputSource,
180c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    uint32_t samplingRate,
181c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    uint32_t format,
182c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    uint32_t channels,
183c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    AudioSystem::audio_in_acoustics acoustics)
184c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
185c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
186c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
187c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(inputSource);
188c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(samplingRate);
189c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(format));
190c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(channels);
191c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(acoustics));
192c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_INPUT, data, &reply);
193fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        return static_cast <audio_io_handle_t> (reply.readInt32());
194c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
195c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
196c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t startInput(audio_io_handle_t input)
197c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
198c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
199c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
200fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(input);
201c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(START_INPUT, data, &reply);
202c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
203c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
204c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
205c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t stopInput(audio_io_handle_t input)
206c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
207c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
208c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
209fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(input);
210c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(STOP_INPUT, data, &reply);
211c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
212c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
213c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
214c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual void releaseInput(audio_io_handle_t input)
215c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
216c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
217c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
218fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent        data.writeInt32(input);
219c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(RELEASE_INPUT, data, &reply);
220c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
221c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
222c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t initStreamVolume(AudioSystem::stream_type stream,
223c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    int indexMin,
224c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    int indexMax)
225c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
226c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
227c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
228c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
229c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(indexMin);
230c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(indexMax);
231c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(INIT_STREAM_VOLUME, data, &reply);
232c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
233c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
234c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
235c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t setStreamVolumeIndex(AudioSystem::stream_type stream, int index)
236c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
237c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
238c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
239c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
240c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(index);
241c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_STREAM_VOLUME, data, &reply);
242c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
243c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
244c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
245c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream, int *index)
246c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
247c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
248c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
249c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
250c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_STREAM_VOLUME, data, &reply);
251c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        int lIndex = reply.readInt32();
252c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        if (index) *index = lIndex;
253c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
254c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
255de070137f11d346fba77605bd76a44c040a618fcEric Laurent
256de070137f11d346fba77605bd76a44c040a618fcEric Laurent    virtual uint32_t getStrategyForStream(AudioSystem::stream_type stream)
257de070137f11d346fba77605bd76a44c040a618fcEric Laurent    {
258de070137f11d346fba77605bd76a44c040a618fcEric Laurent        Parcel data, reply;
259de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
260de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
261de070137f11d346fba77605bd76a44c040a618fcEric Laurent        remote()->transact(GET_STRATEGY_FOR_STREAM, data, &reply);
262de070137f11d346fba77605bd76a44c040a618fcEric Laurent        return reply.readInt32();
263de070137f11d346fba77605bd76a44c040a618fcEric Laurent    }
264de070137f11d346fba77605bd76a44c040a618fcEric Laurent
265de070137f11d346fba77605bd76a44c040a618fcEric Laurent    virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc)
266de070137f11d346fba77605bd76a44c040a618fcEric Laurent    {
267de070137f11d346fba77605bd76a44c040a618fcEric Laurent        Parcel data, reply;
268de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
269de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.write(desc, sizeof(effect_descriptor_t));
270de070137f11d346fba77605bd76a44c040a618fcEric Laurent        remote()->transact(GET_OUTPUT_FOR_EFFECT, data, &reply);
271de070137f11d346fba77605bd76a44c040a618fcEric Laurent        return static_cast <audio_io_handle_t> (reply.readInt32());
272de070137f11d346fba77605bd76a44c040a618fcEric Laurent    }
273de070137f11d346fba77605bd76a44c040a618fcEric Laurent
274de070137f11d346fba77605bd76a44c040a618fcEric Laurent    virtual status_t registerEffect(effect_descriptor_t *desc,
275de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                        audio_io_handle_t output,
276de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                        uint32_t strategy,
277de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                        int session,
278de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                        int id)
279de070137f11d346fba77605bd76a44c040a618fcEric Laurent    {
280de070137f11d346fba77605bd76a44c040a618fcEric Laurent        Parcel data, reply;
281de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
282de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.write(desc, sizeof(effect_descriptor_t));
283de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(output);
284de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(strategy);
285de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(session);
286de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(id);
287de070137f11d346fba77605bd76a44c040a618fcEric Laurent        remote()->transact(REGISTER_EFFECT, data, &reply);
288de070137f11d346fba77605bd76a44c040a618fcEric Laurent        return static_cast <status_t> (reply.readInt32());
289de070137f11d346fba77605bd76a44c040a618fcEric Laurent    }
290de070137f11d346fba77605bd76a44c040a618fcEric Laurent
291de070137f11d346fba77605bd76a44c040a618fcEric Laurent    virtual status_t unregisterEffect(int id)
292de070137f11d346fba77605bd76a44c040a618fcEric Laurent    {
293de070137f11d346fba77605bd76a44c040a618fcEric Laurent        Parcel data, reply;
294de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
295de070137f11d346fba77605bd76a44c040a618fcEric Laurent        data.writeInt32(id);
296de070137f11d346fba77605bd76a44c040a618fcEric Laurent        remote()->transact(UNREGISTER_EFFECT, data, &reply);
297de070137f11d346fba77605bd76a44c040a618fcEric Laurent        return static_cast <status_t> (reply.readInt32());
298de070137f11d346fba77605bd76a44c040a618fcEric Laurent    }
299de070137f11d346fba77605bd76a44c040a618fcEric Laurent
300c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent};
301c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
302c2f1f07084818942352c6bbfb36af9b6b330eb4eEric LaurentIMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService");
303c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
304c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ----------------------------------------------------------------------
305c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
306c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
307c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentstatus_t BnAudioPolicyService::onTransact(
308c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
309c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{
310c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    switch(code) {
311c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case SET_DEVICE_CONNECTION_STATE: {
312c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
313de070137f11d346fba77605bd76a44c040a618fcEric Laurent            AudioSystem::audio_devices device =
314de070137f11d346fba77605bd76a44c040a618fcEric Laurent                    static_cast <AudioSystem::audio_devices>(data.readInt32());
315de070137f11d346fba77605bd76a44c040a618fcEric Laurent            AudioSystem::device_connection_state state =
316de070137f11d346fba77605bd76a44c040a618fcEric Laurent                    static_cast <AudioSystem::device_connection_state>(data.readInt32());
317c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            const char *device_address = data.readCString();
318de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast<uint32_t> (setDeviceConnectionState(device,
319de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                              state,
320de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                              device_address)));
321c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
322c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
323c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
324c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_DEVICE_CONNECTION_STATE: {
325c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
326de070137f11d346fba77605bd76a44c040a618fcEric Laurent            AudioSystem::audio_devices device =
327de070137f11d346fba77605bd76a44c040a618fcEric Laurent                    static_cast<AudioSystem::audio_devices> (data.readInt32());
328c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            const char *device_address = data.readCString();
329de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast<uint32_t> (getDeviceConnectionState(device,
330de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                              device_address)));
331c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
332c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
333c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
334c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case SET_PHONE_STATE: {
335c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
336c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(setPhoneState(data.readInt32())));
337c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
338c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
339c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
340c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case SET_RINGER_MODE: {
341c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
342c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t mode = data.readInt32();
343c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t mask = data.readInt32();
344c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(setRingerMode(mode, mask)));
345c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
346c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
347c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
348c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case SET_FORCE_USE: {
349c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
350c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            AudioSystem::force_use usage = static_cast <AudioSystem::force_use>(data.readInt32());
351de070137f11d346fba77605bd76a44c040a618fcEric Laurent            AudioSystem::forced_config config =
352de070137f11d346fba77605bd76a44c040a618fcEric Laurent                    static_cast <AudioSystem::forced_config>(data.readInt32());
353c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(setForceUse(usage, config)));
354c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
355c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
356c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
357c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_FORCE_USE: {
358c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
359c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            AudioSystem::force_use usage = static_cast <AudioSystem::force_use>(data.readInt32());
360c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(getForceUse(usage)));
361c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
362c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
363c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
364c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_OUTPUT: {
365c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
366de070137f11d346fba77605bd76a44c040a618fcEric Laurent            AudioSystem::stream_type stream =
367de070137f11d346fba77605bd76a44c040a618fcEric Laurent                    static_cast <AudioSystem::stream_type>(data.readInt32());
368c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t samplingRate = data.readInt32();
369c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t format = data.readInt32();
370c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t channels = data.readInt32();
371de070137f11d346fba77605bd76a44c040a618fcEric Laurent            AudioSystem::output_flags flags =
372de070137f11d346fba77605bd76a44c040a618fcEric Laurent                    static_cast <AudioSystem::output_flags>(data.readInt32());
373c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
374c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            audio_io_handle_t output = getOutput(stream,
375c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                                 samplingRate,
376c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                                 format,
377c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                                 channels,
378c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                                 flags);
379fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            reply->writeInt32(static_cast <int>(output));
380c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
381c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
382c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
383c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case START_OUTPUT: {
384c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
385fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32());
386c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t stream = data.readInt32();
387de070137f11d346fba77605bd76a44c040a618fcEric Laurent            int session = data.readInt32();
388de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast <uint32_t>(startOutput(output,
389de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                 (AudioSystem::stream_type)stream,
390de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                 session)));
391c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
392c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
393c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
394c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case STOP_OUTPUT: {
395c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
396fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32());
397c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t stream = data.readInt32();
398de070137f11d346fba77605bd76a44c040a618fcEric Laurent            int session = data.readInt32();
399de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast <uint32_t>(stopOutput(output,
400de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                (AudioSystem::stream_type)stream,
401de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                session)));
402c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
403c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
404c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
405c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case RELEASE_OUTPUT: {
406c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
407fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            audio_io_handle_t output = static_cast <audio_io_handle_t>(data.readInt32());
408c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            releaseOutput(output);
409c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
410c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
411c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
412c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_INPUT: {
413c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
414c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            int inputSource = data.readInt32();
415c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t samplingRate = data.readInt32();
416c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t format = data.readInt32();
417c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t channels = data.readInt32();
418de070137f11d346fba77605bd76a44c040a618fcEric Laurent            AudioSystem::audio_in_acoustics acoustics =
419de070137f11d346fba77605bd76a44c040a618fcEric Laurent                    static_cast <AudioSystem::audio_in_acoustics>(data.readInt32());
420c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            audio_io_handle_t input = getInput(inputSource,
421c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                               samplingRate,
422c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                               format,
423c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                               channels,
424c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                               acoustics);
425fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            reply->writeInt32(static_cast <int>(input));
426c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
427c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
428c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
429c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case START_INPUT: {
430c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
431fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32());
432c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(startInput(input)));
433c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
434c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
435c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
436c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case STOP_INPUT: {
437c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
438fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32());
439c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(stopInput(input)));
440c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
441c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
442c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
443c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case RELEASE_INPUT: {
444c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
445fa2877b9ea48baed934b866d2ab3658b69c4c869Eric Laurent            audio_io_handle_t input = static_cast <audio_io_handle_t>(data.readInt32());
446c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            releaseInput(input);
447c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
448c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
449c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
450c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case INIT_STREAM_VOLUME: {
451c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
452de070137f11d346fba77605bd76a44c040a618fcEric Laurent            AudioSystem::stream_type stream =
453de070137f11d346fba77605bd76a44c040a618fcEric Laurent                    static_cast <AudioSystem::stream_type>(data.readInt32());
454c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            int indexMin = data.readInt32();
455c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            int indexMax = data.readInt32();
456c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(initStreamVolume(stream, indexMin,indexMax)));
457c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
458c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
459c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
460c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case SET_STREAM_VOLUME: {
461c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
462de070137f11d346fba77605bd76a44c040a618fcEric Laurent            AudioSystem::stream_type stream =
463de070137f11d346fba77605bd76a44c040a618fcEric Laurent                    static_cast <AudioSystem::stream_type>(data.readInt32());
464c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            int index = data.readInt32();
465c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(setStreamVolumeIndex(stream, index)));
466c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
467c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
468c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
469c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_STREAM_VOLUME: {
470c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
471de070137f11d346fba77605bd76a44c040a618fcEric Laurent            AudioSystem::stream_type stream =
472de070137f11d346fba77605bd76a44c040a618fcEric Laurent                    static_cast <AudioSystem::stream_type>(data.readInt32());
473c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            int index;
474c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            status_t status = getStreamVolumeIndex(stream, &index);
475c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(index);
476c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(status));
477c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
478c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
479c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
480de070137f11d346fba77605bd76a44c040a618fcEric Laurent        case GET_STRATEGY_FOR_STREAM: {
481de070137f11d346fba77605bd76a44c040a618fcEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
482de070137f11d346fba77605bd76a44c040a618fcEric Laurent            AudioSystem::stream_type stream =
483de070137f11d346fba77605bd76a44c040a618fcEric Laurent                    static_cast <AudioSystem::stream_type>(data.readInt32());
484de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(getStrategyForStream(stream));
485de070137f11d346fba77605bd76a44c040a618fcEric Laurent            return NO_ERROR;
486de070137f11d346fba77605bd76a44c040a618fcEric Laurent        } break;
487de070137f11d346fba77605bd76a44c040a618fcEric Laurent
488de070137f11d346fba77605bd76a44c040a618fcEric Laurent        case GET_OUTPUT_FOR_EFFECT: {
489de070137f11d346fba77605bd76a44c040a618fcEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
490de070137f11d346fba77605bd76a44c040a618fcEric Laurent            effect_descriptor_t desc;
491de070137f11d346fba77605bd76a44c040a618fcEric Laurent            data.read(&desc, sizeof(effect_descriptor_t));
492de070137f11d346fba77605bd76a44c040a618fcEric Laurent            audio_io_handle_t output = getOutputForEffect(&desc);
493de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast <int>(output));
494de070137f11d346fba77605bd76a44c040a618fcEric Laurent            return NO_ERROR;
495de070137f11d346fba77605bd76a44c040a618fcEric Laurent        } break;
496de070137f11d346fba77605bd76a44c040a618fcEric Laurent
497de070137f11d346fba77605bd76a44c040a618fcEric Laurent        case REGISTER_EFFECT: {
498de070137f11d346fba77605bd76a44c040a618fcEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
499de070137f11d346fba77605bd76a44c040a618fcEric Laurent            effect_descriptor_t desc;
500de070137f11d346fba77605bd76a44c040a618fcEric Laurent            data.read(&desc, sizeof(effect_descriptor_t));
501de070137f11d346fba77605bd76a44c040a618fcEric Laurent            audio_io_handle_t output = data.readInt32();
502de070137f11d346fba77605bd76a44c040a618fcEric Laurent            uint32_t strategy = data.readInt32();
503de070137f11d346fba77605bd76a44c040a618fcEric Laurent            int session = data.readInt32();
504de070137f11d346fba77605bd76a44c040a618fcEric Laurent            int id = data.readInt32();
505de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast <int32_t>(registerEffect(&desc,
506de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                   output,
507de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                   strategy,
508de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                   session,
509de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                                                   id)));
510de070137f11d346fba77605bd76a44c040a618fcEric Laurent            return NO_ERROR;
511de070137f11d346fba77605bd76a44c040a618fcEric Laurent        } break;
512de070137f11d346fba77605bd76a44c040a618fcEric Laurent
513de070137f11d346fba77605bd76a44c040a618fcEric Laurent        case UNREGISTER_EFFECT: {
514de070137f11d346fba77605bd76a44c040a618fcEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
515de070137f11d346fba77605bd76a44c040a618fcEric Laurent            int id = data.readInt32();
516de070137f11d346fba77605bd76a44c040a618fcEric Laurent            reply->writeInt32(static_cast <int32_t>(unregisterEffect(id)));
517de070137f11d346fba77605bd76a44c040a618fcEric Laurent            return NO_ERROR;
518de070137f11d346fba77605bd76a44c040a618fcEric Laurent        } break;
519de070137f11d346fba77605bd76a44c040a618fcEric Laurent
520c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        default:
521c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return BBinder::onTransact(code, data, reply, flags);
522c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
523c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}
524c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
525c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ----------------------------------------------------------------------------
526c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
527c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; // namespace android
528