blob: a9a9f1a2f0065d6574c112ee732c23d37de293c9 [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,
Glenn Kastend2304db2014-02-03 07:40:31 -080061 INVALIDATE_STREAM,
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 Kastend2304db2014-02-03 07:40:31 -0800548 virtual status_t invalidateStream(audio_stream_type_t stream)
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 Kastend2304db2014-02-03 07:40:31 -0800553 remote()->transact(INVALIDATE_STREAM, data, &reply);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700554 return reply.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800555 }
Eric Laurentf0ee6f42009-10-21 08:14:22 -0700556
557 virtual status_t setVoiceVolume(float volume)
558 {
559 Parcel data, reply;
560 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
561 data.writeFloat(volume);
562 remote()->transact(SET_VOICE_VOLUME, data, &reply);
563 return reply.readInt32();
564 }
Eric Laurent342e9cf2010-01-19 17:37:09 -0800565
Kévin PETIT377b2ec2014-02-03 12:35:36 +0000566 virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames,
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800567 audio_io_handle_t output) const
Eric Laurent342e9cf2010-01-19 17:37:09 -0800568 {
569 Parcel data, reply;
570 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800571 data.writeInt32((int32_t) output);
Eric Laurent342e9cf2010-01-19 17:37:09 -0800572 remote()->transact(GET_RENDER_POSITION, data, &reply);
573 status_t status = reply.readInt32();
574 if (status == NO_ERROR) {
575 uint32_t tmp = reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700576 if (halFrames != NULL) {
Eric Laurent342e9cf2010-01-19 17:37:09 -0800577 *halFrames = tmp;
578 }
579 tmp = reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700580 if (dspFrames != NULL) {
Eric Laurent342e9cf2010-01-19 17:37:09 -0800581 *dspFrames = tmp;
582 }
583 }
584 return status;
585 }
Eric Laurent05bca2f2010-02-26 02:47:27 -0800586
Glenn Kasten5f972c02014-01-13 09:59:31 -0800587 virtual uint32_t getInputFramesLost(audio_io_handle_t ioHandle) const
Eric Laurent05bca2f2010-02-26 02:47:27 -0800588 {
589 Parcel data, reply;
590 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800591 data.writeInt32((int32_t) ioHandle);
Glenn Kasten5f972c02014-01-13 09:59:31 -0800592 status_t status = remote()->transact(GET_INPUT_FRAMES_LOST, data, &reply);
593 if (status != NO_ERROR) {
594 return 0;
595 }
596 return (uint32_t) reply.readInt32();
Eric Laurent05bca2f2010-02-26 02:47:27 -0800597 }
Eric Laurentbe916aa2010-06-01 23:49:17 -0700598
599 virtual int newAudioSessionId()
600 {
601 Parcel data, reply;
602 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
603 status_t status = remote()->transact(NEW_AUDIO_SESSION_ID, data, &reply);
604 int id = 0;
605 if (status == NO_ERROR) {
606 id = reply.readInt32();
607 }
608 return id;
609 }
610
Marco Nelissend457c972014-02-11 08:47:07 -0800611 virtual void acquireAudioSessionId(int audioSession, int pid)
Marco Nelissen3a34bef2011-08-02 13:33:41 -0700612 {
613 Parcel data, reply;
614 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
615 data.writeInt32(audioSession);
Marco Nelissend457c972014-02-11 08:47:07 -0800616 data.writeInt32(pid);
Marco Nelissen3a34bef2011-08-02 13:33:41 -0700617 remote()->transact(ACQUIRE_AUDIO_SESSION_ID, data, &reply);
618 }
619
Marco Nelissend457c972014-02-11 08:47:07 -0800620 virtual void releaseAudioSessionId(int audioSession, int pid)
Marco Nelissen3a34bef2011-08-02 13:33:41 -0700621 {
622 Parcel data, reply;
623 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
624 data.writeInt32(audioSession);
Marco Nelissend457c972014-02-11 08:47:07 -0800625 data.writeInt32(pid);
Marco Nelissen3a34bef2011-08-02 13:33:41 -0700626 remote()->transact(RELEASE_AUDIO_SESSION_ID, data, &reply);
627 }
628
Glenn Kastenf587ba52012-01-26 16:25:10 -0800629 virtual status_t queryNumberEffects(uint32_t *numEffects) const
Eric Laurentbe916aa2010-06-01 23:49:17 -0700630 {
631 Parcel data, reply;
632 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
633 status_t status = remote()->transact(QUERY_NUM_EFFECTS, data, &reply);
634 if (status != NO_ERROR) {
635 return status;
636 }
637 status = reply.readInt32();
638 if (status != NO_ERROR) {
639 return status;
640 }
Glenn Kasten9d1f02d2012-02-08 17:47:58 -0800641 if (numEffects != NULL) {
Eric Laurentbe916aa2010-06-01 23:49:17 -0700642 *numEffects = (uint32_t)reply.readInt32();
643 }
644 return NO_ERROR;
645 }
646
Glenn Kastenf587ba52012-01-26 16:25:10 -0800647 virtual status_t queryEffect(uint32_t index, effect_descriptor_t *pDescriptor) const
Eric Laurentbe916aa2010-06-01 23:49:17 -0700648 {
649 if (pDescriptor == NULL) {
650 return BAD_VALUE;
651 }
652 Parcel data, reply;
653 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentffe9c252010-06-23 17:38:20 -0700654 data.writeInt32(index);
655 status_t status = remote()->transact(QUERY_EFFECT, data, &reply);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700656 if (status != NO_ERROR) {
657 return status;
658 }
659 status = reply.readInt32();
660 if (status != NO_ERROR) {
661 return status;
662 }
663 reply.read(pDescriptor, sizeof(effect_descriptor_t));
664 return NO_ERROR;
665 }
666
Glenn Kasten5e92a782012-01-30 07:40:52 -0800667 virtual status_t getEffectDescriptor(const effect_uuid_t *pUuid,
Glenn Kastenf587ba52012-01-26 16:25:10 -0800668 effect_descriptor_t *pDescriptor) const
Eric Laurentbe916aa2010-06-01 23:49:17 -0700669 {
670 if (pUuid == NULL || pDescriptor == NULL) {
671 return BAD_VALUE;
672 }
673 Parcel data, reply;
674 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
675 data.write(pUuid, sizeof(effect_uuid_t));
676 status_t status = remote()->transact(GET_EFFECT_DESCRIPTOR, data, &reply);
677 if (status != NO_ERROR) {
678 return status;
679 }
680 status = reply.readInt32();
681 if (status != NO_ERROR) {
682 return status;
683 }
684 reply.read(pDescriptor, sizeof(effect_descriptor_t));
685 return NO_ERROR;
686 }
687
Glenn Kasten8d6cc842012-02-03 11:06:53 -0800688 virtual sp<IEffect> createEffect(
Eric Laurentbe916aa2010-06-01 23:49:17 -0700689 effect_descriptor_t *pDesc,
690 const sp<IEffectClient>& client,
691 int32_t priority,
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800692 audio_io_handle_t output,
Eric Laurentbe916aa2010-06-01 23:49:17 -0700693 int sessionId,
694 status_t *status,
695 int *id,
696 int *enabled)
697 {
698 Parcel data, reply;
699 sp<IEffect> effect;
700
701 if (pDesc == NULL) {
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700702 return effect;
Glenn Kasten507b2862013-07-31 16:12:13 -0700703 if (status != NULL) {
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700704 *status = BAD_VALUE;
705 }
706 }
Eric Laurentbe916aa2010-06-01 23:49:17 -0700707
708 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentbe916aa2010-06-01 23:49:17 -0700709 data.write(pDesc, sizeof(effect_descriptor_t));
710 data.writeStrongBinder(client->asBinder());
711 data.writeInt32(priority);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800712 data.writeInt32((int32_t) output);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700713 data.writeInt32(sessionId);
714
715 status_t lStatus = remote()->transact(CREATE_EFFECT, data, &reply);
716 if (lStatus != NO_ERROR) {
Steve Block29357bc2012-01-06 19:20:56 +0000717 ALOGE("createEffect error: %s", strerror(-lStatus));
Eric Laurentbe916aa2010-06-01 23:49:17 -0700718 } else {
719 lStatus = reply.readInt32();
720 int tmp = reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700721 if (id != NULL) {
Eric Laurentbe916aa2010-06-01 23:49:17 -0700722 *id = tmp;
723 }
724 tmp = reply.readInt32();
Glenn Kastena0d68332012-01-27 16:47:15 -0800725 if (enabled != NULL) {
Eric Laurentbe916aa2010-06-01 23:49:17 -0700726 *enabled = tmp;
727 }
728 effect = interface_cast<IEffect>(reply.readStrongBinder());
729 reply.read(pDesc, sizeof(effect_descriptor_t));
730 }
Glenn Kasten507b2862013-07-31 16:12:13 -0700731 if (status != NULL) {
Eric Laurentbe916aa2010-06-01 23:49:17 -0700732 *status = lStatus;
733 }
734
735 return effect;
736 }
Eric Laurentde070132010-07-13 04:45:46 -0700737
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800738 virtual status_t moveEffects(int session, audio_io_handle_t srcOutput,
739 audio_io_handle_t dstOutput)
Eric Laurentde070132010-07-13 04:45:46 -0700740 {
741 Parcel data, reply;
742 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
743 data.writeInt32(session);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800744 data.writeInt32((int32_t) srcOutput);
745 data.writeInt32((int32_t) dstOutput);
Eric Laurentde070132010-07-13 04:45:46 -0700746 remote()->transact(MOVE_EFFECTS, data, &reply);
747 return reply.readInt32();
748 }
Eric Laurenta4c5a552012-03-29 10:12:40 -0700749
750 virtual audio_module_handle_t loadHwModule(const char *name)
751 {
752 Parcel data, reply;
753 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
754 data.writeCString(name);
755 remote()->transact(LOAD_HW_MODULE, data, &reply);
756 return (audio_module_handle_t) reply.readInt32();
757 }
Glenn Kastencc0f1cf2012-09-24 11:27:18 -0700758
Glenn Kasten3b16c762012-11-14 08:44:39 -0800759 virtual uint32_t getPrimaryOutputSamplingRate()
Glenn Kastencc0f1cf2012-09-24 11:27:18 -0700760 {
761 Parcel data, reply;
762 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
763 remote()->transact(GET_PRIMARY_OUTPUT_SAMPLING_RATE, data, &reply);
764 return reply.readInt32();
765 }
766
Glenn Kastene33054e2012-11-14 12:54:39 -0800767 virtual size_t getPrimaryOutputFrameCount()
Glenn Kastencc0f1cf2012-09-24 11:27:18 -0700768 {
769 Parcel data, reply;
770 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
771 remote()->transact(GET_PRIMARY_OUTPUT_FRAME_COUNT, data, &reply);
772 return reply.readInt32();
773 }
774
Glenn Kasten4182c4e2013-07-15 14:45:07 -0700775 virtual status_t setLowRamDevice(bool isLowRamDevice)
776 {
777 Parcel data, reply;
778 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
779 data.writeInt32((int) isLowRamDevice);
780 remote()->transact(SET_LOW_RAM_DEVICE, data, &reply);
781 return reply.readInt32();
782 }
783
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800784};
785
786IMPLEMENT_META_INTERFACE(AudioFlinger, "android.media.IAudioFlinger");
787
788// ----------------------------------------------------------------------
789
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800790status_t BnAudioFlinger::onTransact(
791 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
792{
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700793 switch (code) {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800794 case CREATE_TRACK: {
795 CHECK_INTERFACE(IAudioFlinger, data, reply);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800796 int streamType = data.readInt32();
797 uint32_t sampleRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -0800798 audio_format_t format = (audio_format_t) data.readInt32();
Glenn Kastendd8104c2012-07-02 12:42:44 -0700799 audio_channel_mask_t channelMask = data.readInt32();
Glenn Kastene33054e2012-11-14 12:54:39 -0800800 size_t frameCount = data.readInt32();
Glenn Kastena075db42012-03-06 11:22:44 -0800801 track_flags_t flags = (track_flags_t) data.readInt32();
Eric Laurent3d00aa62013-09-24 09:53:27 -0700802 bool haveSharedBuffer = data.readInt32() != 0;
803 sp<IMemory> buffer;
804 if (haveSharedBuffer) {
805 buffer = interface_cast<IMemory>(data.readStrongBinder());
806 }
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800807 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Glenn Kasten3acbd052012-02-28 10:39:56 -0800808 pid_t tid = (pid_t) data.readInt32();
Eric Laurentbe916aa2010-06-01 23:49:17 -0700809 int sessionId = data.readInt32();
Marco Nelissen462fd2f2013-01-14 14:12:05 -0800810 int clientUid = data.readInt32();
Glenn Kastend054c322013-07-12 12:59:20 -0700811 String8 name;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800812 status_t status;
Eric Laurent3d00aa62013-09-24 09:53:27 -0700813 sp<IAudioTrack> track;
814 if ((haveSharedBuffer && (buffer == 0)) ||
815 ((buffer != 0) && (buffer->pointer() == NULL))) {
816 ALOGW("CREATE_TRACK: cannot retrieve shared memory");
817 status = DEAD_OBJECT;
818 } else {
819 track = createTrack(
820 (audio_stream_type_t) streamType, sampleRate, format,
Glenn Kasten74935e42013-12-19 08:56:45 -0800821 channelMask, &frameCount, &flags, buffer, output, tid,
Marco Nelissen462fd2f2013-01-14 14:12:05 -0800822 &sessionId, name, clientUid, &status);
Glenn Kasten0cde0762014-01-16 15:06:36 -0800823 LOG_ALWAYS_FATAL_IF((track != 0) != (status == NO_ERROR));
Eric Laurent3d00aa62013-09-24 09:53:27 -0700824 }
Glenn Kasten74935e42013-12-19 08:56:45 -0800825 reply->writeInt32(frameCount);
Glenn Kastene0b07172012-11-06 15:03:34 -0800826 reply->writeInt32(flags);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700827 reply->writeInt32(sessionId);
Glenn Kastend054c322013-07-12 12:59:20 -0700828 reply->writeString8(name);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800829 reply->writeInt32(status);
830 reply->writeStrongBinder(track->asBinder());
831 return NO_ERROR;
832 } break;
833 case OPEN_RECORD: {
834 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800835 audio_io_handle_t input = (audio_io_handle_t) data.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800836 uint32_t sampleRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -0800837 audio_format_t format = (audio_format_t) data.readInt32();
Glenn Kastendd8104c2012-07-02 12:42:44 -0700838 audio_channel_mask_t channelMask = data.readInt32();
Glenn Kastene33054e2012-11-14 12:54:39 -0800839 size_t frameCount = data.readInt32();
Glenn Kastena075db42012-03-06 11:22:44 -0800840 track_flags_t flags = (track_flags_t) data.readInt32();
Glenn Kasten1879fff2012-07-11 15:36:59 -0700841 pid_t tid = (pid_t) data.readInt32();
Eric Laurentbe916aa2010-06-01 23:49:17 -0700842 int sessionId = data.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800843 status_t status;
Glenn Kasten8d6cc842012-02-03 11:06:53 -0800844 sp<IAudioRecord> record = openRecord(input,
Glenn Kasten74935e42013-12-19 08:56:45 -0800845 sampleRate, format, channelMask, &frameCount, &flags, tid, &sessionId, &status);
Glenn Kastene93cf2c2013-09-24 11:52:37 -0700846 LOG_ALWAYS_FATAL_IF((record != 0) != (status == NO_ERROR));
Glenn Kasten74935e42013-12-19 08:56:45 -0800847 reply->writeInt32(frameCount);
Glenn Kasteneeca3262013-07-31 16:12:48 -0700848 reply->writeInt32(flags);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700849 reply->writeInt32(sessionId);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800850 reply->writeInt32(status);
851 reply->writeStrongBinder(record->asBinder());
852 return NO_ERROR;
853 } break;
854 case SAMPLE_RATE: {
855 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800856 reply->writeInt32( sampleRate((audio_io_handle_t) data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800857 return NO_ERROR;
858 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800859 case FORMAT: {
860 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800861 reply->writeInt32( format((audio_io_handle_t) data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800862 return NO_ERROR;
863 } break;
864 case FRAME_COUNT: {
865 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800866 reply->writeInt32( frameCount((audio_io_handle_t) data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800867 return NO_ERROR;
868 } break;
869 case LATENCY: {
870 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800871 reply->writeInt32( latency((audio_io_handle_t) data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800872 return NO_ERROR;
873 } break;
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700874 case SET_MASTER_VOLUME: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800875 CHECK_INTERFACE(IAudioFlinger, data, reply);
876 reply->writeInt32( setMasterVolume(data.readFloat()) );
877 return NO_ERROR;
878 } break;
879 case SET_MASTER_MUTE: {
880 CHECK_INTERFACE(IAudioFlinger, data, reply);
881 reply->writeInt32( setMasterMute(data.readInt32()) );
882 return NO_ERROR;
883 } break;
884 case MASTER_VOLUME: {
885 CHECK_INTERFACE(IAudioFlinger, data, reply);
886 reply->writeFloat( masterVolume() );
887 return NO_ERROR;
888 } break;
889 case MASTER_MUTE: {
890 CHECK_INTERFACE(IAudioFlinger, data, reply);
891 reply->writeInt32( masterMute() );
892 return NO_ERROR;
893 } break;
894 case SET_STREAM_VOLUME: {
895 CHECK_INTERFACE(IAudioFlinger, data, reply);
896 int stream = data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700897 float volume = data.readFloat();
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800898 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -0800899 reply->writeInt32( setStreamVolume((audio_stream_type_t) stream, volume, output) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800900 return NO_ERROR;
901 } break;
902 case SET_STREAM_MUTE: {
903 CHECK_INTERFACE(IAudioFlinger, data, reply);
904 int stream = data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -0800905 reply->writeInt32( setStreamMute((audio_stream_type_t) stream, data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800906 return NO_ERROR;
907 } break;
908 case STREAM_VOLUME: {
909 CHECK_INTERFACE(IAudioFlinger, data, reply);
910 int stream = data.readInt32();
Eric Laurentfa2877b2009-07-28 08:44:33 -0700911 int output = data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -0800912 reply->writeFloat( streamVolume((audio_stream_type_t) stream, output) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800913 return NO_ERROR;
914 } break;
915 case STREAM_MUTE: {
916 CHECK_INTERFACE(IAudioFlinger, data, reply);
917 int stream = data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -0800918 reply->writeInt32( streamMute((audio_stream_type_t) stream) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800919 return NO_ERROR;
920 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800921 case SET_MODE: {
922 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kastenf78aee72012-01-04 11:00:47 -0800923 audio_mode_t mode = (audio_mode_t) data.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800924 reply->writeInt32( setMode(mode) );
925 return NO_ERROR;
926 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800927 case SET_MIC_MUTE: {
928 CHECK_INTERFACE(IAudioFlinger, data, reply);
929 int state = data.readInt32();
930 reply->writeInt32( setMicMute(state) );
931 return NO_ERROR;
932 } break;
933 case GET_MIC_MUTE: {
934 CHECK_INTERFACE(IAudioFlinger, data, reply);
935 reply->writeInt32( getMicMute() );
936 return NO_ERROR;
937 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700938 case SET_PARAMETERS: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800939 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800940 audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700941 String8 keyValuePairs(data.readString8());
942 reply->writeInt32(setParameters(ioHandle, keyValuePairs));
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800943 return NO_ERROR;
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700944 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700945 case GET_PARAMETERS: {
946 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800947 audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700948 String8 keys(data.readString8());
949 reply->writeString8(getParameters(ioHandle, keys));
950 return NO_ERROR;
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700951 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700952
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800953 case REGISTER_CLIENT: {
954 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten85ab62c2012-11-01 11:11:38 -0700955 sp<IAudioFlingerClient> client = interface_cast<IAudioFlingerClient>(
956 data.readStrongBinder());
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800957 registerClient(client);
958 return NO_ERROR;
959 } break;
960 case GET_INPUTBUFFERSIZE: {
961 CHECK_INTERFACE(IAudioFlinger, data, reply);
962 uint32_t sampleRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -0800963 audio_format_t format = (audio_format_t) data.readInt32();
Glenn Kastendd8104c2012-07-02 12:42:44 -0700964 audio_channel_mask_t channelMask = data.readInt32();
965 reply->writeInt32( getInputBufferSize(sampleRate, format, channelMask) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800966 return NO_ERROR;
967 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700968 case OPEN_OUTPUT: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800969 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurenta4c5a552012-03-29 10:12:40 -0700970 audio_module_handle_t module = (audio_module_handle_t)data.readInt32();
971 audio_devices_t devices = (audio_devices_t)data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700972 uint32_t samplingRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -0800973 audio_format_t format = (audio_format_t) data.readInt32();
Eric Laurenta4c5a552012-03-29 10:12:40 -0700974 audio_channel_mask_t channelMask = (audio_channel_mask_t)data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700975 uint32_t latency = data.readInt32();
Eric Laurent0ca3cf92012-04-18 09:24:29 -0700976 audio_output_flags_t flags = (audio_output_flags_t) data.readInt32();
Richard Fitzgeraldb1a270d2013-05-14 12:12:21 +0100977 bool hasOffloadInfo = data.readInt32() != 0;
978 audio_offload_info_t offloadInfo;
979 if (hasOffloadInfo) {
980 data.read(&offloadInfo, sizeof(audio_offload_info_t));
981 }
Eric Laurenta4c5a552012-03-29 10:12:40 -0700982 audio_io_handle_t output = openOutput(module,
983 &devices,
984 &samplingRate,
985 &format,
986 &channelMask,
987 &latency,
Richard Fitzgeraldb1a270d2013-05-14 12:12:21 +0100988 flags,
989 hasOffloadInfo ? &offloadInfo : NULL);
Glenn Kasten70742962014-02-18 08:00:47 -0800990 ALOGV("OPEN_OUTPUT output, %d", output);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800991 reply->writeInt32((int32_t) output);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700992 reply->writeInt32(devices);
993 reply->writeInt32(samplingRate);
994 reply->writeInt32(format);
Eric Laurenta4c5a552012-03-29 10:12:40 -0700995 reply->writeInt32(channelMask);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700996 reply->writeInt32(latency);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800997 return NO_ERROR;
998 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700999 case OPEN_DUPLICATE_OUTPUT: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001000 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001001 audio_io_handle_t output1 = (audio_io_handle_t) data.readInt32();
1002 audio_io_handle_t output2 = (audio_io_handle_t) data.readInt32();
1003 reply->writeInt32((int32_t) openDuplicateOutput(output1, output2));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001004 return NO_ERROR;
1005 } break;
1006 case CLOSE_OUTPUT: {
1007 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001008 reply->writeInt32(closeOutput((audio_io_handle_t) data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001009 return NO_ERROR;
1010 } break;
1011 case SUSPEND_OUTPUT: {
1012 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001013 reply->writeInt32(suspendOutput((audio_io_handle_t) data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001014 return NO_ERROR;
1015 } break;
1016 case RESTORE_OUTPUT: {
1017 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001018 reply->writeInt32(restoreOutput((audio_io_handle_t) data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001019 return NO_ERROR;
1020 } break;
1021 case OPEN_INPUT: {
1022 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurenta4c5a552012-03-29 10:12:40 -07001023 audio_module_handle_t module = (audio_module_handle_t)data.readInt32();
1024 audio_devices_t devices = (audio_devices_t)data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -07001025 uint32_t samplingRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -08001026 audio_format_t format = (audio_format_t) data.readInt32();
Eric Laurenta4c5a552012-03-29 10:12:40 -07001027 audio_channel_mask_t channelMask = (audio_channel_mask_t)data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -07001028
Eric Laurenta4c5a552012-03-29 10:12:40 -07001029 audio_io_handle_t input = openInput(module,
1030 &devices,
1031 &samplingRate,
1032 &format,
1033 &channelMask);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001034 reply->writeInt32((int32_t) input);
Eric Laurentc2f1f072009-07-17 12:17:14 -07001035 reply->writeInt32(devices);
1036 reply->writeInt32(samplingRate);
1037 reply->writeInt32(format);
Eric Laurenta4c5a552012-03-29 10:12:40 -07001038 reply->writeInt32(channelMask);
Eric Laurentc2f1f072009-07-17 12:17:14 -07001039 return NO_ERROR;
1040 } break;
1041 case CLOSE_INPUT: {
1042 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001043 reply->writeInt32(closeInput((audio_io_handle_t) data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001044 return NO_ERROR;
1045 } break;
Glenn Kastend2304db2014-02-03 07:40:31 -08001046 case INVALIDATE_STREAM: {
Eric Laurentc2f1f072009-07-17 12:17:14 -07001047 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kastend2304db2014-02-03 07:40:31 -08001048 audio_stream_type_t stream = (audio_stream_type_t) data.readInt32();
1049 reply->writeInt32(invalidateStream(stream));
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001050 return NO_ERROR;
1051 } break;
Eric Laurentf0ee6f42009-10-21 08:14:22 -07001052 case SET_VOICE_VOLUME: {
1053 CHECK_INTERFACE(IAudioFlinger, data, reply);
1054 float volume = data.readFloat();
1055 reply->writeInt32( setVoiceVolume(volume) );
1056 return NO_ERROR;
1057 } break;
Eric Laurent342e9cf2010-01-19 17:37:09 -08001058 case GET_RENDER_POSITION: {
1059 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001060 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Kévin PETIT377b2ec2014-02-03 12:35:36 +00001061 uint32_t halFrames;
1062 uint32_t dspFrames;
Eric Laurent342e9cf2010-01-19 17:37:09 -08001063 status_t status = getRenderPosition(&halFrames, &dspFrames, output);
1064 reply->writeInt32(status);
1065 if (status == NO_ERROR) {
1066 reply->writeInt32(halFrames);
1067 reply->writeInt32(dspFrames);
1068 }
1069 return NO_ERROR;
1070 }
Eric Laurent05bca2f2010-02-26 02:47:27 -08001071 case GET_INPUT_FRAMES_LOST: {
1072 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001073 audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
Glenn Kasten5f972c02014-01-13 09:59:31 -08001074 reply->writeInt32((int32_t) getInputFramesLost(ioHandle));
Eric Laurent05bca2f2010-02-26 02:47:27 -08001075 return NO_ERROR;
1076 } break;
Eric Laurentbe916aa2010-06-01 23:49:17 -07001077 case NEW_AUDIO_SESSION_ID: {
1078 CHECK_INTERFACE(IAudioFlinger, data, reply);
1079 reply->writeInt32(newAudioSessionId());
1080 return NO_ERROR;
1081 } break;
Marco Nelissen3a34bef2011-08-02 13:33:41 -07001082 case ACQUIRE_AUDIO_SESSION_ID: {
1083 CHECK_INTERFACE(IAudioFlinger, data, reply);
1084 int audioSession = data.readInt32();
Marco Nelissend457c972014-02-11 08:47:07 -08001085 int pid = data.readInt32();
1086 acquireAudioSessionId(audioSession, pid);
Marco Nelissen3a34bef2011-08-02 13:33:41 -07001087 return NO_ERROR;
1088 } break;
1089 case RELEASE_AUDIO_SESSION_ID: {
1090 CHECK_INTERFACE(IAudioFlinger, data, reply);
1091 int audioSession = data.readInt32();
Marco Nelissend457c972014-02-11 08:47:07 -08001092 int pid = data.readInt32();
1093 releaseAudioSessionId(audioSession, pid);
Marco Nelissen3a34bef2011-08-02 13:33:41 -07001094 return NO_ERROR;
1095 } break;
Eric Laurentbe916aa2010-06-01 23:49:17 -07001096 case QUERY_NUM_EFFECTS: {
1097 CHECK_INTERFACE(IAudioFlinger, data, reply);
1098 uint32_t numEffects;
1099 status_t status = queryNumberEffects(&numEffects);
1100 reply->writeInt32(status);
1101 if (status == NO_ERROR) {
1102 reply->writeInt32((int32_t)numEffects);
1103 }
1104 return NO_ERROR;
1105 }
Eric Laurentffe9c252010-06-23 17:38:20 -07001106 case QUERY_EFFECT: {
Eric Laurentbe916aa2010-06-01 23:49:17 -07001107 CHECK_INTERFACE(IAudioFlinger, data, reply);
1108 effect_descriptor_t desc;
Eric Laurentffe9c252010-06-23 17:38:20 -07001109 status_t status = queryEffect(data.readInt32(), &desc);
Eric Laurentbe916aa2010-06-01 23:49:17 -07001110 reply->writeInt32(status);
1111 if (status == NO_ERROR) {
1112 reply->write(&desc, sizeof(effect_descriptor_t));
1113 }
1114 return NO_ERROR;
1115 }
1116 case GET_EFFECT_DESCRIPTOR: {
1117 CHECK_INTERFACE(IAudioFlinger, data, reply);
1118 effect_uuid_t uuid;
1119 data.read(&uuid, sizeof(effect_uuid_t));
1120 effect_descriptor_t desc;
1121 status_t status = getEffectDescriptor(&uuid, &desc);
1122 reply->writeInt32(status);
1123 if (status == NO_ERROR) {
1124 reply->write(&desc, sizeof(effect_descriptor_t));
1125 }
1126 return NO_ERROR;
1127 }
1128 case CREATE_EFFECT: {
1129 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurentbe916aa2010-06-01 23:49:17 -07001130 effect_descriptor_t desc;
1131 data.read(&desc, sizeof(effect_descriptor_t));
1132 sp<IEffectClient> client = interface_cast<IEffectClient>(data.readStrongBinder());
1133 int32_t priority = data.readInt32();
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001134 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Eric Laurentbe916aa2010-06-01 23:49:17 -07001135 int sessionId = data.readInt32();
1136 status_t status;
1137 int id;
1138 int enabled;
Eric Laurent05bca2f2010-02-26 02:47:27 -08001139
Glenn Kasten8d6cc842012-02-03 11:06:53 -08001140 sp<IEffect> effect = createEffect(&desc, client, priority, output, sessionId,
Glenn Kasten85ab62c2012-11-01 11:11:38 -07001141 &status, &id, &enabled);
Eric Laurentbe916aa2010-06-01 23:49:17 -07001142 reply->writeInt32(status);
1143 reply->writeInt32(id);
1144 reply->writeInt32(enabled);
1145 reply->writeStrongBinder(effect->asBinder());
1146 reply->write(&desc, sizeof(effect_descriptor_t));
1147 return NO_ERROR;
1148 } break;
Eric Laurentde070132010-07-13 04:45:46 -07001149 case MOVE_EFFECTS: {
1150 CHECK_INTERFACE(IAudioFlinger, data, reply);
1151 int session = data.readInt32();
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001152 audio_io_handle_t srcOutput = (audio_io_handle_t) data.readInt32();
1153 audio_io_handle_t dstOutput = (audio_io_handle_t) data.readInt32();
Eric Laurentde070132010-07-13 04:45:46 -07001154 reply->writeInt32(moveEffects(session, srcOutput, dstOutput));
1155 return NO_ERROR;
1156 } break;
Eric Laurenta4c5a552012-03-29 10:12:40 -07001157 case LOAD_HW_MODULE: {
1158 CHECK_INTERFACE(IAudioFlinger, data, reply);
1159 reply->writeInt32(loadHwModule(data.readCString()));
1160 return NO_ERROR;
1161 } break;
Glenn Kastencc0f1cf2012-09-24 11:27:18 -07001162 case GET_PRIMARY_OUTPUT_SAMPLING_RATE: {
1163 CHECK_INTERFACE(IAudioFlinger, data, reply);
1164 reply->writeInt32(getPrimaryOutputSamplingRate());
1165 return NO_ERROR;
1166 } break;
1167 case GET_PRIMARY_OUTPUT_FRAME_COUNT: {
1168 CHECK_INTERFACE(IAudioFlinger, data, reply);
1169 reply->writeInt32(getPrimaryOutputFrameCount());
1170 return NO_ERROR;
1171 } break;
Glenn Kasten4182c4e2013-07-15 14:45:07 -07001172 case SET_LOW_RAM_DEVICE: {
1173 CHECK_INTERFACE(IAudioFlinger, data, reply);
1174 bool isLowRamDevice = data.readInt32() != 0;
1175 reply->writeInt32(setLowRamDevice(isLowRamDevice));
1176 return NO_ERROR;
1177 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001178 default:
1179 return BBinder::onTransact(code, data, reply, flags);
1180 }
1181}
1182
1183// ----------------------------------------------------------------------------
1184
1185}; // namespace android