blob: e02107f61d680fe751a12561a892f84f46670435 [file] [log] [blame]
Marco Nelissen3a34bef2011-08-02 13:33:41 -07001/*
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08002**
3** Copyright 2007, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18#define LOG_TAG "IAudioFlinger"
Eric Laurentc2f1f072009-07-17 12:17:14 -070019//#define LOG_NDEBUG 0
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080020#include <utils/Log.h>
21
22#include <stdint.h>
23#include <sys/types.h>
24
Mathias Agopian75624082009-05-19 19:08:10 -070025#include <binder/Parcel.h>
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080026
27#include <media/IAudioFlinger.h>
28
29namespace android {
30
31enum {
32 CREATE_TRACK = IBinder::FIRST_CALL_TRANSACTION,
33 OPEN_RECORD,
34 SAMPLE_RATE,
Glenn Kasten5876f2f2012-11-30 10:52:16 -080035 RESERVED, // obsolete, was CHANNEL_COUNT
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080036 FORMAT,
37 FRAME_COUNT,
38 LATENCY,
39 SET_MASTER_VOLUME,
40 SET_MASTER_MUTE,
41 MASTER_VOLUME,
42 MASTER_MUTE,
43 SET_STREAM_VOLUME,
44 SET_STREAM_MUTE,
45 STREAM_VOLUME,
46 STREAM_MUTE,
47 SET_MODE,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080048 SET_MIC_MUTE,
49 GET_MIC_MUTE,
Eric Laurentc2f1f072009-07-17 12:17:14 -070050 SET_PARAMETERS,
51 GET_PARAMETERS,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080052 REGISTER_CLIENT,
53 GET_INPUTBUFFERSIZE,
Eric Laurentc2f1f072009-07-17 12:17:14 -070054 OPEN_OUTPUT,
55 OPEN_DUPLICATE_OUTPUT,
56 CLOSE_OUTPUT,
57 SUSPEND_OUTPUT,
58 RESTORE_OUTPUT,
59 OPEN_INPUT,
60 CLOSE_INPUT,
Eric Laurentf0ee6f42009-10-21 08:14:22 -070061 SET_STREAM_OUTPUT,
Eric Laurent342e9cf2010-01-19 17:37:09 -080062 SET_VOICE_VOLUME,
Eric Laurent05bca2f2010-02-26 02:47:27 -080063 GET_RENDER_POSITION,
Eric Laurentbe916aa2010-06-01 23:49:17 -070064 GET_INPUT_FRAMES_LOST,
65 NEW_AUDIO_SESSION_ID,
Marco Nelissen3a34bef2011-08-02 13:33:41 -070066 ACQUIRE_AUDIO_SESSION_ID,
67 RELEASE_AUDIO_SESSION_ID,
Eric Laurentbe916aa2010-06-01 23:49:17 -070068 QUERY_NUM_EFFECTS,
Eric Laurentffe9c252010-06-23 17:38:20 -070069 QUERY_EFFECT,
Eric Laurentbe916aa2010-06-01 23:49:17 -070070 GET_EFFECT_DESCRIPTOR,
Eric Laurentde070132010-07-13 04:45:46 -070071 CREATE_EFFECT,
Eric Laurenta4c5a552012-03-29 10:12:40 -070072 MOVE_EFFECTS,
Glenn Kastencc0f1cf2012-09-24 11:27:18 -070073 LOAD_HW_MODULE,
74 GET_PRIMARY_OUTPUT_SAMPLING_RATE,
75 GET_PRIMARY_OUTPUT_FRAME_COUNT,
Glenn Kasten4182c4e2013-07-15 14:45:07 -070076 SET_LOW_RAM_DEVICE,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080077};
78
79class BpAudioFlinger : public BpInterface<IAudioFlinger>
80{
81public:
82 BpAudioFlinger(const sp<IBinder>& impl)
83 : BpInterface<IAudioFlinger>(impl)
84 {
85 }
86
87 virtual sp<IAudioTrack> createTrack(
Glenn Kastenfff6d712012-01-12 16:38:12 -080088 audio_stream_type_t streamType,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080089 uint32_t sampleRate,
Glenn Kasten58f30212012-01-12 12:27:51 -080090 audio_format_t format,
Glenn Kastendd8104c2012-07-02 12:42:44 -070091 audio_channel_mask_t channelMask,
Glenn Kastene33054e2012-11-14 12:54:39 -080092 size_t frameCount,
Glenn Kastene0b07172012-11-06 15:03:34 -080093 track_flags_t *flags,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080094 const sp<IMemory>& sharedBuffer,
Glenn Kasten72ef00d2012-01-17 11:09:42 -080095 audio_io_handle_t output,
Glenn Kasten3acbd052012-02-28 10:39:56 -080096 pid_t tid,
Eric Laurentbe916aa2010-06-01 23:49:17 -070097 int *sessionId,
Glenn Kastend054c322013-07-12 12:59:20 -070098 String8& name,
Marco Nelissen9cae2172013-01-14 14:12:05 -080099 int clientUid,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800100 status_t *status)
101 {
102 Parcel data, reply;
Eric Laurent5841db72009-09-09 05:16:08 -0700103 sp<IAudioTrack> track;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800104 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800105 data.writeInt32((int32_t) streamType);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800106 data.writeInt32(sampleRate);
107 data.writeInt32(format);
Jean-Michel Trivi0d255b22011-05-24 15:53:33 -0700108 data.writeInt32(channelMask);
Glenn 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);
Eric Laurent3d00aa62013-09-24 09:53:27 -0700112 if (sharedBuffer != 0) {
113 data.writeInt32(true);
114 data.writeStrongBinder(sharedBuffer->asBinder());
115 } else {
116 data.writeInt32(false);
117 }
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800118 data.writeInt32((int32_t) output);
Glenn Kasten3acbd052012-02-28 10:39:56 -0800119 data.writeInt32((int32_t) tid);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700120 int lSessionId = 0;
121 if (sessionId != NULL) {
122 lSessionId = *sessionId;
123 }
124 data.writeInt32(lSessionId);
Marco Nelissen9cae2172013-01-14 14:12:05 -0800125 data.writeInt32(clientUid);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800126 status_t lStatus = remote()->transact(CREATE_TRACK, data, &reply);
127 if (lStatus != NO_ERROR) {
Steve Block29357bc2012-01-06 19:20:56 +0000128 ALOGE("createTrack error: %s", strerror(-lStatus));
Eric Laurent5841db72009-09-09 05:16:08 -0700129 } else {
Glenn Kastene0b07172012-11-06 15:03:34 -0800130 lFlags = reply.readInt32();
131 if (flags != NULL) {
132 *flags = lFlags;
133 }
Eric Laurentbe916aa2010-06-01 23:49:17 -0700134 lSessionId = reply.readInt32();
135 if (sessionId != NULL) {
136 *sessionId = lSessionId;
137 }
Glenn Kastend054c322013-07-12 12:59:20 -0700138 name = reply.readString8();
Eric Laurent5841db72009-09-09 05:16:08 -0700139 lStatus = reply.readInt32();
140 track = interface_cast<IAudioTrack>(reply.readStrongBinder());
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800141 }
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800142 if (status) {
143 *status = lStatus;
144 }
Eric Laurent5841db72009-09-09 05:16:08 -0700145 return track;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800146 }
147
148 virtual sp<IAudioRecord> openRecord(
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800149 audio_io_handle_t input,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800150 uint32_t sampleRate,
Glenn Kasten58f30212012-01-12 12:27:51 -0800151 audio_format_t format,
Glenn Kasten28b76b32012-07-03 17:24:41 -0700152 audio_channel_mask_t channelMask,
Glenn Kastene33054e2012-11-14 12:54:39 -0800153 size_t frameCount,
Glenn Kasteneeca3262013-07-31 16:12:48 -0700154 track_flags_t *flags,
Glenn Kasten1879fff2012-07-11 15:36:59 -0700155 pid_t tid,
Eric Laurentbe916aa2010-06-01 23:49:17 -0700156 int *sessionId,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800157 status_t *status)
158 {
159 Parcel data, reply;
Eric Laurent5841db72009-09-09 05:16:08 -0700160 sp<IAudioRecord> record;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800161 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800162 data.writeInt32((int32_t) input);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800163 data.writeInt32(sampleRate);
164 data.writeInt32(format);
Jean-Michel Trivi0d255b22011-05-24 15:53:33 -0700165 data.writeInt32(channelMask);
Glenn Kastene03dd222014-01-28 11:04:39 -0800166 data.writeInt64(frameCount);
Glenn Kasteneeca3262013-07-31 16:12:48 -0700167 track_flags_t lFlags = flags != NULL ? *flags : (track_flags_t) TRACK_DEFAULT;
168 data.writeInt32(lFlags);
Glenn Kasten1879fff2012-07-11 15:36:59 -0700169 data.writeInt32((int32_t) tid);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700170 int lSessionId = 0;
171 if (sessionId != NULL) {
172 lSessionId = *sessionId;
173 }
174 data.writeInt32(lSessionId);
Eric Laurent5841db72009-09-09 05:16:08 -0700175 status_t lStatus = remote()->transact(OPEN_RECORD, data, &reply);
176 if (lStatus != NO_ERROR) {
Steve Block29357bc2012-01-06 19:20:56 +0000177 ALOGE("openRecord error: %s", strerror(-lStatus));
Eric Laurent5841db72009-09-09 05:16:08 -0700178 } else {
Glenn Kasteneeca3262013-07-31 16:12:48 -0700179 lFlags = reply.readInt32();
180 if (flags != NULL) {
181 *flags = lFlags;
182 }
Eric Laurentbe916aa2010-06-01 23:49:17 -0700183 lSessionId = reply.readInt32();
184 if (sessionId != NULL) {
185 *sessionId = lSessionId;
186 }
Eric Laurent5841db72009-09-09 05:16:08 -0700187 lStatus = reply.readInt32();
188 record = interface_cast<IAudioRecord>(reply.readStrongBinder());
Glenn Kastene93cf2c2013-09-24 11:52:37 -0700189 if (lStatus == NO_ERROR) {
190 if (record == 0) {
191 ALOGE("openRecord should have returned an IAudioRecord");
192 lStatus = UNKNOWN_ERROR;
193 }
194 } else {
195 if (record != 0) {
196 ALOGE("openRecord returned an IAudioRecord but with status %d", lStatus);
197 record.clear();
198 }
199 }
Eric Laurent5841db72009-09-09 05:16:08 -0700200 }
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800201 if (status) {
202 *status = lStatus;
203 }
Eric Laurent5841db72009-09-09 05:16:08 -0700204 return record;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800205 }
206
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800207 virtual uint32_t sampleRate(audio_io_handle_t output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800208 {
209 Parcel data, reply;
210 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800211 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800212 remote()->transact(SAMPLE_RATE, data, &reply);
213 return reply.readInt32();
214 }
215
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800216 virtual audio_format_t format(audio_io_handle_t output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800217 {
218 Parcel data, reply;
219 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800220 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800221 remote()->transact(FORMAT, data, &reply);
Glenn Kasten58f30212012-01-12 12:27:51 -0800222 return (audio_format_t) reply.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800223 }
224
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800225 virtual size_t frameCount(audio_io_handle_t output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800226 {
227 Parcel data, reply;
228 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800229 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800230 remote()->transact(FRAME_COUNT, data, &reply);
Glenn Kastene03dd222014-01-28 11:04:39 -0800231 return reply.readInt64();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800232 }
233
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800234 virtual uint32_t latency(audio_io_handle_t output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800235 {
236 Parcel data, reply;
237 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800238 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800239 remote()->transact(LATENCY, data, &reply);
240 return reply.readInt32();
241 }
242
243 virtual status_t setMasterVolume(float value)
244 {
245 Parcel data, reply;
246 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
247 data.writeFloat(value);
248 remote()->transact(SET_MASTER_VOLUME, data, &reply);
249 return reply.readInt32();
250 }
251
252 virtual status_t setMasterMute(bool muted)
253 {
254 Parcel data, reply;
255 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
256 data.writeInt32(muted);
257 remote()->transact(SET_MASTER_MUTE, data, &reply);
258 return reply.readInt32();
259 }
260
261 virtual float masterVolume() const
262 {
263 Parcel data, reply;
264 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
265 remote()->transact(MASTER_VOLUME, data, &reply);
266 return reply.readFloat();
267 }
268
269 virtual bool masterMute() const
270 {
271 Parcel data, reply;
272 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
273 remote()->transact(MASTER_MUTE, data, &reply);
274 return reply.readInt32();
275 }
276
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800277 virtual status_t setStreamVolume(audio_stream_type_t stream, float value,
278 audio_io_handle_t output)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800279 {
280 Parcel data, reply;
281 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800282 data.writeInt32((int32_t) stream);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800283 data.writeFloat(value);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800284 data.writeInt32((int32_t) output);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800285 remote()->transact(SET_STREAM_VOLUME, data, &reply);
286 return reply.readInt32();
287 }
288
Glenn Kastenfff6d712012-01-12 16:38:12 -0800289 virtual status_t setStreamMute(audio_stream_type_t stream, bool muted)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800290 {
291 Parcel data, reply;
292 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800293 data.writeInt32((int32_t) stream);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800294 data.writeInt32(muted);
295 remote()->transact(SET_STREAM_MUTE, data, &reply);
296 return reply.readInt32();
297 }
298
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800299 virtual float streamVolume(audio_stream_type_t stream, audio_io_handle_t output) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800300 {
301 Parcel data, reply;
302 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800303 data.writeInt32((int32_t) stream);
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(STREAM_VOLUME, data, &reply);
306 return reply.readFloat();
307 }
308
Glenn Kastenfff6d712012-01-12 16:38:12 -0800309 virtual bool streamMute(audio_stream_type_t stream) const
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 remote()->transact(STREAM_MUTE, data, &reply);
315 return reply.readInt32();
316 }
317
Glenn Kastenf78aee72012-01-04 11:00:47 -0800318 virtual status_t setMode(audio_mode_t mode)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800319 {
320 Parcel data, reply;
321 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
322 data.writeInt32(mode);
323 remote()->transact(SET_MODE, data, &reply);
324 return reply.readInt32();
325 }
326
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800327 virtual status_t setMicMute(bool state)
328 {
329 Parcel data, reply;
330 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
331 data.writeInt32(state);
332 remote()->transact(SET_MIC_MUTE, data, &reply);
333 return reply.readInt32();
334 }
335
336 virtual bool getMicMute() const
337 {
338 Parcel data, reply;
339 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
340 remote()->transact(GET_MIC_MUTE, data, &reply);
341 return reply.readInt32();
342 }
343
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800344 virtual status_t setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800345 {
346 Parcel data, reply;
347 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800348 data.writeInt32((int32_t) ioHandle);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700349 data.writeString8(keyValuePairs);
350 remote()->transact(SET_PARAMETERS, data, &reply);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800351 return reply.readInt32();
352 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700353
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800354 virtual String8 getParameters(audio_io_handle_t ioHandle, const String8& keys) const
Eric Laurentc2f1f072009-07-17 12:17:14 -0700355 {
356 Parcel data, reply;
357 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800358 data.writeInt32((int32_t) ioHandle);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700359 data.writeString8(keys);
360 remote()->transact(GET_PARAMETERS, data, &reply);
361 return reply.readString8();
362 }
363
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800364 virtual void registerClient(const sp<IAudioFlingerClient>& client)
365 {
366 Parcel data, reply;
367 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
368 data.writeStrongBinder(client->asBinder());
369 remote()->transact(REGISTER_CLIENT, data, &reply);
370 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700371
Glenn Kastendd8104c2012-07-02 12:42:44 -0700372 virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format,
373 audio_channel_mask_t channelMask) const
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800374 {
375 Parcel data, reply;
376 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
377 data.writeInt32(sampleRate);
378 data.writeInt32(format);
Glenn Kastendd8104c2012-07-02 12:42:44 -0700379 data.writeInt32(channelMask);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800380 remote()->transact(GET_INPUTBUFFERSIZE, data, &reply);
Glenn Kastene03dd222014-01-28 11:04:39 -0800381 return reply.readInt64();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800382 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700383
Eric Laurenta4c5a552012-03-29 10:12:40 -0700384 virtual audio_io_handle_t openOutput(audio_module_handle_t module,
385 audio_devices_t *pDevices,
386 uint32_t *pSamplingRate,
387 audio_format_t *pFormat,
388 audio_channel_mask_t *pChannelMask,
389 uint32_t *pLatencyMs,
Richard Fitzgeraldad3af332013-03-25 16:54:37 +0000390 audio_output_flags_t flags,
391 const audio_offload_info_t *offloadInfo)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800392 {
393 Parcel data, reply;
Glenn Kasten7c5977f2013-07-02 14:17:22 -0700394 audio_devices_t devices = pDevices != NULL ? *pDevices : (audio_devices_t)0;
395 uint32_t samplingRate = pSamplingRate != NULL ? *pSamplingRate : 0;
396 audio_format_t format = pFormat != NULL ? *pFormat : AUDIO_FORMAT_DEFAULT;
397 audio_channel_mask_t channelMask = pChannelMask != NULL ?
398 *pChannelMask : (audio_channel_mask_t)0;
399 uint32_t latency = pLatencyMs != NULL ? *pLatencyMs : 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800400 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurenta4c5a552012-03-29 10:12:40 -0700401 data.writeInt32(module);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700402 data.writeInt32(devices);
403 data.writeInt32(samplingRate);
404 data.writeInt32(format);
Eric Laurenta4c5a552012-03-29 10:12:40 -0700405 data.writeInt32(channelMask);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700406 data.writeInt32(latency);
Glenn Kasten18868c52012-03-07 09:15:37 -0800407 data.writeInt32((int32_t) flags);
Richard Fitzgeraldb1a270d2013-05-14 12:12:21 +0100408 if (offloadInfo == NULL) {
409 data.writeInt32(0);
410 } else {
411 data.writeInt32(1);
412 data.write(offloadInfo, sizeof(audio_offload_info_t));
413 }
Eric Laurentc2f1f072009-07-17 12:17:14 -0700414 remote()->transact(OPEN_OUTPUT, data, &reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800415 audio_io_handle_t output = (audio_io_handle_t) reply.readInt32();
416 ALOGV("openOutput() returned output, %d", output);
Eric Laurenta4c5a552012-03-29 10:12:40 -0700417 devices = (audio_devices_t)reply.readInt32();
Glenn Kasten7c5977f2013-07-02 14:17:22 -0700418 if (pDevices != NULL) *pDevices = devices;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700419 samplingRate = reply.readInt32();
Glenn Kasten7c5977f2013-07-02 14:17:22 -0700420 if (pSamplingRate != NULL) *pSamplingRate = samplingRate;
Glenn Kasten58f30212012-01-12 12:27:51 -0800421 format = (audio_format_t) reply.readInt32();
Glenn Kasten7c5977f2013-07-02 14:17:22 -0700422 if (pFormat != NULL) *pFormat = format;
Eric Laurenta4c5a552012-03-29 10:12:40 -0700423 channelMask = (audio_channel_mask_t)reply.readInt32();
Glenn Kasten7c5977f2013-07-02 14:17:22 -0700424 if (pChannelMask != NULL) *pChannelMask = channelMask;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700425 latency = reply.readInt32();
Glenn Kasten7c5977f2013-07-02 14:17:22 -0700426 if (pLatencyMs != NULL) *pLatencyMs = latency;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700427 return output;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800428 }
429
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800430 virtual audio_io_handle_t openDuplicateOutput(audio_io_handle_t output1,
431 audio_io_handle_t output2)
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800432 {
433 Parcel data, reply;
434 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800435 data.writeInt32((int32_t) output1);
436 data.writeInt32((int32_t) output2);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700437 remote()->transact(OPEN_DUPLICATE_OUTPUT, data, &reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800438 return (audio_io_handle_t) reply.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700439 }
440
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800441 virtual status_t closeOutput(audio_io_handle_t output)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700442 {
443 Parcel data, reply;
444 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800445 data.writeInt32((int32_t) output);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700446 remote()->transact(CLOSE_OUTPUT, data, &reply);
447 return reply.readInt32();
448 }
449
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800450 virtual status_t suspendOutput(audio_io_handle_t output)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700451 {
452 Parcel data, reply;
453 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800454 data.writeInt32((int32_t) output);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700455 remote()->transact(SUSPEND_OUTPUT, data, &reply);
456 return reply.readInt32();
457 }
458
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800459 virtual status_t restoreOutput(audio_io_handle_t output)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700460 {
461 Parcel data, reply;
462 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800463 data.writeInt32((int32_t) output);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700464 remote()->transact(RESTORE_OUTPUT, data, &reply);
465 return reply.readInt32();
466 }
467
Eric Laurenta4c5a552012-03-29 10:12:40 -0700468 virtual audio_io_handle_t openInput(audio_module_handle_t module,
469 audio_devices_t *pDevices,
470 uint32_t *pSamplingRate,
471 audio_format_t *pFormat,
472 audio_channel_mask_t *pChannelMask)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700473 {
474 Parcel data, reply;
Glenn Kasten7c5977f2013-07-02 14:17:22 -0700475 audio_devices_t devices = pDevices != NULL ? *pDevices : (audio_devices_t)0;
476 uint32_t samplingRate = pSamplingRate != NULL ? *pSamplingRate : 0;
477 audio_format_t format = pFormat != NULL ? *pFormat : AUDIO_FORMAT_DEFAULT;
478 audio_channel_mask_t channelMask = pChannelMask != NULL ?
479 *pChannelMask : (audio_channel_mask_t)0;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700480
481 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurenta4c5a552012-03-29 10:12:40 -0700482 data.writeInt32(module);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700483 data.writeInt32(devices);
484 data.writeInt32(samplingRate);
485 data.writeInt32(format);
Eric Laurenta4c5a552012-03-29 10:12:40 -0700486 data.writeInt32(channelMask);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700487 remote()->transact(OPEN_INPUT, data, &reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800488 audio_io_handle_t input = (audio_io_handle_t) reply.readInt32();
Eric Laurenta4c5a552012-03-29 10:12:40 -0700489 devices = (audio_devices_t)reply.readInt32();
Glenn Kasten7c5977f2013-07-02 14:17:22 -0700490 if (pDevices != NULL) *pDevices = devices;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700491 samplingRate = reply.readInt32();
Glenn Kasten7c5977f2013-07-02 14:17:22 -0700492 if (pSamplingRate != NULL) *pSamplingRate = samplingRate;
Glenn Kasten58f30212012-01-12 12:27:51 -0800493 format = (audio_format_t) reply.readInt32();
Glenn Kasten7c5977f2013-07-02 14:17:22 -0700494 if (pFormat != NULL) *pFormat = format;
Eric Laurenta4c5a552012-03-29 10:12:40 -0700495 channelMask = (audio_channel_mask_t)reply.readInt32();
Glenn Kasten7c5977f2013-07-02 14:17:22 -0700496 if (pChannelMask != NULL) *pChannelMask = channelMask;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700497 return input;
498 }
499
Eric Laurentfa2877b2009-07-28 08:44:33 -0700500 virtual status_t closeInput(int input)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700501 {
502 Parcel data, reply;
503 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentfa2877b2009-07-28 08:44:33 -0700504 data.writeInt32(input);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700505 remote()->transact(CLOSE_INPUT, data, &reply);
506 return reply.readInt32();
507 }
508
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800509 virtual status_t setStreamOutput(audio_stream_type_t stream, audio_io_handle_t output)
Eric Laurentc2f1f072009-07-17 12:17:14 -0700510 {
511 Parcel data, reply;
512 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kastenfff6d712012-01-12 16:38:12 -0800513 data.writeInt32((int32_t) stream);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800514 data.writeInt32((int32_t) output);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700515 remote()->transact(SET_STREAM_OUTPUT, data, &reply);
516 return reply.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800517 }
Eric Laurentf0ee6f42009-10-21 08:14:22 -0700518
519 virtual status_t setVoiceVolume(float volume)
520 {
521 Parcel data, reply;
522 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
523 data.writeFloat(volume);
524 remote()->transact(SET_VOICE_VOLUME, data, &reply);
525 return reply.readInt32();
526 }
Eric Laurent342e9cf2010-01-19 17:37:09 -0800527
Kévin PETIT377b2ec2014-02-03 12:35:36 +0000528 virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames,
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800529 audio_io_handle_t output) const
Eric Laurent342e9cf2010-01-19 17:37:09 -0800530 {
531 Parcel data, reply;
532 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800533 data.writeInt32((int32_t) output);
Eric Laurent342e9cf2010-01-19 17:37:09 -0800534 remote()->transact(GET_RENDER_POSITION, data, &reply);
535 status_t status = reply.readInt32();
536 if (status == NO_ERROR) {
537 uint32_t tmp = reply.readInt32();
538 if (halFrames) {
539 *halFrames = tmp;
540 }
541 tmp = reply.readInt32();
542 if (dspFrames) {
543 *dspFrames = tmp;
544 }
545 }
546 return status;
547 }
Eric Laurent05bca2f2010-02-26 02:47:27 -0800548
Kévin PETIT377b2ec2014-02-03 12:35:36 +0000549 virtual uint32_t getInputFramesLost(audio_io_handle_t ioHandle) const
Eric Laurent05bca2f2010-02-26 02:47:27 -0800550 {
551 Parcel data, reply;
552 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800553 data.writeInt32((int32_t) ioHandle);
Eric Laurent05bca2f2010-02-26 02:47:27 -0800554 remote()->transact(GET_INPUT_FRAMES_LOST, data, &reply);
555 return reply.readInt32();
556 }
Eric Laurentbe916aa2010-06-01 23:49:17 -0700557
558 virtual int newAudioSessionId()
559 {
560 Parcel data, reply;
561 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
562 status_t status = remote()->transact(NEW_AUDIO_SESSION_ID, data, &reply);
563 int id = 0;
564 if (status == NO_ERROR) {
565 id = reply.readInt32();
566 }
567 return id;
568 }
569
Marco Nelissen3a34bef2011-08-02 13:33:41 -0700570 virtual void acquireAudioSessionId(int audioSession)
571 {
572 Parcel data, reply;
573 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
574 data.writeInt32(audioSession);
575 remote()->transact(ACQUIRE_AUDIO_SESSION_ID, data, &reply);
576 }
577
578 virtual void releaseAudioSessionId(int audioSession)
579 {
580 Parcel data, reply;
581 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
582 data.writeInt32(audioSession);
583 remote()->transact(RELEASE_AUDIO_SESSION_ID, data, &reply);
584 }
585
Glenn Kastenf587ba52012-01-26 16:25:10 -0800586 virtual status_t queryNumberEffects(uint32_t *numEffects) const
Eric Laurentbe916aa2010-06-01 23:49:17 -0700587 {
588 Parcel data, reply;
589 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
590 status_t status = remote()->transact(QUERY_NUM_EFFECTS, data, &reply);
591 if (status != NO_ERROR) {
592 return status;
593 }
594 status = reply.readInt32();
595 if (status != NO_ERROR) {
596 return status;
597 }
Glenn Kasten9d1f02d2012-02-08 17:47:58 -0800598 if (numEffects != NULL) {
Eric Laurentbe916aa2010-06-01 23:49:17 -0700599 *numEffects = (uint32_t)reply.readInt32();
600 }
601 return NO_ERROR;
602 }
603
Glenn Kastenf587ba52012-01-26 16:25:10 -0800604 virtual status_t queryEffect(uint32_t index, effect_descriptor_t *pDescriptor) const
Eric Laurentbe916aa2010-06-01 23:49:17 -0700605 {
606 if (pDescriptor == NULL) {
607 return BAD_VALUE;
608 }
609 Parcel data, reply;
610 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentffe9c252010-06-23 17:38:20 -0700611 data.writeInt32(index);
612 status_t status = remote()->transact(QUERY_EFFECT, data, &reply);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700613 if (status != NO_ERROR) {
614 return status;
615 }
616 status = reply.readInt32();
617 if (status != NO_ERROR) {
618 return status;
619 }
620 reply.read(pDescriptor, sizeof(effect_descriptor_t));
621 return NO_ERROR;
622 }
623
Glenn Kasten5e92a782012-01-30 07:40:52 -0800624 virtual status_t getEffectDescriptor(const effect_uuid_t *pUuid,
Glenn Kastenf587ba52012-01-26 16:25:10 -0800625 effect_descriptor_t *pDescriptor) const
Eric Laurentbe916aa2010-06-01 23:49:17 -0700626 {
627 if (pUuid == NULL || pDescriptor == NULL) {
628 return BAD_VALUE;
629 }
630 Parcel data, reply;
631 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
632 data.write(pUuid, sizeof(effect_uuid_t));
633 status_t status = remote()->transact(GET_EFFECT_DESCRIPTOR, data, &reply);
634 if (status != NO_ERROR) {
635 return status;
636 }
637 status = reply.readInt32();
638 if (status != NO_ERROR) {
639 return status;
640 }
641 reply.read(pDescriptor, sizeof(effect_descriptor_t));
642 return NO_ERROR;
643 }
644
Glenn Kasten8d6cc842012-02-03 11:06:53 -0800645 virtual sp<IEffect> createEffect(
Eric Laurentbe916aa2010-06-01 23:49:17 -0700646 effect_descriptor_t *pDesc,
647 const sp<IEffectClient>& client,
648 int32_t priority,
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800649 audio_io_handle_t output,
Eric Laurentbe916aa2010-06-01 23:49:17 -0700650 int sessionId,
651 status_t *status,
652 int *id,
653 int *enabled)
654 {
655 Parcel data, reply;
656 sp<IEffect> effect;
657
658 if (pDesc == NULL) {
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700659 return effect;
660 if (status) {
661 *status = BAD_VALUE;
662 }
663 }
Eric Laurentbe916aa2010-06-01 23:49:17 -0700664
665 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
Eric Laurentbe916aa2010-06-01 23:49:17 -0700666 data.write(pDesc, sizeof(effect_descriptor_t));
667 data.writeStrongBinder(client->asBinder());
668 data.writeInt32(priority);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800669 data.writeInt32((int32_t) output);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700670 data.writeInt32(sessionId);
671
672 status_t lStatus = remote()->transact(CREATE_EFFECT, data, &reply);
673 if (lStatus != NO_ERROR) {
Steve Block29357bc2012-01-06 19:20:56 +0000674 ALOGE("createEffect error: %s", strerror(-lStatus));
Eric Laurentbe916aa2010-06-01 23:49:17 -0700675 } else {
676 lStatus = reply.readInt32();
677 int tmp = reply.readInt32();
678 if (id) {
679 *id = tmp;
680 }
681 tmp = reply.readInt32();
Glenn Kastena0d68332012-01-27 16:47:15 -0800682 if (enabled != NULL) {
Eric Laurentbe916aa2010-06-01 23:49:17 -0700683 *enabled = tmp;
684 }
685 effect = interface_cast<IEffect>(reply.readStrongBinder());
686 reply.read(pDesc, sizeof(effect_descriptor_t));
687 }
688 if (status) {
689 *status = lStatus;
690 }
691
692 return effect;
693 }
Eric Laurentde070132010-07-13 04:45:46 -0700694
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800695 virtual status_t moveEffects(int session, audio_io_handle_t srcOutput,
696 audio_io_handle_t dstOutput)
Eric Laurentde070132010-07-13 04:45:46 -0700697 {
698 Parcel data, reply;
699 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
700 data.writeInt32(session);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800701 data.writeInt32((int32_t) srcOutput);
702 data.writeInt32((int32_t) dstOutput);
Eric Laurentde070132010-07-13 04:45:46 -0700703 remote()->transact(MOVE_EFFECTS, data, &reply);
704 return reply.readInt32();
705 }
Eric Laurenta4c5a552012-03-29 10:12:40 -0700706
707 virtual audio_module_handle_t loadHwModule(const char *name)
708 {
709 Parcel data, reply;
710 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
711 data.writeCString(name);
712 remote()->transact(LOAD_HW_MODULE, data, &reply);
713 return (audio_module_handle_t) reply.readInt32();
714 }
Glenn Kastencc0f1cf2012-09-24 11:27:18 -0700715
Glenn Kasten3b16c762012-11-14 08:44:39 -0800716 virtual uint32_t getPrimaryOutputSamplingRate()
Glenn Kastencc0f1cf2012-09-24 11:27:18 -0700717 {
718 Parcel data, reply;
719 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
720 remote()->transact(GET_PRIMARY_OUTPUT_SAMPLING_RATE, data, &reply);
721 return reply.readInt32();
722 }
723
Glenn Kastene33054e2012-11-14 12:54:39 -0800724 virtual size_t getPrimaryOutputFrameCount()
Glenn Kastencc0f1cf2012-09-24 11:27:18 -0700725 {
726 Parcel data, reply;
727 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
728 remote()->transact(GET_PRIMARY_OUTPUT_FRAME_COUNT, data, &reply);
Glenn Kastene03dd222014-01-28 11:04:39 -0800729 return reply.readInt64();
Glenn Kastencc0f1cf2012-09-24 11:27:18 -0700730 }
731
Glenn Kasten4182c4e2013-07-15 14:45:07 -0700732 virtual status_t setLowRamDevice(bool isLowRamDevice)
733 {
734 Parcel data, reply;
735 data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
736 data.writeInt32((int) isLowRamDevice);
737 remote()->transact(SET_LOW_RAM_DEVICE, data, &reply);
738 return reply.readInt32();
739 }
740
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800741};
742
743IMPLEMENT_META_INTERFACE(AudioFlinger, "android.media.IAudioFlinger");
744
745// ----------------------------------------------------------------------
746
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800747status_t BnAudioFlinger::onTransact(
748 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
749{
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700750 switch (code) {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800751 case CREATE_TRACK: {
752 CHECK_INTERFACE(IAudioFlinger, data, reply);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800753 int streamType = data.readInt32();
754 uint32_t sampleRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -0800755 audio_format_t format = (audio_format_t) data.readInt32();
Glenn Kastendd8104c2012-07-02 12:42:44 -0700756 audio_channel_mask_t channelMask = data.readInt32();
Glenn Kastene03dd222014-01-28 11:04:39 -0800757 size_t frameCount = data.readInt64();
Glenn Kastena075db42012-03-06 11:22:44 -0800758 track_flags_t flags = (track_flags_t) data.readInt32();
Eric Laurent3d00aa62013-09-24 09:53:27 -0700759 bool haveSharedBuffer = data.readInt32() != 0;
760 sp<IMemory> buffer;
761 if (haveSharedBuffer) {
762 buffer = interface_cast<IMemory>(data.readStrongBinder());
763 }
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800764 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Glenn Kasten3acbd052012-02-28 10:39:56 -0800765 pid_t tid = (pid_t) data.readInt32();
Eric Laurentbe916aa2010-06-01 23:49:17 -0700766 int sessionId = data.readInt32();
Marco Nelissen9cae2172013-01-14 14:12:05 -0800767 int clientUid = data.readInt32();
Glenn Kastend054c322013-07-12 12:59:20 -0700768 String8 name;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800769 status_t status;
Eric Laurent3d00aa62013-09-24 09:53:27 -0700770 sp<IAudioTrack> track;
771 if ((haveSharedBuffer && (buffer == 0)) ||
772 ((buffer != 0) && (buffer->pointer() == NULL))) {
773 ALOGW("CREATE_TRACK: cannot retrieve shared memory");
774 status = DEAD_OBJECT;
775 } else {
776 track = createTrack(
777 (audio_stream_type_t) streamType, sampleRate, format,
778 channelMask, frameCount, &flags, buffer, output, tid,
Marco Nelissen9cae2172013-01-14 14:12:05 -0800779 &sessionId, name, clientUid, &status);
Eric Laurent3d00aa62013-09-24 09:53:27 -0700780 }
Glenn Kastene0b07172012-11-06 15:03:34 -0800781 reply->writeInt32(flags);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700782 reply->writeInt32(sessionId);
Glenn Kastend054c322013-07-12 12:59:20 -0700783 reply->writeString8(name);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800784 reply->writeInt32(status);
785 reply->writeStrongBinder(track->asBinder());
786 return NO_ERROR;
787 } break;
788 case OPEN_RECORD: {
789 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800790 audio_io_handle_t input = (audio_io_handle_t) data.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800791 uint32_t sampleRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -0800792 audio_format_t format = (audio_format_t) data.readInt32();
Glenn Kastendd8104c2012-07-02 12:42:44 -0700793 audio_channel_mask_t channelMask = data.readInt32();
Glenn Kastene03dd222014-01-28 11:04:39 -0800794 size_t frameCount = data.readInt64();
Glenn Kastena075db42012-03-06 11:22:44 -0800795 track_flags_t flags = (track_flags_t) data.readInt32();
Glenn Kasten1879fff2012-07-11 15:36:59 -0700796 pid_t tid = (pid_t) data.readInt32();
Eric Laurentbe916aa2010-06-01 23:49:17 -0700797 int sessionId = data.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800798 status_t status;
Glenn Kasten8d6cc842012-02-03 11:06:53 -0800799 sp<IAudioRecord> record = openRecord(input,
Glenn Kasteneeca3262013-07-31 16:12:48 -0700800 sampleRate, format, channelMask, frameCount, &flags, tid, &sessionId, &status);
Glenn Kastene93cf2c2013-09-24 11:52:37 -0700801 LOG_ALWAYS_FATAL_IF((record != 0) != (status == NO_ERROR));
Glenn Kasteneeca3262013-07-31 16:12:48 -0700802 reply->writeInt32(flags);
Eric Laurentbe916aa2010-06-01 23:49:17 -0700803 reply->writeInt32(sessionId);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800804 reply->writeInt32(status);
805 reply->writeStrongBinder(record->asBinder());
806 return NO_ERROR;
807 } break;
808 case SAMPLE_RATE: {
809 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800810 reply->writeInt32( sampleRate((audio_io_handle_t) data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800811 return NO_ERROR;
812 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800813 case FORMAT: {
814 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800815 reply->writeInt32( format((audio_io_handle_t) data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800816 return NO_ERROR;
817 } break;
818 case FRAME_COUNT: {
819 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kastene03dd222014-01-28 11:04:39 -0800820 reply->writeInt64( frameCount((audio_io_handle_t) data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800821 return NO_ERROR;
822 } break;
823 case LATENCY: {
824 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800825 reply->writeInt32( latency((audio_io_handle_t) data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800826 return NO_ERROR;
827 } break;
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700828 case SET_MASTER_VOLUME: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800829 CHECK_INTERFACE(IAudioFlinger, data, reply);
830 reply->writeInt32( setMasterVolume(data.readFloat()) );
831 return NO_ERROR;
832 } break;
833 case SET_MASTER_MUTE: {
834 CHECK_INTERFACE(IAudioFlinger, data, reply);
835 reply->writeInt32( setMasterMute(data.readInt32()) );
836 return NO_ERROR;
837 } break;
838 case MASTER_VOLUME: {
839 CHECK_INTERFACE(IAudioFlinger, data, reply);
840 reply->writeFloat( masterVolume() );
841 return NO_ERROR;
842 } break;
843 case MASTER_MUTE: {
844 CHECK_INTERFACE(IAudioFlinger, data, reply);
845 reply->writeInt32( masterMute() );
846 return NO_ERROR;
847 } break;
848 case SET_STREAM_VOLUME: {
849 CHECK_INTERFACE(IAudioFlinger, data, reply);
850 int stream = data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700851 float volume = data.readFloat();
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800852 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -0800853 reply->writeInt32( setStreamVolume((audio_stream_type_t) stream, volume, output) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800854 return NO_ERROR;
855 } break;
856 case SET_STREAM_MUTE: {
857 CHECK_INTERFACE(IAudioFlinger, data, reply);
858 int stream = data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -0800859 reply->writeInt32( setStreamMute((audio_stream_type_t) stream, data.readInt32()) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800860 return NO_ERROR;
861 } break;
862 case STREAM_VOLUME: {
863 CHECK_INTERFACE(IAudioFlinger, data, reply);
864 int stream = data.readInt32();
Eric Laurentfa2877b2009-07-28 08:44:33 -0700865 int output = data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -0800866 reply->writeFloat( streamVolume((audio_stream_type_t) stream, output) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800867 return NO_ERROR;
868 } break;
869 case STREAM_MUTE: {
870 CHECK_INTERFACE(IAudioFlinger, data, reply);
871 int stream = data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -0800872 reply->writeInt32( streamMute((audio_stream_type_t) stream) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800873 return NO_ERROR;
874 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800875 case SET_MODE: {
876 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kastenf78aee72012-01-04 11:00:47 -0800877 audio_mode_t mode = (audio_mode_t) data.readInt32();
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800878 reply->writeInt32( setMode(mode) );
879 return NO_ERROR;
880 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800881 case SET_MIC_MUTE: {
882 CHECK_INTERFACE(IAudioFlinger, data, reply);
883 int state = data.readInt32();
884 reply->writeInt32( setMicMute(state) );
885 return NO_ERROR;
886 } break;
887 case GET_MIC_MUTE: {
888 CHECK_INTERFACE(IAudioFlinger, data, reply);
889 reply->writeInt32( getMicMute() );
890 return NO_ERROR;
891 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700892 case SET_PARAMETERS: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800893 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800894 audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700895 String8 keyValuePairs(data.readString8());
896 reply->writeInt32(setParameters(ioHandle, keyValuePairs));
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800897 return NO_ERROR;
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700898 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700899 case GET_PARAMETERS: {
900 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800901 audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700902 String8 keys(data.readString8());
903 reply->writeString8(getParameters(ioHandle, keys));
904 return NO_ERROR;
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700905 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700906
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800907 case REGISTER_CLIENT: {
908 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten85ab62c2012-11-01 11:11:38 -0700909 sp<IAudioFlingerClient> client = interface_cast<IAudioFlingerClient>(
910 data.readStrongBinder());
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800911 registerClient(client);
912 return NO_ERROR;
913 } break;
914 case GET_INPUTBUFFERSIZE: {
915 CHECK_INTERFACE(IAudioFlinger, data, reply);
916 uint32_t sampleRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -0800917 audio_format_t format = (audio_format_t) data.readInt32();
Glenn Kastendd8104c2012-07-02 12:42:44 -0700918 audio_channel_mask_t channelMask = data.readInt32();
Glenn Kastene03dd222014-01-28 11:04:39 -0800919 reply->writeInt64( getInputBufferSize(sampleRate, format, channelMask) );
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800920 return NO_ERROR;
921 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700922 case OPEN_OUTPUT: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800923 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurenta4c5a552012-03-29 10:12:40 -0700924 audio_module_handle_t module = (audio_module_handle_t)data.readInt32();
925 audio_devices_t devices = (audio_devices_t)data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700926 uint32_t samplingRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -0800927 audio_format_t format = (audio_format_t) data.readInt32();
Eric Laurenta4c5a552012-03-29 10:12:40 -0700928 audio_channel_mask_t channelMask = (audio_channel_mask_t)data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700929 uint32_t latency = data.readInt32();
Eric Laurent0ca3cf92012-04-18 09:24:29 -0700930 audio_output_flags_t flags = (audio_output_flags_t) data.readInt32();
Richard Fitzgeraldb1a270d2013-05-14 12:12:21 +0100931 bool hasOffloadInfo = data.readInt32() != 0;
932 audio_offload_info_t offloadInfo;
933 if (hasOffloadInfo) {
934 data.read(&offloadInfo, sizeof(audio_offload_info_t));
935 }
Eric Laurenta4c5a552012-03-29 10:12:40 -0700936 audio_io_handle_t output = openOutput(module,
937 &devices,
938 &samplingRate,
939 &format,
940 &channelMask,
941 &latency,
Richard Fitzgeraldb1a270d2013-05-14 12:12:21 +0100942 flags,
943 hasOffloadInfo ? &offloadInfo : NULL);
Steve Block3856b092011-10-20 11:56:00 +0100944 ALOGV("OPEN_OUTPUT output, %p", output);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800945 reply->writeInt32((int32_t) output);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700946 reply->writeInt32(devices);
947 reply->writeInt32(samplingRate);
948 reply->writeInt32(format);
Eric Laurenta4c5a552012-03-29 10:12:40 -0700949 reply->writeInt32(channelMask);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700950 reply->writeInt32(latency);
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800951 return NO_ERROR;
952 } break;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700953 case OPEN_DUPLICATE_OUTPUT: {
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800954 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800955 audio_io_handle_t output1 = (audio_io_handle_t) data.readInt32();
956 audio_io_handle_t output2 = (audio_io_handle_t) data.readInt32();
957 reply->writeInt32((int32_t) openDuplicateOutput(output1, output2));
Eric Laurentc2f1f072009-07-17 12:17:14 -0700958 return NO_ERROR;
959 } break;
960 case CLOSE_OUTPUT: {
961 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800962 reply->writeInt32(closeOutput((audio_io_handle_t) data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -0700963 return NO_ERROR;
964 } break;
965 case SUSPEND_OUTPUT: {
966 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800967 reply->writeInt32(suspendOutput((audio_io_handle_t) data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -0700968 return NO_ERROR;
969 } break;
970 case RESTORE_OUTPUT: {
971 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800972 reply->writeInt32(restoreOutput((audio_io_handle_t) data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -0700973 return NO_ERROR;
974 } break;
975 case OPEN_INPUT: {
976 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurenta4c5a552012-03-29 10:12:40 -0700977 audio_module_handle_t module = (audio_module_handle_t)data.readInt32();
978 audio_devices_t devices = (audio_devices_t)data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700979 uint32_t samplingRate = data.readInt32();
Glenn Kasten58f30212012-01-12 12:27:51 -0800980 audio_format_t format = (audio_format_t) data.readInt32();
Eric Laurenta4c5a552012-03-29 10:12:40 -0700981 audio_channel_mask_t channelMask = (audio_channel_mask_t)data.readInt32();
Eric Laurentc2f1f072009-07-17 12:17:14 -0700982
Eric Laurenta4c5a552012-03-29 10:12:40 -0700983 audio_io_handle_t input = openInput(module,
984 &devices,
985 &samplingRate,
986 &format,
987 &channelMask);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800988 reply->writeInt32((int32_t) input);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700989 reply->writeInt32(devices);
990 reply->writeInt32(samplingRate);
991 reply->writeInt32(format);
Eric Laurenta4c5a552012-03-29 10:12:40 -0700992 reply->writeInt32(channelMask);
Eric Laurentc2f1f072009-07-17 12:17:14 -0700993 return NO_ERROR;
994 } break;
995 case CLOSE_INPUT: {
996 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800997 reply->writeInt32(closeInput((audio_io_handle_t) data.readInt32()));
Eric Laurentc2f1f072009-07-17 12:17:14 -0700998 return NO_ERROR;
999 } break;
1000 case SET_STREAM_OUTPUT: {
1001 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurentc2f1f072009-07-17 12:17:14 -07001002 uint32_t stream = data.readInt32();
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001003 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Glenn Kastenfff6d712012-01-12 16:38:12 -08001004 reply->writeInt32(setStreamOutput((audio_stream_type_t) stream, output));
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001005 return NO_ERROR;
1006 } break;
Eric Laurentf0ee6f42009-10-21 08:14:22 -07001007 case SET_VOICE_VOLUME: {
1008 CHECK_INTERFACE(IAudioFlinger, data, reply);
1009 float volume = data.readFloat();
1010 reply->writeInt32( setVoiceVolume(volume) );
1011 return NO_ERROR;
1012 } break;
Eric Laurent342e9cf2010-01-19 17:37:09 -08001013 case GET_RENDER_POSITION: {
1014 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001015 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Kévin PETIT377b2ec2014-02-03 12:35:36 +00001016 uint32_t halFrames;
1017 uint32_t dspFrames;
Eric Laurent342e9cf2010-01-19 17:37:09 -08001018 status_t status = getRenderPosition(&halFrames, &dspFrames, output);
1019 reply->writeInt32(status);
1020 if (status == NO_ERROR) {
1021 reply->writeInt32(halFrames);
1022 reply->writeInt32(dspFrames);
1023 }
1024 return NO_ERROR;
1025 }
Eric Laurent05bca2f2010-02-26 02:47:27 -08001026 case GET_INPUT_FRAMES_LOST: {
1027 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001028 audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
Eric Laurent05bca2f2010-02-26 02:47:27 -08001029 reply->writeInt32(getInputFramesLost(ioHandle));
1030 return NO_ERROR;
1031 } break;
Eric Laurentbe916aa2010-06-01 23:49:17 -07001032 case NEW_AUDIO_SESSION_ID: {
1033 CHECK_INTERFACE(IAudioFlinger, data, reply);
1034 reply->writeInt32(newAudioSessionId());
1035 return NO_ERROR;
1036 } break;
Marco Nelissen3a34bef2011-08-02 13:33:41 -07001037 case ACQUIRE_AUDIO_SESSION_ID: {
1038 CHECK_INTERFACE(IAudioFlinger, data, reply);
1039 int audioSession = data.readInt32();
1040 acquireAudioSessionId(audioSession);
1041 return NO_ERROR;
1042 } break;
1043 case RELEASE_AUDIO_SESSION_ID: {
1044 CHECK_INTERFACE(IAudioFlinger, data, reply);
1045 int audioSession = data.readInt32();
1046 releaseAudioSessionId(audioSession);
1047 return NO_ERROR;
1048 } break;
Eric Laurentbe916aa2010-06-01 23:49:17 -07001049 case QUERY_NUM_EFFECTS: {
1050 CHECK_INTERFACE(IAudioFlinger, data, reply);
1051 uint32_t numEffects;
1052 status_t status = queryNumberEffects(&numEffects);
1053 reply->writeInt32(status);
1054 if (status == NO_ERROR) {
1055 reply->writeInt32((int32_t)numEffects);
1056 }
1057 return NO_ERROR;
1058 }
Eric Laurentffe9c252010-06-23 17:38:20 -07001059 case QUERY_EFFECT: {
Eric Laurentbe916aa2010-06-01 23:49:17 -07001060 CHECK_INTERFACE(IAudioFlinger, data, reply);
1061 effect_descriptor_t desc;
Eric Laurentffe9c252010-06-23 17:38:20 -07001062 status_t status = queryEffect(data.readInt32(), &desc);
Eric Laurentbe916aa2010-06-01 23:49:17 -07001063 reply->writeInt32(status);
1064 if (status == NO_ERROR) {
1065 reply->write(&desc, sizeof(effect_descriptor_t));
1066 }
1067 return NO_ERROR;
1068 }
1069 case GET_EFFECT_DESCRIPTOR: {
1070 CHECK_INTERFACE(IAudioFlinger, data, reply);
1071 effect_uuid_t uuid;
1072 data.read(&uuid, sizeof(effect_uuid_t));
1073 effect_descriptor_t desc;
1074 status_t status = getEffectDescriptor(&uuid, &desc);
1075 reply->writeInt32(status);
1076 if (status == NO_ERROR) {
1077 reply->write(&desc, sizeof(effect_descriptor_t));
1078 }
1079 return NO_ERROR;
1080 }
1081 case CREATE_EFFECT: {
1082 CHECK_INTERFACE(IAudioFlinger, data, reply);
Eric Laurentbe916aa2010-06-01 23:49:17 -07001083 effect_descriptor_t desc;
1084 data.read(&desc, sizeof(effect_descriptor_t));
1085 sp<IEffectClient> client = interface_cast<IEffectClient>(data.readStrongBinder());
1086 int32_t priority = data.readInt32();
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001087 audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
Eric Laurentbe916aa2010-06-01 23:49:17 -07001088 int sessionId = data.readInt32();
1089 status_t status;
1090 int id;
1091 int enabled;
Eric Laurent05bca2f2010-02-26 02:47:27 -08001092
Glenn Kasten8d6cc842012-02-03 11:06:53 -08001093 sp<IEffect> effect = createEffect(&desc, client, priority, output, sessionId,
Glenn Kasten85ab62c2012-11-01 11:11:38 -07001094 &status, &id, &enabled);
Eric Laurentbe916aa2010-06-01 23:49:17 -07001095 reply->writeInt32(status);
1096 reply->writeInt32(id);
1097 reply->writeInt32(enabled);
1098 reply->writeStrongBinder(effect->asBinder());
1099 reply->write(&desc, sizeof(effect_descriptor_t));
1100 return NO_ERROR;
1101 } break;
Eric Laurentde070132010-07-13 04:45:46 -07001102 case MOVE_EFFECTS: {
1103 CHECK_INTERFACE(IAudioFlinger, data, reply);
1104 int session = data.readInt32();
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001105 audio_io_handle_t srcOutput = (audio_io_handle_t) data.readInt32();
1106 audio_io_handle_t dstOutput = (audio_io_handle_t) data.readInt32();
Eric Laurentde070132010-07-13 04:45:46 -07001107 reply->writeInt32(moveEffects(session, srcOutput, dstOutput));
1108 return NO_ERROR;
1109 } break;
Eric Laurenta4c5a552012-03-29 10:12:40 -07001110 case LOAD_HW_MODULE: {
1111 CHECK_INTERFACE(IAudioFlinger, data, reply);
1112 reply->writeInt32(loadHwModule(data.readCString()));
1113 return NO_ERROR;
1114 } break;
Glenn Kastencc0f1cf2012-09-24 11:27:18 -07001115 case GET_PRIMARY_OUTPUT_SAMPLING_RATE: {
1116 CHECK_INTERFACE(IAudioFlinger, data, reply);
1117 reply->writeInt32(getPrimaryOutputSamplingRate());
1118 return NO_ERROR;
1119 } break;
1120 case GET_PRIMARY_OUTPUT_FRAME_COUNT: {
1121 CHECK_INTERFACE(IAudioFlinger, data, reply);
Glenn Kastene03dd222014-01-28 11:04:39 -08001122 reply->writeInt64(getPrimaryOutputFrameCount());
Glenn Kastencc0f1cf2012-09-24 11:27:18 -07001123 return NO_ERROR;
1124 } break;
Glenn Kasten4182c4e2013-07-15 14:45:07 -07001125 case SET_LOW_RAM_DEVICE: {
1126 CHECK_INTERFACE(IAudioFlinger, data, reply);
1127 bool isLowRamDevice = data.readInt32() != 0;
1128 reply->writeInt32(setLowRamDevice(isLowRamDevice));
1129 return NO_ERROR;
1130 } break;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001131 default:
1132 return BBinder::onTransact(code, data, reply, flags);
1133 }
1134}
1135
1136// ----------------------------------------------------------------------------
1137
1138}; // namespace android