IAudioPolicyService.cpp revision c2f1f07084818942352c6bbfb36af9b6b330eb4e
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,
47c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    GET_STREAM_VOLUME
48c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent};
49c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
50c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentclass BpAudioPolicyService : public BpInterface<IAudioPolicyService>
51c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{
52c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentpublic:
53c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    BpAudioPolicyService(const sp<IBinder>& impl)
54c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        : BpInterface<IAudioPolicyService>(impl)
55c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
56c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
57c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
58c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t setDeviceConnectionState(
59c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    AudioSystem::audio_devices device,
60c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    AudioSystem::device_connection_state state,
61c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    const char *device_address)
62c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
63c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
64c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
65c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(device));
66c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(state));
67c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeCString(device_address);
68c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_DEVICE_CONNECTION_STATE, data, &reply);
69c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
70c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
71c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
72c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual AudioSystem::device_connection_state getDeviceConnectionState(
73c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    AudioSystem::audio_devices device,
74c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    const char *device_address)
75c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
76c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
77c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
78c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(device));
79c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeCString(device_address);
80c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_DEVICE_CONNECTION_STATE, data, &reply);
81c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <AudioSystem::device_connection_state>(reply.readInt32());
82c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
83c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
84c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t setPhoneState(int state)
85c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
86c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
87c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
88c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(state);
89c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_PHONE_STATE, data, &reply);
90c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
91c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
92c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
93c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t setRingerMode(uint32_t mode, uint32_t mask)
94c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
95c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
96c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
97c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(mode);
98c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(mask);
99c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_RINGER_MODE, data, &reply);
100c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
101c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
102c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
103c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t setForceUse(AudioSystem::force_use usage, AudioSystem::forced_config config)
104c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
105c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
106c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
107c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(usage));
108c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(config));
109c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_FORCE_USE, data, &reply);
110c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
111c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
112c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
113c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual AudioSystem::forced_config getForceUse(AudioSystem::force_use usage)
114c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
115c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
116c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
117c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(usage));
118c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_FORCE_USE, data, &reply);
119c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <AudioSystem::forced_config> (reply.readInt32());
120c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
121c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
122c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual audio_io_handle_t getOutput(
123c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                        AudioSystem::stream_type stream,
124c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                        uint32_t samplingRate,
125c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                        uint32_t format,
126c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                        uint32_t channels,
127c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                        AudioSystem::output_flags flags)
128c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
129c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
130c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
131c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
132c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(samplingRate);
133c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(format));
134c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(channels);
135c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(flags));
136c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_OUTPUT, data, &reply);
137c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        audio_io_handle_t output;
138c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        reply.read(&output, sizeof(audio_io_handle_t));
139c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return output;
140c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
141c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
142c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t startOutput(audio_io_handle_t output, AudioSystem::stream_type stream)
143c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
144c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
145c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
146c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.write(&output, sizeof(audio_io_handle_t));
147c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(stream);
148c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(START_OUTPUT, data, &reply);
149c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
150c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
151c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
152c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t stopOutput(audio_io_handle_t output, AudioSystem::stream_type stream)
153c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
154c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
155c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
156c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.write(&output, sizeof(audio_io_handle_t));
157c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(stream);
158c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(STOP_OUTPUT, data, &reply);
159c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
160c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
161c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
162c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual void releaseOutput(audio_io_handle_t output)
163c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
164c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
165c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
166c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.write(&output, sizeof(audio_io_handle_t));
167c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(RELEASE_OUTPUT, data, &reply);
168c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
169c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
170c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual audio_io_handle_t getInput(
171c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    int inputSource,
172c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    uint32_t samplingRate,
173c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    uint32_t format,
174c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    uint32_t channels,
175c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    AudioSystem::audio_in_acoustics acoustics)
176c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
177c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
178c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
179c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(inputSource);
180c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(samplingRate);
181c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(format));
182c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(channels);
183c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(acoustics));
184c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_INPUT, data, &reply);
185c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        audio_io_handle_t input;
186c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        reply.read(&input, sizeof(audio_io_handle_t));
187c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return input;
188c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
189c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
190c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t startInput(audio_io_handle_t input)
191c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
192c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
193c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
194c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.write(&input, sizeof(audio_io_handle_t));
195c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(START_INPUT, data, &reply);
196c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
197c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
198c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
199c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t stopInput(audio_io_handle_t input)
200c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
201c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
202c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
203c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.write(&input, sizeof(audio_io_handle_t));
204c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(STOP_INPUT, data, &reply);
205c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
206c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
207c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
208c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual void releaseInput(audio_io_handle_t input)
209c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
210c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
211c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
212c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.write(&input, sizeof(audio_io_handle_t));
213c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(RELEASE_INPUT, data, &reply);
214c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
215c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
216c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t initStreamVolume(AudioSystem::stream_type stream,
217c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    int indexMin,
218c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    int indexMax)
219c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
220c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
221c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
222c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
223c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(indexMin);
224c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(indexMax);
225c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(INIT_STREAM_VOLUME, data, &reply);
226c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
227c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
228c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
229c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t setStreamVolumeIndex(AudioSystem::stream_type stream, int index)
230c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
231c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
232c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
233c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
234c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(index);
235c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(SET_STREAM_VOLUME, data, &reply);
236c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
237c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
238c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
239c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream, int *index)
240c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    {
241c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        Parcel data, reply;
242c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
243c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        data.writeInt32(static_cast <uint32_t>(stream));
244c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        remote()->transact(GET_STREAM_VOLUME, data, &reply);
245c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        int lIndex = reply.readInt32();
246c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        if (index) *index = lIndex;
247c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        return static_cast <status_t> (reply.readInt32());
248c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
249c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent};
250c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
251c2f1f07084818942352c6bbfb36af9b6b330eb4eEric LaurentIMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService");
252c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
253c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ----------------------------------------------------------------------
254c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
255c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
256c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentstatus_t BnAudioPolicyService::onTransact(
257c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
258c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{
259c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    switch(code) {
260c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case SET_DEVICE_CONNECTION_STATE: {
261c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
262c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            AudioSystem::audio_devices device = static_cast <AudioSystem::audio_devices>(data.readInt32());
263c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            AudioSystem::device_connection_state state = static_cast <AudioSystem::device_connection_state>(data.readInt32());
264c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            const char *device_address = data.readCString();
265c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(setDeviceConnectionState(device, state, device_address)));
266c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
267c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
268c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
269c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_DEVICE_CONNECTION_STATE: {
270c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
271c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            AudioSystem::audio_devices device = static_cast <AudioSystem::audio_devices>(data.readInt32());
272c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            const char *device_address = data.readCString();
273c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(getDeviceConnectionState(device, device_address)));
274c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
275c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
276c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
277c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case SET_PHONE_STATE: {
278c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
279c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(setPhoneState(data.readInt32())));
280c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
281c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
282c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
283c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case SET_RINGER_MODE: {
284c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
285c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t mode = data.readInt32();
286c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t mask = data.readInt32();
287c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(setRingerMode(mode, mask)));
288c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
289c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
290c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
291c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case SET_FORCE_USE: {
292c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
293c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            AudioSystem::force_use usage = static_cast <AudioSystem::force_use>(data.readInt32());
294c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            AudioSystem::forced_config config = static_cast <AudioSystem::forced_config>(data.readInt32());
295c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(setForceUse(usage, config)));
296c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
297c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
298c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
299c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_FORCE_USE: {
300c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
301c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            AudioSystem::force_use usage = static_cast <AudioSystem::force_use>(data.readInt32());
302c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(getForceUse(usage)));
303c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
304c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
305c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
306c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_OUTPUT: {
307c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
308c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            AudioSystem::stream_type stream = static_cast <AudioSystem::stream_type>(data.readInt32());
309c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t samplingRate = data.readInt32();
310c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t format = data.readInt32();
311c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t channels = data.readInt32();
312c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            AudioSystem::output_flags flags = static_cast <AudioSystem::output_flags>(data.readInt32());
313c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
314c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            audio_io_handle_t output = getOutput(stream,
315c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                                 samplingRate,
316c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                                 format,
317c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                                 channels,
318c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                                 flags);
319c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->write(&output, sizeof(audio_io_handle_t));
320c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
321c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
322c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
323c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case START_OUTPUT: {
324c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
325c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            audio_io_handle_t output;
326c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            data.read(&output, sizeof(audio_io_handle_t));
327c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t stream = data.readInt32();
328c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(startOutput(output, (AudioSystem::stream_type)stream)));
329c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
330c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
331c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
332c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case STOP_OUTPUT: {
333c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
334c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            audio_io_handle_t output;
335c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            data.read(&output, sizeof(audio_io_handle_t));
336c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t stream = data.readInt32();
337c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(stopOutput(output, (AudioSystem::stream_type)stream)));
338c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
339c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
340c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
341c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case RELEASE_OUTPUT: {
342c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
343c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            audio_io_handle_t output;
344c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            data.read(&output, sizeof(audio_io_handle_t));
345c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            releaseOutput(output);
346c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
347c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
348c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
349c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_INPUT: {
350c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
351c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            int inputSource = data.readInt32();
352c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t samplingRate = data.readInt32();
353c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t format = data.readInt32();
354c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            uint32_t channels = data.readInt32();
355c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            AudioSystem::audio_in_acoustics acoustics = static_cast <AudioSystem::audio_in_acoustics>(data.readInt32());
356c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            audio_io_handle_t input = getInput(inputSource,
357c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                               samplingRate,
358c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                               format,
359c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                               channels,
360c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                               acoustics);
361c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->write(&input, sizeof(audio_io_handle_t));
362c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
363c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
364c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
365c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case START_INPUT: {
366c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
367c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            audio_io_handle_t input;
368c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            data.read(&input, sizeof(audio_io_handle_t));
369c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(startInput(input)));
370c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
371c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
372c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
373c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case STOP_INPUT: {
374c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
375c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            audio_io_handle_t input;
376c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            data.read(&input, sizeof(audio_io_handle_t));
377c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(stopInput(input)));
378c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
379c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
380c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
381c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case RELEASE_INPUT: {
382c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
383c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            audio_io_handle_t input;
384c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            data.read(&input, sizeof(audio_io_handle_t));
385c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            releaseInput(input);
386c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
387c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
388c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
389c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case INIT_STREAM_VOLUME: {
390c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
391c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            AudioSystem::stream_type stream = static_cast <AudioSystem::stream_type>(data.readInt32());
392c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            int indexMin = data.readInt32();
393c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            int indexMax = data.readInt32();
394c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(initStreamVolume(stream, indexMin,indexMax)));
395c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
396c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
397c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
398c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case SET_STREAM_VOLUME: {
399c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
400c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            AudioSystem::stream_type stream = static_cast <AudioSystem::stream_type>(data.readInt32());
401c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            int index = data.readInt32();
402c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(setStreamVolumeIndex(stream, index)));
403c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
404c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
405c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
406c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        case GET_STREAM_VOLUME: {
407c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            CHECK_INTERFACE(IAudioPolicyService, data, reply);
408c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            AudioSystem::stream_type stream = static_cast <AudioSystem::stream_type>(data.readInt32());
409c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            int index;
410c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            status_t status = getStreamVolumeIndex(stream, &index);
411c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(index);
412c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            reply->writeInt32(static_cast <uint32_t>(status));
413c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return NO_ERROR;
414c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        } break;
415c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
416c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent        default:
417c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent            return BBinder::onTransact(code, data, reply, flags);
418c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    }
419c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}
420c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
421c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ----------------------------------------------------------------------------
422c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
423c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; // namespace android
424