blob: f72452c2700583f20a4d0466bec454df1a847d7c [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>
Eric Laurente1315cf2011-05-17 19:16:02 -070030#include <hardware/audio_effect.h>
Eric Laurentbe916aa2010-06-01 23:49:17 -070031#include <media/IEffect.h>
32#include <media/IEffectClient.h>
Eric Laurentc2f1f072009-07-17 12:17:14 -070033#include <utils/String8.h>
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080034
35namespace android {
36
37// ----------------------------------------------------------------------------
38
39class IAudioFlinger : public IInterface
40{
41public:
42 DECLARE_META_INTERFACE(AudioFlinger);
43
44 /* create an audio track and registers it with AudioFlinger.
45 * return null if the track cannot be created.
46 */
47 virtual sp<IAudioTrack> createTrack(
48 pid_t pid,
49 int streamType,
50 uint32_t sampleRate,
Jean-Michel Trivi0d255b22011-05-24 15:53:33 -070051 uint32_t format,
52 uint32_t channelMask,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080053 int frameCount,
54 uint32_t flags,
55 const sp<IMemory>& sharedBuffer,
Eric Laurentfa2877b2009-07-28 08:44:33 -070056 int output,
Mike J. Chen500e5102011-08-15 13:28:26 -070057 bool isTimed,
Eric Laurentbe916aa2010-06-01 23:49:17 -070058 int *sessionId,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080059 status_t *status) = 0;
60
61 virtual sp<IAudioRecord> openRecord(
62 pid_t pid,
Eric Laurentfa2877b2009-07-28 08:44:33 -070063 int input,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080064 uint32_t sampleRate,
Jean-Michel Trivi0d255b22011-05-24 15:53:33 -070065 uint32_t format,
66 uint32_t channelMask,
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080067 int frameCount,
68 uint32_t flags,
Eric Laurentbe916aa2010-06-01 23:49:17 -070069 int *sessionId,
The Android Open Source Project89fa4ad2009-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 */
Eric Laurentfa2877b2009-07-28 08:44:33 -070075 virtual uint32_t sampleRate(int output) const = 0;
76 virtual int channelCount(int output) const = 0;
Jean-Michel Trivi0d255b22011-05-24 15:53:33 -070077 virtual uint32_t format(int output) const = 0;
Eric Laurentfa2877b2009-07-28 08:44:33 -070078 virtual size_t frameCount(int output) const = 0;
79 virtual uint32_t latency(int output) const = 0;
The Android Open Source Project89fa4ad2009-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 */
Eric Laurentfa2877b2009-07-28 08:44:33 -070093 virtual status_t setStreamVolume(int stream, float value, int output) = 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080094 virtual status_t setStreamMute(int stream, bool muted) = 0;
95
Eric Laurentfa2877b2009-07-28 08:44:33 -070096 virtual float streamVolume(int stream, int output) const = 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080097 virtual bool streamMute(int stream) const = 0;
98
Eric Laurentc2f1f072009-07-17 12:17:14 -070099 // set audio mode
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800100 virtual status_t setMode(int mode) = 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800101
102 // mic mute/state
103 virtual status_t setMicMute(bool state) = 0;
104 virtual bool getMicMute() const = 0;
105
Eric Laurentfa2877b2009-07-28 08:44:33 -0700106 virtual status_t setParameters(int ioHandle, const String8& keyValuePairs) = 0;
107 virtual String8 getParameters(int ioHandle, const String8& keys) = 0;
Eric Laurentf0ee6f42009-10-21 08:14:22 -0700108
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800109 // register a current process for audio output change notifications
110 virtual void registerClient(const sp<IAudioFlingerClient>& client) = 0;
Eric Laurentf0ee6f42009-10-21 08:14:22 -0700111
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800112 // retrieve the audio recording buffer size
113 virtual size_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount) = 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800114
Eric Laurentfa2877b2009-07-28 08:44:33 -0700115 virtual int openOutput(uint32_t *pDevices,
Eric Laurentc2f1f072009-07-17 12:17:14 -0700116 uint32_t *pSamplingRate,
117 uint32_t *pFormat,
118 uint32_t *pChannels,
119 uint32_t *pLatencyMs,
120 uint32_t flags) = 0;
Eric Laurentfa2877b2009-07-28 08:44:33 -0700121 virtual int openDuplicateOutput(int output1, int output2) = 0;
122 virtual status_t closeOutput(int output) = 0;
123 virtual status_t suspendOutput(int output) = 0;
124 virtual status_t restoreOutput(int output) = 0;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700125
Eric Laurentfa2877b2009-07-28 08:44:33 -0700126 virtual int openInput(uint32_t *pDevices,
Eric Laurentc2f1f072009-07-17 12:17:14 -0700127 uint32_t *pSamplingRate,
128 uint32_t *pFormat,
129 uint32_t *pChannels,
130 uint32_t acoustics) = 0;
Eric Laurentfa2877b2009-07-28 08:44:33 -0700131 virtual status_t closeInput(int input) = 0;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700132
Eric Laurentfa2877b2009-07-28 08:44:33 -0700133 virtual status_t setStreamOutput(uint32_t stream, int output) = 0;
Eric Laurentf0ee6f42009-10-21 08:14:22 -0700134
135 virtual status_t setVoiceVolume(float volume) = 0;
Eric Laurent05bca2f2010-02-26 02:47:27 -0800136
Eric Laurent342e9cf2010-01-19 17:37:09 -0800137 virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int output) = 0;
Eric Laurent05bca2f2010-02-26 02:47:27 -0800138
139 virtual unsigned int getInputFramesLost(int ioHandle) = 0;
Eric Laurentbe916aa2010-06-01 23:49:17 -0700140
141 virtual int newAudioSessionId() = 0;
142
Marco Nelissen3a34bef2011-08-02 13:33:41 -0700143 virtual void acquireAudioSessionId(int audioSession) = 0;
144 virtual void releaseAudioSessionId(int audioSession) = 0;
145
Eric Laurentbe916aa2010-06-01 23:49:17 -0700146 virtual status_t queryNumberEffects(uint32_t *numEffects) = 0;
147
Eric Laurentffe9c252010-06-23 17:38:20 -0700148 virtual status_t queryEffect(uint32_t index, effect_descriptor_t *pDescriptor) = 0;
Eric Laurentbe916aa2010-06-01 23:49:17 -0700149
150 virtual status_t getEffectDescriptor(effect_uuid_t *pEffectUUID, effect_descriptor_t *pDescriptor) = 0;
151
152 virtual sp<IEffect> createEffect(pid_t pid,
153 effect_descriptor_t *pDesc,
154 const sp<IEffectClient>& client,
155 int32_t priority,
156 int output,
157 int sessionId,
158 status_t *status,
159 int *id,
160 int *enabled) = 0;
Eric Laurentde070132010-07-13 04:45:46 -0700161
162 virtual status_t moveEffects(int session, int srcOutput, int dstOutput) = 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -0800163};
164
165
166// ----------------------------------------------------------------------------
167
168class BnAudioFlinger : public BnInterface<IAudioFlinger>
169{
170public:
171 virtual status_t onTransact( uint32_t code,
172 const Parcel& data,
173 Parcel* reply,
174 uint32_t flags = 0);
175};
176
177// ----------------------------------------------------------------------------
178
179}; // namespace android
180
181#endif // ANDROID_IAUDIOFLINGER_H