blob: f28b82dbf0f3d626a745616a4d3abb203b7e1d2b [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,
Marco Nelissen462fd2f2013-01-14 14:12:05 -080098 int clientUid,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080099 status_t *status)
100 {
101 Parcel data, reply;
Eric Laurent5841db72009-09-09 05:16:08 -0700102 sp<IAudioTrack> track;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800103 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800104 data.writeInt32((int32_t) streamType);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800105 data.writeInt32(sampleRate);
106 data.writeInt32(format);
Jean-Michel Trivi0d255b22011-05-24 15:53:33 -0700107 data.writeInt32(channelMask);
Glenn Kasten74935e42013-12-19 08:56:45 -0800108 size_t frameCount = pFrameCount != NULL ? *pFrameCount : 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800109 data.writeInt32(frameCount);
Glenn Kastenb26e3e92012-11-14 08:32:08 -0800110 track_flags_t lFlags = flags != NULL ? *flags : (track_flags_t) TRACK_DEFAULT;
Glenn Kastene0b07172012-11-06 15:03:34 -0800111 data.writeInt32(lFlags);
Eric Laurent3d00aa62013-09-24 09:53:27 -0700112 if (sharedBuffer != 0) {
113 data.writeInt32(true);
114 data.writeStrongBinder(sharedBuffer->asBinder());
115 } else {
116 data.writeInt32(false);
117 }
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800118 data.writeInt32((int32_t) output);
Glenn Kasten3acbd052012-02-28 10:39:56 -0800119 data.writeInt32((int32_t) tid);
Glenn Kastenaea7ea02013-06-26 09:25:47 -0700120 int lSessionId = AUDIO_SESSION_ALLOCATE;
Eric Laurentbe916aa2010-06-01 23:49:17 -0700121 if (sessionId != NULL) {
122 lSessionId = *sessionId;
123 }
124 data.writeInt32(lSessionId);
Marco Nelissen462fd2f2013-01-14 14:12:05 -0800125 data.writeInt32(clientUid);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800126 status_t lStatus = remote()->transact(CREATE_TRACK, data, &reply);
127 if (lStatus != NO_ERROR) {
Steve Block29357bc2012-01-06 19:20:56 +0000128 ALOGE("createTrack error: %s", strerror(-lStatus));
Eric Laurent5841db72009-09-09 05:16:08 -0700129 } else {
Glenn Kasten74935e42013-12-19 08:56:45 -0800130 frameCount = reply.readInt32();
131 if (pFrameCount != NULL) {
132 *pFrameCount = frameCount;
133 }
Glenn Kastene0b07172012-11-06 15:03:34 -0800134 lFlags = reply.readInt32();
135 if (flags != NULL) {
136 *flags = lFlags;
137 }
Eric Laurentbe916aa2010-06-01 23:49:17 -0700138 lSessionId = reply.readInt32();
139 if (sessionId != NULL) {
140 *sessionId = lSessionId;
141 }
Eric Laurent5841db72009-09-09 05:16:08 -0700142 lStatus = reply.readInt32();
143 track = interface_cast<IAudioTrack>(reply.readStrongBinder());
Glenn Kasten0cde0762014-01-16 15:06:36 -0800144 if (lStatus == NO_ERROR) {
145 if (track == 0) {
146 ALOGE("createTrack should have returned an IAudioTrack");
147 lStatus = UNKNOWN_ERROR;
148 }
149 } else {
150 if (track != 0) {
151 ALOGE("createTrack returned an IAudioTrack but with status %d", lStatus);
152 track.clear();
153 }
154 }
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800155 }
Glenn Kasten507b2862013-07-31 16:12:13 -0700156 if (status != NULL) {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800157 *status = lStatus;
158 }
Eric Laurent5841db72009-09-09 05:16:08 -0700159 return track;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800160 }
161
162 virtual sp<IAudioRecord> openRecord(
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800163 audio_io_handle_t input,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800164 uint32_t sampleRate,
Glenn Kasten58f30212012-01-12 12:27:51 -0800165 audio_format_t format,
Glenn Kasten28b76b32012-07-03 17:24:41 -0700166 audio_channel_mask_t channelMask,
Glenn Kasten74935e42013-12-19 08:56:45 -0800167 size_t *pFrameCount,
Glenn Kasteneeca3262013-07-31 16:12:48 -0700168 track_flags_t *flags,
Glenn Kasten1879fff2012-07-11 15:36:59 -0700169 pid_t tid,
Eric Laurentbe916aa2010-06-01 23:49:17 -0700170 int *sessionId,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800171 status_t *status)
172 {
173 Parcel data, reply;
Eric Laurent5841db72009-09-09 05:16:08 -0700174 sp<IAudioRecord> record;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800175 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800176 data.writeInt32((int32_t) input);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800177 data.writeInt32(sampleRate);
178 data.writeInt32(format);
Jean-Michel Trivi0d255b22011-05-24 15:53:33 -0700179 data.writeInt32(channelMask);
Glenn Kasten74935e42013-12-19 08:56:45 -0800180 size_t frameCount = pFrameCount != NULL ? *pFrameCount : 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800181 data.writeInt32(frameCount);
Glenn Kasteneeca3262013-07-31 16:12:48 -0700182 track_flags_t lFlags = flags != NULL ? *flags : (track_flags_t) TRACK_DEFAULT;
183 data.writeInt32(lFlags);
Glenn Kasten1879fff2012-07-11 15:36:59 -0700184 data.writeInt32((int32_t) tid);
Glenn Kastenaea7ea02013-06-26 09:25:47 -0700185 int lSessionId = AUDIO_SESSION_ALLOCATE;
Eric Laurentbe916aa2010-06-01 23:49:17 -0700186 if (sessionId != NULL) {
187 lSessionId = *sessionId;
188 }
189 data.writeInt32(lSessionId);
Eric Laurent5841db72009-09-09 05:16:08 -0700190 status_t lStatus = remote()->transact(OPEN_RECORD, data, &reply);
191 if (lStatus != NO_ERROR) {
Steve Block29357bc2012-01-06 19:20:56 +0000192 ALOGE("openRecord error: %s", strerror(-lStatus));
Eric Laurent5841db72009-09-09 05:16:08 -0700193 } else {
Glenn Kasten74935e42013-12-19 08:56:45 -0800194 frameCount = reply.readInt32();
195 if (pFrameCount != NULL) {
196 *pFrameCount = frameCount;
197 }
Glenn Kasteneeca3262013-07-31 16:12:48 -0700198 lFlags = reply.readInt32();
199 if (flags != NULL) {
200 *flags = lFlags;
201 }
Eric Laurentbe916aa2010-06-01 23:49:17 -0700202 lSessionId = reply.readInt32();
203 if (sessionId != NULL) {
204 *sessionId = lSessionId;
205 }
Eric Laurent5841db72009-09-09 05:16:08 -0700206 lStatus = reply.readInt32();
207 record = interface_cast<IAudioRecord>(reply.readStrongBinder());
Glenn Kastene93cf2c2013-09-24 11:52:37 -0700208 if (lStatus == NO_ERROR) {
209 if (record == 0) {
210 ALOGE("openRecord should have returned an IAudioRecord");
211 lStatus = UNKNOWN_ERROR;
212 }
213 } else {
214 if (record != 0) {
215 ALOGE("openRecord returned an IAudioRecord but with status %d", lStatus);
216 record.clear();
217 }
218 }
Eric Laurent5841db72009-09-09 05:16:08 -0700219 }
Glenn Kasten507b2862013-07-31 16:12:13 -0700220 if (status != NULL) {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800221 *status = lStatus;
222 }
Eric Laurent5841db72009-09-09 05:16:08 -0700223 return record;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800224 }
225
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800226 virtual uint32_t sampleRate(audio_io_handle_t output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800227 {
228 Parcel data, reply;
229 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800230 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800231 remote()->transact(SAMPLE_RATE, data, &reply);
232 return reply.readInt32();
233 }
234
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800235 virtual audio_format_t format(audio_io_handle_t output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800236 {
237 Parcel data, reply;
238 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800239 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800240 remote()->transact(FORMAT, data, &reply);
Glenn Kasten58f30212012-01-12 12:27:51 -0800241 return (audio_format_t) reply.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800242 }
243
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800244 virtual size_t frameCount(audio_io_handle_t output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800245 {
246 Parcel data, reply;
247 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800248 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800249 remote()->transact(FRAME_COUNT, data, &reply);
250 return reply.readInt32();
251 }
252
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800253 virtual uint32_t latency(audio_io_handle_t output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800254 {
255 Parcel data, reply;
256 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800257 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800258 remote()->transact(LATENCY, data, &reply);
259 return reply.readInt32();
260 }
261
262 virtual status_t setMasterVolume(float value)
263 {
264 Parcel data, reply;
265 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
266 data.writeFloat(value);
267 remote()->transact(SET_MASTER_VOLUME, data, &reply);
268 return reply.readInt32();
269 }
270
271 virtual status_t setMasterMute(bool muted)
272 {
273 Parcel data, reply;
274 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
275 data.writeInt32(muted);
276 remote()->transact(SET_MASTER_MUTE, data, &reply);
277 return reply.readInt32();
278 }
279
280 virtual float masterVolume() const
281 {
282 Parcel data, reply;
283 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
284 remote()->transact(MASTER_VOLUME, data, &reply);
285 return reply.readFloat();
286 }
287
288 virtual bool masterMute() const
289 {
290 Parcel data, reply;
291 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
292 remote()->transact(MASTER_MUTE, data, &reply);
293 return reply.readInt32();
294 }
295
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800296 virtual status_t setStreamVolume(audio_stream_type_t stream, float value,
297 audio_io_handle_t output)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800298 {
299 Parcel data, reply;
300 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800301 data.writeInt32((int32_t) stream);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800302 data.writeFloat(value);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800303 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800304 remote()->transact(SET_STREAM_VOLUME, data, &reply);
305 return reply.readInt32();
306 }
307
Glenn Kastenfff6d712012-01-12 16:38:12 -0800308 virtual status_t setStreamMute(audio_stream_type_t stream, bool muted)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800309 {
310 Parcel data, reply;
311 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800312 data.writeInt32((int32_t) stream);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800313 data.writeInt32(muted);
314 remote()->transact(SET_STREAM_MUTE, data, &reply);
315 return reply.readInt32();
316 }
317
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800318 virtual float streamVolume(audio_stream_type_t stream, audio_io_handle_t output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800319 {
320 Parcel data, reply;
321 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800322 data.writeInt32((int32_t) stream);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800323 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800324 remote()->transact(STREAM_VOLUME, data, &reply);
325 return reply.readFloat();
326 }
327
Glenn Kastenfff6d712012-01-12 16:38:12 -0800328 virtual bool streamMute(audio_stream_type_t stream) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800329 {
330 Parcel data, reply;
331 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800332 data.writeInt32((int32_t) stream);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800333 remote()->transact(STREAM_MUTE, data, &reply);
334 return reply.readInt32();
335 }
336
Glenn Kastenf78aee72012-01-04 11:00:47 -0800337 virtual status_t setMode(audio_mode_t mode)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800338 {
339 Parcel data, reply;
340 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
341 data.writeInt32(mode);
342 remote()->transact(SET_MODE, data, &reply);
343 return reply.readInt32();
344 }
345
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800346 virtual status_t setMicMute(bool state)
347 {
348 Parcel data, reply;
349 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
350 data.writeInt32(state);
351 remote()->transact(SET_MIC_MUTE, data, &reply);
352 return reply.readInt32();
353 }
354
355 virtual bool getMicMute() const
356 {
357 Parcel data, reply;
358 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
359 remote()->transact(GET_MIC_MUTE, data, &reply);
360 return reply.readInt32();
361 }
362
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800363 virtual status_t setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800364 {
365 Parcel data, reply;
366 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800367 data.writeInt32((int32_t) ioHandle);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700368 data.writeString8(keyValuePairs);
369 remote()->transact(SET_PARAMETERS, data, &reply);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800370 return reply.readInt32();
371 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700372
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800373 virtual String8 getParameters(audio_io_handle_t ioHandle, const String8& keys) const
Eric Laurentc2f1f072009-07-17 12:17:14 -0700374 {
375 Parcel data, reply;
376 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800377 data.writeInt32((int32_t) ioHandle);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700378 data.writeString8(keys);
379 remote()->transact(GET_PARAMETERS, data, &reply);
380 return reply.readString8();
381 }
382
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800383 virtual void registerClient(const sp<IAudioFlingerClient>& client)
384 {
385 Parcel data, reply;
386 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
387 data.writeStrongBinder(client->asBinder());
388 remote()->transact(REGISTER_CLIENT, data, &reply);
389 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700390
Glenn Kastendd8104c2012-07-02 12:42:44 -0700391 virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format,
392 audio_channel_mask_t channelMask) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800393 {
394 Parcel data, reply;
395 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
396 data.writeInt32(sampleRate);
397 data.writeInt32(format);
Glenn Kastendd8104c2012-07-02 12:42:44 -0700398 data.writeInt32(channelMask);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800399 remote()->transact(GET_INPUTBUFFERSIZE, data, &reply);
400 return reply.readInt32();
401 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700402
Eric Laurenta4c5a552012-03-29 10:12:40 -0700403 virtual audio_io_handle_t openOutput(audio_module_handle_t module,
404 audio_devices_t *pDevices,
405 uint32_t *pSamplingRate,
406 audio_format_t *pFormat,
407 audio_channel_mask_t *pChannelMask,
408 uint32_t *pLatencyMs,
Richard Fitzgeraldad3af332013-03-25 16:54:37 +0000409 audio_output_flags_t flags,
410 const audio_offload_info_t *offloadInfo)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800411 {
412 Parcel data, reply;
Glenn Kasten7c5977f2013-07-02 14:17:22 -0700413 audio_devices_t devices = pDevices != NULL ? *pDevices : (audio_devices_t)0;
414 uint32_t samplingRate = pSamplingRate != NULL ? *pSamplingRate : 0;
415 audio_format_t format = pFormat != NULL ? *pFormat : AUDIO_FORMAT_DEFAULT;
416 audio_channel_mask_t channelMask = pChannelMask != NULL ?
417 *pChannelMask : (audio_channel_mask_t)0;
418 uint32_t latency = pLatencyMs != NULL ? *pLatencyMs : 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800419 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurenta4c5a552012-03-29 10:12:40 -0700420 data.writeInt32(module);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700421 data.writeInt32(devices);
422 data.writeInt32(samplingRate);
423 data.writeInt32(format);
Eric Laurenta4c5a552012-03-29 10:12:40 -0700424 data.writeInt32(channelMask);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700425 data.writeInt32(latency);
Glenn Kasten18868c52012-03-07 09:15:37 -0800426 data.writeInt32((int32_t) flags);
Richard Fitzgeraldb1a270d2013-05-14 12:12:21 +0100427 if (offloadInfo == NULL) {
428 data.writeInt32(0);
429 } else {
430 data.writeInt32(1);
431 data.write(offloadInfo, sizeof(audio_offload_info_t));
432 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700433 remote()->transact(OPEN_OUTPUT, data, &reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800434 audio_io_handle_t output = (audio_io_handle_t) reply.readInt32();
435 ALOGV("openOutput() returned output, %d", output);
Eric Laurenta4c5a552012-03-29 10:12:40 -0700436 devices = (audio_devices_t)reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700437 if (pDevices != NULL) {
438 *pDevices = devices;
439 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700440 samplingRate = reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700441 if (pSamplingRate != NULL) {
442 *pSamplingRate = samplingRate;
443 }
Glenn Kasten58f30212012-01-12 12:27:51 -0800444 format = (audio_format_t) reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700445 if (pFormat != NULL) {
446 *pFormat = format;
447 }
Eric Laurenta4c5a552012-03-29 10:12:40 -0700448 channelMask = (audio_channel_mask_t)reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700449 if (pChannelMask != NULL) {
450 *pChannelMask = channelMask;
451 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700452 latency = reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700453 if (pLatencyMs != NULL) {
454 *pLatencyMs = latency;
455 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700456 return output;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800457 }
458
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800459 virtual audio_io_handle_t openDuplicateOutput(audio_io_handle_t output1,
460 audio_io_handle_t output2)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800461 {
462 Parcel data, reply;
463 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800464 data.writeInt32((int32_t) output1);
465 data.writeInt32((int32_t) output2);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700466 remote()->transact(OPEN_DUPLICATE_OUTPUT, data, &reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800467 return (audio_io_handle_t) reply.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700468 }
469
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800470 virtual status_t closeOutput(audio_io_handle_t output)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700471 {
472 Parcel data, reply;
473 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800474 data.writeInt32((int32_t) output);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700475 remote()->transact(CLOSE_OUTPUT, data, &reply);
476 return reply.readInt32();
477 }
478
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800479 virtual status_t suspendOutput(audio_io_handle_t output)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700480 {
481 Parcel data, reply;
482 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800483 data.writeInt32((int32_t) output);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700484 remote()->transact(SUSPEND_OUTPUT, data, &reply);
485 return reply.readInt32();
486 }
487
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800488 virtual status_t restoreOutput(audio_io_handle_t output)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700489 {
490 Parcel data, reply;
491 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800492 data.writeInt32((int32_t) output);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700493 remote()->transact(RESTORE_OUTPUT, data, &reply);
494 return reply.readInt32();
495 }
496
Eric Laurenta4c5a552012-03-29 10:12:40 -0700497 virtual audio_io_handle_t openInput(audio_module_handle_t module,
498 audio_devices_t *pDevices,
499 uint32_t *pSamplingRate,
500 audio_format_t *pFormat,
501 audio_channel_mask_t *pChannelMask)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700502 {
503 Parcel data, reply;
Glenn Kasten7c5977f2013-07-02 14:17:22 -0700504 audio_devices_t devices = pDevices != NULL ? *pDevices : (audio_devices_t)0;
505 uint32_t samplingRate = pSamplingRate != NULL ? *pSamplingRate : 0;
506 audio_format_t format = pFormat != NULL ? *pFormat : AUDIO_FORMAT_DEFAULT;
507 audio_channel_mask_t channelMask = pChannelMask != NULL ?
508 *pChannelMask : (audio_channel_mask_t)0;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700509
510 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurenta4c5a552012-03-29 10:12:40 -0700511 data.writeInt32(module);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700512 data.writeInt32(devices);
513 data.writeInt32(samplingRate);
514 data.writeInt32(format);
Eric Laurenta4c5a552012-03-29 10:12:40 -0700515 data.writeInt32(channelMask);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700516 remote()->transact(OPEN_INPUT, data, &reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800517 audio_io_handle_t input = (audio_io_handle_t) reply.readInt32();
Eric Laurenta4c5a552012-03-29 10:12:40 -0700518 devices = (audio_devices_t)reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700519 if (pDevices != NULL) {
520 *pDevices = devices;
521 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700522 samplingRate = reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700523 if (pSamplingRate != NULL) {
524 *pSamplingRate = samplingRate;
525 }
Glenn Kasten58f30212012-01-12 12:27:51 -0800526 format = (audio_format_t) reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700527 if (pFormat != NULL) {
528 *pFormat = format;
529 }
Eric Laurenta4c5a552012-03-29 10:12:40 -0700530 channelMask = (audio_channel_mask_t)reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700531 if (pChannelMask != NULL) {
532 *pChannelMask = channelMask;
533 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700534 return input;
535 }
536
Eric Laurentfa2877b2009-07-28 08:44:33 -0700537 virtual status_t closeInput(int input)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700538 {
539 Parcel data, reply;
540 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentfa2877b2009-07-28 08:44:33 -0700541 data.writeInt32(input);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700542 remote()->transact(CLOSE_INPUT, data, &reply);
543 return reply.readInt32();
544 }
545
Glenn Kastend2304db2014-02-03 07:40:31 -0800546 virtual status_t invalidateStream(audio_stream_type_t stream)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700547 {
548 Parcel data, reply;
549 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800550 data.writeInt32((int32_t) stream);
Glenn Kastend2304db2014-02-03 07:40:31 -0800551 remote()->transact(INVALIDATE_STREAM, data, &reply);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700552 return reply.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800553 }
Eric Laurentf0ee6f42009-10-21 08:14:22 -0700554
555 virtual status_t setVoiceVolume(float volume)
556 {
557 Parcel data, reply;
558 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
559 data.writeFloat(volume);
560 remote()->transact(SET_VOICE_VOLUME, data, &reply);
561 return reply.readInt32();
562 }
Eric Laurent342e9cf2010-01-19 17:37:09 -0800563
Kévin PETIT377b2ec2014-02-03 12:35:36 +0000564 virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames,
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800565 audio_io_handle_t output) const
Eric Laurent342e9cf2010-01-19 17:37:09 -0800566 {
567 Parcel data, reply;
568 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800569 data.writeInt32((int32_t) output);
Eric Laurent342e9cf2010-01-19 17:37:09 -0800570 remote()->transact(GET_RENDER_POSITION, data, &reply);
571 status_t status = reply.readInt32();
572 if (status == NO_ERROR) {
573 uint32_t tmp = reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700574 if (halFrames != NULL) {
Eric Laurent342e9cf2010-01-19 17:37:09 -0800575 *halFrames = tmp;
576 }
577 tmp = reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700578 if (dspFrames != NULL) {
Eric Laurent342e9cf2010-01-19 17:37:09 -0800579 *dspFrames = tmp;
580 }
581 }
582 return status;
583 }
Eric Laurent05bca2f2010-02-26 02:47:27 -0800584
Glenn Kasten5f972c02014-01-13 09:59:31 -0800585 virtual uint32_t getInputFramesLost(audio_io_handle_t ioHandle) const
Eric Laurent05bca2f2010-02-26 02:47:27 -0800586 {
587 Parcel data, reply;
588 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800589 data.writeInt32((int32_t) ioHandle);
Glenn Kasten5f972c02014-01-13 09:59:31 -0800590 status_t status = remote()->transact(GET_INPUT_FRAMES_LOST, data, &reply);
591 if (status != NO_ERROR) {
592 return 0;
593 }
594 return (uint32_t) reply.readInt32();
Eric Laurent05bca2f2010-02-26 02:47:27 -0800595 }
Eric Laurentbe916aa2010-06-01 23:49:17 -0700596
597 virtual int newAudioSessionId()
598 {
599 Parcel data, reply;
600 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
601 status_t status = remote()->transact(NEW_AUDIO_SESSION_ID, data, &reply);
Glenn Kasten85d109a2014-01-17 10:25:08 -0800602 int id = AUDIO_SESSION_ALLOCATE;
Eric Laurentbe916aa2010-06-01 23:49:17 -0700603 if (status == NO_ERROR) {
604 id = reply.readInt32();
605 }
606 return id;
607 }
608
Marco Nelissend457c972014-02-11 08:47:07 -0800609 virtual void acquireAudioSessionId(int audioSession, int pid)
Marco Nelissen3a34bef2011-08-02 13:33:41 -0700610 {
611 Parcel data, reply;
612 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
613 data.writeInt32(audioSession);
Marco Nelissend457c972014-02-11 08:47:07 -0800614 data.writeInt32(pid);
Marco Nelissen3a34bef2011-08-02 13:33:41 -0700615 remote()->transact(ACQUIRE_AUDIO_SESSION_ID, data, &reply);
616 }
617
Marco Nelissend457c972014-02-11 08:47:07 -0800618 virtual void releaseAudioSessionId(int audioSession, int pid)
Marco Nelissen3a34bef2011-08-02 13:33:41 -0700619 {
620 Parcel data, reply;
621 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
622 data.writeInt32(audioSession);
Marco Nelissend457c972014-02-11 08:47:07 -0800623 data.writeInt32(pid);
Marco Nelissen3a34bef2011-08-02 13:33:41 -0700624 remote()->transact(RELEASE_AUDIO_SESSION_ID, data, &reply);
625 }
626
Glenn Kastenf587ba52012-01-26 16:25:10 -0800627 virtual status_t queryNumberEffects(uint32_t *numEffects) const
Eric Laurentbe916aa2010-06-01 23:49:17 -0700628 {
629 Parcel data, reply;
630 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
631 status_t status = remote()->transact(QUERY_NUM_EFFECTS, data, &reply);
632 if (status != NO_ERROR) {
633 return status;
634 }
635 status = reply.readInt32();
636 if (status != NO_ERROR) {
637 return status;
638 }
Glenn Kasten9d1f02d2012-02-08 17:47:58 -0800639 if (numEffects != NULL) {
Eric Laurentbe916aa2010-06-01 23:49:17 -0700640 *numEffects = (uint32_t)reply.readInt32();
641 }
642 return NO_ERROR;
643 }
644
Glenn Kastenf587ba52012-01-26 16:25:10 -0800645 virtual status_t queryEffect(uint32_t index, effect_descriptor_t *pDescriptor) const
Eric Laurentbe916aa2010-06-01 23:49:17 -0700646 {
647 if (pDescriptor == NULL) {
648 return BAD_VALUE;
649 }
650 Parcel data, reply;
651 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentffe9c252010-06-23 17:38:20 -0700652 data.writeInt32(index);
653 status_t status = remote()->transact(QUERY_EFFECT, data, &reply);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700654 if (status != NO_ERROR) {
655 return status;
656 }
657 status = reply.readInt32();
658 if (status != NO_ERROR) {
659 return status;
660 }
661 reply.read(pDescriptor, sizeof(effect_descriptor_t));
662 return NO_ERROR;
663 }
664
Glenn Kasten5e92a782012-01-30 07:40:52 -0800665 virtual status_t getEffectDescriptor(const effect_uuid_t *pUuid,
Glenn Kastenf587ba52012-01-26 16:25:10 -0800666 effect_descriptor_t *pDescriptor) const
Eric Laurentbe916aa2010-06-01 23:49:17 -0700667 {
668 if (pUuid == NULL || pDescriptor == NULL) {
669 return BAD_VALUE;
670 }
671 Parcel data, reply;
672 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
673 data.write(pUuid, sizeof(effect_uuid_t));
674 status_t status = remote()->transact(GET_EFFECT_DESCRIPTOR, data, &reply);
675 if (status != NO_ERROR) {
676 return status;
677 }
678 status = reply.readInt32();
679 if (status != NO_ERROR) {
680 return status;
681 }
682 reply.read(pDescriptor, sizeof(effect_descriptor_t));
683 return NO_ERROR;
684 }
685
Glenn Kasten8d6cc842012-02-03 11:06:53 -0800686 virtual sp<IEffect> createEffect(
Eric Laurentbe916aa2010-06-01 23:49:17 -0700687 effect_descriptor_t *pDesc,
688 const sp<IEffectClient>& client,
689 int32_t priority,
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800690 audio_io_handle_t output,
Eric Laurentbe916aa2010-06-01 23:49:17 -0700691 int sessionId,
692 status_t *status,
693 int *id,
694 int *enabled)
695 {
696 Parcel data, reply;
697 sp<IEffect> effect;
698
699 if (pDesc == NULL) {
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700700 return effect;
Glenn Kasten507b2862013-07-31 16:12:13 -0700701 if (status != NULL) {
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700702 *status = BAD_VALUE;
703 }
704 }
Eric Laurentbe916aa2010-06-01 23:49:17 -0700705
706 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentbe916aa2010-06-01 23:49:17 -0700707 data.write(pDesc, sizeof(effect_descriptor_t));
708 data.writeStrongBinder(client->asBinder());
709 data.writeInt32(priority);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800710 data.writeInt32((int32_t) output);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700711 data.writeInt32(sessionId);
712
713 status_t lStatus = remote()->transact(CREATE_EFFECT, data, &reply);
714 if (lStatus != NO_ERROR) {
Steve Block29357bc2012-01-06 19:20:56 +0000715 ALOGE("createEffect error: %s", strerror(-lStatus));
Eric Laurentbe916aa2010-06-01 23:49:17 -0700716 } else {
717 lStatus = reply.readInt32();
718 int tmp = reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700719 if (id != NULL) {
Eric Laurentbe916aa2010-06-01 23:49:17 -0700720 *id = tmp;
721 }
722 tmp = reply.readInt32();
Glenn Kastena0d68332012-01-27 16:47:15 -0800723 if (enabled != NULL) {
Eric Laurentbe916aa2010-06-01 23:49:17 -0700724 *enabled = tmp;
725 }
726 effect = interface_cast<IEffect>(reply.readStrongBinder());
727 reply.read(pDesc, sizeof(effect_descriptor_t));
728 }
Glenn Kasten507b2862013-07-31 16:12:13 -0700729 if (status != NULL) {
Eric Laurentbe916aa2010-06-01 23:49:17 -0700730 *status = lStatus;
731 }
732
733 return effect;
734 }
Eric Laurentde070132010-07-13 04:45:46 -0700735
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800736 virtual status_t moveEffects(int session, audio_io_handle_t srcOutput,
737 audio_io_handle_t dstOutput)
Eric Laurentde070132010-07-13 04:45:46 -0700738 {
739 Parcel data, reply;
740 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
741 data.writeInt32(session);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800742 data.writeInt32((int32_t) srcOutput);
743 data.writeInt32((int32_t) dstOutput);
Eric Laurentde070132010-07-13 04:45:46 -0700744 remote()->transact(MOVE_EFFECTS, data, &reply);
745 return reply.readInt32();
746 }
Eric Laurenta4c5a552012-03-29 10:12:40 -0700747
748 virtual audio_module_handle_t loadHwModule(const char *name)
749 {
750 Parcel data, reply;
751 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
752 data.writeCString(name);
753 remote()->transact(LOAD_HW_MODULE, data, &reply);
754 return (audio_module_handle_t) reply.readInt32();
755 }
Glenn Kastencc0f1cf2012-09-24 11:27:18 -0700756
Glenn Kasten3b16c762012-11-14 08:44:39 -0800757 virtual uint32_t getPrimaryOutputSamplingRate()
Glenn Kastencc0f1cf2012-09-24 11:27:18 -0700758 {
759 Parcel data, reply;
760 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
761 remote()->transact(GET_PRIMARY_OUTPUT_SAMPLING_RATE, data, &reply);
762 return reply.readInt32();
763 }
764
Glenn Kastene33054e2012-11-14 12:54:39 -0800765 virtual size_t getPrimaryOutputFrameCount()
Glenn Kastencc0f1cf2012-09-24 11:27:18 -0700766 {
767 Parcel data, reply;
768 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
769 remote()->transact(GET_PRIMARY_OUTPUT_FRAME_COUNT, data, &reply);
770 return reply.readInt32();
771 }
772
Glenn Kasten4182c4e2013-07-15 14:45:07 -0700773 virtual status_t setLowRamDevice(bool isLowRamDevice)
774 {
775 Parcel data, reply;
776 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
777 data.writeInt32((int) isLowRamDevice);
778 remote()->transact(SET_LOW_RAM_DEVICE, data, &reply);
779 return reply.readInt32();
780 }
781
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800782};
783
784IMPLEMENT_META_INTERFACE(AudioFlinger, "android.media.IAudioFlinger");
785
786// ----------------------------------------------------------------------
787
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800788status_t BnAudioFlinger::onTransact(
789 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
790{
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700791 switch (code) {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800792 case CREATE_TRACK: {
793 CHECK_INTERFACE(IAudioFlinger, data, reply);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800794 int streamType = data.readInt32();
795 uint32_t sampleRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -0800796 audio_format_t format = (audio_format_t) data.readInt32();
Glenn Kastendd8104c2012-07-02 12:42:44 -0700797 audio_channel_mask_t channelMask = data.readInt32();
Glenn Kastene33054e2012-11-14 12:54:39 -0800798 size_t frameCount = data.readInt32();
Glenn Kastena075db42012-03-06 11:22:44 -0800799 track_flags_t flags = (track_flags_t) data.readInt32();
Eric Laurent3d00aa62013-09-24 09:53:27 -0700800 bool haveSharedBuffer = data.readInt32() != 0;
801 sp<IMemory> buffer;
802 if (haveSharedBuffer) {
803 buffer = interface_cast<IMemory>(data.readStrongBinder());
804 }
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800805 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Glenn Kasten3acbd052012-02-28 10:39:56 -0800806 pid_t tid = (pid_t) data.readInt32();
Eric Laurentbe916aa2010-06-01 23:49:17 -0700807 int sessionId = data.readInt32();
Marco Nelissen462fd2f2013-01-14 14:12:05 -0800808 int clientUid = data.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800809 status_t status;
Eric Laurent3d00aa62013-09-24 09:53:27 -0700810 sp<IAudioTrack> track;
811 if ((haveSharedBuffer && (buffer == 0)) ||
812 ((buffer != 0) && (buffer->pointer() == NULL))) {
813 ALOGW("CREATE_TRACK: cannot retrieve shared memory");
814 status = DEAD_OBJECT;
815 } else {
816 track = createTrack(
817 (audio_stream_type_t) streamType, sampleRate, format,
Glenn Kasten74935e42013-12-19 08:56:45 -0800818 channelMask, &frameCount, &flags, buffer, output, tid,
Glenn Kastenc5a17422014-03-13 14:59:59 -0700819 &sessionId, clientUid, &status);
Glenn Kasten0cde0762014-01-16 15:06:36 -0800820 LOG_ALWAYS_FATAL_IF((track != 0) != (status == NO_ERROR));
Eric Laurent3d00aa62013-09-24 09:53:27 -0700821 }
Glenn Kasten74935e42013-12-19 08:56:45 -0800822 reply->writeInt32(frameCount);
Glenn Kastene0b07172012-11-06 15:03:34 -0800823 reply->writeInt32(flags);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700824 reply->writeInt32(sessionId);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800825 reply->writeInt32(status);
826 reply->writeStrongBinder(track->asBinder());
827 return NO_ERROR;
828 } break;
829 case OPEN_RECORD: {
830 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800831 audio_io_handle_t input = (audio_io_handle_t) data.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800832 uint32_t sampleRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -0800833 audio_format_t format = (audio_format_t) data.readInt32();
Glenn Kastendd8104c2012-07-02 12:42:44 -0700834 audio_channel_mask_t channelMask = data.readInt32();
Glenn Kastene33054e2012-11-14 12:54:39 -0800835 size_t frameCount = data.readInt32();
Glenn Kastena075db42012-03-06 11:22:44 -0800836 track_flags_t flags = (track_flags_t) data.readInt32();
Glenn Kasten1879fff2012-07-11 15:36:59 -0700837 pid_t tid = (pid_t) data.readInt32();
Eric Laurentbe916aa2010-06-01 23:49:17 -0700838 int sessionId = data.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800839 status_t status;
Glenn Kasten8d6cc842012-02-03 11:06:53 -0800840 sp<IAudioRecord> record = openRecord(input,
Glenn Kasten74935e42013-12-19 08:56:45 -0800841 sampleRate, format, channelMask, &frameCount, &flags, tid, &sessionId, &status);
Glenn Kastene93cf2c2013-09-24 11:52:37 -0700842 LOG_ALWAYS_FATAL_IF((record != 0) != (status == NO_ERROR));
Glenn Kasten74935e42013-12-19 08:56:45 -0800843 reply->writeInt32(frameCount);
Glenn Kasteneeca3262013-07-31 16:12:48 -0700844 reply->writeInt32(flags);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700845 reply->writeInt32(sessionId);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800846 reply->writeInt32(status);
847 reply->writeStrongBinder(record->asBinder());
848 return NO_ERROR;
849 } break;
850 case SAMPLE_RATE: {
851 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800852 reply->writeInt32( sampleRate((audio_io_handle_t) data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800853 return NO_ERROR;
854 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800855 case FORMAT: {
856 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800857 reply->writeInt32( format((audio_io_handle_t) data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800858 return NO_ERROR;
859 } break;
860 case FRAME_COUNT: {
861 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800862 reply->writeInt32( frameCount((audio_io_handle_t) data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800863 return NO_ERROR;
864 } break;
865 case LATENCY: {
866 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800867 reply->writeInt32( latency((audio_io_handle_t) data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800868 return NO_ERROR;
869 } break;
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700870 case SET_MASTER_VOLUME: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800871 CHECK_INTERFACE(IAudioFlinger, data, reply);
872 reply->writeInt32( setMasterVolume(data.readFloat()) );
873 return NO_ERROR;
874 } break;
875 case SET_MASTER_MUTE: {
876 CHECK_INTERFACE(IAudioFlinger, data, reply);
877 reply->writeInt32( setMasterMute(data.readInt32()) );
878 return NO_ERROR;
879 } break;
880 case MASTER_VOLUME: {
881 CHECK_INTERFACE(IAudioFlinger, data, reply);
882 reply->writeFloat( masterVolume() );
883 return NO_ERROR;
884 } break;
885 case MASTER_MUTE: {
886 CHECK_INTERFACE(IAudioFlinger, data, reply);
887 reply->writeInt32( masterMute() );
888 return NO_ERROR;
889 } break;
890 case SET_STREAM_VOLUME: {
891 CHECK_INTERFACE(IAudioFlinger, data, reply);
892 int stream = data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700893 float volume = data.readFloat();
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800894 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -0800895 reply->writeInt32( setStreamVolume((audio_stream_type_t) stream, volume, output) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800896 return NO_ERROR;
897 } break;
898 case SET_STREAM_MUTE: {
899 CHECK_INTERFACE(IAudioFlinger, data, reply);
900 int stream = data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -0800901 reply->writeInt32( setStreamMute((audio_stream_type_t) stream, data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800902 return NO_ERROR;
903 } break;
904 case STREAM_VOLUME: {
905 CHECK_INTERFACE(IAudioFlinger, data, reply);
906 int stream = data.readInt32();
Eric Laurentfa2877b2009-07-28 08:44:33 -0700907 int output = data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -0800908 reply->writeFloat( streamVolume((audio_stream_type_t) stream, output) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800909 return NO_ERROR;
910 } break;
911 case STREAM_MUTE: {
912 CHECK_INTERFACE(IAudioFlinger, data, reply);
913 int stream = data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -0800914 reply->writeInt32( streamMute((audio_stream_type_t) stream) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800915 return NO_ERROR;
916 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800917 case SET_MODE: {
918 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kastenf78aee72012-01-04 11:00:47 -0800919 audio_mode_t mode = (audio_mode_t) data.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800920 reply->writeInt32( setMode(mode) );
921 return NO_ERROR;
922 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800923 case SET_MIC_MUTE: {
924 CHECK_INTERFACE(IAudioFlinger, data, reply);
925 int state = data.readInt32();
926 reply->writeInt32( setMicMute(state) );
927 return NO_ERROR;
928 } break;
929 case GET_MIC_MUTE: {
930 CHECK_INTERFACE(IAudioFlinger, data, reply);
931 reply->writeInt32( getMicMute() );
932 return NO_ERROR;
933 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700934 case SET_PARAMETERS: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800935 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800936 audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700937 String8 keyValuePairs(data.readString8());
938 reply->writeInt32(setParameters(ioHandle, keyValuePairs));
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800939 return NO_ERROR;
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700940 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700941 case GET_PARAMETERS: {
942 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800943 audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700944 String8 keys(data.readString8());
945 reply->writeString8(getParameters(ioHandle, keys));
946 return NO_ERROR;
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700947 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700948
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800949 case REGISTER_CLIENT: {
950 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten85ab62c2012-11-01 11:11:38 -0700951 sp<IAudioFlingerClient> client = interface_cast<IAudioFlingerClient>(
952 data.readStrongBinder());
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800953 registerClient(client);
954 return NO_ERROR;
955 } break;
956 case GET_INPUTBUFFERSIZE: {
957 CHECK_INTERFACE(IAudioFlinger, data, reply);
958 uint32_t sampleRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -0800959 audio_format_t format = (audio_format_t) data.readInt32();
Glenn Kastendd8104c2012-07-02 12:42:44 -0700960 audio_channel_mask_t channelMask = data.readInt32();
961 reply->writeInt32( getInputBufferSize(sampleRate, format, channelMask) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800962 return NO_ERROR;
963 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700964 case OPEN_OUTPUT: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800965 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurenta4c5a552012-03-29 10:12:40 -0700966 audio_module_handle_t module = (audio_module_handle_t)data.readInt32();
967 audio_devices_t devices = (audio_devices_t)data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700968 uint32_t samplingRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -0800969 audio_format_t format = (audio_format_t) data.readInt32();
Eric Laurenta4c5a552012-03-29 10:12:40 -0700970 audio_channel_mask_t channelMask = (audio_channel_mask_t)data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700971 uint32_t latency = data.readInt32();
Eric Laurent0ca3cf92012-04-18 09:24:29 -0700972 audio_output_flags_t flags = (audio_output_flags_t) data.readInt32();
Richard Fitzgeraldb1a270d2013-05-14 12:12:21 +0100973 bool hasOffloadInfo = data.readInt32() != 0;
974 audio_offload_info_t offloadInfo;
975 if (hasOffloadInfo) {
976 data.read(&offloadInfo, sizeof(audio_offload_info_t));
977 }
Eric Laurenta4c5a552012-03-29 10:12:40 -0700978 audio_io_handle_t output = openOutput(module,
979 &devices,
980 &samplingRate,
981 &format,
982 &channelMask,
983 &latency,
Richard Fitzgeraldb1a270d2013-05-14 12:12:21 +0100984 flags,
985 hasOffloadInfo ? &offloadInfo : NULL);
Glenn Kasten70742962014-02-18 08:00:47 -0800986 ALOGV("OPEN_OUTPUT output, %d", output);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800987 reply->writeInt32((int32_t) output);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700988 reply->writeInt32(devices);
989 reply->writeInt32(samplingRate);
990 reply->writeInt32(format);
Eric Laurenta4c5a552012-03-29 10:12:40 -0700991 reply->writeInt32(channelMask);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700992 reply->writeInt32(latency);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800993 return NO_ERROR;
994 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700995 case OPEN_DUPLICATE_OUTPUT: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800996 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800997 audio_io_handle_t output1 = (audio_io_handle_t) data.readInt32();
998 audio_io_handle_t output2 = (audio_io_handle_t) data.readInt32();
999 reply->writeInt32((int32_t) openDuplicateOutput(output1, output2));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001000 return NO_ERROR;
1001 } break;
1002 case CLOSE_OUTPUT: {
1003 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001004 reply->writeInt32(closeOutput((audio_io_handle_t) data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001005 return NO_ERROR;
1006 } break;
1007 case SUSPEND_OUTPUT: {
1008 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001009 reply->writeInt32(suspendOutput((audio_io_handle_t) data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001010 return NO_ERROR;
1011 } break;
1012 case RESTORE_OUTPUT: {
1013 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001014 reply->writeInt32(restoreOutput((audio_io_handle_t) data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001015 return NO_ERROR;
1016 } break;
1017 case OPEN_INPUT: {
1018 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurenta4c5a552012-03-29 10:12:40 -07001019 audio_module_handle_t module = (audio_module_handle_t)data.readInt32();
1020 audio_devices_t devices = (audio_devices_t)data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -07001021 uint32_t samplingRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -08001022 audio_format_t format = (audio_format_t) data.readInt32();
Eric Laurenta4c5a552012-03-29 10:12:40 -07001023 audio_channel_mask_t channelMask = (audio_channel_mask_t)data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -07001024
Eric Laurenta4c5a552012-03-29 10:12:40 -07001025 audio_io_handle_t input = openInput(module,
1026 &devices,
1027 &samplingRate,
1028 &format,
1029 &channelMask);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001030 reply->writeInt32((int32_t) input);
Eric Laurentc2f1f072009-07-17 12:17:14 -07001031 reply->writeInt32(devices);
1032 reply->writeInt32(samplingRate);
1033 reply->writeInt32(format);
Eric Laurenta4c5a552012-03-29 10:12:40 -07001034 reply->writeInt32(channelMask);
Eric Laurentc2f1f072009-07-17 12:17:14 -07001035 return NO_ERROR;
1036 } break;
1037 case CLOSE_INPUT: {
1038 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001039 reply->writeInt32(closeInput((audio_io_handle_t) data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001040 return NO_ERROR;
1041 } break;
Glenn Kastend2304db2014-02-03 07:40:31 -08001042 case INVALIDATE_STREAM: {
Eric Laurentc2f1f072009-07-17 12:17:14 -07001043 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kastend2304db2014-02-03 07:40:31 -08001044 audio_stream_type_t stream = (audio_stream_type_t) data.readInt32();
1045 reply->writeInt32(invalidateStream(stream));
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001046 return NO_ERROR;
1047 } break;
Eric Laurentf0ee6f42009-10-21 08:14:22 -07001048 case SET_VOICE_VOLUME: {
1049 CHECK_INTERFACE(IAudioFlinger, data, reply);
1050 float volume = data.readFloat();
1051 reply->writeInt32( setVoiceVolume(volume) );
1052 return NO_ERROR;
1053 } break;
Eric Laurent342e9cf2010-01-19 17:37:09 -08001054 case GET_RENDER_POSITION: {
1055 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001056 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Kévin PETIT377b2ec2014-02-03 12:35:36 +00001057 uint32_t halFrames;
1058 uint32_t dspFrames;
Eric Laurent342e9cf2010-01-19 17:37:09 -08001059 status_t status = getRenderPosition(&halFrames, &dspFrames, output);
1060 reply->writeInt32(status);
1061 if (status == NO_ERROR) {
1062 reply->writeInt32(halFrames);
1063 reply->writeInt32(dspFrames);
1064 }
1065 return NO_ERROR;
1066 }
Eric Laurent05bca2f2010-02-26 02:47:27 -08001067 case GET_INPUT_FRAMES_LOST: {
1068 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001069 audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
Glenn Kasten5f972c02014-01-13 09:59:31 -08001070 reply->writeInt32((int32_t) getInputFramesLost(ioHandle));
Eric Laurent05bca2f2010-02-26 02:47:27 -08001071 return NO_ERROR;
1072 } break;
Eric Laurentbe916aa2010-06-01 23:49:17 -07001073 case NEW_AUDIO_SESSION_ID: {
1074 CHECK_INTERFACE(IAudioFlinger, data, reply);
1075 reply->writeInt32(newAudioSessionId());
1076 return NO_ERROR;
1077 } break;
Marco Nelissen3a34bef2011-08-02 13:33:41 -07001078 case ACQUIRE_AUDIO_SESSION_ID: {
1079 CHECK_INTERFACE(IAudioFlinger, data, reply);
1080 int audioSession = data.readInt32();
Marco Nelissend457c972014-02-11 08:47:07 -08001081 int pid = data.readInt32();
1082 acquireAudioSessionId(audioSession, pid);
Marco Nelissen3a34bef2011-08-02 13:33:41 -07001083 return NO_ERROR;
1084 } break;
1085 case RELEASE_AUDIO_SESSION_ID: {
1086 CHECK_INTERFACE(IAudioFlinger, data, reply);
1087 int audioSession = data.readInt32();
Marco Nelissend457c972014-02-11 08:47:07 -08001088 int pid = data.readInt32();
1089 releaseAudioSessionId(audioSession, pid);
Marco Nelissen3a34bef2011-08-02 13:33:41 -07001090 return NO_ERROR;
1091 } break;
Eric Laurentbe916aa2010-06-01 23:49:17 -07001092 case QUERY_NUM_EFFECTS: {
1093 CHECK_INTERFACE(IAudioFlinger, data, reply);
1094 uint32_t numEffects;
1095 status_t status = queryNumberEffects(&numEffects);
1096 reply->writeInt32(status);
1097 if (status == NO_ERROR) {
1098 reply->writeInt32((int32_t)numEffects);
1099 }
1100 return NO_ERROR;
1101 }
Eric Laurentffe9c252010-06-23 17:38:20 -07001102 case QUERY_EFFECT: {
Eric Laurentbe916aa2010-06-01 23:49:17 -07001103 CHECK_INTERFACE(IAudioFlinger, data, reply);
1104 effect_descriptor_t desc;
Eric Laurentffe9c252010-06-23 17:38:20 -07001105 status_t status = queryEffect(data.readInt32(), &desc);
Eric Laurentbe916aa2010-06-01 23:49:17 -07001106 reply->writeInt32(status);
1107 if (status == NO_ERROR) {
1108 reply->write(&desc, sizeof(effect_descriptor_t));
1109 }
1110 return NO_ERROR;
1111 }
1112 case GET_EFFECT_DESCRIPTOR: {
1113 CHECK_INTERFACE(IAudioFlinger, data, reply);
1114 effect_uuid_t uuid;
1115 data.read(&uuid, sizeof(effect_uuid_t));
1116 effect_descriptor_t desc;
1117 status_t status = getEffectDescriptor(&uuid, &desc);
1118 reply->writeInt32(status);
1119 if (status == NO_ERROR) {
1120 reply->write(&desc, sizeof(effect_descriptor_t));
1121 }
1122 return NO_ERROR;
1123 }
1124 case CREATE_EFFECT: {
1125 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurentbe916aa2010-06-01 23:49:17 -07001126 effect_descriptor_t desc;
1127 data.read(&desc, sizeof(effect_descriptor_t));
1128 sp<IEffectClient> client = interface_cast<IEffectClient>(data.readStrongBinder());
1129 int32_t priority = data.readInt32();
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001130 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Eric Laurentbe916aa2010-06-01 23:49:17 -07001131 int sessionId = data.readInt32();
1132 status_t status;
1133 int id;
1134 int enabled;
Eric Laurent05bca2f2010-02-26 02:47:27 -08001135
Glenn Kasten8d6cc842012-02-03 11:06:53 -08001136 sp<IEffect> effect = createEffect(&desc, client, priority, output, sessionId,
Glenn Kasten85ab62c2012-11-01 11:11:38 -07001137 &status, &id, &enabled);
Eric Laurentbe916aa2010-06-01 23:49:17 -07001138 reply->writeInt32(status);
1139 reply->writeInt32(id);
1140 reply->writeInt32(enabled);
1141 reply->writeStrongBinder(effect->asBinder());
1142 reply->write(&desc, sizeof(effect_descriptor_t));
1143 return NO_ERROR;
1144 } break;
Eric Laurentde070132010-07-13 04:45:46 -07001145 case MOVE_EFFECTS: {
1146 CHECK_INTERFACE(IAudioFlinger, data, reply);
1147 int session = data.readInt32();
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001148 audio_io_handle_t srcOutput = (audio_io_handle_t) data.readInt32();
1149 audio_io_handle_t dstOutput = (audio_io_handle_t) data.readInt32();
Eric Laurentde070132010-07-13 04:45:46 -07001150 reply->writeInt32(moveEffects(session, srcOutput, dstOutput));
1151 return NO_ERROR;
1152 } break;
Eric Laurenta4c5a552012-03-29 10:12:40 -07001153 case LOAD_HW_MODULE: {
1154 CHECK_INTERFACE(IAudioFlinger, data, reply);
1155 reply->writeInt32(loadHwModule(data.readCString()));
1156 return NO_ERROR;
1157 } break;
Glenn Kastencc0f1cf2012-09-24 11:27:18 -07001158 case GET_PRIMARY_OUTPUT_SAMPLING_RATE: {
1159 CHECK_INTERFACE(IAudioFlinger, data, reply);
1160 reply->writeInt32(getPrimaryOutputSamplingRate());
1161 return NO_ERROR;
1162 } break;
1163 case GET_PRIMARY_OUTPUT_FRAME_COUNT: {
1164 CHECK_INTERFACE(IAudioFlinger, data, reply);
1165 reply->writeInt32(getPrimaryOutputFrameCount());
1166 return NO_ERROR;
1167 } break;
Glenn Kasten4182c4e2013-07-15 14:45:07 -07001168 case SET_LOW_RAM_DEVICE: {
1169 CHECK_INTERFACE(IAudioFlinger, data, reply);
1170 bool isLowRamDevice = data.readInt32() != 0;
1171 reply->writeInt32(setLowRamDevice(isLowRamDevice));
1172 return NO_ERROR;
1173 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001174 default:
1175 return BBinder::onTransact(code, data, reply, flags);
1176 }
1177}
1178
1179// ----------------------------------------------------------------------------
1180
1181}; // namespace android