blob: 1940fe7a8391f6ecce9a62d3620a121a05f58046 [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;
Glenn Kastene03dd222014-01-28 11:04:39 -0800109 data.writeInt64(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);
Glenn Kasten2301acc2014-01-17 10:21:00 -0800112 // haveSharedBuffer
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 Kastenb53fc4e2014-05-02 08:03:58 -0700131 frameCount = reply.readInt64();
Glenn Kasten74935e42013-12-19 08:56:45 -0800132 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 }
Eric Laurent5841db72009-09-09 05:16:08 -0700143 lStatus = reply.readInt32();
144 track = interface_cast<IAudioTrack>(reply.readStrongBinder());
Glenn Kasten0cde0762014-01-16 15:06:36 -0800145 if (lStatus == NO_ERROR) {
146 if (track == 0) {
147 ALOGE("createTrack should have returned an IAudioTrack");
148 lStatus = UNKNOWN_ERROR;
149 }
150 } else {
151 if (track != 0) {
152 ALOGE("createTrack returned an IAudioTrack but with status %d", lStatus);
153 track.clear();
154 }
155 }
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800156 }
Glenn Kasten507b2862013-07-31 16:12:13 -0700157 if (status != NULL) {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800158 *status = lStatus;
159 }
Eric Laurent5841db72009-09-09 05:16:08 -0700160 return track;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800161 }
162
163 virtual sp<IAudioRecord> openRecord(
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800164 audio_io_handle_t input,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800165 uint32_t sampleRate,
Glenn Kasten58f30212012-01-12 12:27:51 -0800166 audio_format_t format,
Glenn Kasten28b76b32012-07-03 17:24:41 -0700167 audio_channel_mask_t channelMask,
Glenn Kasten74935e42013-12-19 08:56:45 -0800168 size_t *pFrameCount,
Glenn Kasteneeca3262013-07-31 16:12:48 -0700169 track_flags_t *flags,
Glenn Kasten1879fff2012-07-11 15:36:59 -0700170 pid_t tid,
Eric Laurentbe916aa2010-06-01 23:49:17 -0700171 int *sessionId,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800172 status_t *status)
173 {
174 Parcel data, reply;
Eric Laurent5841db72009-09-09 05:16:08 -0700175 sp<IAudioRecord> record;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800176 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800177 data.writeInt32((int32_t) input);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800178 data.writeInt32(sampleRate);
179 data.writeInt32(format);
Jean-Michel Trivi0d255b22011-05-24 15:53:33 -0700180 data.writeInt32(channelMask);
Glenn Kasten74935e42013-12-19 08:56:45 -0800181 size_t frameCount = pFrameCount != NULL ? *pFrameCount : 0;
Glenn Kastene03dd222014-01-28 11:04:39 -0800182 data.writeInt64(frameCount);
Glenn Kasteneeca3262013-07-31 16:12:48 -0700183 track_flags_t lFlags = flags != NULL ? *flags : (track_flags_t) TRACK_DEFAULT;
184 data.writeInt32(lFlags);
Glenn Kasten1879fff2012-07-11 15:36:59 -0700185 data.writeInt32((int32_t) tid);
Glenn Kastenaea7ea02013-06-26 09:25:47 -0700186 int lSessionId = AUDIO_SESSION_ALLOCATE;
Eric Laurentbe916aa2010-06-01 23:49:17 -0700187 if (sessionId != NULL) {
188 lSessionId = *sessionId;
189 }
190 data.writeInt32(lSessionId);
Eric Laurent5841db72009-09-09 05:16:08 -0700191 status_t lStatus = remote()->transact(OPEN_RECORD, data, &reply);
192 if (lStatus != NO_ERROR) {
Steve Block29357bc2012-01-06 19:20:56 +0000193 ALOGE("openRecord error: %s", strerror(-lStatus));
Eric Laurent5841db72009-09-09 05:16:08 -0700194 } else {
Glenn Kastenb53fc4e2014-05-02 08:03:58 -0700195 frameCount = reply.readInt64();
Glenn Kasten74935e42013-12-19 08:56:45 -0800196 if (pFrameCount != NULL) {
197 *pFrameCount = frameCount;
198 }
Glenn Kasteneeca3262013-07-31 16:12:48 -0700199 lFlags = reply.readInt32();
200 if (flags != NULL) {
201 *flags = lFlags;
202 }
Eric Laurentbe916aa2010-06-01 23:49:17 -0700203 lSessionId = reply.readInt32();
204 if (sessionId != NULL) {
205 *sessionId = lSessionId;
206 }
Eric Laurent5841db72009-09-09 05:16:08 -0700207 lStatus = reply.readInt32();
208 record = interface_cast<IAudioRecord>(reply.readStrongBinder());
Glenn Kastene93cf2c2013-09-24 11:52:37 -0700209 if (lStatus == NO_ERROR) {
210 if (record == 0) {
211 ALOGE("openRecord should have returned an IAudioRecord");
212 lStatus = UNKNOWN_ERROR;
213 }
214 } else {
215 if (record != 0) {
216 ALOGE("openRecord returned an IAudioRecord but with status %d", lStatus);
217 record.clear();
218 }
219 }
Eric Laurent5841db72009-09-09 05:16:08 -0700220 }
Glenn Kasten507b2862013-07-31 16:12:13 -0700221 if (status != NULL) {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800222 *status = lStatus;
223 }
Eric Laurent5841db72009-09-09 05:16:08 -0700224 return record;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800225 }
226
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800227 virtual uint32_t sampleRate(audio_io_handle_t output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800228 {
229 Parcel data, reply;
230 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800231 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800232 remote()->transact(SAMPLE_RATE, data, &reply);
233 return reply.readInt32();
234 }
235
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800236 virtual audio_format_t format(audio_io_handle_t output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800237 {
238 Parcel data, reply;
239 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800240 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800241 remote()->transact(FORMAT, data, &reply);
Glenn Kasten58f30212012-01-12 12:27:51 -0800242 return (audio_format_t) reply.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800243 }
244
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800245 virtual size_t frameCount(audio_io_handle_t output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800246 {
247 Parcel data, reply;
248 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800249 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800250 remote()->transact(FRAME_COUNT, data, &reply);
Glenn Kastene03dd222014-01-28 11:04:39 -0800251 return reply.readInt64();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800252 }
253
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800254 virtual uint32_t latency(audio_io_handle_t output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800255 {
256 Parcel data, reply;
257 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800258 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800259 remote()->transact(LATENCY, data, &reply);
260 return reply.readInt32();
261 }
262
263 virtual status_t setMasterVolume(float value)
264 {
265 Parcel data, reply;
266 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
267 data.writeFloat(value);
268 remote()->transact(SET_MASTER_VOLUME, data, &reply);
269 return reply.readInt32();
270 }
271
272 virtual status_t setMasterMute(bool muted)
273 {
274 Parcel data, reply;
275 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
276 data.writeInt32(muted);
277 remote()->transact(SET_MASTER_MUTE, data, &reply);
278 return reply.readInt32();
279 }
280
281 virtual float masterVolume() const
282 {
283 Parcel data, reply;
284 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
285 remote()->transact(MASTER_VOLUME, data, &reply);
286 return reply.readFloat();
287 }
288
289 virtual bool masterMute() const
290 {
291 Parcel data, reply;
292 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
293 remote()->transact(MASTER_MUTE, data, &reply);
294 return reply.readInt32();
295 }
296
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800297 virtual status_t setStreamVolume(audio_stream_type_t stream, float value,
298 audio_io_handle_t output)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800299 {
300 Parcel data, reply;
301 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800302 data.writeInt32((int32_t) stream);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800303 data.writeFloat(value);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800304 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800305 remote()->transact(SET_STREAM_VOLUME, data, &reply);
306 return reply.readInt32();
307 }
308
Glenn Kastenfff6d712012-01-12 16:38:12 -0800309 virtual status_t setStreamMute(audio_stream_type_t stream, bool muted)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800310 {
311 Parcel data, reply;
312 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800313 data.writeInt32((int32_t) stream);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800314 data.writeInt32(muted);
315 remote()->transact(SET_STREAM_MUTE, data, &reply);
316 return reply.readInt32();
317 }
318
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800319 virtual float streamVolume(audio_stream_type_t stream, audio_io_handle_t output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800320 {
321 Parcel data, reply;
322 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800323 data.writeInt32((int32_t) stream);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800324 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800325 remote()->transact(STREAM_VOLUME, data, &reply);
326 return reply.readFloat();
327 }
328
Glenn Kastenfff6d712012-01-12 16:38:12 -0800329 virtual bool streamMute(audio_stream_type_t stream) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800330 {
331 Parcel data, reply;
332 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800333 data.writeInt32((int32_t) stream);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800334 remote()->transact(STREAM_MUTE, data, &reply);
335 return reply.readInt32();
336 }
337
Glenn Kastenf78aee72012-01-04 11:00:47 -0800338 virtual status_t setMode(audio_mode_t mode)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800339 {
340 Parcel data, reply;
341 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
342 data.writeInt32(mode);
343 remote()->transact(SET_MODE, data, &reply);
344 return reply.readInt32();
345 }
346
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800347 virtual status_t setMicMute(bool state)
348 {
349 Parcel data, reply;
350 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
351 data.writeInt32(state);
352 remote()->transact(SET_MIC_MUTE, data, &reply);
353 return reply.readInt32();
354 }
355
356 virtual bool getMicMute() const
357 {
358 Parcel data, reply;
359 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
360 remote()->transact(GET_MIC_MUTE, data, &reply);
361 return reply.readInt32();
362 }
363
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800364 virtual status_t setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800365 {
366 Parcel data, reply;
367 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800368 data.writeInt32((int32_t) ioHandle);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700369 data.writeString8(keyValuePairs);
370 remote()->transact(SET_PARAMETERS, data, &reply);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800371 return reply.readInt32();
372 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700373
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800374 virtual String8 getParameters(audio_io_handle_t ioHandle, const String8& keys) const
Eric Laurentc2f1f072009-07-17 12:17:14 -0700375 {
376 Parcel data, reply;
377 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800378 data.writeInt32((int32_t) ioHandle);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700379 data.writeString8(keys);
380 remote()->transact(GET_PARAMETERS, data, &reply);
381 return reply.readString8();
382 }
383
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800384 virtual void registerClient(const sp<IAudioFlingerClient>& client)
385 {
386 Parcel data, reply;
387 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
388 data.writeStrongBinder(client->asBinder());
389 remote()->transact(REGISTER_CLIENT, data, &reply);
390 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700391
Glenn Kastendd8104c2012-07-02 12:42:44 -0700392 virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format,
393 audio_channel_mask_t channelMask) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800394 {
395 Parcel data, reply;
396 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
397 data.writeInt32(sampleRate);
398 data.writeInt32(format);
Glenn Kastendd8104c2012-07-02 12:42:44 -0700399 data.writeInt32(channelMask);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800400 remote()->transact(GET_INPUTBUFFERSIZE, data, &reply);
Glenn Kastene03dd222014-01-28 11:04:39 -0800401 return reply.readInt64();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800402 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700403
Eric Laurenta4c5a552012-03-29 10:12:40 -0700404 virtual audio_io_handle_t openOutput(audio_module_handle_t module,
405 audio_devices_t *pDevices,
406 uint32_t *pSamplingRate,
407 audio_format_t *pFormat,
408 audio_channel_mask_t *pChannelMask,
409 uint32_t *pLatencyMs,
Richard Fitzgeraldad3af332013-03-25 16:54:37 +0000410 audio_output_flags_t flags,
411 const audio_offload_info_t *offloadInfo)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800412 {
413 Parcel data, reply;
Glenn Kasten45faf7e2014-01-17 10:23:01 -0800414 audio_devices_t devices = pDevices != NULL ? *pDevices : AUDIO_DEVICE_NONE;
Glenn Kasten7c5977f2013-07-02 14:17:22 -0700415 uint32_t samplingRate = pSamplingRate != NULL ? *pSamplingRate : 0;
416 audio_format_t format = pFormat != NULL ? *pFormat : AUDIO_FORMAT_DEFAULT;
417 audio_channel_mask_t channelMask = pChannelMask != NULL ?
418 *pChannelMask : (audio_channel_mask_t)0;
419 uint32_t latency = pLatencyMs != NULL ? *pLatencyMs : 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800420 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurenta4c5a552012-03-29 10:12:40 -0700421 data.writeInt32(module);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700422 data.writeInt32(devices);
423 data.writeInt32(samplingRate);
424 data.writeInt32(format);
Eric Laurenta4c5a552012-03-29 10:12:40 -0700425 data.writeInt32(channelMask);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700426 data.writeInt32(latency);
Glenn Kasten18868c52012-03-07 09:15:37 -0800427 data.writeInt32((int32_t) flags);
Glenn Kasten2301acc2014-01-17 10:21:00 -0800428 // hasOffloadInfo
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 Kasten45faf7e2014-01-17 10:23:01 -0800506 audio_devices_t devices = pDevices != NULL ? *pDevices : AUDIO_DEVICE_NONE;
Glenn Kasten7c5977f2013-07-02 14:17:22 -0700507 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);
Glenn Kasten85d109a2014-01-17 10:25:08 -0800604 int id = AUDIO_SESSION_ALLOCATE;
Eric Laurentbe916aa2010-06-01 23:49:17 -0700605 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);
Glenn Kastene03dd222014-01-28 11:04:39 -0800772 return reply.readInt64();
Glenn Kastencc0f1cf2012-09-24 11:27:18 -0700773 }
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 Kastene03dd222014-01-28 11:04:39 -0800800 size_t frameCount = data.readInt64();
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();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800811 status_t status;
Eric Laurent3d00aa62013-09-24 09:53:27 -0700812 sp<IAudioTrack> track;
813 if ((haveSharedBuffer && (buffer == 0)) ||
814 ((buffer != 0) && (buffer->pointer() == NULL))) {
815 ALOGW("CREATE_TRACK: cannot retrieve shared memory");
816 status = DEAD_OBJECT;
817 } else {
818 track = createTrack(
819 (audio_stream_type_t) streamType, sampleRate, format,
Glenn Kasten74935e42013-12-19 08:56:45 -0800820 channelMask, &frameCount, &flags, buffer, output, tid,
Glenn Kastenc5a17422014-03-13 14:59:59 -0700821 &sessionId, clientUid, &status);
Glenn Kasten0cde0762014-01-16 15:06:36 -0800822 LOG_ALWAYS_FATAL_IF((track != 0) != (status == NO_ERROR));
Eric Laurent3d00aa62013-09-24 09:53:27 -0700823 }
Glenn Kastenb53fc4e2014-05-02 08:03:58 -0700824 reply->writeInt64(frameCount);
Glenn Kastene0b07172012-11-06 15:03:34 -0800825 reply->writeInt32(flags);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700826 reply->writeInt32(sessionId);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800827 reply->writeInt32(status);
828 reply->writeStrongBinder(track->asBinder());
829 return NO_ERROR;
830 } break;
831 case OPEN_RECORD: {
832 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800833 audio_io_handle_t input = (audio_io_handle_t) data.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800834 uint32_t sampleRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -0800835 audio_format_t format = (audio_format_t) data.readInt32();
Glenn Kastendd8104c2012-07-02 12:42:44 -0700836 audio_channel_mask_t channelMask = data.readInt32();
Glenn Kastene03dd222014-01-28 11:04:39 -0800837 size_t frameCount = data.readInt64();
Glenn Kastena075db42012-03-06 11:22:44 -0800838 track_flags_t flags = (track_flags_t) data.readInt32();
Glenn Kasten1879fff2012-07-11 15:36:59 -0700839 pid_t tid = (pid_t) data.readInt32();
Eric Laurentbe916aa2010-06-01 23:49:17 -0700840 int sessionId = data.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800841 status_t status;
Glenn Kasten8d6cc842012-02-03 11:06:53 -0800842 sp<IAudioRecord> record = openRecord(input,
Glenn Kasten74935e42013-12-19 08:56:45 -0800843 sampleRate, format, channelMask, &frameCount, &flags, tid, &sessionId, &status);
Glenn Kastene93cf2c2013-09-24 11:52:37 -0700844 LOG_ALWAYS_FATAL_IF((record != 0) != (status == NO_ERROR));
Glenn Kastenb53fc4e2014-05-02 08:03:58 -0700845 reply->writeInt64(frameCount);
Glenn Kasteneeca3262013-07-31 16:12:48 -0700846 reply->writeInt32(flags);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700847 reply->writeInt32(sessionId);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800848 reply->writeInt32(status);
849 reply->writeStrongBinder(record->asBinder());
850 return NO_ERROR;
851 } break;
852 case SAMPLE_RATE: {
853 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800854 reply->writeInt32( sampleRate((audio_io_handle_t) data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800855 return NO_ERROR;
856 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800857 case FORMAT: {
858 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800859 reply->writeInt32( format((audio_io_handle_t) data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800860 return NO_ERROR;
861 } break;
862 case FRAME_COUNT: {
863 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kastene03dd222014-01-28 11:04:39 -0800864 reply->writeInt64( frameCount((audio_io_handle_t) data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800865 return NO_ERROR;
866 } break;
867 case LATENCY: {
868 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800869 reply->writeInt32( latency((audio_io_handle_t) data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800870 return NO_ERROR;
871 } break;
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700872 case SET_MASTER_VOLUME: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800873 CHECK_INTERFACE(IAudioFlinger, data, reply);
874 reply->writeInt32( setMasterVolume(data.readFloat()) );
875 return NO_ERROR;
876 } break;
877 case SET_MASTER_MUTE: {
878 CHECK_INTERFACE(IAudioFlinger, data, reply);
879 reply->writeInt32( setMasterMute(data.readInt32()) );
880 return NO_ERROR;
881 } break;
882 case MASTER_VOLUME: {
883 CHECK_INTERFACE(IAudioFlinger, data, reply);
884 reply->writeFloat( masterVolume() );
885 return NO_ERROR;
886 } break;
887 case MASTER_MUTE: {
888 CHECK_INTERFACE(IAudioFlinger, data, reply);
889 reply->writeInt32( masterMute() );
890 return NO_ERROR;
891 } break;
892 case SET_STREAM_VOLUME: {
893 CHECK_INTERFACE(IAudioFlinger, data, reply);
894 int stream = data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700895 float volume = data.readFloat();
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800896 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -0800897 reply->writeInt32( setStreamVolume((audio_stream_type_t) stream, volume, output) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800898 return NO_ERROR;
899 } break;
900 case SET_STREAM_MUTE: {
901 CHECK_INTERFACE(IAudioFlinger, data, reply);
902 int stream = data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -0800903 reply->writeInt32( setStreamMute((audio_stream_type_t) stream, data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800904 return NO_ERROR;
905 } break;
906 case STREAM_VOLUME: {
907 CHECK_INTERFACE(IAudioFlinger, data, reply);
908 int stream = data.readInt32();
Eric Laurentfa2877b2009-07-28 08:44:33 -0700909 int output = data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -0800910 reply->writeFloat( streamVolume((audio_stream_type_t) stream, output) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800911 return NO_ERROR;
912 } break;
913 case STREAM_MUTE: {
914 CHECK_INTERFACE(IAudioFlinger, data, reply);
915 int stream = data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -0800916 reply->writeInt32( streamMute((audio_stream_type_t) stream) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800917 return NO_ERROR;
918 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800919 case SET_MODE: {
920 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kastenf78aee72012-01-04 11:00:47 -0800921 audio_mode_t mode = (audio_mode_t) data.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800922 reply->writeInt32( setMode(mode) );
923 return NO_ERROR;
924 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800925 case SET_MIC_MUTE: {
926 CHECK_INTERFACE(IAudioFlinger, data, reply);
927 int state = data.readInt32();
928 reply->writeInt32( setMicMute(state) );
929 return NO_ERROR;
930 } break;
931 case GET_MIC_MUTE: {
932 CHECK_INTERFACE(IAudioFlinger, data, reply);
933 reply->writeInt32( getMicMute() );
934 return NO_ERROR;
935 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700936 case SET_PARAMETERS: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800937 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800938 audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700939 String8 keyValuePairs(data.readString8());
940 reply->writeInt32(setParameters(ioHandle, keyValuePairs));
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800941 return NO_ERROR;
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700942 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700943 case GET_PARAMETERS: {
944 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800945 audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700946 String8 keys(data.readString8());
947 reply->writeString8(getParameters(ioHandle, keys));
948 return NO_ERROR;
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700949 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700950
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800951 case REGISTER_CLIENT: {
952 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten85ab62c2012-11-01 11:11:38 -0700953 sp<IAudioFlingerClient> client = interface_cast<IAudioFlingerClient>(
954 data.readStrongBinder());
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800955 registerClient(client);
956 return NO_ERROR;
957 } break;
958 case GET_INPUTBUFFERSIZE: {
959 CHECK_INTERFACE(IAudioFlinger, data, reply);
960 uint32_t sampleRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -0800961 audio_format_t format = (audio_format_t) data.readInt32();
Glenn Kastendd8104c2012-07-02 12:42:44 -0700962 audio_channel_mask_t channelMask = data.readInt32();
Glenn Kastene03dd222014-01-28 11:04:39 -0800963 reply->writeInt64( getInputBufferSize(sampleRate, format, channelMask) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800964 return NO_ERROR;
965 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700966 case OPEN_OUTPUT: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800967 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurenta4c5a552012-03-29 10:12:40 -0700968 audio_module_handle_t module = (audio_module_handle_t)data.readInt32();
969 audio_devices_t devices = (audio_devices_t)data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700970 uint32_t samplingRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -0800971 audio_format_t format = (audio_format_t) data.readInt32();
Eric Laurenta4c5a552012-03-29 10:12:40 -0700972 audio_channel_mask_t channelMask = (audio_channel_mask_t)data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700973 uint32_t latency = data.readInt32();
Eric Laurent0ca3cf92012-04-18 09:24:29 -0700974 audio_output_flags_t flags = (audio_output_flags_t) data.readInt32();
Richard Fitzgeraldb1a270d2013-05-14 12:12:21 +0100975 bool hasOffloadInfo = data.readInt32() != 0;
976 audio_offload_info_t offloadInfo;
977 if (hasOffloadInfo) {
978 data.read(&offloadInfo, sizeof(audio_offload_info_t));
979 }
Eric Laurenta4c5a552012-03-29 10:12:40 -0700980 audio_io_handle_t output = openOutput(module,
981 &devices,
982 &samplingRate,
983 &format,
984 &channelMask,
985 &latency,
Richard Fitzgeraldb1a270d2013-05-14 12:12:21 +0100986 flags,
987 hasOffloadInfo ? &offloadInfo : NULL);
Glenn Kasten70742962014-02-18 08:00:47 -0800988 ALOGV("OPEN_OUTPUT output, %d", output);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800989 reply->writeInt32((int32_t) output);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700990 reply->writeInt32(devices);
991 reply->writeInt32(samplingRate);
992 reply->writeInt32(format);
Eric Laurenta4c5a552012-03-29 10:12:40 -0700993 reply->writeInt32(channelMask);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700994 reply->writeInt32(latency);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800995 return NO_ERROR;
996 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700997 case OPEN_DUPLICATE_OUTPUT: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800998 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800999 audio_io_handle_t output1 = (audio_io_handle_t) data.readInt32();
1000 audio_io_handle_t output2 = (audio_io_handle_t) data.readInt32();
1001 reply->writeInt32((int32_t) openDuplicateOutput(output1, output2));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001002 return NO_ERROR;
1003 } break;
1004 case CLOSE_OUTPUT: {
1005 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001006 reply->writeInt32(closeOutput((audio_io_handle_t) data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001007 return NO_ERROR;
1008 } break;
1009 case SUSPEND_OUTPUT: {
1010 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001011 reply->writeInt32(suspendOutput((audio_io_handle_t) data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001012 return NO_ERROR;
1013 } break;
1014 case RESTORE_OUTPUT: {
1015 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001016 reply->writeInt32(restoreOutput((audio_io_handle_t) data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001017 return NO_ERROR;
1018 } break;
1019 case OPEN_INPUT: {
1020 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurenta4c5a552012-03-29 10:12:40 -07001021 audio_module_handle_t module = (audio_module_handle_t)data.readInt32();
1022 audio_devices_t devices = (audio_devices_t)data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -07001023 uint32_t samplingRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -08001024 audio_format_t format = (audio_format_t) data.readInt32();
Eric Laurenta4c5a552012-03-29 10:12:40 -07001025 audio_channel_mask_t channelMask = (audio_channel_mask_t)data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -07001026
Eric Laurenta4c5a552012-03-29 10:12:40 -07001027 audio_io_handle_t input = openInput(module,
1028 &devices,
1029 &samplingRate,
1030 &format,
1031 &channelMask);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001032 reply->writeInt32((int32_t) input);
Eric Laurentc2f1f072009-07-17 12:17:14 -07001033 reply->writeInt32(devices);
1034 reply->writeInt32(samplingRate);
1035 reply->writeInt32(format);
Eric Laurenta4c5a552012-03-29 10:12:40 -07001036 reply->writeInt32(channelMask);
Eric Laurentc2f1f072009-07-17 12:17:14 -07001037 return NO_ERROR;
1038 } break;
1039 case CLOSE_INPUT: {
1040 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001041 reply->writeInt32(closeInput((audio_io_handle_t) data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001042 return NO_ERROR;
1043 } break;
Glenn Kastend2304db2014-02-03 07:40:31 -08001044 case INVALIDATE_STREAM: {
Eric Laurentc2f1f072009-07-17 12:17:14 -07001045 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kastend2304db2014-02-03 07:40:31 -08001046 audio_stream_type_t stream = (audio_stream_type_t) data.readInt32();
1047 reply->writeInt32(invalidateStream(stream));
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001048 return NO_ERROR;
1049 } break;
Eric Laurentf0ee6f42009-10-21 08:14:22 -07001050 case SET_VOICE_VOLUME: {
1051 CHECK_INTERFACE(IAudioFlinger, data, reply);
1052 float volume = data.readFloat();
1053 reply->writeInt32( setVoiceVolume(volume) );
1054 return NO_ERROR;
1055 } break;
Eric Laurent342e9cf2010-01-19 17:37:09 -08001056 case GET_RENDER_POSITION: {
1057 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001058 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Kévin PETIT377b2ec2014-02-03 12:35:36 +00001059 uint32_t halFrames;
1060 uint32_t dspFrames;
Eric Laurent342e9cf2010-01-19 17:37:09 -08001061 status_t status = getRenderPosition(&halFrames, &dspFrames, output);
1062 reply->writeInt32(status);
1063 if (status == NO_ERROR) {
1064 reply->writeInt32(halFrames);
1065 reply->writeInt32(dspFrames);
1066 }
1067 return NO_ERROR;
1068 }
Eric Laurent05bca2f2010-02-26 02:47:27 -08001069 case GET_INPUT_FRAMES_LOST: {
1070 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001071 audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
Glenn Kasten5f972c02014-01-13 09:59:31 -08001072 reply->writeInt32((int32_t) getInputFramesLost(ioHandle));
Eric Laurent05bca2f2010-02-26 02:47:27 -08001073 return NO_ERROR;
1074 } break;
Eric Laurentbe916aa2010-06-01 23:49:17 -07001075 case NEW_AUDIO_SESSION_ID: {
1076 CHECK_INTERFACE(IAudioFlinger, data, reply);
1077 reply->writeInt32(newAudioSessionId());
1078 return NO_ERROR;
1079 } break;
Marco Nelissen3a34bef2011-08-02 13:33:41 -07001080 case ACQUIRE_AUDIO_SESSION_ID: {
1081 CHECK_INTERFACE(IAudioFlinger, data, reply);
1082 int audioSession = data.readInt32();
Marco Nelissend457c972014-02-11 08:47:07 -08001083 int pid = data.readInt32();
1084 acquireAudioSessionId(audioSession, pid);
Marco Nelissen3a34bef2011-08-02 13:33:41 -07001085 return NO_ERROR;
1086 } break;
1087 case RELEASE_AUDIO_SESSION_ID: {
1088 CHECK_INTERFACE(IAudioFlinger, data, reply);
1089 int audioSession = data.readInt32();
Marco Nelissend457c972014-02-11 08:47:07 -08001090 int pid = data.readInt32();
1091 releaseAudioSessionId(audioSession, pid);
Marco Nelissen3a34bef2011-08-02 13:33:41 -07001092 return NO_ERROR;
1093 } break;
Eric Laurentbe916aa2010-06-01 23:49:17 -07001094 case QUERY_NUM_EFFECTS: {
1095 CHECK_INTERFACE(IAudioFlinger, data, reply);
1096 uint32_t numEffects;
1097 status_t status = queryNumberEffects(&numEffects);
1098 reply->writeInt32(status);
1099 if (status == NO_ERROR) {
1100 reply->writeInt32((int32_t)numEffects);
1101 }
1102 return NO_ERROR;
1103 }
Eric Laurentffe9c252010-06-23 17:38:20 -07001104 case QUERY_EFFECT: {
Eric Laurentbe916aa2010-06-01 23:49:17 -07001105 CHECK_INTERFACE(IAudioFlinger, data, reply);
1106 effect_descriptor_t desc;
Eric Laurentffe9c252010-06-23 17:38:20 -07001107 status_t status = queryEffect(data.readInt32(), &desc);
Eric Laurentbe916aa2010-06-01 23:49:17 -07001108 reply->writeInt32(status);
1109 if (status == NO_ERROR) {
1110 reply->write(&desc, sizeof(effect_descriptor_t));
1111 }
1112 return NO_ERROR;
1113 }
1114 case GET_EFFECT_DESCRIPTOR: {
1115 CHECK_INTERFACE(IAudioFlinger, data, reply);
1116 effect_uuid_t uuid;
1117 data.read(&uuid, sizeof(effect_uuid_t));
1118 effect_descriptor_t desc;
1119 status_t status = getEffectDescriptor(&uuid, &desc);
1120 reply->writeInt32(status);
1121 if (status == NO_ERROR) {
1122 reply->write(&desc, sizeof(effect_descriptor_t));
1123 }
1124 return NO_ERROR;
1125 }
1126 case CREATE_EFFECT: {
1127 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurentbe916aa2010-06-01 23:49:17 -07001128 effect_descriptor_t desc;
1129 data.read(&desc, sizeof(effect_descriptor_t));
1130 sp<IEffectClient> client = interface_cast<IEffectClient>(data.readStrongBinder());
1131 int32_t priority = data.readInt32();
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001132 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Eric Laurentbe916aa2010-06-01 23:49:17 -07001133 int sessionId = data.readInt32();
1134 status_t status;
1135 int id;
1136 int enabled;
Eric Laurent05bca2f2010-02-26 02:47:27 -08001137
Glenn Kasten8d6cc842012-02-03 11:06:53 -08001138 sp<IEffect> effect = createEffect(&desc, client, priority, output, sessionId,
Glenn Kasten85ab62c2012-11-01 11:11:38 -07001139 &status, &id, &enabled);
Eric Laurentbe916aa2010-06-01 23:49:17 -07001140 reply->writeInt32(status);
1141 reply->writeInt32(id);
1142 reply->writeInt32(enabled);
1143 reply->writeStrongBinder(effect->asBinder());
1144 reply->write(&desc, sizeof(effect_descriptor_t));
1145 return NO_ERROR;
1146 } break;
Eric Laurentde070132010-07-13 04:45:46 -07001147 case MOVE_EFFECTS: {
1148 CHECK_INTERFACE(IAudioFlinger, data, reply);
1149 int session = data.readInt32();
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001150 audio_io_handle_t srcOutput = (audio_io_handle_t) data.readInt32();
1151 audio_io_handle_t dstOutput = (audio_io_handle_t) data.readInt32();
Eric Laurentde070132010-07-13 04:45:46 -07001152 reply->writeInt32(moveEffects(session, srcOutput, dstOutput));
1153 return NO_ERROR;
1154 } break;
Eric Laurenta4c5a552012-03-29 10:12:40 -07001155 case LOAD_HW_MODULE: {
1156 CHECK_INTERFACE(IAudioFlinger, data, reply);
1157 reply->writeInt32(loadHwModule(data.readCString()));
1158 return NO_ERROR;
1159 } break;
Glenn Kastencc0f1cf2012-09-24 11:27:18 -07001160 case GET_PRIMARY_OUTPUT_SAMPLING_RATE: {
1161 CHECK_INTERFACE(IAudioFlinger, data, reply);
1162 reply->writeInt32(getPrimaryOutputSamplingRate());
1163 return NO_ERROR;
1164 } break;
1165 case GET_PRIMARY_OUTPUT_FRAME_COUNT: {
1166 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kastene03dd222014-01-28 11:04:39 -08001167 reply->writeInt64(getPrimaryOutputFrameCount());
Glenn Kastencc0f1cf2012-09-24 11:27:18 -07001168 return NO_ERROR;
1169 } break;
Glenn Kasten4182c4e2013-07-15 14:45:07 -07001170 case SET_LOW_RAM_DEVICE: {
1171 CHECK_INTERFACE(IAudioFlinger, data, reply);
1172 bool isLowRamDevice = data.readInt32() != 0;
1173 reply->writeInt32(setLowRamDevice(isLowRamDevice));
1174 return NO_ERROR;
1175 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001176 default:
1177 return BBinder::onTransact(code, data, reply, flags);
1178 }
1179}
1180
1181// ----------------------------------------------------------------------------
1182
1183}; // namespace android