blob: 4a1296209ab5ff087bad82f3571de360a433dfbd [file] [log] [blame]
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001/* //device/extlibs/pv/android/IAudioflinger.cpp
2**
3** Copyright 2007, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18#define LOG_TAG "IAudioFlinger"
Eric Laurentc2f1f072009-07-17 12:17:14 -070019//#define LOG_NDEBUG 0
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080020#include <utils/Log.h>
21
22#include <stdint.h>
23#include <sys/types.h>
24
Mathias Agopian75624082009-05-19 19:08:10 -070025#include <binder/Parcel.h>
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080026
27#include <media/IAudioFlinger.h>
28
29namespace android {
30
31enum {
32 CREATE_TRACK = IBinder::FIRST_CALL_TRANSACTION,
33 OPEN_RECORD,
34 SAMPLE_RATE,
35 CHANNEL_COUNT,
36 FORMAT,
37 FRAME_COUNT,
38 LATENCY,
39 SET_MASTER_VOLUME,
40 SET_MASTER_MUTE,
41 MASTER_VOLUME,
42 MASTER_MUTE,
43 SET_STREAM_VOLUME,
44 SET_STREAM_MUTE,
45 STREAM_VOLUME,
46 STREAM_MUTE,
47 SET_MODE,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080048 SET_MIC_MUTE,
49 GET_MIC_MUTE,
Eric Laurentc2f1f072009-07-17 12:17:14 -070050 SET_PARAMETERS,
51 GET_PARAMETERS,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080052 REGISTER_CLIENT,
53 GET_INPUTBUFFERSIZE,
Eric Laurentc2f1f072009-07-17 12:17:14 -070054 OPEN_OUTPUT,
55 OPEN_DUPLICATE_OUTPUT,
56 CLOSE_OUTPUT,
57 SUSPEND_OUTPUT,
58 RESTORE_OUTPUT,
59 OPEN_INPUT,
60 CLOSE_INPUT,
Eric Laurentf0ee6f42009-10-21 08:14:22 -070061 SET_STREAM_OUTPUT,
Eric Laurent342e9cf2010-01-19 17:37:09 -080062 SET_VOICE_VOLUME,
Eric Laurent05bca2f2010-02-26 02:47:27 -080063 GET_RENDER_POSITION,
Eric Laurentbe916aa2010-06-01 23:49:17 -070064 GET_INPUT_FRAMES_LOST,
65 NEW_AUDIO_SESSION_ID,
Eric Laurentbe916aa2010-06-01 23:49:17 -070066 QUERY_NUM_EFFECTS,
Eric Laurentffe9c252010-06-23 17:38:20 -070067 QUERY_EFFECT,
Eric Laurentbe916aa2010-06-01 23:49:17 -070068 GET_EFFECT_DESCRIPTOR,
Eric Laurentde070132010-07-13 04:45:46 -070069 CREATE_EFFECT,
70 MOVE_EFFECTS
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080071};
72
73class BpAudioFlinger : public BpInterface<IAudioFlinger>
74{
75public:
76 BpAudioFlinger(const sp<IBinder>& impl)
77 : BpInterface<IAudioFlinger>(impl)
78 {
79 }
80
81 virtual sp<IAudioTrack> createTrack(
82 pid_t pid,
83 int streamType,
84 uint32_t sampleRate,
Jean-Michel Trivi0d255b22011-05-24 15:53:33 -070085 uint32_t format,
86 uint32_t channelMask,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080087 int frameCount,
88 uint32_t flags,
89 const sp<IMemory>& sharedBuffer,
Eric Laurentfa2877b2009-07-28 08:44:33 -070090 int output,
Eric Laurentbe916aa2010-06-01 23:49:17 -070091 int *sessionId,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080092 status_t *status)
93 {
94 Parcel data, reply;
Eric Laurent5841db72009-09-09 05:16:08 -070095 sp<IAudioTrack> track;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080096 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
97 data.writeInt32(pid);
98 data.writeInt32(streamType);
99 data.writeInt32(sampleRate);
100 data.writeInt32(format);
Jean-Michel Trivi0d255b22011-05-24 15:53:33 -0700101 data.writeInt32(channelMask);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800102 data.writeInt32(frameCount);
103 data.writeInt32(flags);
104 data.writeStrongBinder(sharedBuffer->asBinder());
Eric Laurentfa2877b2009-07-28 08:44:33 -0700105 data.writeInt32(output);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700106 int lSessionId = 0;
107 if (sessionId != NULL) {
108 lSessionId = *sessionId;
109 }
110 data.writeInt32(lSessionId);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800111 status_t lStatus = remote()->transact(CREATE_TRACK, data, &reply);
112 if (lStatus != NO_ERROR) {
113 LOGE("createTrack error: %s", strerror(-lStatus));
Eric Laurent5841db72009-09-09 05:16:08 -0700114 } else {
Eric Laurentbe916aa2010-06-01 23:49:17 -0700115 lSessionId = reply.readInt32();
116 if (sessionId != NULL) {
117 *sessionId = lSessionId;
118 }
Eric Laurent5841db72009-09-09 05:16:08 -0700119 lStatus = reply.readInt32();
120 track = interface_cast<IAudioTrack>(reply.readStrongBinder());
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800121 }
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800122 if (status) {
123 *status = lStatus;
124 }
Eric Laurent5841db72009-09-09 05:16:08 -0700125 return track;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800126 }
127
128 virtual sp<IAudioRecord> openRecord(
129 pid_t pid,
Eric Laurentfa2877b2009-07-28 08:44:33 -0700130 int input,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800131 uint32_t sampleRate,
Jean-Michel Trivi0d255b22011-05-24 15:53:33 -0700132 uint32_t format,
133 uint32_t channelMask,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800134 int frameCount,
135 uint32_t flags,
Eric Laurentbe916aa2010-06-01 23:49:17 -0700136 int *sessionId,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800137 status_t *status)
138 {
139 Parcel data, reply;
Eric Laurent5841db72009-09-09 05:16:08 -0700140 sp<IAudioRecord> record;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800141 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
142 data.writeInt32(pid);
Eric Laurentfa2877b2009-07-28 08:44:33 -0700143 data.writeInt32(input);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800144 data.writeInt32(sampleRate);
145 data.writeInt32(format);
Jean-Michel Trivi0d255b22011-05-24 15:53:33 -0700146 data.writeInt32(channelMask);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800147 data.writeInt32(frameCount);
148 data.writeInt32(flags);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700149 int lSessionId = 0;
150 if (sessionId != NULL) {
151 lSessionId = *sessionId;
152 }
153 data.writeInt32(lSessionId);
Eric Laurent5841db72009-09-09 05:16:08 -0700154 status_t lStatus = remote()->transact(OPEN_RECORD, data, &reply);
155 if (lStatus != NO_ERROR) {
156 LOGE("openRecord error: %s", strerror(-lStatus));
157 } else {
Eric Laurentbe916aa2010-06-01 23:49:17 -0700158 lSessionId = reply.readInt32();
159 if (sessionId != NULL) {
160 *sessionId = lSessionId;
161 }
Eric Laurent5841db72009-09-09 05:16:08 -0700162 lStatus = reply.readInt32();
163 record = interface_cast<IAudioRecord>(reply.readStrongBinder());
164 }
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800165 if (status) {
166 *status = lStatus;
167 }
Eric Laurent5841db72009-09-09 05:16:08 -0700168 return record;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800169 }
170
Eric Laurentfa2877b2009-07-28 08:44:33 -0700171 virtual uint32_t sampleRate(int output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800172 {
173 Parcel data, reply;
174 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentfa2877b2009-07-28 08:44:33 -0700175 data.writeInt32(output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800176 remote()->transact(SAMPLE_RATE, data, &reply);
177 return reply.readInt32();
178 }
179
Eric Laurentfa2877b2009-07-28 08:44:33 -0700180 virtual int channelCount(int output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800181 {
182 Parcel data, reply;
183 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentfa2877b2009-07-28 08:44:33 -0700184 data.writeInt32(output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800185 remote()->transact(CHANNEL_COUNT, data, &reply);
186 return reply.readInt32();
187 }
188
Jean-Michel Trivi0d255b22011-05-24 15:53:33 -0700189 virtual uint32_t format(int output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800190 {
191 Parcel data, reply;
192 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentfa2877b2009-07-28 08:44:33 -0700193 data.writeInt32(output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800194 remote()->transact(FORMAT, data, &reply);
195 return reply.readInt32();
196 }
197
Eric Laurentfa2877b2009-07-28 08:44:33 -0700198 virtual size_t frameCount(int output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800199 {
200 Parcel data, reply;
201 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentfa2877b2009-07-28 08:44:33 -0700202 data.writeInt32(output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800203 remote()->transact(FRAME_COUNT, data, &reply);
204 return reply.readInt32();
205 }
206
Eric Laurentfa2877b2009-07-28 08:44:33 -0700207 virtual uint32_t latency(int output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800208 {
209 Parcel data, reply;
210 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentfa2877b2009-07-28 08:44:33 -0700211 data.writeInt32(output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800212 remote()->transact(LATENCY, data, &reply);
213 return reply.readInt32();
214 }
215
216 virtual status_t setMasterVolume(float value)
217 {
218 Parcel data, reply;
219 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
220 data.writeFloat(value);
221 remote()->transact(SET_MASTER_VOLUME, data, &reply);
222 return reply.readInt32();
223 }
224
225 virtual status_t setMasterMute(bool muted)
226 {
227 Parcel data, reply;
228 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
229 data.writeInt32(muted);
230 remote()->transact(SET_MASTER_MUTE, data, &reply);
231 return reply.readInt32();
232 }
233
234 virtual float masterVolume() const
235 {
236 Parcel data, reply;
237 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
238 remote()->transact(MASTER_VOLUME, data, &reply);
239 return reply.readFloat();
240 }
241
242 virtual bool masterMute() const
243 {
244 Parcel data, reply;
245 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
246 remote()->transact(MASTER_MUTE, data, &reply);
247 return reply.readInt32();
248 }
249
Eric Laurentfa2877b2009-07-28 08:44:33 -0700250 virtual status_t setStreamVolume(int stream, float value, int output)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800251 {
252 Parcel data, reply;
253 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
254 data.writeInt32(stream);
255 data.writeFloat(value);
Eric Laurentfa2877b2009-07-28 08:44:33 -0700256 data.writeInt32(output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800257 remote()->transact(SET_STREAM_VOLUME, data, &reply);
258 return reply.readInt32();
259 }
260
261 virtual status_t setStreamMute(int stream, bool muted)
262 {
263 Parcel data, reply;
264 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
265 data.writeInt32(stream);
266 data.writeInt32(muted);
267 remote()->transact(SET_STREAM_MUTE, data, &reply);
268 return reply.readInt32();
269 }
270
Eric Laurentfa2877b2009-07-28 08:44:33 -0700271 virtual float streamVolume(int stream, int output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800272 {
273 Parcel data, reply;
274 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
275 data.writeInt32(stream);
Eric Laurentfa2877b2009-07-28 08:44:33 -0700276 data.writeInt32(output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800277 remote()->transact(STREAM_VOLUME, data, &reply);
278 return reply.readFloat();
279 }
280
281 virtual bool streamMute(int stream) const
282 {
283 Parcel data, reply;
284 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
285 data.writeInt32(stream);
286 remote()->transact(STREAM_MUTE, data, &reply);
287 return reply.readInt32();
288 }
289
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800290 virtual status_t setMode(int mode)
291 {
292 Parcel data, reply;
293 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
294 data.writeInt32(mode);
295 remote()->transact(SET_MODE, data, &reply);
296 return reply.readInt32();
297 }
298
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800299 virtual status_t setMicMute(bool state)
300 {
301 Parcel data, reply;
302 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
303 data.writeInt32(state);
304 remote()->transact(SET_MIC_MUTE, data, &reply);
305 return reply.readInt32();
306 }
307
308 virtual bool getMicMute() const
309 {
310 Parcel data, reply;
311 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
312 remote()->transact(GET_MIC_MUTE, data, &reply);
313 return reply.readInt32();
314 }
315
Eric Laurentfa2877b2009-07-28 08:44:33 -0700316 virtual status_t setParameters(int ioHandle, const String8& keyValuePairs)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800317 {
318 Parcel data, reply;
319 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentfa2877b2009-07-28 08:44:33 -0700320 data.writeInt32(ioHandle);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700321 data.writeString8(keyValuePairs);
322 remote()->transact(SET_PARAMETERS, data, &reply);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800323 return reply.readInt32();
324 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700325
Eric Laurentfa2877b2009-07-28 08:44:33 -0700326 virtual String8 getParameters(int ioHandle, const String8& keys)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700327 {
328 Parcel data, reply;
329 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentfa2877b2009-07-28 08:44:33 -0700330 data.writeInt32(ioHandle);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700331 data.writeString8(keys);
332 remote()->transact(GET_PARAMETERS, data, &reply);
333 return reply.readString8();
334 }
335
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800336 virtual void registerClient(const sp<IAudioFlingerClient>& client)
337 {
338 Parcel data, reply;
339 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
340 data.writeStrongBinder(client->asBinder());
341 remote()->transact(REGISTER_CLIENT, data, &reply);
342 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700343
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800344 virtual size_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount)
345 {
346 Parcel data, reply;
347 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
348 data.writeInt32(sampleRate);
349 data.writeInt32(format);
350 data.writeInt32(channelCount);
351 remote()->transact(GET_INPUTBUFFERSIZE, data, &reply);
352 return reply.readInt32();
353 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700354
Eric Laurentfa2877b2009-07-28 08:44:33 -0700355 virtual int openOutput(uint32_t *pDevices,
Eric Laurentc2f1f072009-07-17 12:17:14 -0700356 uint32_t *pSamplingRate,
357 uint32_t *pFormat,
358 uint32_t *pChannels,
359 uint32_t *pLatencyMs,
360 uint32_t flags)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800361 {
362 Parcel data, reply;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700363 uint32_t devices = pDevices ? *pDevices : 0;
364 uint32_t samplingRate = pSamplingRate ? *pSamplingRate : 0;
365 uint32_t format = pFormat ? *pFormat : 0;
366 uint32_t channels = pChannels ? *pChannels : 0;
367 uint32_t latency = pLatencyMs ? *pLatencyMs : 0;
368
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800369 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentc2f1f072009-07-17 12:17:14 -0700370 data.writeInt32(devices);
371 data.writeInt32(samplingRate);
372 data.writeInt32(format);
373 data.writeInt32(channels);
374 data.writeInt32(latency);
375 data.writeInt32(flags);
376 remote()->transact(OPEN_OUTPUT, data, &reply);
Eric Laurentfa2877b2009-07-28 08:44:33 -0700377 int output = reply.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700378 LOGV("openOutput() returned output, %p", output);
379 devices = reply.readInt32();
380 if (pDevices) *pDevices = devices;
381 samplingRate = reply.readInt32();
382 if (pSamplingRate) *pSamplingRate = samplingRate;
383 format = reply.readInt32();
384 if (pFormat) *pFormat = format;
385 channels = reply.readInt32();
386 if (pChannels) *pChannels = channels;
387 latency = reply.readInt32();
388 if (pLatencyMs) *pLatencyMs = latency;
389 return output;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800390 }
391
Eric Laurentfa2877b2009-07-28 08:44:33 -0700392 virtual int openDuplicateOutput(int output1, int output2)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800393 {
394 Parcel data, reply;
395 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentfa2877b2009-07-28 08:44:33 -0700396 data.writeInt32(output1);
397 data.writeInt32(output2);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700398 remote()->transact(OPEN_DUPLICATE_OUTPUT, data, &reply);
Eric Laurentfa2877b2009-07-28 08:44:33 -0700399 return reply.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700400 }
401
Eric Laurentfa2877b2009-07-28 08:44:33 -0700402 virtual status_t closeOutput(int output)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700403 {
404 Parcel data, reply;
405 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentfa2877b2009-07-28 08:44:33 -0700406 data.writeInt32(output);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700407 remote()->transact(CLOSE_OUTPUT, data, &reply);
408 return reply.readInt32();
409 }
410
Eric Laurentfa2877b2009-07-28 08:44:33 -0700411 virtual status_t suspendOutput(int output)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700412 {
413 Parcel data, reply;
414 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentfa2877b2009-07-28 08:44:33 -0700415 data.writeInt32(output);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700416 remote()->transact(SUSPEND_OUTPUT, data, &reply);
417 return reply.readInt32();
418 }
419
Eric Laurentfa2877b2009-07-28 08:44:33 -0700420 virtual status_t restoreOutput(int output)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700421 {
422 Parcel data, reply;
423 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentfa2877b2009-07-28 08:44:33 -0700424 data.writeInt32(output);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700425 remote()->transact(RESTORE_OUTPUT, data, &reply);
426 return reply.readInt32();
427 }
428
Eric Laurentfa2877b2009-07-28 08:44:33 -0700429 virtual int openInput(uint32_t *pDevices,
430 uint32_t *pSamplingRate,
431 uint32_t *pFormat,
432 uint32_t *pChannels,
433 uint32_t acoustics)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700434 {
435 Parcel data, reply;
436 uint32_t devices = pDevices ? *pDevices : 0;
437 uint32_t samplingRate = pSamplingRate ? *pSamplingRate : 0;
438 uint32_t format = pFormat ? *pFormat : 0;
439 uint32_t channels = pChannels ? *pChannels : 0;
440
441 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
442 data.writeInt32(devices);
443 data.writeInt32(samplingRate);
444 data.writeInt32(format);
445 data.writeInt32(channels);
446 data.writeInt32(acoustics);
447 remote()->transact(OPEN_INPUT, data, &reply);
Eric Laurentfa2877b2009-07-28 08:44:33 -0700448 int input = reply.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700449 devices = reply.readInt32();
450 if (pDevices) *pDevices = devices;
451 samplingRate = reply.readInt32();
452 if (pSamplingRate) *pSamplingRate = samplingRate;
453 format = reply.readInt32();
454 if (pFormat) *pFormat = format;
455 channels = reply.readInt32();
456 if (pChannels) *pChannels = channels;
457 return input;
458 }
459
Eric Laurentfa2877b2009-07-28 08:44:33 -0700460 virtual status_t closeInput(int input)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700461 {
462 Parcel data, reply;
463 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentfa2877b2009-07-28 08:44:33 -0700464 data.writeInt32(input);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700465 remote()->transact(CLOSE_INPUT, data, &reply);
466 return reply.readInt32();
467 }
468
Eric Laurentfa2877b2009-07-28 08:44:33 -0700469 virtual status_t setStreamOutput(uint32_t stream, int output)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700470 {
471 Parcel data, reply;
472 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
473 data.writeInt32(stream);
Eric Laurentfa2877b2009-07-28 08:44:33 -0700474 data.writeInt32(output);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700475 remote()->transact(SET_STREAM_OUTPUT, data, &reply);
476 return reply.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800477 }
Eric Laurentf0ee6f42009-10-21 08:14:22 -0700478
479 virtual status_t setVoiceVolume(float volume)
480 {
481 Parcel data, reply;
482 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
483 data.writeFloat(volume);
484 remote()->transact(SET_VOICE_VOLUME, data, &reply);
485 return reply.readInt32();
486 }
Eric Laurent342e9cf2010-01-19 17:37:09 -0800487
488 virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int output)
489 {
490 Parcel data, reply;
491 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
492 data.writeInt32(output);
493 remote()->transact(GET_RENDER_POSITION, data, &reply);
494 status_t status = reply.readInt32();
495 if (status == NO_ERROR) {
496 uint32_t tmp = reply.readInt32();
497 if (halFrames) {
498 *halFrames = tmp;
499 }
500 tmp = reply.readInt32();
501 if (dspFrames) {
502 *dspFrames = tmp;
503 }
504 }
505 return status;
506 }
Eric Laurent05bca2f2010-02-26 02:47:27 -0800507
508 virtual unsigned int getInputFramesLost(int ioHandle)
509 {
510 Parcel data, reply;
511 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
512 data.writeInt32(ioHandle);
513 remote()->transact(GET_INPUT_FRAMES_LOST, data, &reply);
514 return reply.readInt32();
515 }
Eric Laurentbe916aa2010-06-01 23:49:17 -0700516
517 virtual int newAudioSessionId()
518 {
519 Parcel data, reply;
520 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
521 status_t status = remote()->transact(NEW_AUDIO_SESSION_ID, data, &reply);
522 int id = 0;
523 if (status == NO_ERROR) {
524 id = reply.readInt32();
525 }
526 return id;
527 }
528
Eric Laurentbe916aa2010-06-01 23:49:17 -0700529 virtual status_t queryNumberEffects(uint32_t *numEffects)
530 {
531 Parcel data, reply;
532 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
533 status_t status = remote()->transact(QUERY_NUM_EFFECTS, data, &reply);
534 if (status != NO_ERROR) {
535 return status;
536 }
537 status = reply.readInt32();
538 if (status != NO_ERROR) {
539 return status;
540 }
541 if (numEffects) {
542 *numEffects = (uint32_t)reply.readInt32();
543 }
544 return NO_ERROR;
545 }
546
Eric Laurentffe9c252010-06-23 17:38:20 -0700547 virtual status_t queryEffect(uint32_t index, effect_descriptor_t *pDescriptor)
Eric Laurentbe916aa2010-06-01 23:49:17 -0700548 {
549 if (pDescriptor == NULL) {
550 return BAD_VALUE;
551 }
552 Parcel data, reply;
553 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentffe9c252010-06-23 17:38:20 -0700554 data.writeInt32(index);
555 status_t status = remote()->transact(QUERY_EFFECT, data, &reply);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700556 if (status != NO_ERROR) {
557 return status;
558 }
559 status = reply.readInt32();
560 if (status != NO_ERROR) {
561 return status;
562 }
563 reply.read(pDescriptor, sizeof(effect_descriptor_t));
564 return NO_ERROR;
565 }
566
567 virtual status_t getEffectDescriptor(effect_uuid_t *pUuid, effect_descriptor_t *pDescriptor)
568 {
569 if (pUuid == NULL || pDescriptor == NULL) {
570 return BAD_VALUE;
571 }
572 Parcel data, reply;
573 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
574 data.write(pUuid, sizeof(effect_uuid_t));
575 status_t status = remote()->transact(GET_EFFECT_DESCRIPTOR, data, &reply);
576 if (status != NO_ERROR) {
577 return status;
578 }
579 status = reply.readInt32();
580 if (status != NO_ERROR) {
581 return status;
582 }
583 reply.read(pDescriptor, sizeof(effect_descriptor_t));
584 return NO_ERROR;
585 }
586
587 virtual sp<IEffect> createEffect(pid_t pid,
588 effect_descriptor_t *pDesc,
589 const sp<IEffectClient>& client,
590 int32_t priority,
591 int output,
592 int sessionId,
593 status_t *status,
594 int *id,
595 int *enabled)
596 {
597 Parcel data, reply;
598 sp<IEffect> effect;
599
600 if (pDesc == NULL) {
601 return effect;
602 if (status) {
603 *status = BAD_VALUE;
604 }
605 }
606
607 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
608 data.writeInt32(pid);
609 data.write(pDesc, sizeof(effect_descriptor_t));
610 data.writeStrongBinder(client->asBinder());
611 data.writeInt32(priority);
612 data.writeInt32(output);
613 data.writeInt32(sessionId);
614
615 status_t lStatus = remote()->transact(CREATE_EFFECT, data, &reply);
616 if (lStatus != NO_ERROR) {
617 LOGE("createEffect error: %s", strerror(-lStatus));
618 } else {
619 lStatus = reply.readInt32();
620 int tmp = reply.readInt32();
621 if (id) {
622 *id = tmp;
623 }
624 tmp = reply.readInt32();
625 if (enabled) {
626 *enabled = tmp;
627 }
628 effect = interface_cast<IEffect>(reply.readStrongBinder());
629 reply.read(pDesc, sizeof(effect_descriptor_t));
630 }
631 if (status) {
632 *status = lStatus;
633 }
634
635 return effect;
636 }
Eric Laurentde070132010-07-13 04:45:46 -0700637
638 virtual status_t moveEffects(int session, int srcOutput, int dstOutput)
639 {
640 Parcel data, reply;
641 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
642 data.writeInt32(session);
643 data.writeInt32(srcOutput);
644 data.writeInt32(dstOutput);
645 remote()->transact(MOVE_EFFECTS, data, &reply);
646 return reply.readInt32();
647 }
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800648};
649
650IMPLEMENT_META_INTERFACE(AudioFlinger, "android.media.IAudioFlinger");
651
652// ----------------------------------------------------------------------
653
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800654status_t BnAudioFlinger::onTransact(
655 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
656{
657 switch(code) {
658 case CREATE_TRACK: {
659 CHECK_INTERFACE(IAudioFlinger, data, reply);
660 pid_t pid = data.readInt32();
661 int streamType = data.readInt32();
662 uint32_t sampleRate = data.readInt32();
663 int format = data.readInt32();
664 int channelCount = data.readInt32();
665 size_t bufferCount = data.readInt32();
666 uint32_t flags = data.readInt32();
667 sp<IMemory> buffer = interface_cast<IMemory>(data.readStrongBinder());
Eric Laurentfa2877b2009-07-28 08:44:33 -0700668 int output = data.readInt32();
Eric Laurentbe916aa2010-06-01 23:49:17 -0700669 int sessionId = data.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800670 status_t status;
671 sp<IAudioTrack> track = createTrack(pid,
672 streamType, sampleRate, format,
Eric Laurentbe916aa2010-06-01 23:49:17 -0700673 channelCount, bufferCount, flags, buffer, output, &sessionId, &status);
674 reply->writeInt32(sessionId);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800675 reply->writeInt32(status);
676 reply->writeStrongBinder(track->asBinder());
677 return NO_ERROR;
678 } break;
679 case OPEN_RECORD: {
680 CHECK_INTERFACE(IAudioFlinger, data, reply);
681 pid_t pid = data.readInt32();
Eric Laurentfa2877b2009-07-28 08:44:33 -0700682 int input = data.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800683 uint32_t sampleRate = data.readInt32();
684 int format = data.readInt32();
685 int channelCount = data.readInt32();
686 size_t bufferCount = data.readInt32();
687 uint32_t flags = data.readInt32();
Eric Laurentbe916aa2010-06-01 23:49:17 -0700688 int sessionId = data.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800689 status_t status;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700690 sp<IAudioRecord> record = openRecord(pid, input,
Eric Laurentbe916aa2010-06-01 23:49:17 -0700691 sampleRate, format, channelCount, bufferCount, flags, &sessionId, &status);
692 reply->writeInt32(sessionId);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800693 reply->writeInt32(status);
694 reply->writeStrongBinder(record->asBinder());
695 return NO_ERROR;
696 } break;
697 case SAMPLE_RATE: {
698 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurentfa2877b2009-07-28 08:44:33 -0700699 reply->writeInt32( sampleRate(data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800700 return NO_ERROR;
701 } break;
702 case CHANNEL_COUNT: {
703 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurentfa2877b2009-07-28 08:44:33 -0700704 reply->writeInt32( channelCount(data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800705 return NO_ERROR;
706 } break;
707 case FORMAT: {
708 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurentfa2877b2009-07-28 08:44:33 -0700709 reply->writeInt32( format(data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800710 return NO_ERROR;
711 } break;
712 case FRAME_COUNT: {
713 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurentfa2877b2009-07-28 08:44:33 -0700714 reply->writeInt32( frameCount(data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800715 return NO_ERROR;
716 } break;
717 case LATENCY: {
718 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurentfa2877b2009-07-28 08:44:33 -0700719 reply->writeInt32( latency(data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800720 return NO_ERROR;
721 } break;
722 case SET_MASTER_VOLUME: {
723 CHECK_INTERFACE(IAudioFlinger, data, reply);
724 reply->writeInt32( setMasterVolume(data.readFloat()) );
725 return NO_ERROR;
726 } break;
727 case SET_MASTER_MUTE: {
728 CHECK_INTERFACE(IAudioFlinger, data, reply);
729 reply->writeInt32( setMasterMute(data.readInt32()) );
730 return NO_ERROR;
731 } break;
732 case MASTER_VOLUME: {
733 CHECK_INTERFACE(IAudioFlinger, data, reply);
734 reply->writeFloat( masterVolume() );
735 return NO_ERROR;
736 } break;
737 case MASTER_MUTE: {
738 CHECK_INTERFACE(IAudioFlinger, data, reply);
739 reply->writeInt32( masterMute() );
740 return NO_ERROR;
741 } break;
742 case SET_STREAM_VOLUME: {
743 CHECK_INTERFACE(IAudioFlinger, data, reply);
744 int stream = data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700745 float volume = data.readFloat();
Eric Laurentfa2877b2009-07-28 08:44:33 -0700746 int output = data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700747 reply->writeInt32( setStreamVolume(stream, volume, output) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800748 return NO_ERROR;
749 } break;
750 case SET_STREAM_MUTE: {
751 CHECK_INTERFACE(IAudioFlinger, data, reply);
752 int stream = data.readInt32();
753 reply->writeInt32( setStreamMute(stream, data.readInt32()) );
754 return NO_ERROR;
755 } break;
756 case STREAM_VOLUME: {
757 CHECK_INTERFACE(IAudioFlinger, data, reply);
758 int stream = data.readInt32();
Eric Laurentfa2877b2009-07-28 08:44:33 -0700759 int output = data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700760 reply->writeFloat( streamVolume(stream, output) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800761 return NO_ERROR;
762 } break;
763 case STREAM_MUTE: {
764 CHECK_INTERFACE(IAudioFlinger, data, reply);
765 int stream = data.readInt32();
766 reply->writeInt32( streamMute(stream) );
767 return NO_ERROR;
768 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800769 case SET_MODE: {
770 CHECK_INTERFACE(IAudioFlinger, data, reply);
771 int mode = data.readInt32();
772 reply->writeInt32( setMode(mode) );
773 return NO_ERROR;
774 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800775 case SET_MIC_MUTE: {
776 CHECK_INTERFACE(IAudioFlinger, data, reply);
777 int state = data.readInt32();
778 reply->writeInt32( setMicMute(state) );
779 return NO_ERROR;
780 } break;
781 case GET_MIC_MUTE: {
782 CHECK_INTERFACE(IAudioFlinger, data, reply);
783 reply->writeInt32( getMicMute() );
784 return NO_ERROR;
785 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700786 case SET_PARAMETERS: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800787 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurentfa2877b2009-07-28 08:44:33 -0700788 int ioHandle = data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700789 String8 keyValuePairs(data.readString8());
790 reply->writeInt32(setParameters(ioHandle, keyValuePairs));
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800791 return NO_ERROR;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700792 } break;
793 case GET_PARAMETERS: {
794 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurentfa2877b2009-07-28 08:44:33 -0700795 int ioHandle = data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700796 String8 keys(data.readString8());
797 reply->writeString8(getParameters(ioHandle, keys));
798 return NO_ERROR;
799 } break;
800
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800801 case REGISTER_CLIENT: {
802 CHECK_INTERFACE(IAudioFlinger, data, reply);
803 sp<IAudioFlingerClient> client = interface_cast<IAudioFlingerClient>(data.readStrongBinder());
804 registerClient(client);
805 return NO_ERROR;
806 } break;
807 case GET_INPUTBUFFERSIZE: {
808 CHECK_INTERFACE(IAudioFlinger, data, reply);
809 uint32_t sampleRate = data.readInt32();
810 int format = data.readInt32();
811 int channelCount = data.readInt32();
812 reply->writeInt32( getInputBufferSize(sampleRate, format, channelCount) );
813 return NO_ERROR;
814 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700815 case OPEN_OUTPUT: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800816 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700817 uint32_t devices = data.readInt32();
818 uint32_t samplingRate = data.readInt32();
819 uint32_t format = data.readInt32();
820 uint32_t channels = data.readInt32();
821 uint32_t latency = data.readInt32();
822 uint32_t flags = data.readInt32();
Eric Laurentfa2877b2009-07-28 08:44:33 -0700823 int output = openOutput(&devices,
Eric Laurentc2f1f072009-07-17 12:17:14 -0700824 &samplingRate,
825 &format,
826 &channels,
827 &latency,
828 flags);
829 LOGV("OPEN_OUTPUT output, %p", output);
Eric Laurentfa2877b2009-07-28 08:44:33 -0700830 reply->writeInt32(output);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700831 reply->writeInt32(devices);
832 reply->writeInt32(samplingRate);
833 reply->writeInt32(format);
834 reply->writeInt32(channels);
835 reply->writeInt32(latency);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800836 return NO_ERROR;
837 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700838 case OPEN_DUPLICATE_OUTPUT: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800839 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurentfa2877b2009-07-28 08:44:33 -0700840 int output1 = data.readInt32();
841 int output2 = data.readInt32();
842 reply->writeInt32(openDuplicateOutput(output1, output2));
Eric Laurentc2f1f072009-07-17 12:17:14 -0700843 return NO_ERROR;
844 } break;
845 case CLOSE_OUTPUT: {
846 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurentfa2877b2009-07-28 08:44:33 -0700847 reply->writeInt32(closeOutput(data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -0700848 return NO_ERROR;
849 } break;
850 case SUSPEND_OUTPUT: {
851 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurentfa2877b2009-07-28 08:44:33 -0700852 reply->writeInt32(suspendOutput(data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -0700853 return NO_ERROR;
854 } break;
855 case RESTORE_OUTPUT: {
856 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurentfa2877b2009-07-28 08:44:33 -0700857 reply->writeInt32(restoreOutput(data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -0700858 return NO_ERROR;
859 } break;
860 case OPEN_INPUT: {
861 CHECK_INTERFACE(IAudioFlinger, data, reply);
862 uint32_t devices = data.readInt32();
863 uint32_t samplingRate = data.readInt32();
864 uint32_t format = data.readInt32();
865 uint32_t channels = data.readInt32();
866 uint32_t acoutics = data.readInt32();
867
Eric Laurentfa2877b2009-07-28 08:44:33 -0700868 int input = openInput(&devices,
Eric Laurentc2f1f072009-07-17 12:17:14 -0700869 &samplingRate,
870 &format,
871 &channels,
872 acoutics);
Eric Laurentfa2877b2009-07-28 08:44:33 -0700873 reply->writeInt32(input);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700874 reply->writeInt32(devices);
875 reply->writeInt32(samplingRate);
876 reply->writeInt32(format);
877 reply->writeInt32(channels);
878 return NO_ERROR;
879 } break;
880 case CLOSE_INPUT: {
881 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurentfa2877b2009-07-28 08:44:33 -0700882 reply->writeInt32(closeInput(data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -0700883 return NO_ERROR;
884 } break;
885 case SET_STREAM_OUTPUT: {
886 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700887 uint32_t stream = data.readInt32();
Eric Laurentfa2877b2009-07-28 08:44:33 -0700888 int output = data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700889 reply->writeInt32(setStreamOutput(stream, output));
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800890 return NO_ERROR;
891 } break;
Eric Laurentf0ee6f42009-10-21 08:14:22 -0700892 case SET_VOICE_VOLUME: {
893 CHECK_INTERFACE(IAudioFlinger, data, reply);
894 float volume = data.readFloat();
895 reply->writeInt32( setVoiceVolume(volume) );
896 return NO_ERROR;
897 } break;
Eric Laurent342e9cf2010-01-19 17:37:09 -0800898 case GET_RENDER_POSITION: {
899 CHECK_INTERFACE(IAudioFlinger, data, reply);
900 int output = data.readInt32();
901 uint32_t halFrames;
902 uint32_t dspFrames;
903 status_t status = getRenderPosition(&halFrames, &dspFrames, output);
904 reply->writeInt32(status);
905 if (status == NO_ERROR) {
906 reply->writeInt32(halFrames);
907 reply->writeInt32(dspFrames);
908 }
909 return NO_ERROR;
910 }
Eric Laurent05bca2f2010-02-26 02:47:27 -0800911 case GET_INPUT_FRAMES_LOST: {
912 CHECK_INTERFACE(IAudioFlinger, data, reply);
913 int ioHandle = data.readInt32();
914 reply->writeInt32(getInputFramesLost(ioHandle));
915 return NO_ERROR;
916 } break;
Eric Laurentbe916aa2010-06-01 23:49:17 -0700917 case NEW_AUDIO_SESSION_ID: {
918 CHECK_INTERFACE(IAudioFlinger, data, reply);
919 reply->writeInt32(newAudioSessionId());
920 return NO_ERROR;
921 } break;
Eric Laurentbe916aa2010-06-01 23:49:17 -0700922 case QUERY_NUM_EFFECTS: {
923 CHECK_INTERFACE(IAudioFlinger, data, reply);
924 uint32_t numEffects;
925 status_t status = queryNumberEffects(&numEffects);
926 reply->writeInt32(status);
927 if (status == NO_ERROR) {
928 reply->writeInt32((int32_t)numEffects);
929 }
930 return NO_ERROR;
931 }
Eric Laurentffe9c252010-06-23 17:38:20 -0700932 case QUERY_EFFECT: {
Eric Laurentbe916aa2010-06-01 23:49:17 -0700933 CHECK_INTERFACE(IAudioFlinger, data, reply);
934 effect_descriptor_t desc;
Eric Laurentffe9c252010-06-23 17:38:20 -0700935 status_t status = queryEffect(data.readInt32(), &desc);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700936 reply->writeInt32(status);
937 if (status == NO_ERROR) {
938 reply->write(&desc, sizeof(effect_descriptor_t));
939 }
940 return NO_ERROR;
941 }
942 case GET_EFFECT_DESCRIPTOR: {
943 CHECK_INTERFACE(IAudioFlinger, data, reply);
944 effect_uuid_t uuid;
945 data.read(&uuid, sizeof(effect_uuid_t));
946 effect_descriptor_t desc;
947 status_t status = getEffectDescriptor(&uuid, &desc);
948 reply->writeInt32(status);
949 if (status == NO_ERROR) {
950 reply->write(&desc, sizeof(effect_descriptor_t));
951 }
952 return NO_ERROR;
953 }
954 case CREATE_EFFECT: {
955 CHECK_INTERFACE(IAudioFlinger, data, reply);
956 pid_t pid = data.readInt32();
957 effect_descriptor_t desc;
958 data.read(&desc, sizeof(effect_descriptor_t));
959 sp<IEffectClient> client = interface_cast<IEffectClient>(data.readStrongBinder());
960 int32_t priority = data.readInt32();
961 int output = data.readInt32();
962 int sessionId = data.readInt32();
963 status_t status;
964 int id;
965 int enabled;
Eric Laurent05bca2f2010-02-26 02:47:27 -0800966
Eric Laurentbe916aa2010-06-01 23:49:17 -0700967 sp<IEffect> effect = createEffect(pid, &desc, client, priority, output, sessionId, &status, &id, &enabled);
968 reply->writeInt32(status);
969 reply->writeInt32(id);
970 reply->writeInt32(enabled);
971 reply->writeStrongBinder(effect->asBinder());
972 reply->write(&desc, sizeof(effect_descriptor_t));
973 return NO_ERROR;
974 } break;
Eric Laurentde070132010-07-13 04:45:46 -0700975 case MOVE_EFFECTS: {
976 CHECK_INTERFACE(IAudioFlinger, data, reply);
977 int session = data.readInt32();
978 int srcOutput = data.readInt32();
979 int dstOutput = data.readInt32();
980 reply->writeInt32(moveEffects(session, srcOutput, dstOutput));
981 return NO_ERROR;
982 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800983 default:
984 return BBinder::onTransact(code, data, reply, flags);
985 }
986}
987
988// ----------------------------------------------------------------------------
989
990}; // namespace android