blob: 433ce7cf52f17c6a4c458ee2fc4dd749026a8378 [file] [log] [blame]
The Android Open Source Project9066cfe2009-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 Agopian07952722009-05-19 19:08:10 -070026#include <binder/IInterface.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080027#include <media/IAudioTrack.h>
28#include <media/IAudioRecord.h>
29#include <media/IAudioFlingerClient.h>
Glenn Kasten39d00cb2012-01-17 11:09:42 -080030#include <system/audio.h>
Eric Laurent0fb66c22011-05-17 19:16:02 -070031#include <hardware/audio_effect.h>
Eric Laurent65b65452010-06-01 23:49:17 -070032#include <media/IEffect.h>
33#include <media/IEffectClient.h>
Eric Laurenta553c252009-07-17 12:17:14 -070034#include <utils/String8.h>
The Android Open Source Project9066cfe2009-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 Kastenbc1d77b2012-01-12 16:38:12 -080050 audio_stream_type_t streamType,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080051 uint32_t sampleRate,
Glenn Kasten0a204ed2012-01-12 12:27:51 -080052 audio_format_t format,
Jean-Michel Trivi54392232011-05-24 15:53:33 -070053 uint32_t channelMask,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080054 int frameCount,
55 uint32_t flags,
56 const sp<IMemory>& sharedBuffer,
Glenn Kasten39d00cb2012-01-17 11:09:42 -080057 audio_io_handle_t output,
Eric Laurent65b65452010-06-01 23:49:17 -070058 int *sessionId,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080059 status_t *status) = 0;
60
61 virtual sp<IAudioRecord> openRecord(
62 pid_t pid,
Glenn Kasten39d00cb2012-01-17 11:09:42 -080063 audio_io_handle_t input,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080064 uint32_t sampleRate,
Glenn Kasten0a204ed2012-01-12 12:27:51 -080065 audio_format_t format,
Jean-Michel Trivi54392232011-05-24 15:53:33 -070066 uint32_t channelMask,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080067 int frameCount,
68 uint32_t flags,
Eric Laurent65b65452010-06-01 23:49:17 -070069 int *sessionId,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080070 status_t *status) = 0;
71
72 /* query the audio hardware state. This state never changes,
73 * and therefore can be cached.
74 */
Glenn Kasten39d00cb2012-01-17 11:09:42 -080075 virtual uint32_t sampleRate(audio_io_handle_t output) const = 0;
76 virtual int channelCount(audio_io_handle_t output) const = 0;
77 virtual audio_format_t format(audio_io_handle_t output) const = 0;
78 virtual size_t frameCount(audio_io_handle_t output) const = 0;
79 virtual uint32_t latency(audio_io_handle_t output) const = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080080
81 /* set/get the audio hardware state. This will probably be used by
82 * the preference panel, mostly.
83 */
84 virtual status_t setMasterVolume(float value) = 0;
85 virtual status_t setMasterMute(bool muted) = 0;
86
87 virtual float masterVolume() const = 0;
88 virtual bool masterMute() const = 0;
89
90 /* set/get stream type state. This will probably be used by
91 * the preference panel, mostly.
92 */
Glenn Kasten39d00cb2012-01-17 11:09:42 -080093 virtual status_t setStreamVolume(audio_stream_type_t stream, float value,
94 audio_io_handle_t output) = 0;
Glenn Kastenbc1d77b2012-01-12 16:38:12 -080095 virtual status_t setStreamMute(audio_stream_type_t stream, bool muted) = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080096
Glenn Kasten39d00cb2012-01-17 11:09:42 -080097 virtual float streamVolume(audio_stream_type_t stream,
98 audio_io_handle_t output) const = 0;
Glenn Kastenbc1d77b2012-01-12 16:38:12 -080099 virtual bool streamMute(audio_stream_type_t stream) const = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800100
Eric Laurenta553c252009-07-17 12:17:14 -0700101 // set audio mode
Glenn Kastenaccb1142012-01-04 11:00:47 -0800102 virtual status_t setMode(audio_mode_t mode) = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800103
104 // mic mute/state
105 virtual status_t setMicMute(bool state) = 0;
106 virtual bool getMicMute() const = 0;
107
Glenn Kasten39d00cb2012-01-17 11:09:42 -0800108 virtual status_t setParameters(audio_io_handle_t ioHandle,
109 const String8& keyValuePairs) = 0;
110 virtual String8 getParameters(audio_io_handle_t ioHandle, const String8& keys) const = 0;
Eric Laurent415f3e22009-10-21 08:14:22 -0700111
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800112 // register a current process for audio output change notifications
113 virtual void registerClient(const sp<IAudioFlingerClient>& client) = 0;
Eric Laurent415f3e22009-10-21 08:14:22 -0700114
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800115 // retrieve the audio recording buffer size
Glenn Kasten3f6d83a2012-01-26 16:25:10 -0800116 virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format, int channelCount) const = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800117
Glenn Kasten39d00cb2012-01-17 11:09:42 -0800118 virtual audio_io_handle_t openOutput(uint32_t *pDevices,
Eric Laurenta553c252009-07-17 12:17:14 -0700119 uint32_t *pSamplingRate,
Glenn Kasten0a204ed2012-01-12 12:27:51 -0800120 audio_format_t *pFormat,
Eric Laurenta553c252009-07-17 12:17:14 -0700121 uint32_t *pChannels,
122 uint32_t *pLatencyMs,
123 uint32_t flags) = 0;
Glenn Kasten39d00cb2012-01-17 11:09:42 -0800124 virtual audio_io_handle_t openDuplicateOutput(audio_io_handle_t output1,
125 audio_io_handle_t output2) = 0;
126 virtual status_t closeOutput(audio_io_handle_t output) = 0;
127 virtual status_t suspendOutput(audio_io_handle_t output) = 0;
128 virtual status_t restoreOutput(audio_io_handle_t output) = 0;
Eric Laurenta553c252009-07-17 12:17:14 -0700129
Glenn Kasten39d00cb2012-01-17 11:09:42 -0800130 virtual audio_io_handle_t openInput(uint32_t *pDevices,
Eric Laurenta553c252009-07-17 12:17:14 -0700131 uint32_t *pSamplingRate,
Glenn Kasten0a204ed2012-01-12 12:27:51 -0800132 audio_format_t *pFormat,
Eric Laurenta553c252009-07-17 12:17:14 -0700133 uint32_t *pChannels,
Glenn Kasten882c0a22012-01-27 12:32:34 -0800134 audio_in_acoustics_t acoustics) = 0;
Glenn Kasten39d00cb2012-01-17 11:09:42 -0800135 virtual status_t closeInput(audio_io_handle_t input) = 0;
Eric Laurenta553c252009-07-17 12:17:14 -0700136
Glenn Kasten39d00cb2012-01-17 11:09:42 -0800137 virtual status_t setStreamOutput(audio_stream_type_t stream, audio_io_handle_t output) = 0;
Eric Laurent415f3e22009-10-21 08:14:22 -0700138
139 virtual status_t setVoiceVolume(float volume) = 0;
Eric Laurent47d0a922010-02-26 02:47:27 -0800140
Glenn Kasten39d00cb2012-01-17 11:09:42 -0800141 virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames,
142 audio_io_handle_t output) const = 0;
Eric Laurent47d0a922010-02-26 02:47:27 -0800143
Glenn Kasten39d00cb2012-01-17 11:09:42 -0800144 virtual unsigned int getInputFramesLost(audio_io_handle_t ioHandle) const = 0;
Eric Laurent65b65452010-06-01 23:49:17 -0700145
146 virtual int newAudioSessionId() = 0;
147
Marco Nelissenc74b93f2011-08-02 13:33:41 -0700148 virtual void acquireAudioSessionId(int audioSession) = 0;
149 virtual void releaseAudioSessionId(int audioSession) = 0;
150
Glenn Kasten3f6d83a2012-01-26 16:25:10 -0800151 virtual status_t queryNumberEffects(uint32_t *numEffects) const = 0;
Eric Laurent65b65452010-06-01 23:49:17 -0700152
Glenn Kasten3f6d83a2012-01-26 16:25:10 -0800153 virtual status_t queryEffect(uint32_t index, effect_descriptor_t *pDescriptor) const = 0;
Eric Laurent65b65452010-06-01 23:49:17 -0700154
Glenn Kasten67313332012-01-30 07:40:52 -0800155 virtual status_t getEffectDescriptor(const effect_uuid_t *pEffectUUID,
Glenn Kasten3f6d83a2012-01-26 16:25:10 -0800156 effect_descriptor_t *pDescriptor) const = 0;
Eric Laurent65b65452010-06-01 23:49:17 -0700157
158 virtual sp<IEffect> createEffect(pid_t pid,
159 effect_descriptor_t *pDesc,
160 const sp<IEffectClient>& client,
161 int32_t priority,
Glenn Kasten39d00cb2012-01-17 11:09:42 -0800162 audio_io_handle_t output,
Eric Laurent65b65452010-06-01 23:49:17 -0700163 int sessionId,
164 status_t *status,
165 int *id,
166 int *enabled) = 0;
Eric Laurent8ed6ed02010-07-13 04:45:46 -0700167
Glenn Kasten39d00cb2012-01-17 11:09:42 -0800168 virtual status_t moveEffects(int session, audio_io_handle_t srcOutput,
169 audio_io_handle_t dstOutput) = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800170};
171
172
173// ----------------------------------------------------------------------------
174
175class BnAudioFlinger : public BnInterface<IAudioFlinger>
176{
177public:
178 virtual status_t onTransact( uint32_t code,
179 const Parcel& data,
180 Parcel* reply,
181 uint32_t flags = 0);
182};
183
184// ----------------------------------------------------------------------------
185
186}; // namespace android
187
188#endif // ANDROID_IAUDIOFLINGER_H