blob: 612ce7a188ab6145a3967d0bcf1e4facf8ff4efa [file] [log] [blame]
Nicolas Rouletdcdfaec2017-02-14 10:18:39 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_IAUDIOFLINGER_H
18#define ANDROID_IAUDIOFLINGER_H
19
20#include <stdint.h>
21#include <sys/types.h>
22#include <unistd.h>
23
24#include <utils/RefBase.h>
25#include <utils/Errors.h>
26#include <binder/IInterface.h>
Eric Laurent21da6472017-11-09 16:29:26 -080027#include <binder/Parcel.h>
Eric Laurentf14db3c2017-12-08 14:20:36 -080028#include <binder/Parcelable.h>
Eric Laurent21da6472017-11-09 16:29:26 -080029#include <media/AudioClient.h>
jiabin43810402019-10-24 14:58:31 -070030#include <media/DeviceDescriptorBase.h>
Nicolas Rouletdcdfaec2017-02-14 10:18:39 -080031#include <media/IAudioTrack.h>
Nicolas Rouletdcdfaec2017-02-14 10:18:39 -080032#include <media/IAudioFlingerClient.h>
33#include <system/audio.h>
34#include <system/audio_effect.h>
35#include <system/audio_policy.h>
36#include <media/IEffect.h>
37#include <media/IEffectClient.h>
38#include <utils/String8.h>
jiabin46a76fa2018-01-05 10:18:21 -080039#include <media/MicrophoneInfo.h>
40#include <vector>
Nicolas Rouletdcdfaec2017-02-14 10:18:39 -080041
Ivan Lozanoff6900d2017-08-01 15:47:38 -070042#include "android/media/IAudioRecord.h"
jiabinf6eb4c32020-02-25 14:06:25 -080043#include "android/media/IAudioTrackCallback.h"
Ivan Lozanoff6900d2017-08-01 15:47:38 -070044
Nicolas Rouletdcdfaec2017-02-14 10:18:39 -080045namespace android {
46
47// ----------------------------------------------------------------------------
48
49class IAudioFlinger : public IInterface
50{
51public:
52 DECLARE_META_INTERFACE(AudioFlinger);
53
Eric Laurent21da6472017-11-09 16:29:26 -080054 /* CreateTrackInput contains all input arguments sent by AudioTrack to AudioFlinger
55 * when calling createTrack() including arguments that will be updated by AudioFlinger
56 * and returned in CreateTrackOutput object
57 */
Eric Laurentf14db3c2017-12-08 14:20:36 -080058 class CreateTrackInput : public Parcelable {
Eric Laurent21da6472017-11-09 16:29:26 -080059 public:
Eric Laurentf14db3c2017-12-08 14:20:36 -080060 status_t readFromParcel(const Parcel *parcel) override {
Eric Laurent21da6472017-11-09 16:29:26 -080061 /* input arguments*/
62 memset(&attr, 0, sizeof(audio_attributes_t));
63 if (parcel->read(&attr, sizeof(audio_attributes_t)) != NO_ERROR) {
64 return DEAD_OBJECT;
65 }
66 attr.tags[AUDIO_ATTRIBUTES_TAGS_MAX_SIZE -1] = '\0';
67 memset(&config, 0, sizeof(audio_config_t));
68 if (parcel->read(&config, sizeof(audio_config_t)) != NO_ERROR) {
69 return DEAD_OBJECT;
70 }
Eric Laurentf14db3c2017-12-08 14:20:36 -080071 if (clientInfo.readFromParcel(parcel) != NO_ERROR) {
72 return DEAD_OBJECT;
73 }
Eric Laurent21da6472017-11-09 16:29:26 -080074 if (parcel->readInt32() != 0) {
Ytai Ben-Tsvi7dd39722019-09-05 15:14:30 -070075 // TODO: Using unsecurePointer() has some associated security
76 // pitfalls (see declaration for details).
77 // Either document why it is safe in this case or address
78 // the issue (e.g. by copying).
Eric Laurent21da6472017-11-09 16:29:26 -080079 sharedBuffer = interface_cast<IMemory>(parcel->readStrongBinder());
Ytai Ben-Tsvi7dd39722019-09-05 15:14:30 -070080 if (sharedBuffer == 0 || sharedBuffer->unsecurePointer() == NULL) {
Eric Laurent21da6472017-11-09 16:29:26 -080081 return BAD_VALUE;
82 }
83 }
84 notificationsPerBuffer = parcel->readInt32();
85 speed = parcel->readFloat();
jiabinf6eb4c32020-02-25 14:06:25 -080086 audioTrackCallback = interface_cast<media::IAudioTrackCallback>(
87 parcel->readStrongBinder());
Eric Laurent21da6472017-11-09 16:29:26 -080088
89 /* input/output arguments*/
90 (void)parcel->read(&flags, sizeof(audio_output_flags_t));
91 frameCount = parcel->readInt64();
92 notificationFrameCount = parcel->readInt64();
93 (void)parcel->read(&selectedDeviceId, sizeof(audio_port_handle_t));
94 (void)parcel->read(&sessionId, sizeof(audio_session_t));
95 return NO_ERROR;
96 }
97
Eric Laurentf14db3c2017-12-08 14:20:36 -080098 status_t writeToParcel(Parcel *parcel) const override {
Eric Laurent21da6472017-11-09 16:29:26 -080099 /* input arguments*/
100 (void)parcel->write(&attr, sizeof(audio_attributes_t));
101 (void)parcel->write(&config, sizeof(audio_config_t));
102 (void)clientInfo.writeToParcel(parcel);
103 if (sharedBuffer != 0) {
104 (void)parcel->writeInt32(1);
105 (void)parcel->writeStrongBinder(IInterface::asBinder(sharedBuffer));
106 } else {
107 (void)parcel->writeInt32(0);
108 }
109 (void)parcel->writeInt32(notificationsPerBuffer);
110 (void)parcel->writeFloat(speed);
jiabinf6eb4c32020-02-25 14:06:25 -0800111 (void)parcel->writeStrongBinder(IInterface::asBinder(audioTrackCallback));
Eric Laurent21da6472017-11-09 16:29:26 -0800112
113 /* input/output arguments*/
114 (void)parcel->write(&flags, sizeof(audio_output_flags_t));
115 (void)parcel->writeInt64(frameCount);
116 (void)parcel->writeInt64(notificationFrameCount);
117 (void)parcel->write(&selectedDeviceId, sizeof(audio_port_handle_t));
118 (void)parcel->write(&sessionId, sizeof(audio_session_t));
119 return NO_ERROR;
120 }
121
122 /* input */
123 audio_attributes_t attr;
124 audio_config_t config;
125 AudioClient clientInfo;
126 sp<IMemory> sharedBuffer;
127 uint32_t notificationsPerBuffer;
128 float speed;
jiabinf6eb4c32020-02-25 14:06:25 -0800129 sp<media::IAudioTrackCallback> audioTrackCallback;
Eric Laurent21da6472017-11-09 16:29:26 -0800130
131 /* input/output */
132 audio_output_flags_t flags;
133 size_t frameCount;
134 size_t notificationFrameCount;
135 audio_port_handle_t selectedDeviceId;
136 audio_session_t sessionId;
137 };
138
139 /* CreateTrackOutput contains all output arguments returned by AudioFlinger to AudioTrack
140 * when calling createTrack() including arguments that were passed as I/O for update by
141 * CreateTrackInput.
142 */
Eric Laurentf14db3c2017-12-08 14:20:36 -0800143 class CreateTrackOutput : public Parcelable {
Eric Laurent21da6472017-11-09 16:29:26 -0800144 public:
Eric Laurentf14db3c2017-12-08 14:20:36 -0800145 status_t readFromParcel(const Parcel *parcel) override {
Eric Laurent21da6472017-11-09 16:29:26 -0800146 /* input/output arguments*/
147 (void)parcel->read(&flags, sizeof(audio_output_flags_t));
148 frameCount = parcel->readInt64();
149 notificationFrameCount = parcel->readInt64();
150 (void)parcel->read(&selectedDeviceId, sizeof(audio_port_handle_t));
151 (void)parcel->read(&sessionId, sizeof(audio_session_t));
152
153 /* output arguments*/
154 sampleRate = parcel->readUint32();
155 afFrameCount = parcel->readInt64();
156 afSampleRate = parcel->readInt64();
157 afLatencyMs = parcel->readInt32();
158 (void)parcel->read(&outputId, sizeof(audio_io_handle_t));
Eric Laurent973db022018-11-20 14:54:31 -0800159 (void)parcel->read(&portId, sizeof(audio_port_handle_t));
Eric Laurent21da6472017-11-09 16:29:26 -0800160 return NO_ERROR;
161 }
162
Eric Laurentf14db3c2017-12-08 14:20:36 -0800163 status_t writeToParcel(Parcel *parcel) const override {
Eric Laurent21da6472017-11-09 16:29:26 -0800164 /* input/output arguments*/
165 (void)parcel->write(&flags, sizeof(audio_output_flags_t));
166 (void)parcel->writeInt64(frameCount);
167 (void)parcel->writeInt64(notificationFrameCount);
168 (void)parcel->write(&selectedDeviceId, sizeof(audio_port_handle_t));
169 (void)parcel->write(&sessionId, sizeof(audio_session_t));
170
171 /* output arguments*/
172 (void)parcel->writeUint32(sampleRate);
173 (void)parcel->writeInt64(afFrameCount);
174 (void)parcel->writeInt64(afSampleRate);
175 (void)parcel->writeInt32(afLatencyMs);
176 (void)parcel->write(&outputId, sizeof(audio_io_handle_t));
Eric Laurent973db022018-11-20 14:54:31 -0800177 (void)parcel->write(&portId, sizeof(audio_port_handle_t));
Eric Laurent21da6472017-11-09 16:29:26 -0800178 return NO_ERROR;
179 }
180
181 /* input/output */
182 audio_output_flags_t flags;
183 size_t frameCount;
184 size_t notificationFrameCount;
185 audio_port_handle_t selectedDeviceId;
186 audio_session_t sessionId;
187
188 /* output */
189 uint32_t sampleRate;
190 size_t afFrameCount;
191 uint32_t afSampleRate;
192 uint32_t afLatencyMs;
193 audio_io_handle_t outputId;
Eric Laurent973db022018-11-20 14:54:31 -0800194 audio_port_handle_t portId;
Eric Laurent21da6472017-11-09 16:29:26 -0800195 };
Nicolas Rouletdcdfaec2017-02-14 10:18:39 -0800196
Eric Laurentf14db3c2017-12-08 14:20:36 -0800197 /* CreateRecordInput contains all input arguments sent by AudioRecord to AudioFlinger
198 * when calling createRecord() including arguments that will be updated by AudioFlinger
199 * and returned in CreateRecordOutput object
200 */
201 class CreateRecordInput : public Parcelable {
202 public:
203 status_t readFromParcel(const Parcel *parcel) override {
204 /* input arguments*/
205 memset(&attr, 0, sizeof(audio_attributes_t));
206 if (parcel->read(&attr, sizeof(audio_attributes_t)) != NO_ERROR) {
207 return DEAD_OBJECT;
208 }
209 attr.tags[AUDIO_ATTRIBUTES_TAGS_MAX_SIZE -1] = '\0';
210 memset(&config, 0, sizeof(audio_config_base_t));
211 if (parcel->read(&config, sizeof(audio_config_base_t)) != NO_ERROR) {
212 return DEAD_OBJECT;
213 }
214 if (clientInfo.readFromParcel(parcel) != NO_ERROR) {
215 return DEAD_OBJECT;
216 }
217 opPackageName = parcel->readString16();
Mikhail Naganov2996f672019-04-18 12:29:59 -0700218 if (parcel->read(&riid, sizeof(audio_unique_id_t)) != NO_ERROR) {
219 return DEAD_OBJECT;
220 }
Eric Laurentf14db3c2017-12-08 14:20:36 -0800221
222 /* input/output arguments*/
223 (void)parcel->read(&flags, sizeof(audio_input_flags_t));
224 frameCount = parcel->readInt64();
225 notificationFrameCount = parcel->readInt64();
226 (void)parcel->read(&selectedDeviceId, sizeof(audio_port_handle_t));
227 (void)parcel->read(&sessionId, sizeof(audio_session_t));
228 return NO_ERROR;
229 }
230
231 status_t writeToParcel(Parcel *parcel) const override {
232 /* input arguments*/
233 (void)parcel->write(&attr, sizeof(audio_attributes_t));
234 (void)parcel->write(&config, sizeof(audio_config_base_t));
235 (void)clientInfo.writeToParcel(parcel);
236 (void)parcel->writeString16(opPackageName);
Mikhail Naganov2996f672019-04-18 12:29:59 -0700237 (void)parcel->write(&riid, sizeof(audio_unique_id_t));
Eric Laurentf14db3c2017-12-08 14:20:36 -0800238
239 /* input/output arguments*/
240 (void)parcel->write(&flags, sizeof(audio_input_flags_t));
241 (void)parcel->writeInt64(frameCount);
242 (void)parcel->writeInt64(notificationFrameCount);
243 (void)parcel->write(&selectedDeviceId, sizeof(audio_port_handle_t));
244 (void)parcel->write(&sessionId, sizeof(audio_session_t));
245 return NO_ERROR;
246 }
247
248 /* input */
249 audio_attributes_t attr;
250 audio_config_base_t config;
251 AudioClient clientInfo;
252 String16 opPackageName;
Mikhail Naganov2996f672019-04-18 12:29:59 -0700253 audio_unique_id_t riid;
Eric Laurentf14db3c2017-12-08 14:20:36 -0800254
255 /* input/output */
256 audio_input_flags_t flags;
257 size_t frameCount;
258 size_t notificationFrameCount;
259 audio_port_handle_t selectedDeviceId;
260 audio_session_t sessionId;
261 };
262
263 /* CreateRecordOutput contains all output arguments returned by AudioFlinger to AudioRecord
264 * when calling createRecord() including arguments that were passed as I/O for update by
265 * CreateRecordInput.
266 */
267 class CreateRecordOutput : public Parcelable {
268 public:
269 status_t readFromParcel(const Parcel *parcel) override {
270 /* input/output arguments*/
271 (void)parcel->read(&flags, sizeof(audio_input_flags_t));
272 frameCount = parcel->readInt64();
273 notificationFrameCount = parcel->readInt64();
274 (void)parcel->read(&selectedDeviceId, sizeof(audio_port_handle_t));
275 (void)parcel->read(&sessionId, sizeof(audio_session_t));
276
277 /* output arguments*/
278 sampleRate = parcel->readUint32();
279 (void)parcel->read(&inputId, sizeof(audio_io_handle_t));
280 if (parcel->readInt32() != 0) {
281 cblk = interface_cast<IMemory>(parcel->readStrongBinder());
Ytai Ben-Tsvi7dd39722019-09-05 15:14:30 -0700282 // TODO: Using unsecurePointer() has some associated security
283 // pitfalls (see declaration for details).
284 // Either document why it is safe in this case or address
285 // the issue (e.g. by copying).
286 if (cblk == 0 || cblk->unsecurePointer() == NULL) {
Eric Laurentf14db3c2017-12-08 14:20:36 -0800287 return BAD_VALUE;
288 }
289 }
290 if (parcel->readInt32() != 0) {
291 buffers = interface_cast<IMemory>(parcel->readStrongBinder());
Ytai Ben-Tsvi7dd39722019-09-05 15:14:30 -0700292 // TODO: Using unsecurePointer() has some associated security
293 // pitfalls (see declaration for details).
294 // Either document why it is safe in this case or address
295 // the issue (e.g. by copying).
296 if (buffers == 0 || buffers->unsecurePointer() == NULL) {
Eric Laurentf14db3c2017-12-08 14:20:36 -0800297 return BAD_VALUE;
298 }
299 }
Eric Laurent973db022018-11-20 14:54:31 -0800300 (void)parcel->read(&portId, sizeof(audio_port_handle_t));
Eric Laurentf14db3c2017-12-08 14:20:36 -0800301 return NO_ERROR;
302 }
303
304 status_t writeToParcel(Parcel *parcel) const override {
305 /* input/output arguments*/
306 (void)parcel->write(&flags, sizeof(audio_input_flags_t));
307 (void)parcel->writeInt64(frameCount);
308 (void)parcel->writeInt64(notificationFrameCount);
309 (void)parcel->write(&selectedDeviceId, sizeof(audio_port_handle_t));
310 (void)parcel->write(&sessionId, sizeof(audio_session_t));
311
312 /* output arguments*/
313 (void)parcel->writeUint32(sampleRate);
314 (void)parcel->write(&inputId, sizeof(audio_io_handle_t));
315 if (cblk != 0) {
316 (void)parcel->writeInt32(1);
317 (void)parcel->writeStrongBinder(IInterface::asBinder(cblk));
318 } else {
319 (void)parcel->writeInt32(0);
320 }
321 if (buffers != 0) {
322 (void)parcel->writeInt32(1);
323 (void)parcel->writeStrongBinder(IInterface::asBinder(buffers));
324 } else {
325 (void)parcel->writeInt32(0);
326 }
Eric Laurent973db022018-11-20 14:54:31 -0800327 (void)parcel->write(&portId, sizeof(audio_port_handle_t));
Eric Laurentf14db3c2017-12-08 14:20:36 -0800328
329 return NO_ERROR;
330 }
331
332 /* input/output */
333 audio_input_flags_t flags;
334 size_t frameCount;
335 size_t notificationFrameCount;
336 audio_port_handle_t selectedDeviceId;
337 audio_session_t sessionId;
338
339 /* output */
340 uint32_t sampleRate;
341 audio_io_handle_t inputId;
342 sp<IMemory> cblk;
343 sp<IMemory> buffers;
Eric Laurent973db022018-11-20 14:54:31 -0800344 audio_port_handle_t portId;
Eric Laurentf14db3c2017-12-08 14:20:36 -0800345 };
346
Nicolas Rouletdcdfaec2017-02-14 10:18:39 -0800347 // invariant on exit for all APIs that return an sp<>:
348 // (return value != 0) == (*status == NO_ERROR)
349
350 /* create an audio track and registers it with AudioFlinger.
351 * return null if the track cannot be created.
352 */
Eric Laurent21da6472017-11-09 16:29:26 -0800353 virtual sp<IAudioTrack> createTrack(const CreateTrackInput& input,
354 CreateTrackOutput& output,
355 status_t *status) = 0;
Nicolas Rouletdcdfaec2017-02-14 10:18:39 -0800356
Eric Laurentf14db3c2017-12-08 14:20:36 -0800357 virtual sp<media::IAudioRecord> createRecord(const CreateRecordInput& input,
358 CreateRecordOutput& output,
359 status_t *status) = 0;
Nicolas Rouletdcdfaec2017-02-14 10:18:39 -0800360
361 // FIXME Surprisingly, format/latency don't work for input handles
362
363 /* query the audio hardware state. This state never changes,
364 * and therefore can be cached.
365 */
366 virtual uint32_t sampleRate(audio_io_handle_t ioHandle) const = 0;
367
368 // reserved; formerly channelCount()
369
370 virtual audio_format_t format(audio_io_handle_t output) const = 0;
371 virtual size_t frameCount(audio_io_handle_t ioHandle) const = 0;
372
373 // return estimated latency in milliseconds
374 virtual uint32_t latency(audio_io_handle_t output) const = 0;
375
376 /* set/get the audio hardware state. This will probably be used by
377 * the preference panel, mostly.
378 */
379 virtual status_t setMasterVolume(float value) = 0;
380 virtual status_t setMasterMute(bool muted) = 0;
381
382 virtual float masterVolume() const = 0;
383 virtual bool masterMute() const = 0;
384
Richard Folke Tullberg3fae0372017-01-13 09:04:25 +0100385 virtual status_t setMasterBalance(float balance) = 0;
386 virtual status_t getMasterBalance(float *balance) const = 0;
387
Nicolas Rouletdcdfaec2017-02-14 10:18:39 -0800388 /* set/get stream type state. This will probably be used by
389 * the preference panel, mostly.
390 */
391 virtual status_t setStreamVolume(audio_stream_type_t stream, float value,
392 audio_io_handle_t output) = 0;
393 virtual status_t setStreamMute(audio_stream_type_t stream, bool muted) = 0;
394
395 virtual float streamVolume(audio_stream_type_t stream,
396 audio_io_handle_t output) const = 0;
397 virtual bool streamMute(audio_stream_type_t stream) const = 0;
398
399 // set audio mode
400 virtual status_t setMode(audio_mode_t mode) = 0;
401
402 // mic mute/state
403 virtual status_t setMicMute(bool state) = 0;
404 virtual bool getMicMute() const = 0;
Eric Laurent5ada82e2019-08-29 17:53:54 -0700405 virtual void setRecordSilenced(audio_port_handle_t portId, bool silenced) = 0;
Nicolas Rouletdcdfaec2017-02-14 10:18:39 -0800406
407 virtual status_t setParameters(audio_io_handle_t ioHandle,
408 const String8& keyValuePairs) = 0;
409 virtual String8 getParameters(audio_io_handle_t ioHandle, const String8& keys)
410 const = 0;
411
412 // Register an object to receive audio input/output change and track notifications.
413 // For a given calling pid, AudioFlinger disregards any registrations after the first.
414 // Thus the IAudioFlingerClient must be a singleton per process.
415 virtual void registerClient(const sp<IAudioFlingerClient>& client) = 0;
416
Judy Hsiaoabab5222019-11-09 18:14:58 +0800417 // retrieve the audio recording buffer size in bytes
Nicolas Rouletdcdfaec2017-02-14 10:18:39 -0800418 // FIXME This API assumes a route, and so should be deprecated.
419 virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format,
420 audio_channel_mask_t channelMask) const = 0;
421
422 virtual status_t openOutput(audio_module_handle_t module,
423 audio_io_handle_t *output,
424 audio_config_t *config,
jiabin43810402019-10-24 14:58:31 -0700425 const sp<DeviceDescriptorBase>& device,
Nicolas Rouletdcdfaec2017-02-14 10:18:39 -0800426 uint32_t *latencyMs,
427 audio_output_flags_t flags) = 0;
428 virtual audio_io_handle_t openDuplicateOutput(audio_io_handle_t output1,
429 audio_io_handle_t output2) = 0;
430 virtual status_t closeOutput(audio_io_handle_t output) = 0;
431 virtual status_t suspendOutput(audio_io_handle_t output) = 0;
432 virtual status_t restoreOutput(audio_io_handle_t output) = 0;
433
434 virtual status_t openInput(audio_module_handle_t module,
435 audio_io_handle_t *input,
436 audio_config_t *config,
437 audio_devices_t *device,
438 const String8& address,
439 audio_source_t source,
440 audio_input_flags_t flags) = 0;
441 virtual status_t closeInput(audio_io_handle_t input) = 0;
442
443 virtual status_t invalidateStream(audio_stream_type_t stream) = 0;
444
445 virtual status_t setVoiceVolume(float volume) = 0;
446
447 virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames,
448 audio_io_handle_t output) const = 0;
449
450 virtual uint32_t getInputFramesLost(audio_io_handle_t ioHandle) const = 0;
451
452 virtual audio_unique_id_t newAudioUniqueId(audio_unique_id_use_t use) = 0;
453
Andy Hung8b0bfd92019-12-23 13:11:11 -0800454 virtual void acquireAudioSessionId(audio_session_t audioSession, pid_t pid, uid_t uid) = 0;
Nicolas Rouletdcdfaec2017-02-14 10:18:39 -0800455 virtual void releaseAudioSessionId(audio_session_t audioSession, pid_t pid) = 0;
456
457 virtual status_t queryNumberEffects(uint32_t *numEffects) const = 0;
458
459 virtual status_t queryEffect(uint32_t index, effect_descriptor_t *pDescriptor) const = 0;
460
461 virtual status_t getEffectDescriptor(const effect_uuid_t *pEffectUUID,
Ari Hausman-Cohen2046ec72018-04-24 14:00:55 -0700462 const effect_uuid_t *pTypeUUID,
463 uint32_t preferredTypeFlag,
464 effect_descriptor_t *pDescriptor) const = 0;
Nicolas Rouletdcdfaec2017-02-14 10:18:39 -0800465
466 virtual sp<IEffect> createEffect(
467 effect_descriptor_t *pDesc,
468 const sp<IEffectClient>& client,
469 int32_t priority,
470 // AudioFlinger doesn't take over handle reference from client
471 audio_io_handle_t output,
472 audio_session_t sessionId,
Eric Laurent94876032019-11-13 12:45:28 -0800473 const AudioDeviceTypeAddr& device,
Nicolas Rouletdcdfaec2017-02-14 10:18:39 -0800474 const String16& callingPackage,
475 pid_t pid,
Eric Laurent2fe0acd2020-03-13 14:30:46 -0700476 bool probe,
Nicolas Rouletdcdfaec2017-02-14 10:18:39 -0800477 status_t *status,
478 int *id,
479 int *enabled) = 0;
480
481 virtual status_t moveEffects(audio_session_t session, audio_io_handle_t srcOutput,
482 audio_io_handle_t dstOutput) = 0;
483
Eric Laurentb20cf7d2019-04-05 19:37:34 -0700484 virtual void setEffectSuspended(int effectId,
485 audio_session_t sessionId,
486 bool suspended) = 0;
487
Nicolas Rouletdcdfaec2017-02-14 10:18:39 -0800488 virtual audio_module_handle_t loadHwModule(const char *name) = 0;
489
490 // helpers for android.media.AudioManager.getProperty(), see description there for meaning
491 // FIXME move these APIs to AudioPolicy to permit a more accurate implementation
492 // that looks on primary device for a stream with fast flag, primary flag, or first one.
493 virtual uint32_t getPrimaryOutputSamplingRate() = 0;
494 virtual size_t getPrimaryOutputFrameCount() = 0;
495
496 // Intended for AudioService to inform AudioFlinger of device's low RAM attribute,
497 // and should be called at most once. For a definition of what "low RAM" means, see
Andy Hung6f248bb2018-01-23 14:04:37 -0800498 // android.app.ActivityManager.isLowRamDevice(). The totalMemory parameter
499 // is obtained from android.app.ActivityManager.MemoryInfo.totalMem.
500 virtual status_t setLowRamDevice(bool isLowRamDevice, int64_t totalMemory) = 0;
Nicolas Rouletdcdfaec2017-02-14 10:18:39 -0800501
502 /* List available audio ports and their attributes */
503 virtual status_t listAudioPorts(unsigned int *num_ports,
504 struct audio_port *ports) = 0;
505
506 /* Get attributes for a given audio port */
507 virtual status_t getAudioPort(struct audio_port *port) = 0;
508
509 /* Create an audio patch between several source and sink ports */
510 virtual status_t createAudioPatch(const struct audio_patch *patch,
511 audio_patch_handle_t *handle) = 0;
512
513 /* Release an audio patch */
514 virtual status_t releaseAudioPatch(audio_patch_handle_t handle) = 0;
515
516 /* List existing audio patches */
517 virtual status_t listAudioPatches(unsigned int *num_patches,
518 struct audio_patch *patches) = 0;
519 /* Set audio port configuration */
520 virtual status_t setAudioPortConfig(const struct audio_port_config *config) = 0;
521
522 /* Get the HW synchronization source used for an audio session */
523 virtual audio_hw_sync_t getAudioHwSyncForSession(audio_session_t sessionId) = 0;
524
525 /* Indicate JAVA services are ready (scheduling, power management ...) */
526 virtual status_t systemReady() = 0;
527
528 // Returns the number of frames per audio HAL buffer.
529 virtual size_t frameCountHAL(audio_io_handle_t ioHandle) const = 0;
jiabin46a76fa2018-01-05 10:18:21 -0800530
531 /* List available microphones and their characteristics */
532 virtual status_t getMicrophones(std::vector<media::MicrophoneInfo> *microphones) = 0;
Eric Laurent42896a02019-09-27 15:40:33 -0700533
534 virtual status_t setAudioHalPids(const std::vector<pid_t>& pids) = 0;
Nicolas Rouletdcdfaec2017-02-14 10:18:39 -0800535};
536
537
538// ----------------------------------------------------------------------------
539
540class BnAudioFlinger : public BnInterface<IAudioFlinger>
541{
542public:
543 virtual status_t onTransact( uint32_t code,
544 const Parcel& data,
545 Parcel* reply,
546 uint32_t flags = 0);
547
548 // Requests media.log to start merging log buffers
549 virtual void requestLogMerge() = 0;
550};
551
552// ----------------------------------------------------------------------------
553
554}; // namespace android
555
556#endif // ANDROID_IAUDIOFLINGER_H