blob: d7471eee0958ecbeba73717ca8f85dd5b52305e8 [file] [log] [blame]
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -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>
Mathias Agopian75624082009-05-19 19:08:10 -070026#include <binder/IInterface.h>
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080027#include <media/IAudioTrack.h>
28#include <media/IAudioRecord.h>
29#include <media/IAudioFlingerClient.h>
Glenn Kasten72ef00d2012-01-17 11:09:42 -080030#include <system/audio.h>
Eric Laurente1315cf2011-05-17 19:16:02 -070031#include <hardware/audio_effect.h>
Eric Laurentbe916aa2010-06-01 23:49:17 -070032#include <media/IEffect.h>
33#include <media/IEffectClient.h>
Eric Laurentc2f1f072009-07-17 12:17:14 -070034#include <utils/String8.h>
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080035
36namespace android {
37
38// ----------------------------------------------------------------------------
39
40class IAudioFlinger : public IInterface
41{
42public:
43 DECLARE_META_INTERFACE(AudioFlinger);
44
45 /* create an audio track and registers it with AudioFlinger.
46 * return null if the track cannot be created.
47 */
48 virtual sp<IAudioTrack> createTrack(
49 pid_t pid,
Glenn Kastenfff6d712012-01-12 16:38:12 -080050 audio_stream_type_t streamType,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080051 uint32_t sampleRate,
Glenn Kasten58f30212012-01-12 12:27:51 -080052 audio_format_t format,
Jean-Michel Trivi0d255b22011-05-24 15:53:33 -070053 uint32_t channelMask,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080054 int frameCount,
55 uint32_t flags,
56 const sp<IMemory>& sharedBuffer,
Glenn Kasten72ef00d2012-01-17 11:09:42 -080057 audio_io_handle_t output,
John Grossman4ff14ba2012-02-08 16:37:41 -080058 bool isTimed,
Eric Laurentbe916aa2010-06-01 23:49:17 -070059 int *sessionId,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080060 status_t *status) = 0;
61
62 virtual sp<IAudioRecord> openRecord(
63 pid_t pid,
Glenn Kasten72ef00d2012-01-17 11:09:42 -080064 audio_io_handle_t input,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080065 uint32_t sampleRate,
Glenn Kasten58f30212012-01-12 12:27:51 -080066 audio_format_t format,
Jean-Michel Trivi0d255b22011-05-24 15:53:33 -070067 uint32_t channelMask,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080068 int frameCount,
69 uint32_t flags,
Eric Laurentbe916aa2010-06-01 23:49:17 -070070 int *sessionId,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080071 status_t *status) = 0;
72
73 /* query the audio hardware state. This state never changes,
74 * and therefore can be cached.
75 */
Glenn Kasten72ef00d2012-01-17 11:09:42 -080076 virtual uint32_t sampleRate(audio_io_handle_t output) const = 0;
77 virtual int channelCount(audio_io_handle_t output) const = 0;
78 virtual audio_format_t format(audio_io_handle_t output) const = 0;
79 virtual size_t frameCount(audio_io_handle_t output) const = 0;
Glenn Kasten688aac72012-03-09 10:30:26 -080080
81 // return estimated latency in milliseconds
Glenn Kasten72ef00d2012-01-17 11:09:42 -080082 virtual uint32_t latency(audio_io_handle_t output) const = 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080083
84 /* set/get the audio hardware state. This will probably be used by
85 * the preference panel, mostly.
86 */
87 virtual status_t setMasterVolume(float value) = 0;
88 virtual status_t setMasterMute(bool muted) = 0;
89
90 virtual float masterVolume() const = 0;
91 virtual bool masterMute() const = 0;
92
93 /* set/get stream type state. This will probably be used by
94 * the preference panel, mostly.
95 */
Glenn Kasten72ef00d2012-01-17 11:09:42 -080096 virtual status_t setStreamVolume(audio_stream_type_t stream, float value,
97 audio_io_handle_t output) = 0;
Glenn Kastenfff6d712012-01-12 16:38:12 -080098 virtual status_t setStreamMute(audio_stream_type_t stream, bool muted) = 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080099
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800100 virtual float streamVolume(audio_stream_type_t stream,
101 audio_io_handle_t output) const = 0;
Glenn Kastenfff6d712012-01-12 16:38:12 -0800102 virtual bool streamMute(audio_stream_type_t stream) const = 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800103
Eric Laurentc2f1f072009-07-17 12:17:14 -0700104 // set audio mode
Glenn Kastenf78aee72012-01-04 11:00:47 -0800105 virtual status_t setMode(audio_mode_t mode) = 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800106
107 // mic mute/state
108 virtual status_t setMicMute(bool state) = 0;
109 virtual bool getMicMute() const = 0;
110
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800111 virtual status_t setParameters(audio_io_handle_t ioHandle,
112 const String8& keyValuePairs) = 0;
113 virtual String8 getParameters(audio_io_handle_t ioHandle, const String8& keys) const = 0;
Eric Laurentf0ee6f42009-10-21 08:14:22 -0700114
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800115 // register a current process for audio output change notifications
116 virtual void registerClient(const sp<IAudioFlingerClient>& client) = 0;
Eric Laurentf0ee6f42009-10-21 08:14:22 -0700117
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800118 // retrieve the audio recording buffer size
Glenn Kastenf587ba52012-01-26 16:25:10 -0800119 virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format, int channelCount) const = 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800120
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800121 virtual audio_io_handle_t openOutput(uint32_t *pDevices,
Eric Laurentc2f1f072009-07-17 12:17:14 -0700122 uint32_t *pSamplingRate,
Glenn Kasten58f30212012-01-12 12:27:51 -0800123 audio_format_t *pFormat,
Eric Laurentc2f1f072009-07-17 12:17:14 -0700124 uint32_t *pChannels,
125 uint32_t *pLatencyMs,
126 uint32_t flags) = 0;
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800127 virtual audio_io_handle_t openDuplicateOutput(audio_io_handle_t output1,
128 audio_io_handle_t output2) = 0;
129 virtual status_t closeOutput(audio_io_handle_t output) = 0;
130 virtual status_t suspendOutput(audio_io_handle_t output) = 0;
131 virtual status_t restoreOutput(audio_io_handle_t output) = 0;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700132
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800133 virtual audio_io_handle_t openInput(uint32_t *pDevices,
Eric Laurentc2f1f072009-07-17 12:17:14 -0700134 uint32_t *pSamplingRate,
Glenn Kasten58f30212012-01-12 12:27:51 -0800135 audio_format_t *pFormat,
Eric Laurentc2f1f072009-07-17 12:17:14 -0700136 uint32_t *pChannels,
Glenn Kastende9719b2012-01-27 12:32:34 -0800137 audio_in_acoustics_t acoustics) = 0;
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800138 virtual status_t closeInput(audio_io_handle_t input) = 0;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700139
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800140 virtual status_t setStreamOutput(audio_stream_type_t stream, audio_io_handle_t output) = 0;
Eric Laurentf0ee6f42009-10-21 08:14:22 -0700141
142 virtual status_t setVoiceVolume(float volume) = 0;
Eric Laurent05bca2f2010-02-26 02:47:27 -0800143
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800144 virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames,
145 audio_io_handle_t output) const = 0;
Eric Laurent05bca2f2010-02-26 02:47:27 -0800146
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800147 virtual unsigned int getInputFramesLost(audio_io_handle_t ioHandle) const = 0;
Eric Laurentbe916aa2010-06-01 23:49:17 -0700148
149 virtual int newAudioSessionId() = 0;
150
Marco Nelissen3a34bef2011-08-02 13:33:41 -0700151 virtual void acquireAudioSessionId(int audioSession) = 0;
152 virtual void releaseAudioSessionId(int audioSession) = 0;
153
Glenn Kastenf587ba52012-01-26 16:25:10 -0800154 virtual status_t queryNumberEffects(uint32_t *numEffects) const = 0;
Eric Laurentbe916aa2010-06-01 23:49:17 -0700155
Glenn Kastenf587ba52012-01-26 16:25:10 -0800156 virtual status_t queryEffect(uint32_t index, effect_descriptor_t *pDescriptor) const = 0;
Eric Laurentbe916aa2010-06-01 23:49:17 -0700157
Glenn Kasten5e92a782012-01-30 07:40:52 -0800158 virtual status_t getEffectDescriptor(const effect_uuid_t *pEffectUUID,
Glenn Kastenf587ba52012-01-26 16:25:10 -0800159 effect_descriptor_t *pDescriptor) const = 0;
Eric Laurentbe916aa2010-06-01 23:49:17 -0700160
161 virtual sp<IEffect> createEffect(pid_t pid,
162 effect_descriptor_t *pDesc,
163 const sp<IEffectClient>& client,
164 int32_t priority,
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800165 audio_io_handle_t output,
Eric Laurentbe916aa2010-06-01 23:49:17 -0700166 int sessionId,
167 status_t *status,
168 int *id,
169 int *enabled) = 0;
Eric Laurentde070132010-07-13 04:45:46 -0700170
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800171 virtual status_t moveEffects(int session, audio_io_handle_t srcOutput,
172 audio_io_handle_t dstOutput) = 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800173};
174
175
176// ----------------------------------------------------------------------------
177
178class BnAudioFlinger : public BnInterface<IAudioFlinger>
179{
180public:
181 virtual status_t onTransact( uint32_t code,
182 const Parcel& data,
183 Parcel* reply,
184 uint32_t flags = 0);
185};
186
187// ----------------------------------------------------------------------------
188
189}; // namespace android
190
191#endif // ANDROID_IAUDIOFLINGER_H