blob: e6963233b7e10f4f886b5f6a10f22cfcf4493016 [file] [log] [blame]
Marco Nelissen3a34bef2011-08-02 13:33:41 -07001/*
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08002**
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,
Glenn Kasten5876f2f2012-11-30 10:52:16 -080035 RESERVED, // obsolete, was CHANNEL_COUNT
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080036 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,
Marco Nelissen3a34bef2011-08-02 13:33:41 -070066 ACQUIRE_AUDIO_SESSION_ID,
67 RELEASE_AUDIO_SESSION_ID,
Eric Laurentbe916aa2010-06-01 23:49:17 -070068 QUERY_NUM_EFFECTS,
Eric Laurentffe9c252010-06-23 17:38:20 -070069 QUERY_EFFECT,
Eric Laurentbe916aa2010-06-01 23:49:17 -070070 GET_EFFECT_DESCRIPTOR,
Eric Laurentde070132010-07-13 04:45:46 -070071 CREATE_EFFECT,
Eric Laurenta4c5a552012-03-29 10:12:40 -070072 MOVE_EFFECTS,
Glenn Kastencc0f1cf2012-09-24 11:27:18 -070073 LOAD_HW_MODULE,
74 GET_PRIMARY_OUTPUT_SAMPLING_RATE,
75 GET_PRIMARY_OUTPUT_FRAME_COUNT,
Glenn Kasten4182c4e2013-07-15 14:45:07 -070076 SET_LOW_RAM_DEVICE,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080077};
78
79class BpAudioFlinger : public BpInterface<IAudioFlinger>
80{
81public:
82 BpAudioFlinger(const sp<IBinder>& impl)
83 : BpInterface<IAudioFlinger>(impl)
84 {
85 }
86
87 virtual sp<IAudioTrack> createTrack(
Glenn Kastenfff6d712012-01-12 16:38:12 -080088 audio_stream_type_t streamType,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080089 uint32_t sampleRate,
Glenn Kasten58f30212012-01-12 12:27:51 -080090 audio_format_t format,
Glenn Kastendd8104c2012-07-02 12:42:44 -070091 audio_channel_mask_t channelMask,
Glenn Kasten74935e42013-12-19 08:56:45 -080092 size_t *pFrameCount,
Glenn Kastene0b07172012-11-06 15:03:34 -080093 track_flags_t *flags,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080094 const sp<IMemory>& sharedBuffer,
Glenn Kasten72ef00d2012-01-17 11:09:42 -080095 audio_io_handle_t output,
Glenn Kasten3acbd052012-02-28 10:39:56 -080096 pid_t tid,
Eric Laurentbe916aa2010-06-01 23:49:17 -070097 int *sessionId,
Glenn Kastend054c322013-07-12 12:59:20 -070098 String8& name,
Marco Nelissen462fd2f2013-01-14 14:12:05 -080099 int clientUid,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800100 status_t *status)
101 {
102 Parcel data, reply;
Eric Laurent5841db72009-09-09 05:16:08 -0700103 sp<IAudioTrack> track;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800104 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800105 data.writeInt32((int32_t) streamType);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800106 data.writeInt32(sampleRate);
107 data.writeInt32(format);
Jean-Michel Trivi0d255b22011-05-24 15:53:33 -0700108 data.writeInt32(channelMask);
Glenn Kasten74935e42013-12-19 08:56:45 -0800109 size_t frameCount = pFrameCount != NULL ? *pFrameCount : 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800110 data.writeInt32(frameCount);
Glenn Kastenb26e3e92012-11-14 08:32:08 -0800111 track_flags_t lFlags = flags != NULL ? *flags : (track_flags_t) TRACK_DEFAULT;
Glenn Kastene0b07172012-11-06 15:03:34 -0800112 data.writeInt32(lFlags);
Eric Laurent3d00aa62013-09-24 09:53:27 -0700113 if (sharedBuffer != 0) {
114 data.writeInt32(true);
115 data.writeStrongBinder(sharedBuffer->asBinder());
116 } else {
117 data.writeInt32(false);
118 }
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800119 data.writeInt32((int32_t) output);
Glenn Kasten3acbd052012-02-28 10:39:56 -0800120 data.writeInt32((int32_t) tid);
Glenn Kastenaea7ea02013-06-26 09:25:47 -0700121 int lSessionId = AUDIO_SESSION_ALLOCATE;
Eric Laurentbe916aa2010-06-01 23:49:17 -0700122 if (sessionId != NULL) {
123 lSessionId = *sessionId;
124 }
125 data.writeInt32(lSessionId);
Marco Nelissen462fd2f2013-01-14 14:12:05 -0800126 data.writeInt32(clientUid);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800127 status_t lStatus = remote()->transact(CREATE_TRACK, data, &reply);
128 if (lStatus != NO_ERROR) {
Steve Block29357bc2012-01-06 19:20:56 +0000129 ALOGE("createTrack error: %s", strerror(-lStatus));
Eric Laurent5841db72009-09-09 05:16:08 -0700130 } else {
Glenn Kasten74935e42013-12-19 08:56:45 -0800131 frameCount = reply.readInt32();
132 if (pFrameCount != NULL) {
133 *pFrameCount = frameCount;
134 }
Glenn Kastene0b07172012-11-06 15:03:34 -0800135 lFlags = reply.readInt32();
136 if (flags != NULL) {
137 *flags = lFlags;
138 }
Eric Laurentbe916aa2010-06-01 23:49:17 -0700139 lSessionId = reply.readInt32();
140 if (sessionId != NULL) {
141 *sessionId = lSessionId;
142 }
Glenn Kastend054c322013-07-12 12:59:20 -0700143 name = reply.readString8();
Eric Laurent5841db72009-09-09 05:16:08 -0700144 lStatus = reply.readInt32();
145 track = interface_cast<IAudioTrack>(reply.readStrongBinder());
Glenn Kasten0cde0762014-01-16 15:06:36 -0800146 if (lStatus == NO_ERROR) {
147 if (track == 0) {
148 ALOGE("createTrack should have returned an IAudioTrack");
149 lStatus = UNKNOWN_ERROR;
150 }
151 } else {
152 if (track != 0) {
153 ALOGE("createTrack returned an IAudioTrack but with status %d", lStatus);
154 track.clear();
155 }
156 }
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800157 }
Glenn Kasten507b2862013-07-31 16:12:13 -0700158 if (status != NULL) {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800159 *status = lStatus;
160 }
Eric Laurent5841db72009-09-09 05:16:08 -0700161 return track;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800162 }
163
164 virtual sp<IAudioRecord> openRecord(
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800165 audio_io_handle_t input,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800166 uint32_t sampleRate,
Glenn Kasten58f30212012-01-12 12:27:51 -0800167 audio_format_t format,
Glenn Kasten28b76b32012-07-03 17:24:41 -0700168 audio_channel_mask_t channelMask,
Glenn Kasten74935e42013-12-19 08:56:45 -0800169 size_t *pFrameCount,
Glenn Kasteneeca3262013-07-31 16:12:48 -0700170 track_flags_t *flags,
Glenn Kasten1879fff2012-07-11 15:36:59 -0700171 pid_t tid,
Eric Laurentbe916aa2010-06-01 23:49:17 -0700172 int *sessionId,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800173 status_t *status)
174 {
175 Parcel data, reply;
Eric Laurent5841db72009-09-09 05:16:08 -0700176 sp<IAudioRecord> record;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800177 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800178 data.writeInt32((int32_t) input);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800179 data.writeInt32(sampleRate);
180 data.writeInt32(format);
Jean-Michel Trivi0d255b22011-05-24 15:53:33 -0700181 data.writeInt32(channelMask);
Glenn Kasten74935e42013-12-19 08:56:45 -0800182 size_t frameCount = pFrameCount != NULL ? *pFrameCount : 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800183 data.writeInt32(frameCount);
Glenn Kasteneeca3262013-07-31 16:12:48 -0700184 track_flags_t lFlags = flags != NULL ? *flags : (track_flags_t) TRACK_DEFAULT;
185 data.writeInt32(lFlags);
Glenn Kasten1879fff2012-07-11 15:36:59 -0700186 data.writeInt32((int32_t) tid);
Glenn Kastenaea7ea02013-06-26 09:25:47 -0700187 int lSessionId = AUDIO_SESSION_ALLOCATE;
Eric Laurentbe916aa2010-06-01 23:49:17 -0700188 if (sessionId != NULL) {
189 lSessionId = *sessionId;
190 }
191 data.writeInt32(lSessionId);
Eric Laurent5841db72009-09-09 05:16:08 -0700192 status_t lStatus = remote()->transact(OPEN_RECORD, data, &reply);
193 if (lStatus != NO_ERROR) {
Steve Block29357bc2012-01-06 19:20:56 +0000194 ALOGE("openRecord error: %s", strerror(-lStatus));
Eric Laurent5841db72009-09-09 05:16:08 -0700195 } else {
Glenn Kasten74935e42013-12-19 08:56:45 -0800196 frameCount = reply.readInt32();
197 if (pFrameCount != NULL) {
198 *pFrameCount = frameCount;
199 }
Glenn Kasteneeca3262013-07-31 16:12:48 -0700200 lFlags = reply.readInt32();
201 if (flags != NULL) {
202 *flags = lFlags;
203 }
Eric Laurentbe916aa2010-06-01 23:49:17 -0700204 lSessionId = reply.readInt32();
205 if (sessionId != NULL) {
206 *sessionId = lSessionId;
207 }
Eric Laurent5841db72009-09-09 05:16:08 -0700208 lStatus = reply.readInt32();
209 record = interface_cast<IAudioRecord>(reply.readStrongBinder());
Glenn Kastene93cf2c2013-09-24 11:52:37 -0700210 if (lStatus == NO_ERROR) {
211 if (record == 0) {
212 ALOGE("openRecord should have returned an IAudioRecord");
213 lStatus = UNKNOWN_ERROR;
214 }
215 } else {
216 if (record != 0) {
217 ALOGE("openRecord returned an IAudioRecord but with status %d", lStatus);
218 record.clear();
219 }
220 }
Eric Laurent5841db72009-09-09 05:16:08 -0700221 }
Glenn Kasten507b2862013-07-31 16:12:13 -0700222 if (status != NULL) {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800223 *status = lStatus;
224 }
Eric Laurent5841db72009-09-09 05:16:08 -0700225 return record;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800226 }
227
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800228 virtual uint32_t sampleRate(audio_io_handle_t output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800229 {
230 Parcel data, reply;
231 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800232 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800233 remote()->transact(SAMPLE_RATE, data, &reply);
234 return reply.readInt32();
235 }
236
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800237 virtual audio_format_t format(audio_io_handle_t output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800238 {
239 Parcel data, reply;
240 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800241 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800242 remote()->transact(FORMAT, data, &reply);
Glenn Kasten58f30212012-01-12 12:27:51 -0800243 return (audio_format_t) reply.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800244 }
245
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800246 virtual size_t frameCount(audio_io_handle_t output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800247 {
248 Parcel data, reply;
249 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800250 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800251 remote()->transact(FRAME_COUNT, data, &reply);
252 return reply.readInt32();
253 }
254
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800255 virtual uint32_t latency(audio_io_handle_t output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800256 {
257 Parcel data, reply;
258 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800259 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800260 remote()->transact(LATENCY, data, &reply);
261 return reply.readInt32();
262 }
263
264 virtual status_t setMasterVolume(float value)
265 {
266 Parcel data, reply;
267 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
268 data.writeFloat(value);
269 remote()->transact(SET_MASTER_VOLUME, data, &reply);
270 return reply.readInt32();
271 }
272
273 virtual status_t setMasterMute(bool muted)
274 {
275 Parcel data, reply;
276 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
277 data.writeInt32(muted);
278 remote()->transact(SET_MASTER_MUTE, data, &reply);
279 return reply.readInt32();
280 }
281
282 virtual float masterVolume() const
283 {
284 Parcel data, reply;
285 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
286 remote()->transact(MASTER_VOLUME, data, &reply);
287 return reply.readFloat();
288 }
289
290 virtual bool masterMute() const
291 {
292 Parcel data, reply;
293 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
294 remote()->transact(MASTER_MUTE, data, &reply);
295 return reply.readInt32();
296 }
297
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800298 virtual status_t setStreamVolume(audio_stream_type_t stream, float value,
299 audio_io_handle_t output)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800300 {
301 Parcel data, reply;
302 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800303 data.writeInt32((int32_t) stream);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800304 data.writeFloat(value);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800305 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800306 remote()->transact(SET_STREAM_VOLUME, data, &reply);
307 return reply.readInt32();
308 }
309
Glenn Kastenfff6d712012-01-12 16:38:12 -0800310 virtual status_t setStreamMute(audio_stream_type_t stream, bool muted)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800311 {
312 Parcel data, reply;
313 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800314 data.writeInt32((int32_t) stream);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800315 data.writeInt32(muted);
316 remote()->transact(SET_STREAM_MUTE, data, &reply);
317 return reply.readInt32();
318 }
319
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800320 virtual float streamVolume(audio_stream_type_t stream, audio_io_handle_t output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800321 {
322 Parcel data, reply;
323 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800324 data.writeInt32((int32_t) stream);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800325 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800326 remote()->transact(STREAM_VOLUME, data, &reply);
327 return reply.readFloat();
328 }
329
Glenn Kastenfff6d712012-01-12 16:38:12 -0800330 virtual bool streamMute(audio_stream_type_t stream) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800331 {
332 Parcel data, reply;
333 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800334 data.writeInt32((int32_t) stream);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800335 remote()->transact(STREAM_MUTE, data, &reply);
336 return reply.readInt32();
337 }
338
Glenn Kastenf78aee72012-01-04 11:00:47 -0800339 virtual status_t setMode(audio_mode_t mode)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800340 {
341 Parcel data, reply;
342 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
343 data.writeInt32(mode);
344 remote()->transact(SET_MODE, data, &reply);
345 return reply.readInt32();
346 }
347
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800348 virtual status_t setMicMute(bool state)
349 {
350 Parcel data, reply;
351 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
352 data.writeInt32(state);
353 remote()->transact(SET_MIC_MUTE, data, &reply);
354 return reply.readInt32();
355 }
356
357 virtual bool getMicMute() const
358 {
359 Parcel data, reply;
360 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
361 remote()->transact(GET_MIC_MUTE, data, &reply);
362 return reply.readInt32();
363 }
364
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800365 virtual status_t setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800366 {
367 Parcel data, reply;
368 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800369 data.writeInt32((int32_t) ioHandle);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700370 data.writeString8(keyValuePairs);
371 remote()->transact(SET_PARAMETERS, data, &reply);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800372 return reply.readInt32();
373 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700374
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800375 virtual String8 getParameters(audio_io_handle_t ioHandle, const String8& keys) const
Eric Laurentc2f1f072009-07-17 12:17:14 -0700376 {
377 Parcel data, reply;
378 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800379 data.writeInt32((int32_t) ioHandle);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700380 data.writeString8(keys);
381 remote()->transact(GET_PARAMETERS, data, &reply);
382 return reply.readString8();
383 }
384
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800385 virtual void registerClient(const sp<IAudioFlingerClient>& client)
386 {
387 Parcel data, reply;
388 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
389 data.writeStrongBinder(client->asBinder());
390 remote()->transact(REGISTER_CLIENT, data, &reply);
391 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700392
Glenn Kastendd8104c2012-07-02 12:42:44 -0700393 virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format,
394 audio_channel_mask_t channelMask) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800395 {
396 Parcel data, reply;
397 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
398 data.writeInt32(sampleRate);
399 data.writeInt32(format);
Glenn Kastendd8104c2012-07-02 12:42:44 -0700400 data.writeInt32(channelMask);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800401 remote()->transact(GET_INPUTBUFFERSIZE, data, &reply);
402 return reply.readInt32();
403 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700404
Eric Laurenta4c5a552012-03-29 10:12:40 -0700405 virtual audio_io_handle_t openOutput(audio_module_handle_t module,
406 audio_devices_t *pDevices,
407 uint32_t *pSamplingRate,
408 audio_format_t *pFormat,
409 audio_channel_mask_t *pChannelMask,
410 uint32_t *pLatencyMs,
Richard Fitzgeraldad3af332013-03-25 16:54:37 +0000411 audio_output_flags_t flags,
412 const audio_offload_info_t *offloadInfo)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800413 {
414 Parcel data, reply;
Glenn Kasten7c5977f2013-07-02 14:17:22 -0700415 audio_devices_t devices = pDevices != NULL ? *pDevices : (audio_devices_t)0;
416 uint32_t samplingRate = pSamplingRate != NULL ? *pSamplingRate : 0;
417 audio_format_t format = pFormat != NULL ? *pFormat : AUDIO_FORMAT_DEFAULT;
418 audio_channel_mask_t channelMask = pChannelMask != NULL ?
419 *pChannelMask : (audio_channel_mask_t)0;
420 uint32_t latency = pLatencyMs != NULL ? *pLatencyMs : 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800421 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurenta4c5a552012-03-29 10:12:40 -0700422 data.writeInt32(module);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700423 data.writeInt32(devices);
424 data.writeInt32(samplingRate);
425 data.writeInt32(format);
Eric Laurenta4c5a552012-03-29 10:12:40 -0700426 data.writeInt32(channelMask);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700427 data.writeInt32(latency);
Glenn Kasten18868c52012-03-07 09:15:37 -0800428 data.writeInt32((int32_t) flags);
Richard Fitzgeraldb1a270d2013-05-14 12:12:21 +0100429 if (offloadInfo == NULL) {
430 data.writeInt32(0);
431 } else {
432 data.writeInt32(1);
433 data.write(offloadInfo, sizeof(audio_offload_info_t));
434 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700435 remote()->transact(OPEN_OUTPUT, data, &reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800436 audio_io_handle_t output = (audio_io_handle_t) reply.readInt32();
437 ALOGV("openOutput() returned output, %d", output);
Eric Laurenta4c5a552012-03-29 10:12:40 -0700438 devices = (audio_devices_t)reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700439 if (pDevices != NULL) {
440 *pDevices = devices;
441 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700442 samplingRate = reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700443 if (pSamplingRate != NULL) {
444 *pSamplingRate = samplingRate;
445 }
Glenn Kasten58f30212012-01-12 12:27:51 -0800446 format = (audio_format_t) reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700447 if (pFormat != NULL) {
448 *pFormat = format;
449 }
Eric Laurenta4c5a552012-03-29 10:12:40 -0700450 channelMask = (audio_channel_mask_t)reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700451 if (pChannelMask != NULL) {
452 *pChannelMask = channelMask;
453 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700454 latency = reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700455 if (pLatencyMs != NULL) {
456 *pLatencyMs = latency;
457 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700458 return output;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800459 }
460
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800461 virtual audio_io_handle_t openDuplicateOutput(audio_io_handle_t output1,
462 audio_io_handle_t output2)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800463 {
464 Parcel data, reply;
465 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800466 data.writeInt32((int32_t) output1);
467 data.writeInt32((int32_t) output2);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700468 remote()->transact(OPEN_DUPLICATE_OUTPUT, data, &reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800469 return (audio_io_handle_t) reply.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700470 }
471
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800472 virtual status_t closeOutput(audio_io_handle_t output)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700473 {
474 Parcel data, reply;
475 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800476 data.writeInt32((int32_t) output);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700477 remote()->transact(CLOSE_OUTPUT, data, &reply);
478 return reply.readInt32();
479 }
480
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800481 virtual status_t suspendOutput(audio_io_handle_t output)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700482 {
483 Parcel data, reply;
484 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800485 data.writeInt32((int32_t) output);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700486 remote()->transact(SUSPEND_OUTPUT, data, &reply);
487 return reply.readInt32();
488 }
489
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800490 virtual status_t restoreOutput(audio_io_handle_t output)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700491 {
492 Parcel data, reply;
493 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800494 data.writeInt32((int32_t) output);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700495 remote()->transact(RESTORE_OUTPUT, data, &reply);
496 return reply.readInt32();
497 }
498
Eric Laurenta4c5a552012-03-29 10:12:40 -0700499 virtual audio_io_handle_t openInput(audio_module_handle_t module,
500 audio_devices_t *pDevices,
501 uint32_t *pSamplingRate,
502 audio_format_t *pFormat,
503 audio_channel_mask_t *pChannelMask)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700504 {
505 Parcel data, reply;
Glenn Kasten7c5977f2013-07-02 14:17:22 -0700506 audio_devices_t devices = pDevices != NULL ? *pDevices : (audio_devices_t)0;
507 uint32_t samplingRate = pSamplingRate != NULL ? *pSamplingRate : 0;
508 audio_format_t format = pFormat != NULL ? *pFormat : AUDIO_FORMAT_DEFAULT;
509 audio_channel_mask_t channelMask = pChannelMask != NULL ?
510 *pChannelMask : (audio_channel_mask_t)0;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700511
512 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurenta4c5a552012-03-29 10:12:40 -0700513 data.writeInt32(module);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700514 data.writeInt32(devices);
515 data.writeInt32(samplingRate);
516 data.writeInt32(format);
Eric Laurenta4c5a552012-03-29 10:12:40 -0700517 data.writeInt32(channelMask);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700518 remote()->transact(OPEN_INPUT, data, &reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800519 audio_io_handle_t input = (audio_io_handle_t) reply.readInt32();
Eric Laurenta4c5a552012-03-29 10:12:40 -0700520 devices = (audio_devices_t)reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700521 if (pDevices != NULL) {
522 *pDevices = devices;
523 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700524 samplingRate = reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700525 if (pSamplingRate != NULL) {
526 *pSamplingRate = samplingRate;
527 }
Glenn Kasten58f30212012-01-12 12:27:51 -0800528 format = (audio_format_t) reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700529 if (pFormat != NULL) {
530 *pFormat = format;
531 }
Eric Laurenta4c5a552012-03-29 10:12:40 -0700532 channelMask = (audio_channel_mask_t)reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700533 if (pChannelMask != NULL) {
534 *pChannelMask = channelMask;
535 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700536 return input;
537 }
538
Eric Laurentfa2877b2009-07-28 08:44:33 -0700539 virtual status_t closeInput(int input)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700540 {
541 Parcel data, reply;
542 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentfa2877b2009-07-28 08:44:33 -0700543 data.writeInt32(input);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700544 remote()->transact(CLOSE_INPUT, data, &reply);
545 return reply.readInt32();
546 }
547
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800548 virtual status_t setStreamOutput(audio_stream_type_t stream, audio_io_handle_t output)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700549 {
550 Parcel data, reply;
551 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800552 data.writeInt32((int32_t) stream);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800553 data.writeInt32((int32_t) output);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700554 remote()->transact(SET_STREAM_OUTPUT, data, &reply);
555 return reply.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800556 }
Eric Laurentf0ee6f42009-10-21 08:14:22 -0700557
558 virtual status_t setVoiceVolume(float volume)
559 {
560 Parcel data, reply;
561 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
562 data.writeFloat(volume);
563 remote()->transact(SET_VOICE_VOLUME, data, &reply);
564 return reply.readInt32();
565 }
Eric Laurent342e9cf2010-01-19 17:37:09 -0800566
Kévin PETIT377b2ec2014-02-03 12:35:36 +0000567 virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames,
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800568 audio_io_handle_t output) const
Eric Laurent342e9cf2010-01-19 17:37:09 -0800569 {
570 Parcel data, reply;
571 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800572 data.writeInt32((int32_t) output);
Eric Laurent342e9cf2010-01-19 17:37:09 -0800573 remote()->transact(GET_RENDER_POSITION, data, &reply);
574 status_t status = reply.readInt32();
575 if (status == NO_ERROR) {
576 uint32_t tmp = reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700577 if (halFrames != NULL) {
Eric Laurent342e9cf2010-01-19 17:37:09 -0800578 *halFrames = tmp;
579 }
580 tmp = reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700581 if (dspFrames != NULL) {
Eric Laurent342e9cf2010-01-19 17:37:09 -0800582 *dspFrames = tmp;
583 }
584 }
585 return status;
586 }
Eric Laurent05bca2f2010-02-26 02:47:27 -0800587
Glenn Kasten5f972c02014-01-13 09:59:31 -0800588 virtual uint32_t getInputFramesLost(audio_io_handle_t ioHandle) const
Eric Laurent05bca2f2010-02-26 02:47:27 -0800589 {
590 Parcel data, reply;
591 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800592 data.writeInt32((int32_t) ioHandle);
Glenn Kasten5f972c02014-01-13 09:59:31 -0800593 status_t status = remote()->transact(GET_INPUT_FRAMES_LOST, data, &reply);
594 if (status != NO_ERROR) {
595 return 0;
596 }
597 return (uint32_t) reply.readInt32();
Eric Laurent05bca2f2010-02-26 02:47:27 -0800598 }
Eric Laurentbe916aa2010-06-01 23:49:17 -0700599
600 virtual int newAudioSessionId()
601 {
602 Parcel data, reply;
603 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
604 status_t status = remote()->transact(NEW_AUDIO_SESSION_ID, data, &reply);
605 int id = 0;
606 if (status == NO_ERROR) {
607 id = reply.readInt32();
608 }
609 return id;
610 }
611
Marco Nelissend457c972014-02-11 08:47:07 -0800612 virtual void acquireAudioSessionId(int audioSession, int pid)
Marco Nelissen3a34bef2011-08-02 13:33:41 -0700613 {
614 Parcel data, reply;
615 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
616 data.writeInt32(audioSession);
Marco Nelissend457c972014-02-11 08:47:07 -0800617 data.writeInt32(pid);
Marco Nelissen3a34bef2011-08-02 13:33:41 -0700618 remote()->transact(ACQUIRE_AUDIO_SESSION_ID, data, &reply);
619 }
620
Marco Nelissend457c972014-02-11 08:47:07 -0800621 virtual void releaseAudioSessionId(int audioSession, int pid)
Marco Nelissen3a34bef2011-08-02 13:33:41 -0700622 {
623 Parcel data, reply;
624 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
625 data.writeInt32(audioSession);
Marco Nelissend457c972014-02-11 08:47:07 -0800626 data.writeInt32(pid);
Marco Nelissen3a34bef2011-08-02 13:33:41 -0700627 remote()->transact(RELEASE_AUDIO_SESSION_ID, data, &reply);
628 }
629
Glenn Kastenf587ba52012-01-26 16:25:10 -0800630 virtual status_t queryNumberEffects(uint32_t *numEffects) const
Eric Laurentbe916aa2010-06-01 23:49:17 -0700631 {
632 Parcel data, reply;
633 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
634 status_t status = remote()->transact(QUERY_NUM_EFFECTS, data, &reply);
635 if (status != NO_ERROR) {
636 return status;
637 }
638 status = reply.readInt32();
639 if (status != NO_ERROR) {
640 return status;
641 }
Glenn Kasten9d1f02d2012-02-08 17:47:58 -0800642 if (numEffects != NULL) {
Eric Laurentbe916aa2010-06-01 23:49:17 -0700643 *numEffects = (uint32_t)reply.readInt32();
644 }
645 return NO_ERROR;
646 }
647
Glenn Kastenf587ba52012-01-26 16:25:10 -0800648 virtual status_t queryEffect(uint32_t index, effect_descriptor_t *pDescriptor) const
Eric Laurentbe916aa2010-06-01 23:49:17 -0700649 {
650 if (pDescriptor == NULL) {
651 return BAD_VALUE;
652 }
653 Parcel data, reply;
654 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentffe9c252010-06-23 17:38:20 -0700655 data.writeInt32(index);
656 status_t status = remote()->transact(QUERY_EFFECT, data, &reply);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700657 if (status != NO_ERROR) {
658 return status;
659 }
660 status = reply.readInt32();
661 if (status != NO_ERROR) {
662 return status;
663 }
664 reply.read(pDescriptor, sizeof(effect_descriptor_t));
665 return NO_ERROR;
666 }
667
Glenn Kasten5e92a782012-01-30 07:40:52 -0800668 virtual status_t getEffectDescriptor(const effect_uuid_t *pUuid,
Glenn Kastenf587ba52012-01-26 16:25:10 -0800669 effect_descriptor_t *pDescriptor) const
Eric Laurentbe916aa2010-06-01 23:49:17 -0700670 {
671 if (pUuid == NULL || pDescriptor == NULL) {
672 return BAD_VALUE;
673 }
674 Parcel data, reply;
675 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
676 data.write(pUuid, sizeof(effect_uuid_t));
677 status_t status = remote()->transact(GET_EFFECT_DESCRIPTOR, data, &reply);
678 if (status != NO_ERROR) {
679 return status;
680 }
681 status = reply.readInt32();
682 if (status != NO_ERROR) {
683 return status;
684 }
685 reply.read(pDescriptor, sizeof(effect_descriptor_t));
686 return NO_ERROR;
687 }
688
Glenn Kasten8d6cc842012-02-03 11:06:53 -0800689 virtual sp<IEffect> createEffect(
Eric Laurentbe916aa2010-06-01 23:49:17 -0700690 effect_descriptor_t *pDesc,
691 const sp<IEffectClient>& client,
692 int32_t priority,
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800693 audio_io_handle_t output,
Eric Laurentbe916aa2010-06-01 23:49:17 -0700694 int sessionId,
695 status_t *status,
696 int *id,
697 int *enabled)
698 {
699 Parcel data, reply;
700 sp<IEffect> effect;
701
702 if (pDesc == NULL) {
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700703 return effect;
Glenn Kasten507b2862013-07-31 16:12:13 -0700704 if (status != NULL) {
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700705 *status = BAD_VALUE;
706 }
707 }
Eric Laurentbe916aa2010-06-01 23:49:17 -0700708
709 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentbe916aa2010-06-01 23:49:17 -0700710 data.write(pDesc, sizeof(effect_descriptor_t));
711 data.writeStrongBinder(client->asBinder());
712 data.writeInt32(priority);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800713 data.writeInt32((int32_t) output);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700714 data.writeInt32(sessionId);
715
716 status_t lStatus = remote()->transact(CREATE_EFFECT, data, &reply);
717 if (lStatus != NO_ERROR) {
Steve Block29357bc2012-01-06 19:20:56 +0000718 ALOGE("createEffect error: %s", strerror(-lStatus));
Eric Laurentbe916aa2010-06-01 23:49:17 -0700719 } else {
720 lStatus = reply.readInt32();
721 int tmp = reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700722 if (id != NULL) {
Eric Laurentbe916aa2010-06-01 23:49:17 -0700723 *id = tmp;
724 }
725 tmp = reply.readInt32();
Glenn Kastena0d68332012-01-27 16:47:15 -0800726 if (enabled != NULL) {
Eric Laurentbe916aa2010-06-01 23:49:17 -0700727 *enabled = tmp;
728 }
729 effect = interface_cast<IEffect>(reply.readStrongBinder());
730 reply.read(pDesc, sizeof(effect_descriptor_t));
731 }
Glenn Kasten507b2862013-07-31 16:12:13 -0700732 if (status != NULL) {
Eric Laurentbe916aa2010-06-01 23:49:17 -0700733 *status = lStatus;
734 }
735
736 return effect;
737 }
Eric Laurentde070132010-07-13 04:45:46 -0700738
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800739 virtual status_t moveEffects(int session, audio_io_handle_t srcOutput,
740 audio_io_handle_t dstOutput)
Eric Laurentde070132010-07-13 04:45:46 -0700741 {
742 Parcel data, reply;
743 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
744 data.writeInt32(session);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800745 data.writeInt32((int32_t) srcOutput);
746 data.writeInt32((int32_t) dstOutput);
Eric Laurentde070132010-07-13 04:45:46 -0700747 remote()->transact(MOVE_EFFECTS, data, &reply);
748 return reply.readInt32();
749 }
Eric Laurenta4c5a552012-03-29 10:12:40 -0700750
751 virtual audio_module_handle_t loadHwModule(const char *name)
752 {
753 Parcel data, reply;
754 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
755 data.writeCString(name);
756 remote()->transact(LOAD_HW_MODULE, data, &reply);
757 return (audio_module_handle_t) reply.readInt32();
758 }
Glenn Kastencc0f1cf2012-09-24 11:27:18 -0700759
Glenn Kasten3b16c762012-11-14 08:44:39 -0800760 virtual uint32_t getPrimaryOutputSamplingRate()
Glenn Kastencc0f1cf2012-09-24 11:27:18 -0700761 {
762 Parcel data, reply;
763 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
764 remote()->transact(GET_PRIMARY_OUTPUT_SAMPLING_RATE, data, &reply);
765 return reply.readInt32();
766 }
767
Glenn Kastene33054e2012-11-14 12:54:39 -0800768 virtual size_t getPrimaryOutputFrameCount()
Glenn Kastencc0f1cf2012-09-24 11:27:18 -0700769 {
770 Parcel data, reply;
771 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
772 remote()->transact(GET_PRIMARY_OUTPUT_FRAME_COUNT, data, &reply);
773 return reply.readInt32();
774 }
775
Glenn Kasten4182c4e2013-07-15 14:45:07 -0700776 virtual status_t setLowRamDevice(bool isLowRamDevice)
777 {
778 Parcel data, reply;
779 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
780 data.writeInt32((int) isLowRamDevice);
781 remote()->transact(SET_LOW_RAM_DEVICE, data, &reply);
782 return reply.readInt32();
783 }
784
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800785};
786
787IMPLEMENT_META_INTERFACE(AudioFlinger, "android.media.IAudioFlinger");
788
789// ----------------------------------------------------------------------
790
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800791status_t BnAudioFlinger::onTransact(
792 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
793{
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700794 switch (code) {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800795 case CREATE_TRACK: {
796 CHECK_INTERFACE(IAudioFlinger, data, reply);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800797 int streamType = data.readInt32();
798 uint32_t sampleRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -0800799 audio_format_t format = (audio_format_t) data.readInt32();
Glenn Kastendd8104c2012-07-02 12:42:44 -0700800 audio_channel_mask_t channelMask = data.readInt32();
Glenn Kastene33054e2012-11-14 12:54:39 -0800801 size_t frameCount = data.readInt32();
Glenn Kastena075db42012-03-06 11:22:44 -0800802 track_flags_t flags = (track_flags_t) data.readInt32();
Eric Laurent3d00aa62013-09-24 09:53:27 -0700803 bool haveSharedBuffer = data.readInt32() != 0;
804 sp<IMemory> buffer;
805 if (haveSharedBuffer) {
806 buffer = interface_cast<IMemory>(data.readStrongBinder());
807 }
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800808 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Glenn Kasten3acbd052012-02-28 10:39:56 -0800809 pid_t tid = (pid_t) data.readInt32();
Eric Laurentbe916aa2010-06-01 23:49:17 -0700810 int sessionId = data.readInt32();
Marco Nelissen462fd2f2013-01-14 14:12:05 -0800811 int clientUid = data.readInt32();
Glenn Kastend054c322013-07-12 12:59:20 -0700812 String8 name;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800813 status_t status;
Eric Laurent3d00aa62013-09-24 09:53:27 -0700814 sp<IAudioTrack> track;
815 if ((haveSharedBuffer && (buffer == 0)) ||
816 ((buffer != 0) && (buffer->pointer() == NULL))) {
817 ALOGW("CREATE_TRACK: cannot retrieve shared memory");
818 status = DEAD_OBJECT;
819 } else {
820 track = createTrack(
821 (audio_stream_type_t) streamType, sampleRate, format,
Glenn Kasten74935e42013-12-19 08:56:45 -0800822 channelMask, &frameCount, &flags, buffer, output, tid,
Marco Nelissen462fd2f2013-01-14 14:12:05 -0800823 &sessionId, name, clientUid, &status);
Glenn Kasten0cde0762014-01-16 15:06:36 -0800824 LOG_ALWAYS_FATAL_IF((track != 0) != (status == NO_ERROR));
Eric Laurent3d00aa62013-09-24 09:53:27 -0700825 }
Glenn Kasten74935e42013-12-19 08:56:45 -0800826 reply->writeInt32(frameCount);
Glenn Kastene0b07172012-11-06 15:03:34 -0800827 reply->writeInt32(flags);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700828 reply->writeInt32(sessionId);
Glenn Kastend054c322013-07-12 12:59:20 -0700829 reply->writeString8(name);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800830 reply->writeInt32(status);
831 reply->writeStrongBinder(track->asBinder());
832 return NO_ERROR;
833 } break;
834 case OPEN_RECORD: {
835 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800836 audio_io_handle_t input = (audio_io_handle_t) data.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800837 uint32_t sampleRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -0800838 audio_format_t format = (audio_format_t) data.readInt32();
Glenn Kastendd8104c2012-07-02 12:42:44 -0700839 audio_channel_mask_t channelMask = data.readInt32();
Glenn Kastene33054e2012-11-14 12:54:39 -0800840 size_t frameCount = data.readInt32();
Glenn Kastena075db42012-03-06 11:22:44 -0800841 track_flags_t flags = (track_flags_t) data.readInt32();
Glenn Kasten1879fff2012-07-11 15:36:59 -0700842 pid_t tid = (pid_t) data.readInt32();
Eric Laurentbe916aa2010-06-01 23:49:17 -0700843 int sessionId = data.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800844 status_t status;
Glenn Kasten8d6cc842012-02-03 11:06:53 -0800845 sp<IAudioRecord> record = openRecord(input,
Glenn Kasten74935e42013-12-19 08:56:45 -0800846 sampleRate, format, channelMask, &frameCount, &flags, tid, &sessionId, &status);
Glenn Kastene93cf2c2013-09-24 11:52:37 -0700847 LOG_ALWAYS_FATAL_IF((record != 0) != (status == NO_ERROR));
Glenn Kasten74935e42013-12-19 08:56:45 -0800848 reply->writeInt32(frameCount);
Glenn Kasteneeca3262013-07-31 16:12:48 -0700849 reply->writeInt32(flags);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700850 reply->writeInt32(sessionId);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800851 reply->writeInt32(status);
852 reply->writeStrongBinder(record->asBinder());
853 return NO_ERROR;
854 } break;
855 case SAMPLE_RATE: {
856 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800857 reply->writeInt32( sampleRate((audio_io_handle_t) data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800858 return NO_ERROR;
859 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800860 case FORMAT: {
861 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800862 reply->writeInt32( format((audio_io_handle_t) data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800863 return NO_ERROR;
864 } break;
865 case FRAME_COUNT: {
866 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800867 reply->writeInt32( frameCount((audio_io_handle_t) data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800868 return NO_ERROR;
869 } break;
870 case LATENCY: {
871 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800872 reply->writeInt32( latency((audio_io_handle_t) data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800873 return NO_ERROR;
874 } break;
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700875 case SET_MASTER_VOLUME: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800876 CHECK_INTERFACE(IAudioFlinger, data, reply);
877 reply->writeInt32( setMasterVolume(data.readFloat()) );
878 return NO_ERROR;
879 } break;
880 case SET_MASTER_MUTE: {
881 CHECK_INTERFACE(IAudioFlinger, data, reply);
882 reply->writeInt32( setMasterMute(data.readInt32()) );
883 return NO_ERROR;
884 } break;
885 case MASTER_VOLUME: {
886 CHECK_INTERFACE(IAudioFlinger, data, reply);
887 reply->writeFloat( masterVolume() );
888 return NO_ERROR;
889 } break;
890 case MASTER_MUTE: {
891 CHECK_INTERFACE(IAudioFlinger, data, reply);
892 reply->writeInt32( masterMute() );
893 return NO_ERROR;
894 } break;
895 case SET_STREAM_VOLUME: {
896 CHECK_INTERFACE(IAudioFlinger, data, reply);
897 int stream = data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700898 float volume = data.readFloat();
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800899 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -0800900 reply->writeInt32( setStreamVolume((audio_stream_type_t) stream, volume, output) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800901 return NO_ERROR;
902 } break;
903 case SET_STREAM_MUTE: {
904 CHECK_INTERFACE(IAudioFlinger, data, reply);
905 int stream = data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -0800906 reply->writeInt32( setStreamMute((audio_stream_type_t) stream, data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800907 return NO_ERROR;
908 } break;
909 case STREAM_VOLUME: {
910 CHECK_INTERFACE(IAudioFlinger, data, reply);
911 int stream = data.readInt32();
Eric Laurentfa2877b2009-07-28 08:44:33 -0700912 int output = data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -0800913 reply->writeFloat( streamVolume((audio_stream_type_t) stream, output) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800914 return NO_ERROR;
915 } break;
916 case STREAM_MUTE: {
917 CHECK_INTERFACE(IAudioFlinger, data, reply);
918 int stream = data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -0800919 reply->writeInt32( streamMute((audio_stream_type_t) stream) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800920 return NO_ERROR;
921 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800922 case SET_MODE: {
923 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kastenf78aee72012-01-04 11:00:47 -0800924 audio_mode_t mode = (audio_mode_t) data.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800925 reply->writeInt32( setMode(mode) );
926 return NO_ERROR;
927 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800928 case SET_MIC_MUTE: {
929 CHECK_INTERFACE(IAudioFlinger, data, reply);
930 int state = data.readInt32();
931 reply->writeInt32( setMicMute(state) );
932 return NO_ERROR;
933 } break;
934 case GET_MIC_MUTE: {
935 CHECK_INTERFACE(IAudioFlinger, data, reply);
936 reply->writeInt32( getMicMute() );
937 return NO_ERROR;
938 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700939 case SET_PARAMETERS: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800940 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800941 audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700942 String8 keyValuePairs(data.readString8());
943 reply->writeInt32(setParameters(ioHandle, keyValuePairs));
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800944 return NO_ERROR;
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700945 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700946 case GET_PARAMETERS: {
947 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800948 audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700949 String8 keys(data.readString8());
950 reply->writeString8(getParameters(ioHandle, keys));
951 return NO_ERROR;
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700952 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700953
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800954 case REGISTER_CLIENT: {
955 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten85ab62c2012-11-01 11:11:38 -0700956 sp<IAudioFlingerClient> client = interface_cast<IAudioFlingerClient>(
957 data.readStrongBinder());
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800958 registerClient(client);
959 return NO_ERROR;
960 } break;
961 case GET_INPUTBUFFERSIZE: {
962 CHECK_INTERFACE(IAudioFlinger, data, reply);
963 uint32_t sampleRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -0800964 audio_format_t format = (audio_format_t) data.readInt32();
Glenn Kastendd8104c2012-07-02 12:42:44 -0700965 audio_channel_mask_t channelMask = data.readInt32();
966 reply->writeInt32( getInputBufferSize(sampleRate, format, channelMask) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800967 return NO_ERROR;
968 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700969 case OPEN_OUTPUT: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800970 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurenta4c5a552012-03-29 10:12:40 -0700971 audio_module_handle_t module = (audio_module_handle_t)data.readInt32();
972 audio_devices_t devices = (audio_devices_t)data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700973 uint32_t samplingRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -0800974 audio_format_t format = (audio_format_t) data.readInt32();
Eric Laurenta4c5a552012-03-29 10:12:40 -0700975 audio_channel_mask_t channelMask = (audio_channel_mask_t)data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700976 uint32_t latency = data.readInt32();
Eric Laurent0ca3cf92012-04-18 09:24:29 -0700977 audio_output_flags_t flags = (audio_output_flags_t) data.readInt32();
Richard Fitzgeraldb1a270d2013-05-14 12:12:21 +0100978 bool hasOffloadInfo = data.readInt32() != 0;
979 audio_offload_info_t offloadInfo;
980 if (hasOffloadInfo) {
981 data.read(&offloadInfo, sizeof(audio_offload_info_t));
982 }
Eric Laurenta4c5a552012-03-29 10:12:40 -0700983 audio_io_handle_t output = openOutput(module,
984 &devices,
985 &samplingRate,
986 &format,
987 &channelMask,
988 &latency,
Richard Fitzgeraldb1a270d2013-05-14 12:12:21 +0100989 flags,
990 hasOffloadInfo ? &offloadInfo : NULL);
Glenn Kasten70742962014-02-18 08:00:47 -0800991 ALOGV("OPEN_OUTPUT output, %d", output);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800992 reply->writeInt32((int32_t) output);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700993 reply->writeInt32(devices);
994 reply->writeInt32(samplingRate);
995 reply->writeInt32(format);
Eric Laurenta4c5a552012-03-29 10:12:40 -0700996 reply->writeInt32(channelMask);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700997 reply->writeInt32(latency);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800998 return NO_ERROR;
999 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -07001000 case OPEN_DUPLICATE_OUTPUT: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001001 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001002 audio_io_handle_t output1 = (audio_io_handle_t) data.readInt32();
1003 audio_io_handle_t output2 = (audio_io_handle_t) data.readInt32();
1004 reply->writeInt32((int32_t) openDuplicateOutput(output1, output2));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001005 return NO_ERROR;
1006 } break;
1007 case CLOSE_OUTPUT: {
1008 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001009 reply->writeInt32(closeOutput((audio_io_handle_t) data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001010 return NO_ERROR;
1011 } break;
1012 case SUSPEND_OUTPUT: {
1013 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001014 reply->writeInt32(suspendOutput((audio_io_handle_t) data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001015 return NO_ERROR;
1016 } break;
1017 case RESTORE_OUTPUT: {
1018 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001019 reply->writeInt32(restoreOutput((audio_io_handle_t) data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001020 return NO_ERROR;
1021 } break;
1022 case OPEN_INPUT: {
1023 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurenta4c5a552012-03-29 10:12:40 -07001024 audio_module_handle_t module = (audio_module_handle_t)data.readInt32();
1025 audio_devices_t devices = (audio_devices_t)data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -07001026 uint32_t samplingRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -08001027 audio_format_t format = (audio_format_t) data.readInt32();
Eric Laurenta4c5a552012-03-29 10:12:40 -07001028 audio_channel_mask_t channelMask = (audio_channel_mask_t)data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -07001029
Eric Laurenta4c5a552012-03-29 10:12:40 -07001030 audio_io_handle_t input = openInput(module,
1031 &devices,
1032 &samplingRate,
1033 &format,
1034 &channelMask);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001035 reply->writeInt32((int32_t) input);
Eric Laurentc2f1f072009-07-17 12:17:14 -07001036 reply->writeInt32(devices);
1037 reply->writeInt32(samplingRate);
1038 reply->writeInt32(format);
Eric Laurenta4c5a552012-03-29 10:12:40 -07001039 reply->writeInt32(channelMask);
Eric Laurentc2f1f072009-07-17 12:17:14 -07001040 return NO_ERROR;
1041 } break;
1042 case CLOSE_INPUT: {
1043 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001044 reply->writeInt32(closeInput((audio_io_handle_t) data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001045 return NO_ERROR;
1046 } break;
1047 case SET_STREAM_OUTPUT: {
1048 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurentc2f1f072009-07-17 12:17:14 -07001049 uint32_t stream = data.readInt32();
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001050 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -08001051 reply->writeInt32(setStreamOutput((audio_stream_type_t) stream, output));
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001052 return NO_ERROR;
1053 } break;
Eric Laurentf0ee6f42009-10-21 08:14:22 -07001054 case SET_VOICE_VOLUME: {
1055 CHECK_INTERFACE(IAudioFlinger, data, reply);
1056 float volume = data.readFloat();
1057 reply->writeInt32( setVoiceVolume(volume) );
1058 return NO_ERROR;
1059 } break;
Eric Laurent342e9cf2010-01-19 17:37:09 -08001060 case GET_RENDER_POSITION: {
1061 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001062 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Kévin PETIT377b2ec2014-02-03 12:35:36 +00001063 uint32_t halFrames;
1064 uint32_t dspFrames;
Eric Laurent342e9cf2010-01-19 17:37:09 -08001065 status_t status = getRenderPosition(&halFrames, &dspFrames, output);
1066 reply->writeInt32(status);
1067 if (status == NO_ERROR) {
1068 reply->writeInt32(halFrames);
1069 reply->writeInt32(dspFrames);
1070 }
1071 return NO_ERROR;
1072 }
Eric Laurent05bca2f2010-02-26 02:47:27 -08001073 case GET_INPUT_FRAMES_LOST: {
1074 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001075 audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
Glenn Kasten5f972c02014-01-13 09:59:31 -08001076 reply->writeInt32((int32_t) getInputFramesLost(ioHandle));
Eric Laurent05bca2f2010-02-26 02:47:27 -08001077 return NO_ERROR;
1078 } break;
Eric Laurentbe916aa2010-06-01 23:49:17 -07001079 case NEW_AUDIO_SESSION_ID: {
1080 CHECK_INTERFACE(IAudioFlinger, data, reply);
1081 reply->writeInt32(newAudioSessionId());
1082 return NO_ERROR;
1083 } break;
Marco Nelissen3a34bef2011-08-02 13:33:41 -07001084 case ACQUIRE_AUDIO_SESSION_ID: {
1085 CHECK_INTERFACE(IAudioFlinger, data, reply);
1086 int audioSession = data.readInt32();
Marco Nelissend457c972014-02-11 08:47:07 -08001087 int pid = data.readInt32();
1088 acquireAudioSessionId(audioSession, pid);
Marco Nelissen3a34bef2011-08-02 13:33:41 -07001089 return NO_ERROR;
1090 } break;
1091 case RELEASE_AUDIO_SESSION_ID: {
1092 CHECK_INTERFACE(IAudioFlinger, data, reply);
1093 int audioSession = data.readInt32();
Marco Nelissend457c972014-02-11 08:47:07 -08001094 int pid = data.readInt32();
1095 releaseAudioSessionId(audioSession, pid);
Marco Nelissen3a34bef2011-08-02 13:33:41 -07001096 return NO_ERROR;
1097 } break;
Eric Laurentbe916aa2010-06-01 23:49:17 -07001098 case QUERY_NUM_EFFECTS: {
1099 CHECK_INTERFACE(IAudioFlinger, data, reply);
1100 uint32_t numEffects;
1101 status_t status = queryNumberEffects(&numEffects);
1102 reply->writeInt32(status);
1103 if (status == NO_ERROR) {
1104 reply->writeInt32((int32_t)numEffects);
1105 }
1106 return NO_ERROR;
1107 }
Eric Laurentffe9c252010-06-23 17:38:20 -07001108 case QUERY_EFFECT: {
Eric Laurentbe916aa2010-06-01 23:49:17 -07001109 CHECK_INTERFACE(IAudioFlinger, data, reply);
1110 effect_descriptor_t desc;
Eric Laurentffe9c252010-06-23 17:38:20 -07001111 status_t status = queryEffect(data.readInt32(), &desc);
Eric Laurentbe916aa2010-06-01 23:49:17 -07001112 reply->writeInt32(status);
1113 if (status == NO_ERROR) {
1114 reply->write(&desc, sizeof(effect_descriptor_t));
1115 }
1116 return NO_ERROR;
1117 }
1118 case GET_EFFECT_DESCRIPTOR: {
1119 CHECK_INTERFACE(IAudioFlinger, data, reply);
1120 effect_uuid_t uuid;
1121 data.read(&uuid, sizeof(effect_uuid_t));
1122 effect_descriptor_t desc;
1123 status_t status = getEffectDescriptor(&uuid, &desc);
1124 reply->writeInt32(status);
1125 if (status == NO_ERROR) {
1126 reply->write(&desc, sizeof(effect_descriptor_t));
1127 }
1128 return NO_ERROR;
1129 }
1130 case CREATE_EFFECT: {
1131 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurentbe916aa2010-06-01 23:49:17 -07001132 effect_descriptor_t desc;
1133 data.read(&desc, sizeof(effect_descriptor_t));
1134 sp<IEffectClient> client = interface_cast<IEffectClient>(data.readStrongBinder());
1135 int32_t priority = data.readInt32();
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001136 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Eric Laurentbe916aa2010-06-01 23:49:17 -07001137 int sessionId = data.readInt32();
1138 status_t status;
1139 int id;
1140 int enabled;
Eric Laurent05bca2f2010-02-26 02:47:27 -08001141
Glenn Kasten8d6cc842012-02-03 11:06:53 -08001142 sp<IEffect> effect = createEffect(&desc, client, priority, output, sessionId,
Glenn Kasten85ab62c2012-11-01 11:11:38 -07001143 &status, &id, &enabled);
Eric Laurentbe916aa2010-06-01 23:49:17 -07001144 reply->writeInt32(status);
1145 reply->writeInt32(id);
1146 reply->writeInt32(enabled);
1147 reply->writeStrongBinder(effect->asBinder());
1148 reply->write(&desc, sizeof(effect_descriptor_t));
1149 return NO_ERROR;
1150 } break;
Eric Laurentde070132010-07-13 04:45:46 -07001151 case MOVE_EFFECTS: {
1152 CHECK_INTERFACE(IAudioFlinger, data, reply);
1153 int session = data.readInt32();
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001154 audio_io_handle_t srcOutput = (audio_io_handle_t) data.readInt32();
1155 audio_io_handle_t dstOutput = (audio_io_handle_t) data.readInt32();
Eric Laurentde070132010-07-13 04:45:46 -07001156 reply->writeInt32(moveEffects(session, srcOutput, dstOutput));
1157 return NO_ERROR;
1158 } break;
Eric Laurenta4c5a552012-03-29 10:12:40 -07001159 case LOAD_HW_MODULE: {
1160 CHECK_INTERFACE(IAudioFlinger, data, reply);
1161 reply->writeInt32(loadHwModule(data.readCString()));
1162 return NO_ERROR;
1163 } break;
Glenn Kastencc0f1cf2012-09-24 11:27:18 -07001164 case GET_PRIMARY_OUTPUT_SAMPLING_RATE: {
1165 CHECK_INTERFACE(IAudioFlinger, data, reply);
1166 reply->writeInt32(getPrimaryOutputSamplingRate());
1167 return NO_ERROR;
1168 } break;
1169 case GET_PRIMARY_OUTPUT_FRAME_COUNT: {
1170 CHECK_INTERFACE(IAudioFlinger, data, reply);
1171 reply->writeInt32(getPrimaryOutputFrameCount());
1172 return NO_ERROR;
1173 } break;
Glenn Kasten4182c4e2013-07-15 14:45:07 -07001174 case SET_LOW_RAM_DEVICE: {
1175 CHECK_INTERFACE(IAudioFlinger, data, reply);
1176 bool isLowRamDevice = data.readInt32() != 0;
1177 reply->writeInt32(setLowRamDevice(isLowRamDevice));
1178 return NO_ERROR;
1179 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001180 default:
1181 return BBinder::onTransact(code, data, reply, flags);
1182 }
1183}
1184
1185// ----------------------------------------------------------------------------
1186
1187}; // namespace android