|
1 /* |
|
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> |
|
27 #include "IAudioTrack.h" |
|
28 #include "IAudioRecord.h" |
|
29 #include "IAudioFlingerClient.h" |
|
30 #include "EffectApi.h" |
|
31 #include "IEffect.h" |
|
32 #include "IEffectClient.h" |
|
33 #include <utils/String8.h> |
|
34 |
|
35 namespace android { |
|
36 |
|
37 // ---------------------------------------------------------------------------- |
|
38 |
|
39 class IAudioFlinger : public IInterface |
|
40 { |
|
41 public: |
|
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, |
|
51 int format, |
|
52 int channelCount, |
|
53 int frameCount, |
|
54 uint32_t flags, |
|
55 const sp<IMemory>& sharedBuffer, |
|
56 int output, |
|
57 int *sessionId, |
|
58 status_t *status) = 0; |
|
59 |
|
60 virtual sp<IAudioRecord> openRecord( |
|
61 pid_t pid, |
|
62 int input, |
|
63 uint32_t sampleRate, |
|
64 int format, |
|
65 int channelCount, |
|
66 int frameCount, |
|
67 uint32_t flags, |
|
68 int *sessionId, |
|
69 status_t *status) = 0; |
|
70 |
|
71 /* query the audio hardware state. This state never changes, |
|
72 * and therefore can be cached. |
|
73 */ |
|
74 virtual uint32_t sampleRate(int output) const = 0; |
|
75 virtual int channelCount(int output) const = 0; |
|
76 virtual int format(int output) const = 0; |
|
77 virtual size_t frameCount(int output) const = 0; |
|
78 virtual uint32_t latency(int output) const = 0; |
|
79 |
|
80 /* set/get the audio hardware state. This will probably be used by |
|
81 * the preference panel, mostly. |
|
82 */ |
|
83 virtual status_t setMasterVolume(float value) = 0; |
|
84 virtual status_t setMasterMute(bool muted) = 0; |
|
85 |
|
86 virtual float masterVolume() const = 0; |
|
87 virtual bool masterMute() const = 0; |
|
88 |
|
89 /* set/get stream type state. This will probably be used by |
|
90 * the preference panel, mostly. |
|
91 */ |
|
92 virtual status_t setStreamVolume(int stream, float value, int output) = 0; |
|
93 virtual status_t setStreamMute(int stream, bool muted) = 0; |
|
94 |
|
95 virtual float streamVolume(int stream, int output) const = 0; |
|
96 virtual bool streamMute(int stream) const = 0; |
|
97 |
|
98 // set audio mode |
|
99 virtual status_t setMode(int mode) = 0; |
|
100 |
|
101 // mic mute/state |
|
102 virtual status_t setMicMute(bool state) = 0; |
|
103 virtual bool getMicMute() const = 0; |
|
104 |
|
105 // is any track active on this stream? |
|
106 virtual bool isStreamActive(int stream) const = 0; |
|
107 |
|
108 virtual status_t setParameters(int ioHandle, const String8& keyValuePairs) = 0; |
|
109 virtual String8 getParameters(int ioHandle, const String8& keys) = 0; |
|
110 |
|
111 // register a current process for audio output change notifications |
|
112 virtual void registerClient(const sp<IAudioFlingerClient>& client) = 0; |
|
113 |
|
114 // retrieve the audio recording buffer size |
|
115 virtual size_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount) = 0; |
|
116 |
|
117 virtual int openOutput(uint32_t *pDevices, |
|
118 uint32_t *pSamplingRate, |
|
119 uint32_t *pFormat, |
|
120 uint32_t *pChannels, |
|
121 uint32_t *pLatencyMs, |
|
122 uint32_t flags) = 0; |
|
123 virtual int openDuplicateOutput(int output1, int output2) = 0; |
|
124 virtual status_t closeOutput(int output) = 0; |
|
125 virtual status_t suspendOutput(int output) = 0; |
|
126 virtual status_t restoreOutput(int output) = 0; |
|
127 |
|
128 virtual int openInput(uint32_t *pDevices, |
|
129 uint32_t *pSamplingRate, |
|
130 uint32_t *pFormat, |
|
131 uint32_t *pChannels, |
|
132 uint32_t acoustics) = 0; |
|
133 virtual status_t closeInput(int input) = 0; |
|
134 |
|
135 virtual status_t setStreamOutput(uint32_t stream, int output) = 0; |
|
136 |
|
137 virtual status_t setVoiceVolume(float volume) = 0; |
|
138 |
|
139 virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int output) = 0; |
|
140 |
|
141 virtual unsigned int getInputFramesLost(int ioHandle) = 0; |
|
142 |
|
143 virtual int newAudioSessionId() = 0; |
|
144 |
|
145 virtual status_t loadEffectLibrary(const char *libPath, int *handle) = 0; |
|
146 |
|
147 virtual status_t unloadEffectLibrary(int handle) = 0; |
|
148 |
|
149 virtual status_t queryNumberEffects(uint32_t *numEffects) = 0; |
|
150 |
|
151 virtual status_t queryEffect(uint32_t index, effect_descriptor_t *pDescriptor) = 0; |
|
152 |
|
153 virtual status_t getEffectDescriptor(effect_uuid_t *pEffectUUID, effect_descriptor_t *pDescriptor) = 0; |
|
154 |
|
155 virtual sp<IEffect> createEffect(pid_t pid, |
|
156 effect_descriptor_t *pDesc, |
|
157 const sp<IEffectClient>& client, |
|
158 int32_t priority, |
|
159 int output, |
|
160 int sessionId, |
|
161 status_t *status, |
|
162 int *id, |
|
163 int *enabled) = 0; |
|
164 |
|
165 virtual status_t moveEffects(int session, int srcOutput, int dstOutput) = 0; |
|
166 }; |
|
167 |
|
168 |
|
169 // ---------------------------------------------------------------------------- |
|
170 |
|
171 class BnAudioFlinger : public BnInterface<IAudioFlinger> |
|
172 { |
|
173 public: |
|
174 virtual status_t onTransact( uint32_t code, |
|
175 const Parcel& data, |
|
176 Parcel* reply, |
|
177 uint32_t flags = 0); |
|
178 }; |
|
179 |
|
180 // ---------------------------------------------------------------------------- |
|
181 |
|
182 }; // namespace android |
|
183 |
|
184 #endif // ANDROID_IAUDIOFLINGER_H |