blob: 451edba4b2c170d04ed8f8e43eecfc114e686e07 [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,
Glenn Kasten9eae0362016-04-19 09:09:14 -070065 NEW_AUDIO_UNIQUE_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,
Eric Laurent4b123402014-04-11 09:22:20 -070077 LIST_AUDIO_PORTS,
78 GET_AUDIO_PORT,
79 CREATE_AUDIO_PATCH,
80 RELEASE_AUDIO_PATCH,
81 LIST_AUDIO_PATCHES,
Eric Laurent93c3d412014-08-01 14:48:35 -070082 SET_AUDIO_PORT_CONFIG,
Glenn Kasten9eae0362016-04-19 09:09:14 -070083 GET_AUDIO_HW_SYNC_FOR_SESSION,
Glenn Kasten4a8308b2016-04-18 14:10:01 -070084 SYSTEM_READY,
85 FRAME_COUNT_HAL,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080086};
87
Eric Laurentf75c2fe2015-04-02 13:49:15 -070088#define MAX_ITEMS_PER_LIST 1024
89
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080090class BpAudioFlinger : public BpInterface<IAudioFlinger>
91{
92public:
Chih-Hung Hsieh090ef602016-04-27 10:39:54 -070093 explicit BpAudioFlinger(const sp<IBinder>& impl)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080094 : BpInterface<IAudioFlinger>(impl)
95 {
96 }
97
98 virtual sp<IAudioTrack> createTrack(
Glenn Kastenfff6d712012-01-12 16:38:12 -080099 audio_stream_type_t streamType,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800100 uint32_t sampleRate,
Glenn Kasten58f30212012-01-12 12:27:51 -0800101 audio_format_t format,
Glenn Kastendd8104c2012-07-02 12:42:44 -0700102 audio_channel_mask_t channelMask,
Glenn Kasten74935e42013-12-19 08:56:45 -0800103 size_t *pFrameCount,
Eric Laurent05067782016-06-01 18:27:28 -0700104 audio_output_flags_t *flags,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800105 const sp<IMemory>& sharedBuffer,
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800106 audio_io_handle_t output,
Haynes Mathew George9ea77cd2016-04-06 17:07:48 -0700107 pid_t pid,
Glenn Kasten3acbd052012-02-28 10:39:56 -0800108 pid_t tid,
Glenn Kastend848eb42016-03-08 13:42:11 -0800109 audio_session_t *sessionId,
Marco Nelissen462fd2f2013-01-14 14:12:05 -0800110 int clientUid,
Eric Laurent20b9ef02016-12-05 11:03:16 -0800111 status_t *status,
112 audio_port_handle_t portId)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800113 {
114 Parcel data, reply;
Eric Laurent5841db72009-09-09 05:16:08 -0700115 sp<IAudioTrack> track;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800116 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800117 data.writeInt32((int32_t) streamType);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800118 data.writeInt32(sampleRate);
119 data.writeInt32(format);
Jean-Michel Trivi0d255b22011-05-24 15:53:33 -0700120 data.writeInt32(channelMask);
Glenn Kasten74935e42013-12-19 08:56:45 -0800121 size_t frameCount = pFrameCount != NULL ? *pFrameCount : 0;
Glenn Kastene03dd222014-01-28 11:04:39 -0800122 data.writeInt64(frameCount);
Eric Laurent05067782016-06-01 18:27:28 -0700123 audio_output_flags_t lFlags = flags != NULL ? *flags : AUDIO_OUTPUT_FLAG_NONE;
Glenn Kastene0b07172012-11-06 15:03:34 -0800124 data.writeInt32(lFlags);
Glenn Kasten2301acc2014-01-17 10:21:00 -0800125 // haveSharedBuffer
Eric Laurent3d00aa62013-09-24 09:53:27 -0700126 if (sharedBuffer != 0) {
127 data.writeInt32(true);
Marco Nelissen06b46062014-11-14 07:58:25 -0800128 data.writeStrongBinder(IInterface::asBinder(sharedBuffer));
Eric Laurent3d00aa62013-09-24 09:53:27 -0700129 } else {
130 data.writeInt32(false);
131 }
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800132 data.writeInt32((int32_t) output);
Haynes Mathew George9ea77cd2016-04-06 17:07:48 -0700133 data.writeInt32((int32_t) pid);
Glenn Kasten3acbd052012-02-28 10:39:56 -0800134 data.writeInt32((int32_t) tid);
Glenn Kastend848eb42016-03-08 13:42:11 -0800135 audio_session_t lSessionId = AUDIO_SESSION_ALLOCATE;
Eric Laurentbe916aa2010-06-01 23:49:17 -0700136 if (sessionId != NULL) {
137 lSessionId = *sessionId;
138 }
139 data.writeInt32(lSessionId);
Marco Nelissen462fd2f2013-01-14 14:12:05 -0800140 data.writeInt32(clientUid);
Eric Laurent20b9ef02016-12-05 11:03:16 -0800141 data.writeInt32(portId);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800142 status_t lStatus = remote()->transact(CREATE_TRACK, data, &reply);
143 if (lStatus != NO_ERROR) {
Steve Block29357bc2012-01-06 19:20:56 +0000144 ALOGE("createTrack error: %s", strerror(-lStatus));
Eric Laurent5841db72009-09-09 05:16:08 -0700145 } else {
Glenn Kastenb53fc4e2014-05-02 08:03:58 -0700146 frameCount = reply.readInt64();
Glenn Kasten74935e42013-12-19 08:56:45 -0800147 if (pFrameCount != NULL) {
148 *pFrameCount = frameCount;
149 }
Eric Laurent05067782016-06-01 18:27:28 -0700150 lFlags = (audio_output_flags_t)reply.readInt32();
Glenn Kastene0b07172012-11-06 15:03:34 -0800151 if (flags != NULL) {
152 *flags = lFlags;
153 }
Glenn Kastend848eb42016-03-08 13:42:11 -0800154 lSessionId = (audio_session_t) reply.readInt32();
Eric Laurentbe916aa2010-06-01 23:49:17 -0700155 if (sessionId != NULL) {
156 *sessionId = lSessionId;
157 }
Eric Laurent5841db72009-09-09 05:16:08 -0700158 lStatus = reply.readInt32();
159 track = interface_cast<IAudioTrack>(reply.readStrongBinder());
Glenn Kasten0cde0762014-01-16 15:06:36 -0800160 if (lStatus == NO_ERROR) {
161 if (track == 0) {
162 ALOGE("createTrack should have returned an IAudioTrack");
163 lStatus = UNKNOWN_ERROR;
164 }
165 } else {
166 if (track != 0) {
167 ALOGE("createTrack returned an IAudioTrack but with status %d", lStatus);
168 track.clear();
169 }
170 }
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800171 }
Glenn Kasten507b2862013-07-31 16:12:13 -0700172 if (status != NULL) {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800173 *status = lStatus;
174 }
Eric Laurent5841db72009-09-09 05:16:08 -0700175 return track;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800176 }
177
178 virtual sp<IAudioRecord> openRecord(
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800179 audio_io_handle_t input,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800180 uint32_t sampleRate,
Glenn Kasten58f30212012-01-12 12:27:51 -0800181 audio_format_t format,
Glenn Kasten28b76b32012-07-03 17:24:41 -0700182 audio_channel_mask_t channelMask,
Svet Ganovbe71aa22015-04-28 12:06:02 -0700183 const String16& opPackageName,
Glenn Kasten74935e42013-12-19 08:56:45 -0800184 size_t *pFrameCount,
Eric Laurent05067782016-06-01 18:27:28 -0700185 audio_input_flags_t *flags,
Haynes Mathew George9ea77cd2016-04-06 17:07:48 -0700186 pid_t pid,
Glenn Kasten1879fff2012-07-11 15:36:59 -0700187 pid_t tid,
Jean-Michel Trivi4cb66832015-05-01 18:34:17 -0700188 int clientUid,
Glenn Kastend848eb42016-03-08 13:42:11 -0800189 audio_session_t *sessionId,
Glenn Kasten7df8c0b2014-07-03 12:23:29 -0700190 size_t *notificationFrames,
Glenn Kastend776ac62014-05-07 09:16:09 -0700191 sp<IMemory>& cblk,
192 sp<IMemory>& buffers,
Eric Laurent20b9ef02016-12-05 11:03:16 -0800193 status_t *status,
194 audio_port_handle_t portId)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800195 {
196 Parcel data, reply;
Eric Laurent5841db72009-09-09 05:16:08 -0700197 sp<IAudioRecord> record;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800198 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800199 data.writeInt32((int32_t) input);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800200 data.writeInt32(sampleRate);
201 data.writeInt32(format);
Jean-Michel Trivi0d255b22011-05-24 15:53:33 -0700202 data.writeInt32(channelMask);
Dianne Hackborneaa34702015-04-29 12:57:58 -0700203 data.writeString16(opPackageName);
Glenn Kasten74935e42013-12-19 08:56:45 -0800204 size_t frameCount = pFrameCount != NULL ? *pFrameCount : 0;
Glenn Kastene03dd222014-01-28 11:04:39 -0800205 data.writeInt64(frameCount);
Eric Laurent05067782016-06-01 18:27:28 -0700206 audio_input_flags_t lFlags = flags != NULL ? *flags : AUDIO_INPUT_FLAG_NONE;
Glenn Kasteneeca3262013-07-31 16:12:48 -0700207 data.writeInt32(lFlags);
Haynes Mathew George9ea77cd2016-04-06 17:07:48 -0700208 data.writeInt32((int32_t) pid);
Glenn Kasten1879fff2012-07-11 15:36:59 -0700209 data.writeInt32((int32_t) tid);
Jean-Michel Trivi4cb66832015-05-01 18:34:17 -0700210 data.writeInt32((int32_t) clientUid);
Glenn Kastend848eb42016-03-08 13:42:11 -0800211 audio_session_t lSessionId = AUDIO_SESSION_ALLOCATE;
Eric Laurentbe916aa2010-06-01 23:49:17 -0700212 if (sessionId != NULL) {
213 lSessionId = *sessionId;
214 }
215 data.writeInt32(lSessionId);
Glenn Kasten74105912014-07-03 12:28:53 -0700216 data.writeInt64(notificationFrames != NULL ? *notificationFrames : 0);
Eric Laurent20b9ef02016-12-05 11:03:16 -0800217 data.writeInt32(portId);
Glenn Kastend776ac62014-05-07 09:16:09 -0700218 cblk.clear();
219 buffers.clear();
Eric Laurent5841db72009-09-09 05:16:08 -0700220 status_t lStatus = remote()->transact(OPEN_RECORD, data, &reply);
221 if (lStatus != NO_ERROR) {
Steve Block29357bc2012-01-06 19:20:56 +0000222 ALOGE("openRecord error: %s", strerror(-lStatus));
Eric Laurent5841db72009-09-09 05:16:08 -0700223 } else {
Glenn Kastenb53fc4e2014-05-02 08:03:58 -0700224 frameCount = reply.readInt64();
Glenn Kasten74935e42013-12-19 08:56:45 -0800225 if (pFrameCount != NULL) {
226 *pFrameCount = frameCount;
227 }
Eric Laurent05067782016-06-01 18:27:28 -0700228 lFlags = (audio_input_flags_t)reply.readInt32();
Glenn Kasteneeca3262013-07-31 16:12:48 -0700229 if (flags != NULL) {
230 *flags = lFlags;
231 }
Glenn Kastend848eb42016-03-08 13:42:11 -0800232 lSessionId = (audio_session_t) reply.readInt32();
Eric Laurentbe916aa2010-06-01 23:49:17 -0700233 if (sessionId != NULL) {
234 *sessionId = lSessionId;
235 }
Glenn Kasten7df8c0b2014-07-03 12:23:29 -0700236 size_t lNotificationFrames = (size_t) reply.readInt64();
237 if (notificationFrames != NULL) {
238 *notificationFrames = lNotificationFrames;
239 }
Eric Laurent5841db72009-09-09 05:16:08 -0700240 lStatus = reply.readInt32();
241 record = interface_cast<IAudioRecord>(reply.readStrongBinder());
Glenn Kastend776ac62014-05-07 09:16:09 -0700242 cblk = interface_cast<IMemory>(reply.readStrongBinder());
243 if (cblk != 0 && cblk->pointer() == NULL) {
244 cblk.clear();
245 }
246 buffers = interface_cast<IMemory>(reply.readStrongBinder());
247 if (buffers != 0 && buffers->pointer() == NULL) {
248 buffers.clear();
249 }
Glenn Kastene93cf2c2013-09-24 11:52:37 -0700250 if (lStatus == NO_ERROR) {
251 if (record == 0) {
252 ALOGE("openRecord should have returned an IAudioRecord");
253 lStatus = UNKNOWN_ERROR;
Glenn Kastend776ac62014-05-07 09:16:09 -0700254 } else if (cblk == 0) {
255 ALOGE("openRecord should have returned a cblk");
256 lStatus = NO_MEMORY;
Glenn Kastene93cf2c2013-09-24 11:52:37 -0700257 }
Glenn Kastend776ac62014-05-07 09:16:09 -0700258 // buffers is permitted to be 0
Glenn Kastene93cf2c2013-09-24 11:52:37 -0700259 } else {
Glenn Kastend776ac62014-05-07 09:16:09 -0700260 if (record != 0 || cblk != 0 || buffers != 0) {
261 ALOGE("openRecord returned an IAudioRecord, cblk, "
262 "or buffers but with status %d", lStatus);
Glenn Kastene93cf2c2013-09-24 11:52:37 -0700263 }
264 }
Glenn Kastend776ac62014-05-07 09:16:09 -0700265 if (lStatus != NO_ERROR) {
266 record.clear();
267 cblk.clear();
268 buffers.clear();
269 }
Eric Laurent5841db72009-09-09 05:16:08 -0700270 }
Glenn Kasten507b2862013-07-31 16:12:13 -0700271 if (status != NULL) {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800272 *status = lStatus;
273 }
Eric Laurent5841db72009-09-09 05:16:08 -0700274 return record;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800275 }
276
Glenn Kasten2c073da2016-02-26 09:14:08 -0800277 virtual uint32_t sampleRate(audio_io_handle_t ioHandle) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800278 {
279 Parcel data, reply;
280 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten2c073da2016-02-26 09:14:08 -0800281 data.writeInt32((int32_t) ioHandle);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800282 remote()->transact(SAMPLE_RATE, data, &reply);
283 return reply.readInt32();
284 }
285
Glenn Kasten4a8308b2016-04-18 14:10:01 -0700286 // RESERVED for channelCount()
287
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800288 virtual audio_format_t format(audio_io_handle_t output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800289 {
290 Parcel data, reply;
291 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800292 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800293 remote()->transact(FORMAT, data, &reply);
Glenn Kasten58f30212012-01-12 12:27:51 -0800294 return (audio_format_t) reply.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800295 }
296
Glenn Kasten2c073da2016-02-26 09:14:08 -0800297 virtual size_t frameCount(audio_io_handle_t ioHandle) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800298 {
299 Parcel data, reply;
300 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten2c073da2016-02-26 09:14:08 -0800301 data.writeInt32((int32_t) ioHandle);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800302 remote()->transact(FRAME_COUNT, data, &reply);
Glenn Kastene03dd222014-01-28 11:04:39 -0800303 return reply.readInt64();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800304 }
305
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800306 virtual uint32_t latency(audio_io_handle_t output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800307 {
308 Parcel data, reply;
309 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800310 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800311 remote()->transact(LATENCY, data, &reply);
312 return reply.readInt32();
313 }
314
315 virtual status_t setMasterVolume(float value)
316 {
317 Parcel data, reply;
318 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
319 data.writeFloat(value);
320 remote()->transact(SET_MASTER_VOLUME, data, &reply);
321 return reply.readInt32();
322 }
323
324 virtual status_t setMasterMute(bool muted)
325 {
326 Parcel data, reply;
327 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
328 data.writeInt32(muted);
329 remote()->transact(SET_MASTER_MUTE, data, &reply);
330 return reply.readInt32();
331 }
332
333 virtual float masterVolume() const
334 {
335 Parcel data, reply;
336 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
337 remote()->transact(MASTER_VOLUME, data, &reply);
338 return reply.readFloat();
339 }
340
341 virtual bool masterMute() const
342 {
343 Parcel data, reply;
344 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
345 remote()->transact(MASTER_MUTE, data, &reply);
346 return reply.readInt32();
347 }
348
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800349 virtual status_t setStreamVolume(audio_stream_type_t stream, float value,
350 audio_io_handle_t output)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800351 {
352 Parcel data, reply;
353 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800354 data.writeInt32((int32_t) stream);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800355 data.writeFloat(value);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800356 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800357 remote()->transact(SET_STREAM_VOLUME, data, &reply);
358 return reply.readInt32();
359 }
360
Glenn Kastenfff6d712012-01-12 16:38:12 -0800361 virtual status_t setStreamMute(audio_stream_type_t stream, bool muted)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800362 {
363 Parcel data, reply;
364 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800365 data.writeInt32((int32_t) stream);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800366 data.writeInt32(muted);
367 remote()->transact(SET_STREAM_MUTE, data, &reply);
368 return reply.readInt32();
369 }
370
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800371 virtual float streamVolume(audio_stream_type_t stream, audio_io_handle_t output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800372 {
373 Parcel data, reply;
374 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800375 data.writeInt32((int32_t) stream);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800376 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800377 remote()->transact(STREAM_VOLUME, data, &reply);
378 return reply.readFloat();
379 }
380
Glenn Kastenfff6d712012-01-12 16:38:12 -0800381 virtual bool streamMute(audio_stream_type_t stream) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800382 {
383 Parcel data, reply;
384 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800385 data.writeInt32((int32_t) stream);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800386 remote()->transact(STREAM_MUTE, data, &reply);
387 return reply.readInt32();
388 }
389
Glenn Kastenf78aee72012-01-04 11:00:47 -0800390 virtual status_t setMode(audio_mode_t mode)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800391 {
392 Parcel data, reply;
393 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
394 data.writeInt32(mode);
395 remote()->transact(SET_MODE, data, &reply);
396 return reply.readInt32();
397 }
398
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800399 virtual status_t setMicMute(bool state)
400 {
401 Parcel data, reply;
402 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
403 data.writeInt32(state);
404 remote()->transact(SET_MIC_MUTE, data, &reply);
405 return reply.readInt32();
406 }
407
408 virtual bool getMicMute() const
409 {
410 Parcel data, reply;
411 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
412 remote()->transact(GET_MIC_MUTE, data, &reply);
413 return reply.readInt32();
414 }
415
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800416 virtual status_t setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800417 {
418 Parcel data, reply;
419 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800420 data.writeInt32((int32_t) ioHandle);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700421 data.writeString8(keyValuePairs);
422 remote()->transact(SET_PARAMETERS, data, &reply);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800423 return reply.readInt32();
424 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700425
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800426 virtual String8 getParameters(audio_io_handle_t ioHandle, const String8& keys) const
Eric Laurentc2f1f072009-07-17 12:17:14 -0700427 {
428 Parcel data, reply;
429 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800430 data.writeInt32((int32_t) ioHandle);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700431 data.writeString8(keys);
432 remote()->transact(GET_PARAMETERS, data, &reply);
433 return reply.readString8();
434 }
435
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800436 virtual void registerClient(const sp<IAudioFlingerClient>& client)
437 {
438 Parcel data, reply;
439 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Marco Nelissen06b46062014-11-14 07:58:25 -0800440 data.writeStrongBinder(IInterface::asBinder(client));
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800441 remote()->transact(REGISTER_CLIENT, data, &reply);
442 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700443
Glenn Kastendd8104c2012-07-02 12:42:44 -0700444 virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format,
445 audio_channel_mask_t channelMask) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800446 {
447 Parcel data, reply;
448 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
449 data.writeInt32(sampleRate);
450 data.writeInt32(format);
Glenn Kastendd8104c2012-07-02 12:42:44 -0700451 data.writeInt32(channelMask);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800452 remote()->transact(GET_INPUTBUFFERSIZE, data, &reply);
Glenn Kastene03dd222014-01-28 11:04:39 -0800453 return reply.readInt64();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800454 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700455
Eric Laurentcf2c0212014-07-25 16:20:43 -0700456 virtual status_t openOutput(audio_module_handle_t module,
457 audio_io_handle_t *output,
458 audio_config_t *config,
459 audio_devices_t *devices,
460 const String8& address,
461 uint32_t *latencyMs,
462 audio_output_flags_t flags)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800463 {
Eric Laurentcf2c0212014-07-25 16:20:43 -0700464 if (output == NULL || config == NULL || devices == NULL || latencyMs == NULL) {
465 return BAD_VALUE;
466 }
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800467 Parcel data, reply;
468 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurenta4c5a552012-03-29 10:12:40 -0700469 data.writeInt32(module);
Eric Laurentcf2c0212014-07-25 16:20:43 -0700470 data.write(config, sizeof(audio_config_t));
471 data.writeInt32(*devices);
472 data.writeString8(address);
Glenn Kasten18868c52012-03-07 09:15:37 -0800473 data.writeInt32((int32_t) flags);
Eric Laurentcf2c0212014-07-25 16:20:43 -0700474 status_t status = remote()->transact(OPEN_OUTPUT, data, &reply);
475 if (status != NO_ERROR) {
476 *output = AUDIO_IO_HANDLE_NONE;
477 return status;
Richard Fitzgeraldb1a270d2013-05-14 12:12:21 +0100478 }
Eric Laurentcf2c0212014-07-25 16:20:43 -0700479 status = (status_t)reply.readInt32();
480 if (status != NO_ERROR) {
481 *output = AUDIO_IO_HANDLE_NONE;
482 return status;
Glenn Kasten507b2862013-07-31 16:12:13 -0700483 }
Eric Laurentcf2c0212014-07-25 16:20:43 -0700484 *output = (audio_io_handle_t)reply.readInt32();
485 ALOGV("openOutput() returned output, %d", *output);
486 reply.read(config, sizeof(audio_config_t));
487 *devices = (audio_devices_t)reply.readInt32();
488 *latencyMs = reply.readInt32();
489 return NO_ERROR;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800490 }
491
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800492 virtual audio_io_handle_t openDuplicateOutput(audio_io_handle_t output1,
493 audio_io_handle_t output2)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800494 {
495 Parcel data, reply;
496 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800497 data.writeInt32((int32_t) output1);
498 data.writeInt32((int32_t) output2);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700499 remote()->transact(OPEN_DUPLICATE_OUTPUT, data, &reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800500 return (audio_io_handle_t) reply.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700501 }
502
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800503 virtual status_t closeOutput(audio_io_handle_t output)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700504 {
505 Parcel data, reply;
506 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800507 data.writeInt32((int32_t) output);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700508 remote()->transact(CLOSE_OUTPUT, data, &reply);
509 return reply.readInt32();
510 }
511
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800512 virtual status_t suspendOutput(audio_io_handle_t output)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700513 {
514 Parcel data, reply;
515 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800516 data.writeInt32((int32_t) output);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700517 remote()->transact(SUSPEND_OUTPUT, data, &reply);
518 return reply.readInt32();
519 }
520
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800521 virtual status_t restoreOutput(audio_io_handle_t output)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700522 {
523 Parcel data, reply;
524 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800525 data.writeInt32((int32_t) output);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700526 remote()->transact(RESTORE_OUTPUT, data, &reply);
527 return reply.readInt32();
528 }
529
Eric Laurentcf2c0212014-07-25 16:20:43 -0700530 virtual status_t openInput(audio_module_handle_t module,
531 audio_io_handle_t *input,
532 audio_config_t *config,
533 audio_devices_t *device,
534 const String8& address,
535 audio_source_t source,
536 audio_input_flags_t flags)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700537 {
Eric Laurentcf2c0212014-07-25 16:20:43 -0700538 if (input == NULL || config == NULL || device == NULL) {
539 return BAD_VALUE;
540 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700541 Parcel data, reply;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700542 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurenta4c5a552012-03-29 10:12:40 -0700543 data.writeInt32(module);
Eric Laurentcf2c0212014-07-25 16:20:43 -0700544 data.writeInt32(*input);
545 data.write(config, sizeof(audio_config_t));
546 data.writeInt32(*device);
547 data.writeString8(address);
548 data.writeInt32(source);
Glenn Kastenec40d282014-07-15 15:31:26 -0700549 data.writeInt32(flags);
Eric Laurentcf2c0212014-07-25 16:20:43 -0700550 status_t status = remote()->transact(OPEN_INPUT, data, &reply);
551 if (status != NO_ERROR) {
552 *input = AUDIO_IO_HANDLE_NONE;
553 return status;
Glenn Kasten507b2862013-07-31 16:12:13 -0700554 }
Eric Laurentcf2c0212014-07-25 16:20:43 -0700555 status = (status_t)reply.readInt32();
556 if (status != NO_ERROR) {
557 *input = AUDIO_IO_HANDLE_NONE;
558 return status;
Glenn Kasten507b2862013-07-31 16:12:13 -0700559 }
Eric Laurentcf2c0212014-07-25 16:20:43 -0700560 *input = (audio_io_handle_t)reply.readInt32();
561 reply.read(config, sizeof(audio_config_t));
562 *device = (audio_devices_t)reply.readInt32();
563 return NO_ERROR;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700564 }
565
Eric Laurentfa2877b2009-07-28 08:44:33 -0700566 virtual status_t closeInput(int input)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700567 {
568 Parcel data, reply;
569 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentfa2877b2009-07-28 08:44:33 -0700570 data.writeInt32(input);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700571 remote()->transact(CLOSE_INPUT, data, &reply);
572 return reply.readInt32();
573 }
574
Glenn Kastend2304db2014-02-03 07:40:31 -0800575 virtual status_t invalidateStream(audio_stream_type_t stream)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700576 {
577 Parcel data, reply;
578 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800579 data.writeInt32((int32_t) stream);
Glenn Kastend2304db2014-02-03 07:40:31 -0800580 remote()->transact(INVALIDATE_STREAM, data, &reply);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700581 return reply.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800582 }
Eric Laurentf0ee6f42009-10-21 08:14:22 -0700583
584 virtual status_t setVoiceVolume(float volume)
585 {
586 Parcel data, reply;
587 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
588 data.writeFloat(volume);
589 remote()->transact(SET_VOICE_VOLUME, data, &reply);
590 return reply.readInt32();
591 }
Eric Laurent342e9cf2010-01-19 17:37:09 -0800592
Kévin PETIT377b2ec2014-02-03 12:35:36 +0000593 virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames,
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800594 audio_io_handle_t output) const
Eric Laurent342e9cf2010-01-19 17:37:09 -0800595 {
596 Parcel data, reply;
597 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800598 data.writeInt32((int32_t) output);
Eric Laurent342e9cf2010-01-19 17:37:09 -0800599 remote()->transact(GET_RENDER_POSITION, data, &reply);
600 status_t status = reply.readInt32();
601 if (status == NO_ERROR) {
602 uint32_t tmp = reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700603 if (halFrames != NULL) {
Eric Laurent342e9cf2010-01-19 17:37:09 -0800604 *halFrames = tmp;
605 }
606 tmp = reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700607 if (dspFrames != NULL) {
Eric Laurent342e9cf2010-01-19 17:37:09 -0800608 *dspFrames = tmp;
609 }
610 }
611 return status;
612 }
Eric Laurent05bca2f2010-02-26 02:47:27 -0800613
Glenn Kasten5f972c02014-01-13 09:59:31 -0800614 virtual uint32_t getInputFramesLost(audio_io_handle_t ioHandle) const
Eric Laurent05bca2f2010-02-26 02:47:27 -0800615 {
616 Parcel data, reply;
617 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800618 data.writeInt32((int32_t) ioHandle);
Glenn Kasten5f972c02014-01-13 09:59:31 -0800619 status_t status = remote()->transact(GET_INPUT_FRAMES_LOST, data, &reply);
620 if (status != NO_ERROR) {
621 return 0;
622 }
623 return (uint32_t) reply.readInt32();
Eric Laurent05bca2f2010-02-26 02:47:27 -0800624 }
Eric Laurentbe916aa2010-06-01 23:49:17 -0700625
Glenn Kasteneeecb982016-02-26 10:44:04 -0800626 virtual audio_unique_id_t newAudioUniqueId(audio_unique_id_use_t use)
Eric Laurentbe916aa2010-06-01 23:49:17 -0700627 {
628 Parcel data, reply;
629 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasteneeecb982016-02-26 10:44:04 -0800630 data.writeInt32((int32_t) use);
Glenn Kasten9eae0362016-04-19 09:09:14 -0700631 status_t status = remote()->transact(NEW_AUDIO_UNIQUE_ID, data, &reply);
632 audio_unique_id_t id = AUDIO_UNIQUE_ID_ALLOCATE;
Eric Laurentbe916aa2010-06-01 23:49:17 -0700633 if (status == NO_ERROR) {
634 id = reply.readInt32();
635 }
636 return id;
637 }
638
Glenn Kastend848eb42016-03-08 13:42:11 -0800639 virtual void acquireAudioSessionId(audio_session_t audioSession, int pid)
Marco Nelissen3a34bef2011-08-02 13:33:41 -0700640 {
641 Parcel data, reply;
642 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
643 data.writeInt32(audioSession);
Marco Nelissend457c972014-02-11 08:47:07 -0800644 data.writeInt32(pid);
Marco Nelissen3a34bef2011-08-02 13:33:41 -0700645 remote()->transact(ACQUIRE_AUDIO_SESSION_ID, data, &reply);
646 }
647
Glenn Kastend848eb42016-03-08 13:42:11 -0800648 virtual void releaseAudioSessionId(audio_session_t audioSession, int pid)
Marco Nelissen3a34bef2011-08-02 13:33:41 -0700649 {
650 Parcel data, reply;
651 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
652 data.writeInt32(audioSession);
Marco Nelissend457c972014-02-11 08:47:07 -0800653 data.writeInt32(pid);
Marco Nelissen3a34bef2011-08-02 13:33:41 -0700654 remote()->transact(RELEASE_AUDIO_SESSION_ID, data, &reply);
655 }
656
Glenn Kastenf587ba52012-01-26 16:25:10 -0800657 virtual status_t queryNumberEffects(uint32_t *numEffects) const
Eric Laurentbe916aa2010-06-01 23:49:17 -0700658 {
659 Parcel data, reply;
660 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
661 status_t status = remote()->transact(QUERY_NUM_EFFECTS, data, &reply);
662 if (status != NO_ERROR) {
663 return status;
664 }
665 status = reply.readInt32();
666 if (status != NO_ERROR) {
667 return status;
668 }
Glenn Kasten9d1f02d2012-02-08 17:47:58 -0800669 if (numEffects != NULL) {
Eric Laurentbe916aa2010-06-01 23:49:17 -0700670 *numEffects = (uint32_t)reply.readInt32();
671 }
672 return NO_ERROR;
673 }
674
Glenn Kastenf587ba52012-01-26 16:25:10 -0800675 virtual status_t queryEffect(uint32_t index, effect_descriptor_t *pDescriptor) const
Eric Laurentbe916aa2010-06-01 23:49:17 -0700676 {
677 if (pDescriptor == NULL) {
678 return BAD_VALUE;
679 }
680 Parcel data, reply;
681 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentffe9c252010-06-23 17:38:20 -0700682 data.writeInt32(index);
683 status_t status = remote()->transact(QUERY_EFFECT, data, &reply);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700684 if (status != NO_ERROR) {
685 return status;
686 }
687 status = reply.readInt32();
688 if (status != NO_ERROR) {
689 return status;
690 }
691 reply.read(pDescriptor, sizeof(effect_descriptor_t));
692 return NO_ERROR;
693 }
694
Glenn Kasten5e92a782012-01-30 07:40:52 -0800695 virtual status_t getEffectDescriptor(const effect_uuid_t *pUuid,
Glenn Kastenf587ba52012-01-26 16:25:10 -0800696 effect_descriptor_t *pDescriptor) const
Eric Laurentbe916aa2010-06-01 23:49:17 -0700697 {
698 if (pUuid == NULL || pDescriptor == NULL) {
699 return BAD_VALUE;
700 }
701 Parcel data, reply;
702 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
703 data.write(pUuid, sizeof(effect_uuid_t));
704 status_t status = remote()->transact(GET_EFFECT_DESCRIPTOR, data, &reply);
705 if (status != NO_ERROR) {
706 return status;
707 }
708 status = reply.readInt32();
709 if (status != NO_ERROR) {
710 return status;
711 }
712 reply.read(pDescriptor, sizeof(effect_descriptor_t));
713 return NO_ERROR;
714 }
715
Glenn Kasten8d6cc842012-02-03 11:06:53 -0800716 virtual sp<IEffect> createEffect(
Eric Laurentbe916aa2010-06-01 23:49:17 -0700717 effect_descriptor_t *pDesc,
718 const sp<IEffectClient>& client,
719 int32_t priority,
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800720 audio_io_handle_t output,
Glenn Kastend848eb42016-03-08 13:42:11 -0800721 audio_session_t sessionId,
Svet Ganovbe71aa22015-04-28 12:06:02 -0700722 const String16& opPackageName,
Eric Laurentb6436272016-12-07 19:24:50 -0800723 pid_t pid,
Eric Laurentbe916aa2010-06-01 23:49:17 -0700724 status_t *status,
725 int *id,
726 int *enabled)
727 {
728 Parcel data, reply;
729 sp<IEffect> effect;
730
731 if (pDesc == NULL) {
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700732 return effect;
Glenn Kasten507b2862013-07-31 16:12:13 -0700733 if (status != NULL) {
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700734 *status = BAD_VALUE;
735 }
736 }
Eric Laurentbe916aa2010-06-01 23:49:17 -0700737
738 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentbe916aa2010-06-01 23:49:17 -0700739 data.write(pDesc, sizeof(effect_descriptor_t));
Marco Nelissen06b46062014-11-14 07:58:25 -0800740 data.writeStrongBinder(IInterface::asBinder(client));
Eric Laurentbe916aa2010-06-01 23:49:17 -0700741 data.writeInt32(priority);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800742 data.writeInt32((int32_t) output);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700743 data.writeInt32(sessionId);
Svet Ganovbe71aa22015-04-28 12:06:02 -0700744 data.writeString16(opPackageName);
Eric Laurentb6436272016-12-07 19:24:50 -0800745 data.writeInt32((int32_t) pid);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700746
747 status_t lStatus = remote()->transact(CREATE_EFFECT, data, &reply);
748 if (lStatus != NO_ERROR) {
Steve Block29357bc2012-01-06 19:20:56 +0000749 ALOGE("createEffect error: %s", strerror(-lStatus));
Eric Laurentbe916aa2010-06-01 23:49:17 -0700750 } else {
751 lStatus = reply.readInt32();
752 int tmp = reply.readInt32();
Glenn Kasten507b2862013-07-31 16:12:13 -0700753 if (id != NULL) {
Eric Laurentbe916aa2010-06-01 23:49:17 -0700754 *id = tmp;
755 }
756 tmp = reply.readInt32();
Glenn Kastena0d68332012-01-27 16:47:15 -0800757 if (enabled != NULL) {
Eric Laurentbe916aa2010-06-01 23:49:17 -0700758 *enabled = tmp;
759 }
760 effect = interface_cast<IEffect>(reply.readStrongBinder());
761 reply.read(pDesc, sizeof(effect_descriptor_t));
762 }
Glenn Kasten507b2862013-07-31 16:12:13 -0700763 if (status != NULL) {
Eric Laurentbe916aa2010-06-01 23:49:17 -0700764 *status = lStatus;
765 }
766
767 return effect;
768 }
Eric Laurentde070132010-07-13 04:45:46 -0700769
Glenn Kastend848eb42016-03-08 13:42:11 -0800770 virtual status_t moveEffects(audio_session_t session, audio_io_handle_t srcOutput,
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800771 audio_io_handle_t dstOutput)
Eric Laurentde070132010-07-13 04:45:46 -0700772 {
773 Parcel data, reply;
774 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
775 data.writeInt32(session);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800776 data.writeInt32((int32_t) srcOutput);
777 data.writeInt32((int32_t) dstOutput);
Eric Laurentde070132010-07-13 04:45:46 -0700778 remote()->transact(MOVE_EFFECTS, data, &reply);
779 return reply.readInt32();
780 }
Eric Laurenta4c5a552012-03-29 10:12:40 -0700781
782 virtual audio_module_handle_t loadHwModule(const char *name)
783 {
784 Parcel data, reply;
785 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
786 data.writeCString(name);
787 remote()->transact(LOAD_HW_MODULE, data, &reply);
788 return (audio_module_handle_t) reply.readInt32();
789 }
Glenn Kastencc0f1cf2012-09-24 11:27:18 -0700790
Glenn Kasten3b16c762012-11-14 08:44:39 -0800791 virtual uint32_t getPrimaryOutputSamplingRate()
Glenn Kastencc0f1cf2012-09-24 11:27:18 -0700792 {
793 Parcel data, reply;
794 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
795 remote()->transact(GET_PRIMARY_OUTPUT_SAMPLING_RATE, data, &reply);
796 return reply.readInt32();
797 }
798
Glenn Kastene33054e2012-11-14 12:54:39 -0800799 virtual size_t getPrimaryOutputFrameCount()
Glenn Kastencc0f1cf2012-09-24 11:27:18 -0700800 {
801 Parcel data, reply;
802 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
803 remote()->transact(GET_PRIMARY_OUTPUT_FRAME_COUNT, data, &reply);
Glenn Kastene03dd222014-01-28 11:04:39 -0800804 return reply.readInt64();
Glenn Kastencc0f1cf2012-09-24 11:27:18 -0700805 }
806
Glenn Kasten4182c4e2013-07-15 14:45:07 -0700807 virtual status_t setLowRamDevice(bool isLowRamDevice)
808 {
809 Parcel data, reply;
810 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
811 data.writeInt32((int) isLowRamDevice);
812 remote()->transact(SET_LOW_RAM_DEVICE, data, &reply);
813 return reply.readInt32();
814 }
Eric Laurent4b123402014-04-11 09:22:20 -0700815 virtual status_t listAudioPorts(unsigned int *num_ports,
816 struct audio_port *ports)
817 {
818 if (num_ports == NULL || *num_ports == 0 || ports == NULL) {
819 return BAD_VALUE;
820 }
821 Parcel data, reply;
822 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
823 data.writeInt32(*num_ports);
824 status_t status = remote()->transact(LIST_AUDIO_PORTS, data, &reply);
825 if (status != NO_ERROR ||
826 (status = (status_t)reply.readInt32()) != NO_ERROR) {
827 return status;
828 }
829 *num_ports = (unsigned int)reply.readInt32();
830 reply.read(ports, *num_ports * sizeof(struct audio_port));
831 return status;
832 }
833 virtual status_t getAudioPort(struct audio_port *port)
834 {
835 if (port == NULL) {
836 return BAD_VALUE;
837 }
838 Parcel data, reply;
839 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
840 data.write(port, sizeof(struct audio_port));
841 status_t status = remote()->transact(GET_AUDIO_PORT, data, &reply);
842 if (status != NO_ERROR ||
843 (status = (status_t)reply.readInt32()) != NO_ERROR) {
844 return status;
845 }
846 reply.read(port, sizeof(struct audio_port));
847 return status;
848 }
849 virtual status_t createAudioPatch(const struct audio_patch *patch,
850 audio_patch_handle_t *handle)
851 {
852 if (patch == NULL || handle == NULL) {
853 return BAD_VALUE;
854 }
855 Parcel data, reply;
856 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
857 data.write(patch, sizeof(struct audio_patch));
858 data.write(handle, sizeof(audio_patch_handle_t));
859 status_t status = remote()->transact(CREATE_AUDIO_PATCH, data, &reply);
860 if (status != NO_ERROR ||
861 (status = (status_t)reply.readInt32()) != NO_ERROR) {
862 return status;
863 }
864 reply.read(handle, sizeof(audio_patch_handle_t));
865 return status;
866 }
867 virtual status_t releaseAudioPatch(audio_patch_handle_t handle)
868 {
869 Parcel data, reply;
870 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
871 data.write(&handle, sizeof(audio_patch_handle_t));
872 status_t status = remote()->transact(RELEASE_AUDIO_PATCH, data, &reply);
873 if (status != NO_ERROR) {
874 status = (status_t)reply.readInt32();
875 }
876 return status;
877 }
878 virtual status_t listAudioPatches(unsigned int *num_patches,
879 struct audio_patch *patches)
880 {
881 if (num_patches == NULL || *num_patches == 0 || patches == NULL) {
882 return BAD_VALUE;
883 }
884 Parcel data, reply;
885 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
886 data.writeInt32(*num_patches);
887 status_t status = remote()->transact(LIST_AUDIO_PATCHES, data, &reply);
888 if (status != NO_ERROR ||
889 (status = (status_t)reply.readInt32()) != NO_ERROR) {
890 return status;
891 }
892 *num_patches = (unsigned int)reply.readInt32();
893 reply.read(patches, *num_patches * sizeof(struct audio_patch));
894 return status;
895 }
896 virtual status_t setAudioPortConfig(const struct audio_port_config *config)
897 {
898 if (config == NULL) {
899 return BAD_VALUE;
900 }
901 Parcel data, reply;
902 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
903 data.write(config, sizeof(struct audio_port_config));
904 status_t status = remote()->transact(SET_AUDIO_PORT_CONFIG, data, &reply);
905 if (status != NO_ERROR) {
906 status = (status_t)reply.readInt32();
907 }
908 return status;
909 }
Eric Laurent93c3d412014-08-01 14:48:35 -0700910 virtual audio_hw_sync_t getAudioHwSyncForSession(audio_session_t sessionId)
911 {
912 Parcel data, reply;
913 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
914 data.writeInt32(sessionId);
Glenn Kasten9eae0362016-04-19 09:09:14 -0700915 status_t status = remote()->transact(GET_AUDIO_HW_SYNC_FOR_SESSION, data, &reply);
Eric Laurent93c3d412014-08-01 14:48:35 -0700916 if (status != NO_ERROR) {
917 return AUDIO_HW_SYNC_INVALID;
918 }
919 return (audio_hw_sync_t)reply.readInt32();
920 }
Eric Laurent72e3f392015-05-20 14:43:50 -0700921 virtual status_t systemReady()
922 {
923 Parcel data, reply;
924 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
925 return remote()->transact(SYSTEM_READY, data, &reply, IBinder::FLAG_ONEWAY);
926 }
Glenn Kasten4a8308b2016-04-18 14:10:01 -0700927 virtual size_t frameCountHAL(audio_io_handle_t ioHandle) const
928 {
929 Parcel data, reply;
930 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
931 data.writeInt32((int32_t) ioHandle);
932 status_t status = remote()->transact(FRAME_COUNT_HAL, data, &reply);
933 if (status != NO_ERROR) {
934 return 0;
935 }
936 return reply.readInt64();
937 }
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800938};
939
940IMPLEMENT_META_INTERFACE(AudioFlinger, "android.media.IAudioFlinger");
941
942// ----------------------------------------------------------------------
943
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800944status_t BnAudioFlinger::onTransact(
945 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
946{
Nicolas Rouletdcdfaec2017-02-14 10:18:39 -0800947 // Whitelist of relevant events to trigger log merging.
948 // Log merging should activate during audio activity of any kind. This are considered the
949 // most relevant events.
950 // TODO should select more wisely the items from the list
951 switch (code) {
952 case CREATE_TRACK:
953 case OPEN_RECORD:
954 case SET_MASTER_VOLUME:
955 case SET_MASTER_MUTE:
956 case SET_STREAM_VOLUME:
957 case SET_STREAM_MUTE:
958 case SET_MIC_MUTE:
959 case SET_PARAMETERS:
960 case OPEN_INPUT:
961 case SET_VOICE_VOLUME:
962 case CREATE_EFFECT:
963 case SYSTEM_READY: {
964 requestLogMerge();
965 break;
966 }
967 default:
968 break;
969 }
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700970 switch (code) {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800971 case CREATE_TRACK: {
972 CHECK_INTERFACE(IAudioFlinger, data, reply);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800973 int streamType = data.readInt32();
974 uint32_t sampleRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -0800975 audio_format_t format = (audio_format_t) data.readInt32();
Glenn Kastendd8104c2012-07-02 12:42:44 -0700976 audio_channel_mask_t channelMask = data.readInt32();
Glenn Kastene03dd222014-01-28 11:04:39 -0800977 size_t frameCount = data.readInt64();
Eric Laurent05067782016-06-01 18:27:28 -0700978 audio_output_flags_t flags = (audio_output_flags_t) data.readInt32();
Eric Laurent3d00aa62013-09-24 09:53:27 -0700979 bool haveSharedBuffer = data.readInt32() != 0;
980 sp<IMemory> buffer;
981 if (haveSharedBuffer) {
982 buffer = interface_cast<IMemory>(data.readStrongBinder());
983 }
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800984 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Haynes Mathew George9ea77cd2016-04-06 17:07:48 -0700985 pid_t pid = (pid_t) data.readInt32();
Glenn Kasten3acbd052012-02-28 10:39:56 -0800986 pid_t tid = (pid_t) data.readInt32();
Glenn Kastend848eb42016-03-08 13:42:11 -0800987 audio_session_t sessionId = (audio_session_t) data.readInt32();
Marco Nelissen462fd2f2013-01-14 14:12:05 -0800988 int clientUid = data.readInt32();
Eric Laurent20b9ef02016-12-05 11:03:16 -0800989 audio_port_handle_t portId = (audio_port_handle_t) data.readInt32();
Wei Jia983dca32015-09-10 09:47:29 -0700990 status_t status = NO_ERROR;
Eric Laurent3d00aa62013-09-24 09:53:27 -0700991 sp<IAudioTrack> track;
992 if ((haveSharedBuffer && (buffer == 0)) ||
993 ((buffer != 0) && (buffer->pointer() == NULL))) {
994 ALOGW("CREATE_TRACK: cannot retrieve shared memory");
995 status = DEAD_OBJECT;
996 } else {
997 track = createTrack(
998 (audio_stream_type_t) streamType, sampleRate, format,
Haynes Mathew George9ea77cd2016-04-06 17:07:48 -0700999 channelMask, &frameCount, &flags, buffer, output, pid, tid,
Eric Laurent20b9ef02016-12-05 11:03:16 -08001000 &sessionId, clientUid, &status, portId);
Glenn Kasten0cde0762014-01-16 15:06:36 -08001001 LOG_ALWAYS_FATAL_IF((track != 0) != (status == NO_ERROR));
Eric Laurent3d00aa62013-09-24 09:53:27 -07001002 }
Glenn Kastenb53fc4e2014-05-02 08:03:58 -07001003 reply->writeInt64(frameCount);
Glenn Kastene0b07172012-11-06 15:03:34 -08001004 reply->writeInt32(flags);
Eric Laurentbe916aa2010-06-01 23:49:17 -07001005 reply->writeInt32(sessionId);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001006 reply->writeInt32(status);
Marco Nelissen06b46062014-11-14 07:58:25 -08001007 reply->writeStrongBinder(IInterface::asBinder(track));
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001008 return NO_ERROR;
1009 } break;
1010 case OPEN_RECORD: {
1011 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001012 audio_io_handle_t input = (audio_io_handle_t) data.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001013 uint32_t sampleRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -08001014 audio_format_t format = (audio_format_t) data.readInt32();
Glenn Kastendd8104c2012-07-02 12:42:44 -07001015 audio_channel_mask_t channelMask = data.readInt32();
Svet Ganovbe71aa22015-04-28 12:06:02 -07001016 const String16& opPackageName = data.readString16();
Glenn Kastene03dd222014-01-28 11:04:39 -08001017 size_t frameCount = data.readInt64();
Eric Laurent05067782016-06-01 18:27:28 -07001018 audio_input_flags_t flags = (audio_input_flags_t) data.readInt32();
Haynes Mathew George9ea77cd2016-04-06 17:07:48 -07001019 pid_t pid = (pid_t) data.readInt32();
Glenn Kasten1879fff2012-07-11 15:36:59 -07001020 pid_t tid = (pid_t) data.readInt32();
Jean-Michel Trivi4cb66832015-05-01 18:34:17 -07001021 int clientUid = data.readInt32();
Glenn Kastend848eb42016-03-08 13:42:11 -08001022 audio_session_t sessionId = (audio_session_t) data.readInt32();
Glenn Kasten74105912014-07-03 12:28:53 -07001023 size_t notificationFrames = data.readInt64();
Eric Laurent20b9ef02016-12-05 11:03:16 -08001024 audio_port_handle_t portId = (audio_port_handle_t) data.readInt32();
Glenn Kastend776ac62014-05-07 09:16:09 -07001025 sp<IMemory> cblk;
1026 sp<IMemory> buffers;
Wei Jia983dca32015-09-10 09:47:29 -07001027 status_t status = NO_ERROR;
Glenn Kasten8d6cc842012-02-03 11:06:53 -08001028 sp<IAudioRecord> record = openRecord(input,
Haynes Mathew George9ea77cd2016-04-06 17:07:48 -07001029 sampleRate, format, channelMask, opPackageName, &frameCount, &flags,
1030 pid, tid, clientUid, &sessionId, &notificationFrames, cblk, buffers,
Eric Laurent20b9ef02016-12-05 11:03:16 -08001031 &status, portId);
Glenn Kastene93cf2c2013-09-24 11:52:37 -07001032 LOG_ALWAYS_FATAL_IF((record != 0) != (status == NO_ERROR));
Glenn Kastenb53fc4e2014-05-02 08:03:58 -07001033 reply->writeInt64(frameCount);
Glenn Kasteneeca3262013-07-31 16:12:48 -07001034 reply->writeInt32(flags);
Eric Laurentbe916aa2010-06-01 23:49:17 -07001035 reply->writeInt32(sessionId);
Glenn Kasten7df8c0b2014-07-03 12:23:29 -07001036 reply->writeInt64(notificationFrames);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001037 reply->writeInt32(status);
Marco Nelissen06b46062014-11-14 07:58:25 -08001038 reply->writeStrongBinder(IInterface::asBinder(record));
1039 reply->writeStrongBinder(IInterface::asBinder(cblk));
1040 reply->writeStrongBinder(IInterface::asBinder(buffers));
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001041 return NO_ERROR;
1042 } break;
1043 case SAMPLE_RATE: {
1044 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001045 reply->writeInt32( sampleRate((audio_io_handle_t) data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001046 return NO_ERROR;
1047 } break;
Glenn Kasten4a8308b2016-04-18 14:10:01 -07001048
1049 // RESERVED for channelCount()
1050
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001051 case FORMAT: {
1052 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001053 reply->writeInt32( format((audio_io_handle_t) data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001054 return NO_ERROR;
1055 } break;
1056 case FRAME_COUNT: {
1057 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kastene03dd222014-01-28 11:04:39 -08001058 reply->writeInt64( frameCount((audio_io_handle_t) data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001059 return NO_ERROR;
1060 } break;
1061 case LATENCY: {
1062 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001063 reply->writeInt32( latency((audio_io_handle_t) data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001064 return NO_ERROR;
1065 } break;
Glenn Kastene53b9ea2012-03-12 16:29:55 -07001066 case SET_MASTER_VOLUME: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001067 CHECK_INTERFACE(IAudioFlinger, data, reply);
1068 reply->writeInt32( setMasterVolume(data.readFloat()) );
1069 return NO_ERROR;
1070 } break;
1071 case SET_MASTER_MUTE: {
1072 CHECK_INTERFACE(IAudioFlinger, data, reply);
1073 reply->writeInt32( setMasterMute(data.readInt32()) );
1074 return NO_ERROR;
1075 } break;
1076 case MASTER_VOLUME: {
1077 CHECK_INTERFACE(IAudioFlinger, data, reply);
1078 reply->writeFloat( masterVolume() );
1079 return NO_ERROR;
1080 } break;
1081 case MASTER_MUTE: {
1082 CHECK_INTERFACE(IAudioFlinger, data, reply);
1083 reply->writeInt32( masterMute() );
1084 return NO_ERROR;
1085 } break;
1086 case SET_STREAM_VOLUME: {
1087 CHECK_INTERFACE(IAudioFlinger, data, reply);
1088 int stream = data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -07001089 float volume = data.readFloat();
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001090 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -08001091 reply->writeInt32( setStreamVolume((audio_stream_type_t) stream, volume, output) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001092 return NO_ERROR;
1093 } break;
1094 case SET_STREAM_MUTE: {
1095 CHECK_INTERFACE(IAudioFlinger, data, reply);
1096 int stream = data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -08001097 reply->writeInt32( setStreamMute((audio_stream_type_t) stream, data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001098 return NO_ERROR;
1099 } break;
1100 case STREAM_VOLUME: {
1101 CHECK_INTERFACE(IAudioFlinger, data, reply);
1102 int stream = data.readInt32();
Eric Laurentfa2877b2009-07-28 08:44:33 -07001103 int output = data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -08001104 reply->writeFloat( streamVolume((audio_stream_type_t) stream, output) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001105 return NO_ERROR;
1106 } break;
1107 case STREAM_MUTE: {
1108 CHECK_INTERFACE(IAudioFlinger, data, reply);
1109 int stream = data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -08001110 reply->writeInt32( streamMute((audio_stream_type_t) stream) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001111 return NO_ERROR;
1112 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001113 case SET_MODE: {
1114 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kastenf78aee72012-01-04 11:00:47 -08001115 audio_mode_t mode = (audio_mode_t) data.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001116 reply->writeInt32( setMode(mode) );
1117 return NO_ERROR;
1118 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001119 case SET_MIC_MUTE: {
1120 CHECK_INTERFACE(IAudioFlinger, data, reply);
1121 int state = data.readInt32();
1122 reply->writeInt32( setMicMute(state) );
1123 return NO_ERROR;
1124 } break;
1125 case GET_MIC_MUTE: {
1126 CHECK_INTERFACE(IAudioFlinger, data, reply);
1127 reply->writeInt32( getMicMute() );
1128 return NO_ERROR;
1129 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -07001130 case SET_PARAMETERS: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001131 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001132 audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -07001133 String8 keyValuePairs(data.readString8());
1134 reply->writeInt32(setParameters(ioHandle, keyValuePairs));
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001135 return NO_ERROR;
Glenn Kastene53b9ea2012-03-12 16:29:55 -07001136 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -07001137 case GET_PARAMETERS: {
1138 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001139 audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -07001140 String8 keys(data.readString8());
1141 reply->writeString8(getParameters(ioHandle, keys));
1142 return NO_ERROR;
Glenn Kastene53b9ea2012-03-12 16:29:55 -07001143 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -07001144
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001145 case REGISTER_CLIENT: {
1146 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten85ab62c2012-11-01 11:11:38 -07001147 sp<IAudioFlingerClient> client = interface_cast<IAudioFlingerClient>(
1148 data.readStrongBinder());
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001149 registerClient(client);
1150 return NO_ERROR;
1151 } break;
1152 case GET_INPUTBUFFERSIZE: {
1153 CHECK_INTERFACE(IAudioFlinger, data, reply);
1154 uint32_t sampleRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -08001155 audio_format_t format = (audio_format_t) data.readInt32();
Glenn Kastendd8104c2012-07-02 12:42:44 -07001156 audio_channel_mask_t channelMask = data.readInt32();
Glenn Kastene03dd222014-01-28 11:04:39 -08001157 reply->writeInt64( getInputBufferSize(sampleRate, format, channelMask) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001158 return NO_ERROR;
1159 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -07001160 case OPEN_OUTPUT: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001161 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurenta4c5a552012-03-29 10:12:40 -07001162 audio_module_handle_t module = (audio_module_handle_t)data.readInt32();
Wei Jiae995e472015-09-09 09:48:34 -07001163 audio_config_t config = {};
1164 if (data.read(&config, sizeof(audio_config_t)) != NO_ERROR) {
1165 ALOGE("b/23905951");
1166 }
Eric Laurenta4c5a552012-03-29 10:12:40 -07001167 audio_devices_t devices = (audio_devices_t)data.readInt32();
Eric Laurentcf2c0212014-07-25 16:20:43 -07001168 String8 address(data.readString8());
Eric Laurent0ca3cf92012-04-18 09:24:29 -07001169 audio_output_flags_t flags = (audio_output_flags_t) data.readInt32();
Wei Jia983dca32015-09-10 09:47:29 -07001170 uint32_t latencyMs = 0;
Wei Jia4cac44b2015-09-16 15:01:16 -07001171 audio_io_handle_t output = AUDIO_IO_HANDLE_NONE;
Eric Laurentcf2c0212014-07-25 16:20:43 -07001172 status_t status = openOutput(module, &output, &config,
1173 &devices, address, &latencyMs, flags);
Glenn Kasten70742962014-02-18 08:00:47 -08001174 ALOGV("OPEN_OUTPUT output, %d", output);
Eric Laurentcf2c0212014-07-25 16:20:43 -07001175 reply->writeInt32((int32_t)status);
1176 if (status == NO_ERROR) {
1177 reply->writeInt32((int32_t)output);
1178 reply->write(&config, sizeof(audio_config_t));
1179 reply->writeInt32(devices);
1180 reply->writeInt32(latencyMs);
1181 }
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001182 return NO_ERROR;
1183 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -07001184 case OPEN_DUPLICATE_OUTPUT: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001185 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001186 audio_io_handle_t output1 = (audio_io_handle_t) data.readInt32();
1187 audio_io_handle_t output2 = (audio_io_handle_t) data.readInt32();
1188 reply->writeInt32((int32_t) openDuplicateOutput(output1, output2));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001189 return NO_ERROR;
1190 } break;
1191 case CLOSE_OUTPUT: {
1192 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001193 reply->writeInt32(closeOutput((audio_io_handle_t) data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001194 return NO_ERROR;
1195 } break;
1196 case SUSPEND_OUTPUT: {
1197 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001198 reply->writeInt32(suspendOutput((audio_io_handle_t) data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001199 return NO_ERROR;
1200 } break;
1201 case RESTORE_OUTPUT: {
1202 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001203 reply->writeInt32(restoreOutput((audio_io_handle_t) data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001204 return NO_ERROR;
1205 } break;
1206 case OPEN_INPUT: {
1207 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurenta4c5a552012-03-29 10:12:40 -07001208 audio_module_handle_t module = (audio_module_handle_t)data.readInt32();
Eric Laurentcf2c0212014-07-25 16:20:43 -07001209 audio_io_handle_t input = (audio_io_handle_t)data.readInt32();
Wei Jiae995e472015-09-09 09:48:34 -07001210 audio_config_t config = {};
1211 if (data.read(&config, sizeof(audio_config_t)) != NO_ERROR) {
1212 ALOGE("b/23905951");
1213 }
Eric Laurentcf2c0212014-07-25 16:20:43 -07001214 audio_devices_t device = (audio_devices_t)data.readInt32();
1215 String8 address(data.readString8());
1216 audio_source_t source = (audio_source_t)data.readInt32();
Glenn Kastenec40d282014-07-15 15:31:26 -07001217 audio_input_flags_t flags = (audio_input_flags_t) data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -07001218
Eric Laurentcf2c0212014-07-25 16:20:43 -07001219 status_t status = openInput(module, &input, &config,
1220 &device, address, source, flags);
1221 reply->writeInt32((int32_t) status);
1222 if (status == NO_ERROR) {
1223 reply->writeInt32((int32_t) input);
1224 reply->write(&config, sizeof(audio_config_t));
1225 reply->writeInt32(device);
1226 }
Eric Laurentc2f1f072009-07-17 12:17:14 -07001227 return NO_ERROR;
1228 } break;
1229 case CLOSE_INPUT: {
1230 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001231 reply->writeInt32(closeInput((audio_io_handle_t) data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -07001232 return NO_ERROR;
1233 } break;
Glenn Kastend2304db2014-02-03 07:40:31 -08001234 case INVALIDATE_STREAM: {
Eric Laurentc2f1f072009-07-17 12:17:14 -07001235 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kastend2304db2014-02-03 07:40:31 -08001236 audio_stream_type_t stream = (audio_stream_type_t) data.readInt32();
1237 reply->writeInt32(invalidateStream(stream));
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001238 return NO_ERROR;
1239 } break;
Eric Laurentf0ee6f42009-10-21 08:14:22 -07001240 case SET_VOICE_VOLUME: {
1241 CHECK_INTERFACE(IAudioFlinger, data, reply);
1242 float volume = data.readFloat();
1243 reply->writeInt32( setVoiceVolume(volume) );
1244 return NO_ERROR;
1245 } break;
Eric Laurent342e9cf2010-01-19 17:37:09 -08001246 case GET_RENDER_POSITION: {
1247 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001248 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Wei Jia983dca32015-09-10 09:47:29 -07001249 uint32_t halFrames = 0;
1250 uint32_t dspFrames = 0;
Eric Laurent342e9cf2010-01-19 17:37:09 -08001251 status_t status = getRenderPosition(&halFrames, &dspFrames, output);
1252 reply->writeInt32(status);
1253 if (status == NO_ERROR) {
1254 reply->writeInt32(halFrames);
1255 reply->writeInt32(dspFrames);
1256 }
1257 return NO_ERROR;
1258 }
Eric Laurent05bca2f2010-02-26 02:47:27 -08001259 case GET_INPUT_FRAMES_LOST: {
1260 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001261 audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
Glenn Kasten5f972c02014-01-13 09:59:31 -08001262 reply->writeInt32((int32_t) getInputFramesLost(ioHandle));
Eric Laurent05bca2f2010-02-26 02:47:27 -08001263 return NO_ERROR;
1264 } break;
Glenn Kasten9eae0362016-04-19 09:09:14 -07001265 case NEW_AUDIO_UNIQUE_ID: {
Eric Laurentbe916aa2010-06-01 23:49:17 -07001266 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasteneeecb982016-02-26 10:44:04 -08001267 reply->writeInt32(newAudioUniqueId((audio_unique_id_use_t) data.readInt32()));
Eric Laurentbe916aa2010-06-01 23:49:17 -07001268 return NO_ERROR;
1269 } break;
Marco Nelissen3a34bef2011-08-02 13:33:41 -07001270 case ACQUIRE_AUDIO_SESSION_ID: {
1271 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kastend848eb42016-03-08 13:42:11 -08001272 audio_session_t audioSession = (audio_session_t) data.readInt32();
Marco Nelissend457c972014-02-11 08:47:07 -08001273 int pid = data.readInt32();
1274 acquireAudioSessionId(audioSession, pid);
Marco Nelissen3a34bef2011-08-02 13:33:41 -07001275 return NO_ERROR;
1276 } break;
1277 case RELEASE_AUDIO_SESSION_ID: {
1278 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kastend848eb42016-03-08 13:42:11 -08001279 audio_session_t audioSession = (audio_session_t) data.readInt32();
Marco Nelissend457c972014-02-11 08:47:07 -08001280 int pid = data.readInt32();
1281 releaseAudioSessionId(audioSession, pid);
Marco Nelissen3a34bef2011-08-02 13:33:41 -07001282 return NO_ERROR;
1283 } break;
Eric Laurentbe916aa2010-06-01 23:49:17 -07001284 case QUERY_NUM_EFFECTS: {
1285 CHECK_INTERFACE(IAudioFlinger, data, reply);
Wei Jia983dca32015-09-10 09:47:29 -07001286 uint32_t numEffects = 0;
Eric Laurentbe916aa2010-06-01 23:49:17 -07001287 status_t status = queryNumberEffects(&numEffects);
1288 reply->writeInt32(status);
1289 if (status == NO_ERROR) {
1290 reply->writeInt32((int32_t)numEffects);
1291 }
1292 return NO_ERROR;
1293 }
Eric Laurentffe9c252010-06-23 17:38:20 -07001294 case QUERY_EFFECT: {
Eric Laurentbe916aa2010-06-01 23:49:17 -07001295 CHECK_INTERFACE(IAudioFlinger, data, reply);
Wei Jia983dca32015-09-10 09:47:29 -07001296 effect_descriptor_t desc = {};
Eric Laurentffe9c252010-06-23 17:38:20 -07001297 status_t status = queryEffect(data.readInt32(), &desc);
Eric Laurentbe916aa2010-06-01 23:49:17 -07001298 reply->writeInt32(status);
1299 if (status == NO_ERROR) {
1300 reply->write(&desc, sizeof(effect_descriptor_t));
1301 }
1302 return NO_ERROR;
1303 }
1304 case GET_EFFECT_DESCRIPTOR: {
1305 CHECK_INTERFACE(IAudioFlinger, data, reply);
1306 effect_uuid_t uuid;
1307 data.read(&uuid, sizeof(effect_uuid_t));
Wei Jia983dca32015-09-10 09:47:29 -07001308 effect_descriptor_t desc = {};
Eric Laurentbe916aa2010-06-01 23:49:17 -07001309 status_t status = getEffectDescriptor(&uuid, &desc);
1310 reply->writeInt32(status);
1311 if (status == NO_ERROR) {
1312 reply->write(&desc, sizeof(effect_descriptor_t));
1313 }
1314 return NO_ERROR;
1315 }
1316 case CREATE_EFFECT: {
1317 CHECK_INTERFACE(IAudioFlinger, data, reply);
Wei Jiae995e472015-09-09 09:48:34 -07001318 effect_descriptor_t desc = {};
1319 if (data.read(&desc, sizeof(effect_descriptor_t)) != NO_ERROR) {
1320 ALOGE("b/23905951");
1321 }
Eric Laurentbe916aa2010-06-01 23:49:17 -07001322 sp<IEffectClient> client = interface_cast<IEffectClient>(data.readStrongBinder());
1323 int32_t priority = data.readInt32();
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001324 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Glenn Kastend848eb42016-03-08 13:42:11 -08001325 audio_session_t sessionId = (audio_session_t) data.readInt32();
Svet Ganovbe71aa22015-04-28 12:06:02 -07001326 const String16 opPackageName = data.readString16();
Eric Laurentb6436272016-12-07 19:24:50 -08001327 pid_t pid = (pid_t)data.readInt32();
1328
Wei Jia983dca32015-09-10 09:47:29 -07001329 status_t status = NO_ERROR;
1330 int id = 0;
1331 int enabled = 0;
Eric Laurent05bca2f2010-02-26 02:47:27 -08001332
Glenn Kasten8d6cc842012-02-03 11:06:53 -08001333 sp<IEffect> effect = createEffect(&desc, client, priority, output, sessionId,
Eric Laurentb6436272016-12-07 19:24:50 -08001334 opPackageName, pid, &status, &id, &enabled);
Eric Laurentbe916aa2010-06-01 23:49:17 -07001335 reply->writeInt32(status);
1336 reply->writeInt32(id);
1337 reply->writeInt32(enabled);
Marco Nelissen06b46062014-11-14 07:58:25 -08001338 reply->writeStrongBinder(IInterface::asBinder(effect));
Eric Laurentbe916aa2010-06-01 23:49:17 -07001339 reply->write(&desc, sizeof(effect_descriptor_t));
1340 return NO_ERROR;
1341 } break;
Eric Laurentde070132010-07-13 04:45:46 -07001342 case MOVE_EFFECTS: {
1343 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kastend848eb42016-03-08 13:42:11 -08001344 audio_session_t session = (audio_session_t) data.readInt32();
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001345 audio_io_handle_t srcOutput = (audio_io_handle_t) data.readInt32();
1346 audio_io_handle_t dstOutput = (audio_io_handle_t) data.readInt32();
Eric Laurentde070132010-07-13 04:45:46 -07001347 reply->writeInt32(moveEffects(session, srcOutput, dstOutput));
1348 return NO_ERROR;
1349 } break;
Eric Laurenta4c5a552012-03-29 10:12:40 -07001350 case LOAD_HW_MODULE: {
1351 CHECK_INTERFACE(IAudioFlinger, data, reply);
1352 reply->writeInt32(loadHwModule(data.readCString()));
1353 return NO_ERROR;
1354 } break;
Glenn Kastencc0f1cf2012-09-24 11:27:18 -07001355 case GET_PRIMARY_OUTPUT_SAMPLING_RATE: {
1356 CHECK_INTERFACE(IAudioFlinger, data, reply);
1357 reply->writeInt32(getPrimaryOutputSamplingRate());
1358 return NO_ERROR;
1359 } break;
1360 case GET_PRIMARY_OUTPUT_FRAME_COUNT: {
1361 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kastene03dd222014-01-28 11:04:39 -08001362 reply->writeInt64(getPrimaryOutputFrameCount());
Glenn Kastencc0f1cf2012-09-24 11:27:18 -07001363 return NO_ERROR;
1364 } break;
Glenn Kasten4182c4e2013-07-15 14:45:07 -07001365 case SET_LOW_RAM_DEVICE: {
1366 CHECK_INTERFACE(IAudioFlinger, data, reply);
1367 bool isLowRamDevice = data.readInt32() != 0;
1368 reply->writeInt32(setLowRamDevice(isLowRamDevice));
1369 return NO_ERROR;
1370 } break;
Eric Laurent4b123402014-04-11 09:22:20 -07001371 case LIST_AUDIO_PORTS: {
1372 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurentf75c2fe2015-04-02 13:49:15 -07001373 unsigned int numPortsReq = data.readInt32();
1374 if (numPortsReq > MAX_ITEMS_PER_LIST) {
1375 numPortsReq = MAX_ITEMS_PER_LIST;
1376 }
1377 unsigned int numPorts = numPortsReq;
Eric Laurent4b123402014-04-11 09:22:20 -07001378 struct audio_port *ports =
Eric Laurentf75c2fe2015-04-02 13:49:15 -07001379 (struct audio_port *)calloc(numPortsReq,
Eric Laurent4b123402014-04-11 09:22:20 -07001380 sizeof(struct audio_port));
Eric Laurentf75c2fe2015-04-02 13:49:15 -07001381 if (ports == NULL) {
1382 reply->writeInt32(NO_MEMORY);
1383 reply->writeInt32(0);
1384 return NO_ERROR;
1385 }
1386 status_t status = listAudioPorts(&numPorts, ports);
Eric Laurent4b123402014-04-11 09:22:20 -07001387 reply->writeInt32(status);
Eric Laurentf75c2fe2015-04-02 13:49:15 -07001388 reply->writeInt32(numPorts);
Eric Laurent4b123402014-04-11 09:22:20 -07001389 if (status == NO_ERROR) {
Eric Laurentf75c2fe2015-04-02 13:49:15 -07001390 if (numPortsReq > numPorts) {
1391 numPortsReq = numPorts;
1392 }
1393 reply->write(ports, numPortsReq * sizeof(struct audio_port));
Eric Laurent4b123402014-04-11 09:22:20 -07001394 }
1395 free(ports);
1396 return NO_ERROR;
1397 } break;
1398 case GET_AUDIO_PORT: {
1399 CHECK_INTERFACE(IAudioFlinger, data, reply);
Wei Jiae995e472015-09-09 09:48:34 -07001400 struct audio_port port = {};
1401 if (data.read(&port, sizeof(struct audio_port)) != NO_ERROR) {
1402 ALOGE("b/23905951");
1403 }
Eric Laurent4b123402014-04-11 09:22:20 -07001404 status_t status = getAudioPort(&port);
1405 reply->writeInt32(status);
1406 if (status == NO_ERROR) {
1407 reply->write(&port, sizeof(struct audio_port));
1408 }
1409 return NO_ERROR;
1410 } break;
1411 case CREATE_AUDIO_PATCH: {
1412 CHECK_INTERFACE(IAudioFlinger, data, reply);
1413 struct audio_patch patch;
1414 data.read(&patch, sizeof(struct audio_patch));
Glenn Kastena13cde92016-03-28 15:26:02 -07001415 audio_patch_handle_t handle = AUDIO_PATCH_HANDLE_NONE;
Wei Jiae995e472015-09-09 09:48:34 -07001416 if (data.read(&handle, sizeof(audio_patch_handle_t)) != NO_ERROR) {
1417 ALOGE("b/23905951");
1418 }
Eric Laurent4b123402014-04-11 09:22:20 -07001419 status_t status = createAudioPatch(&patch, &handle);
1420 reply->writeInt32(status);
1421 if (status == NO_ERROR) {
1422 reply->write(&handle, sizeof(audio_patch_handle_t));
1423 }
1424 return NO_ERROR;
1425 } break;
1426 case RELEASE_AUDIO_PATCH: {
1427 CHECK_INTERFACE(IAudioFlinger, data, reply);
1428 audio_patch_handle_t handle;
1429 data.read(&handle, sizeof(audio_patch_handle_t));
1430 status_t status = releaseAudioPatch(handle);
1431 reply->writeInt32(status);
1432 return NO_ERROR;
1433 } break;
1434 case LIST_AUDIO_PATCHES: {
1435 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurentf75c2fe2015-04-02 13:49:15 -07001436 unsigned int numPatchesReq = data.readInt32();
1437 if (numPatchesReq > MAX_ITEMS_PER_LIST) {
1438 numPatchesReq = MAX_ITEMS_PER_LIST;
1439 }
1440 unsigned int numPatches = numPatchesReq;
Eric Laurent4b123402014-04-11 09:22:20 -07001441 struct audio_patch *patches =
Eric Laurentf75c2fe2015-04-02 13:49:15 -07001442 (struct audio_patch *)calloc(numPatchesReq,
Eric Laurent4b123402014-04-11 09:22:20 -07001443 sizeof(struct audio_patch));
Eric Laurentf75c2fe2015-04-02 13:49:15 -07001444 if (patches == NULL) {
1445 reply->writeInt32(NO_MEMORY);
1446 reply->writeInt32(0);
1447 return NO_ERROR;
1448 }
1449 status_t status = listAudioPatches(&numPatches, patches);
Eric Laurent4b123402014-04-11 09:22:20 -07001450 reply->writeInt32(status);
Eric Laurentf75c2fe2015-04-02 13:49:15 -07001451 reply->writeInt32(numPatches);
Eric Laurent4b123402014-04-11 09:22:20 -07001452 if (status == NO_ERROR) {
Eric Laurentf75c2fe2015-04-02 13:49:15 -07001453 if (numPatchesReq > numPatches) {
1454 numPatchesReq = numPatches;
1455 }
1456 reply->write(patches, numPatchesReq * sizeof(struct audio_patch));
Eric Laurent4b123402014-04-11 09:22:20 -07001457 }
1458 free(patches);
1459 return NO_ERROR;
1460 } break;
1461 case SET_AUDIO_PORT_CONFIG: {
1462 CHECK_INTERFACE(IAudioFlinger, data, reply);
1463 struct audio_port_config config;
1464 data.read(&config, sizeof(struct audio_port_config));
1465 status_t status = setAudioPortConfig(&config);
1466 reply->writeInt32(status);
1467 return NO_ERROR;
1468 } break;
Glenn Kasten9eae0362016-04-19 09:09:14 -07001469 case GET_AUDIO_HW_SYNC_FOR_SESSION: {
Eric Laurent93c3d412014-08-01 14:48:35 -07001470 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kastend848eb42016-03-08 13:42:11 -08001471 reply->writeInt32(getAudioHwSyncForSession((audio_session_t) data.readInt32()));
Eric Laurent93c3d412014-08-01 14:48:35 -07001472 return NO_ERROR;
1473 } break;
Eric Laurent72e3f392015-05-20 14:43:50 -07001474 case SYSTEM_READY: {
1475 CHECK_INTERFACE(IAudioFlinger, data, reply);
1476 systemReady();
1477 return NO_ERROR;
1478 } break;
Glenn Kasten4a8308b2016-04-18 14:10:01 -07001479 case FRAME_COUNT_HAL: {
1480 CHECK_INTERFACE(IAudioFlinger, data, reply);
1481 reply->writeInt64( frameCountHAL((audio_io_handle_t) data.readInt32()) );
1482 return NO_ERROR;
1483 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001484 default:
1485 return BBinder::onTransact(code, data, reply, flags);
1486 }
1487}
1488
1489// ----------------------------------------------------------------------------
1490
Glenn Kasten40bc9062015-03-20 09:09:33 -07001491} // namespace android