blob: 33c7d03d93e04959ea89c4333dbbf9f6703124c8 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2006-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#define LOG_TAG "AudioSystem"
18//#define LOG_NDEBUG 0
19
20#include <utils/Log.h>
Mathias Agopian07952722009-05-19 19:08:10 -070021#include <binder/IServiceManager.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080022#include <media/AudioSystem.h>
Eric Laurenta553c252009-07-17 12:17:14 -070023#include <media/IAudioPolicyService.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080024#include <math.h>
25
Dima Zavin34bb4192011-05-11 14:15:23 -070026#include <system/audio.h>
Dima Zavin24fc2fb2011-04-19 22:30:36 -070027
Eric Laurenta553c252009-07-17 12:17:14 -070028// ----------------------------------------------------------------------------
Eric Laurenta553c252009-07-17 12:17:14 -070029
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080030namespace android {
31
32// client singleton for AudioFlinger binder interface
33Mutex AudioSystem::gLock;
34sp<IAudioFlinger> AudioSystem::gAudioFlinger;
35sp<AudioSystem::AudioFlingerClient> AudioSystem::gAudioFlingerClient;
36audio_error_callback AudioSystem::gAudioErrorCallback = NULL;
37// Cached values
Glenn Kastenb7cffb42012-01-20 09:37:45 -080038
39DefaultKeyedVector<audio_stream_type_t, audio_io_handle_t> AudioSystem::gStreamOutputMap(0);
Eric Laurenta553c252009-07-17 12:17:14 -070040DefaultKeyedVector<audio_io_handle_t, AudioSystem::OutputDescriptor *> AudioSystem::gOutputs(0);
41
Glenn Kasten81801ad2012-01-10 09:01:19 -080042// Cached values for recording queries, all protected by gLock
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080043uint32_t AudioSystem::gPrevInSamplingRate = 16000;
Glenn Kasten0a204ed2012-01-12 12:27:51 -080044audio_format_t AudioSystem::gPrevInFormat = AUDIO_FORMAT_PCM_16_BIT;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080045int AudioSystem::gPrevInChannelCount = 1;
46size_t AudioSystem::gInBuffSize = 0;
47
48
49// establish binder interface to AudioFlinger service
50const sp<IAudioFlinger>& AudioSystem::get_audio_flinger()
51{
52 Mutex::Autolock _l(gLock);
Glenn Kasten70ed6b72012-01-10 10:46:34 -080053 if (gAudioFlinger == 0) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080054 sp<IServiceManager> sm = defaultServiceManager();
55 sp<IBinder> binder;
56 do {
57 binder = sm->getService(String16("media.audio_flinger"));
58 if (binder != 0)
59 break;
Steve Block8564c8d2012-01-05 23:22:43 +000060 ALOGW("AudioFlinger not published, waiting...");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080061 usleep(500000); // 0.5 s
Glenn Kasten18db49a2012-03-12 16:29:55 -070062 } while (true);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080063 if (gAudioFlingerClient == NULL) {
64 gAudioFlingerClient = new AudioFlingerClient();
65 } else {
66 if (gAudioErrorCallback) {
67 gAudioErrorCallback(NO_ERROR);
68 }
Glenn Kasten18db49a2012-03-12 16:29:55 -070069 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080070 binder->linkToDeath(gAudioFlingerClient);
71 gAudioFlinger = interface_cast<IAudioFlinger>(binder);
72 gAudioFlinger->registerClient(gAudioFlingerClient);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080073 }
Steve Block3762c312012-01-06 19:20:56 +000074 ALOGE_IF(gAudioFlinger==0, "no AudioFlinger!?");
Eric Laurenta553c252009-07-17 12:17:14 -070075
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080076 return gAudioFlinger;
77}
78
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080079status_t AudioSystem::muteMicrophone(bool state) {
80 const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
81 if (af == 0) return PERMISSION_DENIED;
82 return af->setMicMute(state);
83}
84
85status_t AudioSystem::isMicrophoneMuted(bool* state) {
86 const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
87 if (af == 0) return PERMISSION_DENIED;
88 *state = af->getMicMute();
89 return NO_ERROR;
90}
91
92status_t AudioSystem::setMasterVolume(float value)
93{
94 const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
95 if (af == 0) return PERMISSION_DENIED;
96 af->setMasterVolume(value);
97 return NO_ERROR;
98}
99
100status_t AudioSystem::setMasterMute(bool mute)
101{
102 const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
103 if (af == 0) return PERMISSION_DENIED;
104 af->setMasterMute(mute);
105 return NO_ERROR;
106}
107
108status_t AudioSystem::getMasterVolume(float* volume)
109{
110 const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
111 if (af == 0) return PERMISSION_DENIED;
112 *volume = af->masterVolume();
113 return NO_ERROR;
114}
115
116status_t AudioSystem::getMasterMute(bool* mute)
117{
118 const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
119 if (af == 0) return PERMISSION_DENIED;
120 *mute = af->masterMute();
121 return NO_ERROR;
122}
123
Glenn Kasten39d00cb2012-01-17 11:09:42 -0800124status_t AudioSystem::setStreamVolume(audio_stream_type_t stream, float value,
125 audio_io_handle_t output)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800126{
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700127 if (uint32_t(stream) >= AUDIO_STREAM_CNT) return BAD_VALUE;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800128 const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
129 if (af == 0) return PERMISSION_DENIED;
Eric Laurenta553c252009-07-17 12:17:14 -0700130 af->setStreamVolume(stream, value, output);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800131 return NO_ERROR;
132}
133
Glenn Kastenbc1d77b2012-01-12 16:38:12 -0800134status_t AudioSystem::setStreamMute(audio_stream_type_t stream, bool mute)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800135{
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700136 if (uint32_t(stream) >= AUDIO_STREAM_CNT) return BAD_VALUE;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800137 const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
138 if (af == 0) return PERMISSION_DENIED;
139 af->setStreamMute(stream, mute);
140 return NO_ERROR;
141}
142
Glenn Kasten39d00cb2012-01-17 11:09:42 -0800143status_t AudioSystem::getStreamVolume(audio_stream_type_t stream, float* volume,
144 audio_io_handle_t output)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800145{
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700146 if (uint32_t(stream) >= AUDIO_STREAM_CNT) return BAD_VALUE;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800147 const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
148 if (af == 0) return PERMISSION_DENIED;
Eric Laurenta553c252009-07-17 12:17:14 -0700149 *volume = af->streamVolume(stream, output);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800150 return NO_ERROR;
151}
152
Glenn Kastenbc1d77b2012-01-12 16:38:12 -0800153status_t AudioSystem::getStreamMute(audio_stream_type_t stream, bool* mute)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800154{
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700155 if (uint32_t(stream) >= AUDIO_STREAM_CNT) return BAD_VALUE;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800156 const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
157 if (af == 0) return PERMISSION_DENIED;
158 *mute = af->streamMute(stream);
159 return NO_ERROR;
160}
161
Glenn Kastenaccb1142012-01-04 11:00:47 -0800162status_t AudioSystem::setMode(audio_mode_t mode)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800163{
Glenn Kasten01aaf2c2012-01-06 16:47:31 -0800164 if (uint32_t(mode) >= AUDIO_MODE_CNT) return BAD_VALUE;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800165 const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
166 if (af == 0) return PERMISSION_DENIED;
167 return af->setMode(mode);
168}
169
Eric Laurenta553c252009-07-17 12:17:14 -0700170status_t AudioSystem::setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800171 const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
172 if (af == 0) return PERMISSION_DENIED;
Eric Laurenta553c252009-07-17 12:17:14 -0700173 return af->setParameters(ioHandle, keyValuePairs);
174}
175
176String8 AudioSystem::getParameters(audio_io_handle_t ioHandle, const String8& keys) {
177 const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
178 String8 result = String8("");
179 if (af == 0) return result;
180
181 result = af->getParameters(ioHandle, keys);
182 return result;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800183}
184
185// convert volume steps to natural log scale
186
187// change this value to change volume scaling
188static const float dBPerStep = 0.5f;
189// shouldn't need to touch these
190static const float dBConvert = -dBPerStep * 2.302585093f / 20.0f;
191static const float dBConvertInverse = 1.0f / dBConvert;
192
193float AudioSystem::linearToLog(int volume)
194{
195 // float v = volume ? exp(float(100 - volume) * dBConvert) : 0;
Steve Block5baa3a62011-12-20 16:23:08 +0000196 // ALOGD("linearToLog(%d)=%f", volume, v);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800197 // return v;
198 return volume ? exp(float(100 - volume) * dBConvert) : 0;
199}
200
201int AudioSystem::logToLinear(float volume)
202{
203 // int v = volume ? 100 - int(dBConvertInverse * log(volume) + 0.5) : 0;
Steve Block5baa3a62011-12-20 16:23:08 +0000204 // ALOGD("logTolinear(%d)=%f", v, volume);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800205 // return v;
206 return volume ? 100 - int(dBConvertInverse * log(volume) + 0.5) : 0;
207}
208
Andreas Huber28ea0132012-01-18 10:51:55 -0800209// DEPRECATED
210status_t AudioSystem::getOutputSamplingRate(int* samplingRate, int streamType) {
211 return getOutputSamplingRate(samplingRate, (audio_stream_type_t)streamType);
212}
213
Glenn Kastenbc1d77b2012-01-12 16:38:12 -0800214status_t AudioSystem::getOutputSamplingRate(int* samplingRate, audio_stream_type_t streamType)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800215{
Eric Laurenta553c252009-07-17 12:17:14 -0700216 OutputDescriptor *outputDesc;
217 audio_io_handle_t output;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800218
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700219 if (streamType == AUDIO_STREAM_DEFAULT) {
220 streamType = AUDIO_STREAM_MUSIC;
Eric Laurenta553c252009-07-17 12:17:14 -0700221 }
222
Glenn Kastenbc1d77b2012-01-12 16:38:12 -0800223 output = getOutput(streamType);
Eric Laurenta553c252009-07-17 12:17:14 -0700224 if (output == 0) {
225 return PERMISSION_DENIED;
226 }
227
228 gLock.lock();
229 outputDesc = AudioSystem::gOutputs.valueFor(output);
Glenn Kasten3694ec12012-01-27 16:47:15 -0800230 if (outputDesc == NULL) {
Steve Block71f2cf12011-10-20 11:56:00 +0100231 ALOGV("getOutputSamplingRate() no output descriptor for output %d in gOutputs", output);
Eric Laurenta553c252009-07-17 12:17:14 -0700232 gLock.unlock();
233 const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
234 if (af == 0) return PERMISSION_DENIED;
235 *samplingRate = af->sampleRate(output);
236 } else {
Steve Block71f2cf12011-10-20 11:56:00 +0100237 ALOGV("getOutputSamplingRate() reading from output desc");
Eric Laurenta553c252009-07-17 12:17:14 -0700238 *samplingRate = outputDesc->samplingRate;
239 gLock.unlock();
240 }
241
Steve Block71f2cf12011-10-20 11:56:00 +0100242 ALOGV("getOutputSamplingRate() streamType %d, output %d, sampling rate %d", streamType, output, *samplingRate);
Eric Laurenta553c252009-07-17 12:17:14 -0700243
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800244 return NO_ERROR;
245}
246
Andreas Huber28ea0132012-01-18 10:51:55 -0800247// DEPRECATED
248status_t AudioSystem::getOutputFrameCount(int* frameCount, int streamType) {
249 return getOutputFrameCount(frameCount, (audio_stream_type_t)streamType);
250}
251
Glenn Kastenbc1d77b2012-01-12 16:38:12 -0800252status_t AudioSystem::getOutputFrameCount(int* frameCount, audio_stream_type_t streamType)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800253{
Eric Laurenta553c252009-07-17 12:17:14 -0700254 OutputDescriptor *outputDesc;
255 audio_io_handle_t output;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800256
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700257 if (streamType == AUDIO_STREAM_DEFAULT) {
258 streamType = AUDIO_STREAM_MUSIC;
Eric Laurenta553c252009-07-17 12:17:14 -0700259 }
Eric Laurent3547cc02009-04-02 09:32:43 -0700260
Glenn Kastenbc1d77b2012-01-12 16:38:12 -0800261 output = getOutput(streamType);
Eric Laurenta553c252009-07-17 12:17:14 -0700262 if (output == 0) {
263 return PERMISSION_DENIED;
264 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800265
Eric Laurenta553c252009-07-17 12:17:14 -0700266 gLock.lock();
267 outputDesc = AudioSystem::gOutputs.valueFor(output);
Glenn Kasten3694ec12012-01-27 16:47:15 -0800268 if (outputDesc == NULL) {
Eric Laurenta553c252009-07-17 12:17:14 -0700269 gLock.unlock();
270 const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
271 if (af == 0) return PERMISSION_DENIED;
272 *frameCount = af->frameCount(output);
273 } else {
274 *frameCount = outputDesc->frameCount;
275 gLock.unlock();
276 }
277
Steve Block71f2cf12011-10-20 11:56:00 +0100278 ALOGV("getOutputFrameCount() streamType %d, output %d, frameCount %d", streamType, output, *frameCount);
Eric Laurenta553c252009-07-17 12:17:14 -0700279
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800280 return NO_ERROR;
281}
282
Glenn Kastenbc1d77b2012-01-12 16:38:12 -0800283status_t AudioSystem::getOutputLatency(uint32_t* latency, audio_stream_type_t streamType)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800284{
Eric Laurenta553c252009-07-17 12:17:14 -0700285 OutputDescriptor *outputDesc;
286 audio_io_handle_t output;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800287
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700288 if (streamType == AUDIO_STREAM_DEFAULT) {
289 streamType = AUDIO_STREAM_MUSIC;
Eric Laurenta553c252009-07-17 12:17:14 -0700290 }
Eric Laurent3547cc02009-04-02 09:32:43 -0700291
Glenn Kastenbc1d77b2012-01-12 16:38:12 -0800292 output = getOutput(streamType);
Eric Laurenta553c252009-07-17 12:17:14 -0700293 if (output == 0) {
294 return PERMISSION_DENIED;
295 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800296
Eric Laurenta553c252009-07-17 12:17:14 -0700297 gLock.lock();
298 outputDesc = AudioSystem::gOutputs.valueFor(output);
Glenn Kasten3694ec12012-01-27 16:47:15 -0800299 if (outputDesc == NULL) {
Eric Laurenta553c252009-07-17 12:17:14 -0700300 gLock.unlock();
301 const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
302 if (af == 0) return PERMISSION_DENIED;
303 *latency = af->latency(output);
304 } else {
305 *latency = outputDesc->latency;
306 gLock.unlock();
307 }
308
Steve Block71f2cf12011-10-20 11:56:00 +0100309 ALOGV("getOutputLatency() streamType %d, output %d, latency %d", streamType, output, *latency);
Eric Laurenta553c252009-07-17 12:17:14 -0700310
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800311 return NO_ERROR;
312}
313
Glenn Kasten0a204ed2012-01-12 12:27:51 -0800314status_t AudioSystem::getInputBufferSize(uint32_t sampleRate, audio_format_t format, int channelCount,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800315 size_t* buffSize)
316{
Glenn Kasten81801ad2012-01-10 09:01:19 -0800317 gLock.lock();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800318 // Do we have a stale gInBufferSize or are we requesting the input buffer size for new values
Glenn Kasten81801ad2012-01-10 09:01:19 -0800319 size_t inBuffSize = gInBuffSize;
320 if ((inBuffSize == 0) || (sampleRate != gPrevInSamplingRate) || (format != gPrevInFormat)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800321 || (channelCount != gPrevInChannelCount)) {
Glenn Kasten81801ad2012-01-10 09:01:19 -0800322 gLock.unlock();
323 const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
324 if (af == 0) {
325 return PERMISSION_DENIED;
326 }
327 inBuffSize = af->getInputBufferSize(sampleRate, format, channelCount);
328 gLock.lock();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800329 // save the request params
330 gPrevInSamplingRate = sampleRate;
Eric Laurenta553c252009-07-17 12:17:14 -0700331 gPrevInFormat = format;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800332 gPrevInChannelCount = channelCount;
333
Glenn Kasten81801ad2012-01-10 09:01:19 -0800334 gInBuffSize = inBuffSize;
Eric Laurenta553c252009-07-17 12:17:14 -0700335 }
Glenn Kasten81801ad2012-01-10 09:01:19 -0800336 gLock.unlock();
337 *buffSize = inBuffSize;
Eric Laurenta553c252009-07-17 12:17:14 -0700338
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800339 return NO_ERROR;
340}
341
Eric Laurent415f3e22009-10-21 08:14:22 -0700342status_t AudioSystem::setVoiceVolume(float value)
343{
344 const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
345 if (af == 0) return PERMISSION_DENIED;
346 return af->setVoiceVolume(value);
347}
348
Glenn Kastenbc1d77b2012-01-12 16:38:12 -0800349status_t AudioSystem::getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, audio_stream_type_t stream)
Eric Laurent0986e792010-01-19 17:37:09 -0800350{
351 const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
352 if (af == 0) return PERMISSION_DENIED;
353
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700354 if (stream == AUDIO_STREAM_DEFAULT) {
355 stream = AUDIO_STREAM_MUSIC;
Eric Laurent0986e792010-01-19 17:37:09 -0800356 }
357
Glenn Kastenbc1d77b2012-01-12 16:38:12 -0800358 return af->getRenderPosition(halFrames, dspFrames, getOutput(stream));
Eric Laurent0986e792010-01-19 17:37:09 -0800359}
360
Eric Laurent47d0a922010-02-26 02:47:27 -0800361unsigned int AudioSystem::getInputFramesLost(audio_io_handle_t ioHandle) {
362 const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
363 unsigned int result = 0;
364 if (af == 0) return result;
Eric Laurentef9500f2010-03-11 14:47:00 -0800365 if (ioHandle == 0) return result;
Eric Laurent47d0a922010-02-26 02:47:27 -0800366
367 result = af->getInputFramesLost(ioHandle);
368 return result;
369}
370
Eric Laurent65b65452010-06-01 23:49:17 -0700371int AudioSystem::newAudioSessionId() {
372 const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
373 if (af == 0) return 0;
374 return af->newAudioSessionId();
375}
376
Marco Nelissenc74b93f2011-08-02 13:33:41 -0700377void AudioSystem::acquireAudioSessionId(int audioSession) {
378 const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
379 if (af != 0) {
380 af->acquireAudioSessionId(audioSession);
381 }
382}
383
384void AudioSystem::releaseAudioSessionId(int audioSession) {
385 const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
386 if (af != 0) {
387 af->releaseAudioSessionId(audioSession);
388 }
389}
390
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800391// ---------------------------------------------------------------------------
392
Eric Laurenta553c252009-07-17 12:17:14 -0700393void AudioSystem::AudioFlingerClient::binderDied(const wp<IBinder>& who) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800394 Mutex::Autolock _l(AudioSystem::gLock);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800395
Eric Laurenta553c252009-07-17 12:17:14 -0700396 AudioSystem::gAudioFlinger.clear();
Eric Laurent787aa592010-01-25 10:27:15 -0800397 // clear output handles and stream to output map caches
398 AudioSystem::gStreamOutputMap.clear();
399 AudioSystem::gOutputs.clear();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800400
401 if (gAudioErrorCallback) {
402 gAudioErrorCallback(DEAD_OBJECT);
403 }
Steve Block8564c8d2012-01-05 23:22:43 +0000404 ALOGW("AudioFlinger server died!");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800405}
406
Glenn Kasten39d00cb2012-01-17 11:09:42 -0800407void AudioSystem::AudioFlingerClient::ioConfigChanged(int event, audio_io_handle_t ioHandle,
Glenn Kastenffed04a2012-03-01 09:14:51 -0800408 const void *param2) {
Steve Block71f2cf12011-10-20 11:56:00 +0100409 ALOGV("ioConfigChanged() event %d", event);
Glenn Kastenffed04a2012-03-01 09:14:51 -0800410 const OutputDescriptor *desc;
Glenn Kastenb7cffb42012-01-20 09:37:45 -0800411 audio_stream_type_t stream;
Eric Laurenta553c252009-07-17 12:17:14 -0700412
Eric Laurentddb78e72009-07-28 08:44:33 -0700413 if (ioHandle == 0) return;
Eric Laurenta553c252009-07-17 12:17:14 -0700414
415 Mutex::Autolock _l(AudioSystem::gLock);
416
417 switch (event) {
418 case STREAM_CONFIG_CHANGED:
Glenn Kasten3694ec12012-01-27 16:47:15 -0800419 if (param2 == NULL) break;
Glenn Kastenffed04a2012-03-01 09:14:51 -0800420 stream = *(const audio_stream_type_t *)param2;
Steve Block71f2cf12011-10-20 11:56:00 +0100421 ALOGV("ioConfigChanged() STREAM_CONFIG_CHANGED stream %d, output %d", stream, ioHandle);
Eric Laurenta553c252009-07-17 12:17:14 -0700422 if (gStreamOutputMap.indexOfKey(stream) >= 0) {
423 gStreamOutputMap.replaceValueFor(stream, ioHandle);
424 }
425 break;
426 case OUTPUT_OPENED: {
427 if (gOutputs.indexOfKey(ioHandle) >= 0) {
Steve Block71f2cf12011-10-20 11:56:00 +0100428 ALOGV("ioConfigChanged() opening already existing output! %d", ioHandle);
Eric Laurenta553c252009-07-17 12:17:14 -0700429 break;
430 }
Glenn Kasten3694ec12012-01-27 16:47:15 -0800431 if (param2 == NULL) break;
Glenn Kastenffed04a2012-03-01 09:14:51 -0800432 desc = (const OutputDescriptor *)param2;
Eric Laurenta553c252009-07-17 12:17:14 -0700433
434 OutputDescriptor *outputDesc = new OutputDescriptor(*desc);
435 gOutputs.add(ioHandle, outputDesc);
Steve Block71f2cf12011-10-20 11:56:00 +0100436 ALOGV("ioConfigChanged() new output samplingRate %d, format %d channels %d frameCount %d latency %d",
Eric Laurenta553c252009-07-17 12:17:14 -0700437 outputDesc->samplingRate, outputDesc->format, outputDesc->channels, outputDesc->frameCount, outputDesc->latency);
438 } break;
439 case OUTPUT_CLOSED: {
440 if (gOutputs.indexOfKey(ioHandle) < 0) {
Steve Block8564c8d2012-01-05 23:22:43 +0000441 ALOGW("ioConfigChanged() closing unknow output! %d", ioHandle);
Eric Laurenta553c252009-07-17 12:17:14 -0700442 break;
443 }
Steve Block71f2cf12011-10-20 11:56:00 +0100444 ALOGV("ioConfigChanged() output %d closed", ioHandle);
Eric Laurenta553c252009-07-17 12:17:14 -0700445
446 gOutputs.removeItem(ioHandle);
447 for (int i = gStreamOutputMap.size() - 1; i >= 0 ; i--) {
448 if (gStreamOutputMap.valueAt(i) == ioHandle) {
449 gStreamOutputMap.removeItemsAt(i);
450 }
451 }
452 } break;
453
454 case OUTPUT_CONFIG_CHANGED: {
455 int index = gOutputs.indexOfKey(ioHandle);
456 if (index < 0) {
Steve Block8564c8d2012-01-05 23:22:43 +0000457 ALOGW("ioConfigChanged() modifying unknow output! %d", ioHandle);
Eric Laurenta553c252009-07-17 12:17:14 -0700458 break;
459 }
Glenn Kasten3694ec12012-01-27 16:47:15 -0800460 if (param2 == NULL) break;
Glenn Kastenffed04a2012-03-01 09:14:51 -0800461 desc = (const OutputDescriptor *)param2;
Eric Laurenta553c252009-07-17 12:17:14 -0700462
Steve Block71f2cf12011-10-20 11:56:00 +0100463 ALOGV("ioConfigChanged() new config for output %d samplingRate %d, format %d channels %d frameCount %d latency %d",
Eric Laurenta553c252009-07-17 12:17:14 -0700464 ioHandle, desc->samplingRate, desc->format,
465 desc->channels, desc->frameCount, desc->latency);
466 OutputDescriptor *outputDesc = gOutputs.valueAt(index);
467 delete outputDesc;
468 outputDesc = new OutputDescriptor(*desc);
469 gOutputs.replaceValueFor(ioHandle, outputDesc);
470 } break;
471 case INPUT_OPENED:
472 case INPUT_CLOSED:
473 case INPUT_CONFIG_CHANGED:
474 break;
475
476 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800477}
478
479void AudioSystem::setErrorCallback(audio_error_callback cb) {
Eric Laurenta553c252009-07-17 12:17:14 -0700480 Mutex::Autolock _l(gLock);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800481 gAudioErrorCallback = cb;
482}
483
Glenn Kastenbc1d77b2012-01-12 16:38:12 -0800484bool AudioSystem::routedToA2dpOutput(audio_stream_type_t streamType) {
Glenn Kasten18db49a2012-03-12 16:29:55 -0700485 switch (streamType) {
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700486 case AUDIO_STREAM_MUSIC:
487 case AUDIO_STREAM_VOICE_CALL:
488 case AUDIO_STREAM_BLUETOOTH_SCO:
489 case AUDIO_STREAM_SYSTEM:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800490 return true;
491 default:
492 return false;
493 }
494}
495
496
Eric Laurenta553c252009-07-17 12:17:14 -0700497// client singleton for AudioPolicyService binder interface
498sp<IAudioPolicyService> AudioSystem::gAudioPolicyService;
499sp<AudioSystem::AudioPolicyServiceClient> AudioSystem::gAudioPolicyServiceClient;
500
501
502// establish binder interface to AudioFlinger service
503const sp<IAudioPolicyService>& AudioSystem::get_audio_policy_service()
504{
505 gLock.lock();
Glenn Kasten70ed6b72012-01-10 10:46:34 -0800506 if (gAudioPolicyService == 0) {
Eric Laurenta553c252009-07-17 12:17:14 -0700507 sp<IServiceManager> sm = defaultServiceManager();
508 sp<IBinder> binder;
509 do {
510 binder = sm->getService(String16("media.audio_policy"));
511 if (binder != 0)
512 break;
Steve Block8564c8d2012-01-05 23:22:43 +0000513 ALOGW("AudioPolicyService not published, waiting...");
Eric Laurenta553c252009-07-17 12:17:14 -0700514 usleep(500000); // 0.5 s
Glenn Kasten18db49a2012-03-12 16:29:55 -0700515 } while (true);
Eric Laurenta553c252009-07-17 12:17:14 -0700516 if (gAudioPolicyServiceClient == NULL) {
517 gAudioPolicyServiceClient = new AudioPolicyServiceClient();
518 }
519 binder->linkToDeath(gAudioPolicyServiceClient);
520 gAudioPolicyService = interface_cast<IAudioPolicyService>(binder);
521 gLock.unlock();
522 } else {
523 gLock.unlock();
524 }
525 return gAudioPolicyService;
526}
527
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700528status_t AudioSystem::setDeviceConnectionState(audio_devices_t device,
529 audio_policy_dev_state_t state,
530 const char *device_address)
Eric Laurenta553c252009-07-17 12:17:14 -0700531{
532 const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
Eric Laurentdca56b92011-09-02 14:20:56 -0700533 const char *address = "";
534
Eric Laurenta553c252009-07-17 12:17:14 -0700535 if (aps == 0) return PERMISSION_DENIED;
536
Eric Laurentdca56b92011-09-02 14:20:56 -0700537 if (device_address != NULL) {
538 address = device_address;
539 }
540
541 return aps->setDeviceConnectionState(device, state, address);
Eric Laurenta553c252009-07-17 12:17:14 -0700542}
543
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700544audio_policy_dev_state_t AudioSystem::getDeviceConnectionState(audio_devices_t device,
Eric Laurenta553c252009-07-17 12:17:14 -0700545 const char *device_address)
546{
547 const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700548 if (aps == 0) return AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE;
Eric Laurenta553c252009-07-17 12:17:14 -0700549
550 return aps->getDeviceConnectionState(device, device_address);
551}
552
Glenn Kastenaccb1142012-01-04 11:00:47 -0800553status_t AudioSystem::setPhoneState(audio_mode_t state)
Eric Laurenta553c252009-07-17 12:17:14 -0700554{
Glenn Kasten8f397cd2012-01-18 14:58:32 -0800555 if (uint32_t(state) >= AUDIO_MODE_CNT) return BAD_VALUE;
Eric Laurenta553c252009-07-17 12:17:14 -0700556 const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
557 if (aps == 0) return PERMISSION_DENIED;
558
559 return aps->setPhoneState(state);
560}
561
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700562status_t AudioSystem::setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config)
Eric Laurenta553c252009-07-17 12:17:14 -0700563{
564 const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
565 if (aps == 0) return PERMISSION_DENIED;
566 return aps->setForceUse(usage, config);
567}
568
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700569audio_policy_forced_cfg_t AudioSystem::getForceUse(audio_policy_force_use_t usage)
Eric Laurenta553c252009-07-17 12:17:14 -0700570{
571 const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700572 if (aps == 0) return AUDIO_POLICY_FORCE_NONE;
Eric Laurenta553c252009-07-17 12:17:14 -0700573 return aps->getForceUse(usage);
574}
575
576
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700577audio_io_handle_t AudioSystem::getOutput(audio_stream_type_t stream,
Eric Laurenta553c252009-07-17 12:17:14 -0700578 uint32_t samplingRate,
Glenn Kasten0a204ed2012-01-12 12:27:51 -0800579 audio_format_t format,
Eric Laurenta553c252009-07-17 12:17:14 -0700580 uint32_t channels,
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700581 audio_policy_output_flags_t flags)
Eric Laurenta553c252009-07-17 12:17:14 -0700582{
Eric Laurentddb78e72009-07-28 08:44:33 -0700583 audio_io_handle_t output = 0;
Eric Laurentef9500f2010-03-11 14:47:00 -0800584 // Do not use stream to output map cache if the direct output
585 // flag is set or if we are likely to use a direct output
586 // (e.g voice call stream @ 8kHz could use BT SCO device and be routed to
587 // a direct output on some platforms).
588 // TODO: the output cache and stream to output mapping implementation needs to
589 // be reworked for proper operation with direct outputs. This code is too specific
590 // to the first use case we want to cover (Voice Recognition and Voice Dialer over
591 // Bluetooth SCO
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700592 if ((flags & AUDIO_POLICY_OUTPUT_FLAG_DIRECT) == 0 &&
593 ((stream != AUDIO_STREAM_VOICE_CALL && stream != AUDIO_STREAM_BLUETOOTH_SCO) ||
594 channels != AUDIO_CHANNEL_OUT_MONO ||
Eric Laurentef9500f2010-03-11 14:47:00 -0800595 (samplingRate != 8000 && samplingRate != 16000))) {
Eric Laurenta553c252009-07-17 12:17:14 -0700596 Mutex::Autolock _l(gLock);
597 output = AudioSystem::gStreamOutputMap.valueFor(stream);
Steve Block71f2cf12011-10-20 11:56:00 +0100598 ALOGV_IF((output != 0), "getOutput() read %d from cache for stream %d", output, stream);
Eric Laurenta553c252009-07-17 12:17:14 -0700599 }
Eric Laurentddb78e72009-07-28 08:44:33 -0700600 if (output == 0) {
Eric Laurenta553c252009-07-17 12:17:14 -0700601 const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
Eric Laurentddb78e72009-07-28 08:44:33 -0700602 if (aps == 0) return 0;
Eric Laurenta553c252009-07-17 12:17:14 -0700603 output = aps->getOutput(stream, samplingRate, format, channels, flags);
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700604 if ((flags & AUDIO_POLICY_OUTPUT_FLAG_DIRECT) == 0) {
Eric Laurenta553c252009-07-17 12:17:14 -0700605 Mutex::Autolock _l(gLock);
606 AudioSystem::gStreamOutputMap.add(stream, output);
607 }
608 }
609 return output;
610}
611
Eric Laurent8ed6ed02010-07-13 04:45:46 -0700612status_t AudioSystem::startOutput(audio_io_handle_t output,
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700613 audio_stream_type_t stream,
Eric Laurent8ed6ed02010-07-13 04:45:46 -0700614 int session)
Eric Laurenta553c252009-07-17 12:17:14 -0700615{
616 const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
617 if (aps == 0) return PERMISSION_DENIED;
Eric Laurent8ed6ed02010-07-13 04:45:46 -0700618 return aps->startOutput(output, stream, session);
Eric Laurenta553c252009-07-17 12:17:14 -0700619}
620
Eric Laurent8ed6ed02010-07-13 04:45:46 -0700621status_t AudioSystem::stopOutput(audio_io_handle_t output,
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700622 audio_stream_type_t stream,
Eric Laurent8ed6ed02010-07-13 04:45:46 -0700623 int session)
Eric Laurenta553c252009-07-17 12:17:14 -0700624{
625 const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
626 if (aps == 0) return PERMISSION_DENIED;
Eric Laurent8ed6ed02010-07-13 04:45:46 -0700627 return aps->stopOutput(output, stream, session);
Eric Laurenta553c252009-07-17 12:17:14 -0700628}
629
630void AudioSystem::releaseOutput(audio_io_handle_t output)
631{
632 const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
633 if (aps == 0) return;
634 aps->releaseOutput(output);
635}
636
Glenn Kasten0f0fbd92012-01-23 13:58:49 -0800637audio_io_handle_t AudioSystem::getInput(audio_source_t inputSource,
Eric Laurenta553c252009-07-17 12:17:14 -0700638 uint32_t samplingRate,
Glenn Kasten0a204ed2012-01-12 12:27:51 -0800639 audio_format_t format,
Eric Laurenta553c252009-07-17 12:17:14 -0700640 uint32_t channels,
Eric Laurent464d5b32011-06-17 21:29:58 -0700641 audio_in_acoustics_t acoustics,
642 int sessionId)
Eric Laurenta553c252009-07-17 12:17:14 -0700643{
644 const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
Eric Laurentddb78e72009-07-28 08:44:33 -0700645 if (aps == 0) return 0;
Eric Laurent464d5b32011-06-17 21:29:58 -0700646 return aps->getInput(inputSource, samplingRate, format, channels, acoustics, sessionId);
Eric Laurenta553c252009-07-17 12:17:14 -0700647}
648
649status_t AudioSystem::startInput(audio_io_handle_t input)
650{
651 const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
652 if (aps == 0) return PERMISSION_DENIED;
653 return aps->startInput(input);
654}
655
656status_t AudioSystem::stopInput(audio_io_handle_t input)
657{
658 const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
659 if (aps == 0) return PERMISSION_DENIED;
660 return aps->stopInput(input);
661}
662
663void AudioSystem::releaseInput(audio_io_handle_t input)
664{
665 const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
666 if (aps == 0) return;
667 aps->releaseInput(input);
668}
669
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700670status_t AudioSystem::initStreamVolume(audio_stream_type_t stream,
Eric Laurenta553c252009-07-17 12:17:14 -0700671 int indexMin,
672 int indexMax)
673{
674 const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
675 if (aps == 0) return PERMISSION_DENIED;
676 return aps->initStreamVolume(stream, indexMin, indexMax);
677}
678
Eric Laurent9bc8358d2011-11-18 16:43:31 -0800679status_t AudioSystem::setStreamVolumeIndex(audio_stream_type_t stream,
680 int index,
681 audio_devices_t device)
Eric Laurenta553c252009-07-17 12:17:14 -0700682{
683 const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
684 if (aps == 0) return PERMISSION_DENIED;
Eric Laurent9bc8358d2011-11-18 16:43:31 -0800685 return aps->setStreamVolumeIndex(stream, index, device);
Eric Laurenta553c252009-07-17 12:17:14 -0700686}
687
Eric Laurent9bc8358d2011-11-18 16:43:31 -0800688status_t AudioSystem::getStreamVolumeIndex(audio_stream_type_t stream,
689 int *index,
690 audio_devices_t device)
Eric Laurenta553c252009-07-17 12:17:14 -0700691{
692 const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
693 if (aps == 0) return PERMISSION_DENIED;
Eric Laurent9bc8358d2011-11-18 16:43:31 -0800694 return aps->getStreamVolumeIndex(stream, index, device);
Eric Laurenta553c252009-07-17 12:17:14 -0700695}
696
Dima Zavin24fc2fb2011-04-19 22:30:36 -0700697uint32_t AudioSystem::getStrategyForStream(audio_stream_type_t stream)
Eric Laurent8ed6ed02010-07-13 04:45:46 -0700698{
699 const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
700 if (aps == 0) return 0;
701 return aps->getStrategyForStream(stream);
702}
703
Eric Laurentc9ab9f52012-03-08 13:42:42 -0800704audio_devices_t AudioSystem::getDevicesForStream(audio_stream_type_t stream)
Glenn Kasten8b4b97a2011-02-04 13:54:26 -0800705{
706 const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
Eric Laurentc9ab9f52012-03-08 13:42:42 -0800707 if (aps == 0) return (audio_devices_t)0;
Glenn Kasten8b4b97a2011-02-04 13:54:26 -0800708 return aps->getDevicesForStream(stream);
709}
710
Eric Laurent8ed6ed02010-07-13 04:45:46 -0700711audio_io_handle_t AudioSystem::getOutputForEffect(effect_descriptor_t *desc)
712{
713 const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
714 if (aps == 0) return PERMISSION_DENIED;
715 return aps->getOutputForEffect(desc);
716}
717
718status_t AudioSystem::registerEffect(effect_descriptor_t *desc,
Eric Laurent464d5b32011-06-17 21:29:58 -0700719 audio_io_handle_t io,
Eric Laurent8ed6ed02010-07-13 04:45:46 -0700720 uint32_t strategy,
721 int session,
722 int id)
723{
724 const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
725 if (aps == 0) return PERMISSION_DENIED;
Eric Laurent464d5b32011-06-17 21:29:58 -0700726 return aps->registerEffect(desc, io, strategy, session, id);
Eric Laurent8ed6ed02010-07-13 04:45:46 -0700727}
728
729status_t AudioSystem::unregisterEffect(int id)
730{
731 const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
732 if (aps == 0) return PERMISSION_DENIED;
733 return aps->unregisterEffect(id);
734}
735
Eric Laurent6752ec82011-08-10 10:37:50 -0700736status_t AudioSystem::setEffectEnabled(int id, bool enabled)
737{
738 const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
739 if (aps == 0) return PERMISSION_DENIED;
740 return aps->setEffectEnabled(id, enabled);
741}
742
Glenn Kastenbc1d77b2012-01-12 16:38:12 -0800743status_t AudioSystem::isStreamActive(audio_stream_type_t stream, bool* state, uint32_t inPastMs)
Eric Laurent464d5b32011-06-17 21:29:58 -0700744{
Eric Laurent25101b02011-02-02 09:33:30 -0800745 const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
746 if (aps == 0) return PERMISSION_DENIED;
Eric Laurent464d5b32011-06-17 21:29:58 -0700747 if (state == NULL) return BAD_VALUE;
Eric Laurent25101b02011-02-02 09:33:30 -0800748 *state = aps->isStreamActive(stream, inPastMs);
749 return NO_ERROR;
750}
751
752
Eric Laurent05ce0942011-08-30 10:18:54 -0700753void AudioSystem::clearAudioConfigCache()
754{
755 Mutex::Autolock _l(gLock);
Steve Block71f2cf12011-10-20 11:56:00 +0100756 ALOGV("clearAudioConfigCache()");
Eric Laurent05ce0942011-08-30 10:18:54 -0700757 gStreamOutputMap.clear();
758 gOutputs.clear();
759}
760
Eric Laurenta553c252009-07-17 12:17:14 -0700761// ---------------------------------------------------------------------------
762
763void AudioSystem::AudioPolicyServiceClient::binderDied(const wp<IBinder>& who) {
764 Mutex::Autolock _l(AudioSystem::gLock);
765 AudioSystem::gAudioPolicyService.clear();
766
Steve Block8564c8d2012-01-05 23:22:43 +0000767 ALOGW("AudioPolicyService server died!");
Eric Laurenta553c252009-07-17 12:17:14 -0700768}
769
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800770}; // namespace android