blob: e86f4a2423bf091439d937872ba76a93d1489429 [file] [log] [blame]
Mathias Agopian65ab4712010-07-14 17:59:35 -07001/*
2 * Copyright (C) 2009 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 "AudioPolicyService"
18//#define LOG_NDEBUG 0
19
Glenn Kasten153b9fe2013-07-15 11:23:36 -070020#include "Configuration.h"
Mathias Agopian65ab4712010-07-14 17:59:35 -070021#undef __STRICT_ANSI__
22#define __STDINT_LIMITS
23#define __STDC_LIMIT_MACROS
24#include <stdint.h>
25
26#include <sys/time.h>
27#include <binder/IServiceManager.h>
28#include <utils/Log.h>
29#include <cutils/properties.h>
30#include <binder/IPCThreadState.h>
31#include <utils/String16.h>
32#include <utils/threads.h>
33#include "AudioPolicyService.h"
Glenn Kasten44deb052012-02-05 18:09:08 -080034#include "ServiceUtilities.h"
Mathias Agopian65ab4712010-07-14 17:59:35 -070035#include <hardware_legacy/power.h>
Eric Laurent7c7f10b2011-06-17 21:29:58 -070036#include <media/AudioEffect.h>
37#include <media/EffectsFactoryApi.h>
Mathias Agopian65ab4712010-07-14 17:59:35 -070038
Dima Zavinfce7a472011-04-19 22:30:36 -070039#include <hardware/hardware.h>
Dima Zavin64760242011-05-11 14:15:23 -070040#include <system/audio.h>
Dima Zavin7394a4f2011-06-13 18:16:26 -070041#include <system/audio_policy.h>
Dima Zavinfce7a472011-04-19 22:30:36 -070042#include <hardware/audio_policy.h>
Eric Laurent7c7f10b2011-06-17 21:29:58 -070043#include <audio_effects/audio_effects_conf.h>
Glenn Kasten1ab85ec2013-05-31 09:18:43 -070044#include <media/AudioParameter.h>
Dima Zavinfce7a472011-04-19 22:30:36 -070045
Mathias Agopian65ab4712010-07-14 17:59:35 -070046namespace android {
47
Glenn Kasten8dad0e32012-01-09 08:41:22 -080048static const char kDeadlockedString[] = "AudioPolicyService may be deadlocked\n";
49static const char kCmdDeadlockedString[] = "AudioPolicyService command thread may be deadlocked\n";
Mathias Agopian65ab4712010-07-14 17:59:35 -070050
51static const int kDumpLockRetries = 50;
Glenn Kasten22ecc912012-01-09 08:33:38 -080052static const int kDumpLockSleepUs = 20000;
Mathias Agopian65ab4712010-07-14 17:59:35 -070053
Eric Laurent0ede8922014-05-09 18:04:42 -070054static const nsecs_t kAudioCommandTimeoutNs = seconds(3); // 3 seconds
Christer Fletcher5fa8c4b2013-01-18 15:27:03 +010055
Dima Zavinfce7a472011-04-19 22:30:36 -070056namespace {
57 extern struct audio_policy_service_ops aps_ops;
58};
59
Mathias Agopian65ab4712010-07-14 17:59:35 -070060// ----------------------------------------------------------------------------
61
62AudioPolicyService::AudioPolicyService()
Eric Laurentdce54a12014-03-10 12:19:46 -070063 : BnAudioPolicyService(), mpAudioPolicyDev(NULL), mpAudioPolicy(NULL),
64 mAudioPolicyManager(NULL), mAudioPolicyClient(NULL)
Mathias Agopian65ab4712010-07-14 17:59:35 -070065{
66 char value[PROPERTY_VALUE_MAX];
Dima Zavinfce7a472011-04-19 22:30:36 -070067 const struct hw_module_t *module;
68 int forced_val;
69 int rc;
Mathias Agopian65ab4712010-07-14 17:59:35 -070070
Eric Laurent93575202011-01-18 18:39:02 -080071 Mutex::Autolock _l(mLock);
72
Mathias Agopian65ab4712010-07-14 17:59:35 -070073 // start tone playback thread
Eric Laurentbfb1b832013-01-07 09:53:42 -080074 mTonePlaybackThread = new AudioCommandThread(String8("ApmTone"), this);
Mathias Agopian65ab4712010-07-14 17:59:35 -070075 // start audio commands thread
Eric Laurentbfb1b832013-01-07 09:53:42 -080076 mAudioCommandThread = new AudioCommandThread(String8("ApmAudio"), this);
77 // start output activity command thread
78 mOutputCommandThread = new AudioCommandThread(String8("ApmOutput"), this);
Eric Laurentdce54a12014-03-10 12:19:46 -070079
80#ifdef USE_LEGACY_AUDIO_POLICY
81 ALOGI("AudioPolicyService CSTOR in legacy mode");
82
Dima Zavinfce7a472011-04-19 22:30:36 -070083 /* instantiate the audio policy manager */
84 rc = hw_get_module(AUDIO_POLICY_HARDWARE_MODULE_ID, &module);
Glenn Kasten6e2ebe92013-08-13 09:14:51 -070085 if (rc) {
Dima Zavinfce7a472011-04-19 22:30:36 -070086 return;
Glenn Kasten6e2ebe92013-08-13 09:14:51 -070087 }
Dima Zavinfce7a472011-04-19 22:30:36 -070088 rc = audio_policy_dev_open(module, &mpAudioPolicyDev);
Steve Block29357bc2012-01-06 19:20:56 +000089 ALOGE_IF(rc, "couldn't open audio policy device (%s)", strerror(-rc));
Glenn Kasten6e2ebe92013-08-13 09:14:51 -070090 if (rc) {
Dima Zavinfce7a472011-04-19 22:30:36 -070091 return;
Glenn Kasten6e2ebe92013-08-13 09:14:51 -070092 }
Eric Laurent93575202011-01-18 18:39:02 -080093
Dima Zavinfce7a472011-04-19 22:30:36 -070094 rc = mpAudioPolicyDev->create_audio_policy(mpAudioPolicyDev, &aps_ops, this,
95 &mpAudioPolicy);
Steve Block29357bc2012-01-06 19:20:56 +000096 ALOGE_IF(rc, "couldn't create audio policy (%s)", strerror(-rc));
Glenn Kasten6e2ebe92013-08-13 09:14:51 -070097 if (rc) {
Dima Zavinfce7a472011-04-19 22:30:36 -070098 return;
Glenn Kasten6e2ebe92013-08-13 09:14:51 -070099 }
Dima Zavinfce7a472011-04-19 22:30:36 -0700100
101 rc = mpAudioPolicy->init_check(mpAudioPolicy);
Steve Block29357bc2012-01-06 19:20:56 +0000102 ALOGE_IF(rc, "couldn't init_check the audio policy (%s)", strerror(-rc));
Glenn Kasten6e2ebe92013-08-13 09:14:51 -0700103 if (rc) {
Dima Zavinfce7a472011-04-19 22:30:36 -0700104 return;
Glenn Kasten6e2ebe92013-08-13 09:14:51 -0700105 }
Steve Blockdf64d152012-01-04 20:05:49 +0000106 ALOGI("Loaded audio policy from %s (%s)", module->name, module->id);
Eric Laurentdce54a12014-03-10 12:19:46 -0700107#else
108 ALOGI("AudioPolicyService CSTOR in new mode");
109
110 mAudioPolicyClient = new AudioPolicyClient(this);
111 mAudioPolicyManager = new AudioPolicyManager(mAudioPolicyClient);
112#endif
Eric Laurent7c7f10b2011-06-17 21:29:58 -0700113
114 // load audio pre processing modules
115 if (access(AUDIO_EFFECT_VENDOR_CONFIG_FILE, R_OK) == 0) {
116 loadPreProcessorConfig(AUDIO_EFFECT_VENDOR_CONFIG_FILE);
117 } else if (access(AUDIO_EFFECT_DEFAULT_CONFIG_FILE, R_OK) == 0) {
118 loadPreProcessorConfig(AUDIO_EFFECT_DEFAULT_CONFIG_FILE);
119 }
Mathias Agopian65ab4712010-07-14 17:59:35 -0700120}
121
122AudioPolicyService::~AudioPolicyService()
123{
124 mTonePlaybackThread->exit();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700125 mAudioCommandThread->exit();
Eric Laurent657ff612014-05-07 11:58:24 -0700126 mOutputCommandThread->exit();
Eric Laurent7c7f10b2011-06-17 21:29:58 -0700127
128 // release audio pre processing resources
129 for (size_t i = 0; i < mInputSources.size(); i++) {
Glenn Kasten9fda4b82012-02-02 14:04:37 -0800130 delete mInputSources.valueAt(i);
Eric Laurent7c7f10b2011-06-17 21:29:58 -0700131 }
132 mInputSources.clear();
133
134 for (size_t i = 0; i < mInputs.size(); i++) {
135 mInputs.valueAt(i)->mEffects.clear();
136 delete mInputs.valueAt(i);
137 }
138 mInputs.clear();
139
Eric Laurentdce54a12014-03-10 12:19:46 -0700140#ifdef USE_LEGACY_AUDIO_POLICY
Glenn Kasten6e2ebe92013-08-13 09:14:51 -0700141 if (mpAudioPolicy != NULL && mpAudioPolicyDev != NULL) {
Dima Zavinfce7a472011-04-19 22:30:36 -0700142 mpAudioPolicyDev->destroy_audio_policy(mpAudioPolicyDev, mpAudioPolicy);
Glenn Kasten6e2ebe92013-08-13 09:14:51 -0700143 }
144 if (mpAudioPolicyDev != NULL) {
Dima Zavinfce7a472011-04-19 22:30:36 -0700145 audio_policy_dev_close(mpAudioPolicyDev);
Glenn Kasten6e2ebe92013-08-13 09:14:51 -0700146 }
Eric Laurentdce54a12014-03-10 12:19:46 -0700147#else
148 delete mAudioPolicyManager;
149 delete mAudioPolicyClient;
150#endif
Eric Laurentb52c1522014-05-20 11:27:36 -0700151
152 mNotificationClients.clear();
153}
154
155// A notification client is always registered by AudioSystem when the client process
156// connects to AudioPolicyService.
157void AudioPolicyService::registerClient(const sp<IAudioPolicyServiceClient>& client)
158{
159
160 Mutex::Autolock _l(mLock);
161
162 uid_t uid = IPCThreadState::self()->getCallingUid();
163 if (mNotificationClients.indexOfKey(uid) < 0) {
164 sp<NotificationClient> notificationClient = new NotificationClient(this,
165 client,
166 uid);
167 ALOGV("registerClient() client %p, uid %d", client.get(), uid);
168
169 mNotificationClients.add(uid, notificationClient);
170
171 sp<IBinder> binder = client->asBinder();
172 binder->linkToDeath(notificationClient);
173 }
174}
175
176// removeNotificationClient() is called when the client process dies.
177void AudioPolicyService::removeNotificationClient(uid_t uid)
178{
179 Mutex::Autolock _l(mLock);
180
181 mNotificationClients.removeItem(uid);
182
183#ifndef USE_LEGACY_AUDIO_POLICY
184 if (mAudioPolicyManager) {
185 mAudioPolicyManager->clearAudioPatches(uid);
186 }
187#endif
188}
189
190void AudioPolicyService::onAudioPortListUpdate()
191{
192 mOutputCommandThread->updateAudioPortListCommand();
193}
194
195void AudioPolicyService::doOnAudioPortListUpdate()
196{
197 Mutex::Autolock _l(mLock);
198 for (size_t i = 0; i < mNotificationClients.size(); i++) {
199 mNotificationClients.valueAt(i)->onAudioPortListUpdate();
200 }
201}
202
203void AudioPolicyService::onAudioPatchListUpdate()
204{
205 mOutputCommandThread->updateAudioPatchListCommand();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700206}
207
Eric Laurent951f4552014-05-20 10:48:17 -0700208status_t AudioPolicyService::clientCreateAudioPatch(const struct audio_patch *patch,
209 audio_patch_handle_t *handle,
210 int delayMs)
211{
212 return mAudioCommandThread->createAudioPatchCommand(patch, handle, delayMs);
213}
214
215status_t AudioPolicyService::clientReleaseAudioPatch(audio_patch_handle_t handle,
216 int delayMs)
217{
218 return mAudioCommandThread->releaseAudioPatchCommand(handle, delayMs);
219}
220
Eric Laurentb52c1522014-05-20 11:27:36 -0700221void AudioPolicyService::doOnAudioPatchListUpdate()
222{
223 Mutex::Autolock _l(mLock);
224 for (size_t i = 0; i < mNotificationClients.size(); i++) {
225 mNotificationClients.valueAt(i)->onAudioPatchListUpdate();
226 }
227}
228
Eric Laurente1715a42014-05-20 11:30:42 -0700229status_t AudioPolicyService::clientSetAudioPortConfig(const struct audio_port_config *config,
230 int delayMs)
231{
232 return mAudioCommandThread->setAudioPortConfigCommand(config, delayMs);
233}
234
Eric Laurentb52c1522014-05-20 11:27:36 -0700235AudioPolicyService::NotificationClient::NotificationClient(const sp<AudioPolicyService>& service,
236 const sp<IAudioPolicyServiceClient>& client,
237 uid_t uid)
238 : mService(service), mUid(uid), mAudioPolicyServiceClient(client)
239{
240}
241
242AudioPolicyService::NotificationClient::~NotificationClient()
243{
244}
245
246void AudioPolicyService::NotificationClient::binderDied(const wp<IBinder>& who __unused)
247{
248 sp<NotificationClient> keep(this);
249 sp<AudioPolicyService> service = mService.promote();
250 if (service != 0) {
251 service->removeNotificationClient(mUid);
252 }
253}
254
255void AudioPolicyService::NotificationClient::onAudioPortListUpdate()
256{
257 if (mAudioPolicyServiceClient != 0) {
258 mAudioPolicyServiceClient->onAudioPortListUpdate();
259 }
260}
261
262void AudioPolicyService::NotificationClient::onAudioPatchListUpdate()
263{
264 if (mAudioPolicyServiceClient != 0) {
265 mAudioPolicyServiceClient->onAudioPatchListUpdate();
266 }
267}
Eric Laurent57dae992011-07-24 13:36:09 -0700268
Mathias Agopian65ab4712010-07-14 17:59:35 -0700269void AudioPolicyService::binderDied(const wp<IBinder>& who) {
Glenn Kasten411e4472012-11-02 10:00:06 -0700270 ALOGW("binderDied() %p, calling pid %d", who.unsafe_get(),
Eric Laurentde070132010-07-13 04:45:46 -0700271 IPCThreadState::self()->getCallingPid());
Mathias Agopian65ab4712010-07-14 17:59:35 -0700272}
273
274static bool tryLock(Mutex& mutex)
275{
276 bool locked = false;
277 for (int i = 0; i < kDumpLockRetries; ++i) {
278 if (mutex.tryLock() == NO_ERROR) {
279 locked = true;
280 break;
281 }
Glenn Kasten22ecc912012-01-09 08:33:38 -0800282 usleep(kDumpLockSleepUs);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700283 }
284 return locked;
285}
286
287status_t AudioPolicyService::dumpInternals(int fd)
288{
289 const size_t SIZE = 256;
290 char buffer[SIZE];
291 String8 result;
292
Eric Laurentdce54a12014-03-10 12:19:46 -0700293#ifdef USE_LEGACY_AUDIO_POLICY
Dima Zavinfce7a472011-04-19 22:30:36 -0700294 snprintf(buffer, SIZE, "PolicyManager Interface: %p\n", mpAudioPolicy);
Eric Laurentdce54a12014-03-10 12:19:46 -0700295#else
296 snprintf(buffer, SIZE, "AudioPolicyManager: %p\n", mAudioPolicyManager);
297#endif
Mathias Agopian65ab4712010-07-14 17:59:35 -0700298 result.append(buffer);
299 snprintf(buffer, SIZE, "Command Thread: %p\n", mAudioCommandThread.get());
300 result.append(buffer);
301 snprintf(buffer, SIZE, "Tones Thread: %p\n", mTonePlaybackThread.get());
302 result.append(buffer);
303
304 write(fd, result.string(), result.size());
305 return NO_ERROR;
306}
307
Glenn Kasten0f11b512014-01-31 16:18:54 -0800308status_t AudioPolicyService::dump(int fd, const Vector<String16>& args __unused)
Mathias Agopian65ab4712010-07-14 17:59:35 -0700309{
Glenn Kasten44deb052012-02-05 18:09:08 -0800310 if (!dumpAllowed()) {
Mathias Agopian65ab4712010-07-14 17:59:35 -0700311 dumpPermissionDenial(fd);
312 } else {
313 bool locked = tryLock(mLock);
314 if (!locked) {
315 String8 result(kDeadlockedString);
316 write(fd, result.string(), result.size());
317 }
318
319 dumpInternals(fd);
Glenn Kasten9d1f02d2012-02-08 17:47:58 -0800320 if (mAudioCommandThread != 0) {
Mathias Agopian65ab4712010-07-14 17:59:35 -0700321 mAudioCommandThread->dump(fd);
322 }
Glenn Kasten9d1f02d2012-02-08 17:47:58 -0800323 if (mTonePlaybackThread != 0) {
Mathias Agopian65ab4712010-07-14 17:59:35 -0700324 mTonePlaybackThread->dump(fd);
325 }
326
Eric Laurentdce54a12014-03-10 12:19:46 -0700327#ifdef USE_LEGACY_AUDIO_POLICY
Dima Zavinfce7a472011-04-19 22:30:36 -0700328 if (mpAudioPolicy) {
329 mpAudioPolicy->dump(mpAudioPolicy, fd);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700330 }
Eric Laurentdce54a12014-03-10 12:19:46 -0700331#else
332 if (mAudioPolicyManager) {
333 mAudioPolicyManager->dump(fd);
334 }
335#endif
Mathias Agopian65ab4712010-07-14 17:59:35 -0700336
337 if (locked) mLock.unlock();
338 }
339 return NO_ERROR;
340}
341
342status_t AudioPolicyService::dumpPermissionDenial(int fd)
343{
344 const size_t SIZE = 256;
345 char buffer[SIZE];
346 String8 result;
347 snprintf(buffer, SIZE, "Permission Denial: "
348 "can't dump AudioPolicyService from pid=%d, uid=%d\n",
349 IPCThreadState::self()->getCallingPid(),
350 IPCThreadState::self()->getCallingUid());
351 result.append(buffer);
352 write(fd, result.string(), result.size());
353 return NO_ERROR;
354}
355
Glenn Kasten81872a22012-03-07 16:49:22 -0800356void AudioPolicyService::setPreProcessorEnabled(const InputDesc *inputDesc, bool enabled)
Eric Laurent7c7f10b2011-06-17 21:29:58 -0700357{
Glenn Kasten81872a22012-03-07 16:49:22 -0800358 const Vector<sp<AudioEffect> > &fxVector = inputDesc->mEffects;
Eric Laurent7c7f10b2011-06-17 21:29:58 -0700359 for (size_t i = 0; i < fxVector.size(); i++) {
Glenn Kastena1117922012-01-26 10:53:32 -0800360 fxVector.itemAt(i)->setEnabled(enabled);
Eric Laurent7c7f10b2011-06-17 21:29:58 -0700361 }
362}
363
Mathias Agopian65ab4712010-07-14 17:59:35 -0700364status_t AudioPolicyService::onTransact(
365 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
366{
367 return BnAudioPolicyService::onTransact(code, data, reply, flags);
368}
369
370
Mathias Agopian65ab4712010-07-14 17:59:35 -0700371// ----------- AudioPolicyService::AudioCommandThread implementation ----------
372
Eric Laurentbfb1b832013-01-07 09:53:42 -0800373AudioPolicyService::AudioCommandThread::AudioCommandThread(String8 name,
374 const wp<AudioPolicyService>& service)
375 : Thread(false), mName(name), mService(service)
Mathias Agopian65ab4712010-07-14 17:59:35 -0700376{
377 mpToneGenerator = NULL;
378}
379
380
381AudioPolicyService::AudioCommandThread::~AudioCommandThread()
382{
Eric Laurentbfb1b832013-01-07 09:53:42 -0800383 if (!mAudioCommands.isEmpty()) {
Mathias Agopian65ab4712010-07-14 17:59:35 -0700384 release_wake_lock(mName.string());
385 }
386 mAudioCommands.clear();
Glenn Kastene9dd0172012-01-27 18:08:45 -0800387 delete mpToneGenerator;
Mathias Agopian65ab4712010-07-14 17:59:35 -0700388}
389
390void AudioPolicyService::AudioCommandThread::onFirstRef()
391{
Eric Laurentbfb1b832013-01-07 09:53:42 -0800392 run(mName.string(), ANDROID_PRIORITY_AUDIO);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700393}
394
395bool AudioPolicyService::AudioCommandThread::threadLoop()
396{
397 nsecs_t waitTime = INT64_MAX;
398
399 mLock.lock();
400 while (!exitPending())
401 {
Eric Laurent59a89232014-06-08 14:14:17 -0700402 sp<AudioPolicyService> svc;
403 while (!mAudioCommands.isEmpty() && !exitPending()) {
Mathias Agopian65ab4712010-07-14 17:59:35 -0700404 nsecs_t curTime = systemTime();
405 // commands are sorted by increasing time stamp: execute them from index 0 and up
406 if (mAudioCommands[0]->mTime <= curTime) {
Eric Laurent0ede8922014-05-09 18:04:42 -0700407 sp<AudioCommand> command = mAudioCommands[0];
Mathias Agopian65ab4712010-07-14 17:59:35 -0700408 mAudioCommands.removeAt(0);
Eric Laurent0ede8922014-05-09 18:04:42 -0700409 mLastCommand = command;
Mathias Agopian65ab4712010-07-14 17:59:35 -0700410
411 switch (command->mCommand) {
412 case START_TONE: {
413 mLock.unlock();
Eric Laurent0ede8922014-05-09 18:04:42 -0700414 ToneData *data = (ToneData *)command->mParam.get();
Steve Block3856b092011-10-20 11:56:00 +0100415 ALOGV("AudioCommandThread() processing start tone %d on stream %d",
Mathias Agopian65ab4712010-07-14 17:59:35 -0700416 data->mType, data->mStream);
Glenn Kastene9dd0172012-01-27 18:08:45 -0800417 delete mpToneGenerator;
Mathias Agopian65ab4712010-07-14 17:59:35 -0700418 mpToneGenerator = new ToneGenerator(data->mStream, 1.0);
419 mpToneGenerator->startTone(data->mType);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700420 mLock.lock();
421 }break;
422 case STOP_TONE: {
423 mLock.unlock();
Steve Block3856b092011-10-20 11:56:00 +0100424 ALOGV("AudioCommandThread() processing stop tone");
Mathias Agopian65ab4712010-07-14 17:59:35 -0700425 if (mpToneGenerator != NULL) {
426 mpToneGenerator->stopTone();
427 delete mpToneGenerator;
428 mpToneGenerator = NULL;
429 }
430 mLock.lock();
431 }break;
432 case SET_VOLUME: {
Eric Laurent0ede8922014-05-09 18:04:42 -0700433 VolumeData *data = (VolumeData *)command->mParam.get();
Steve Block3856b092011-10-20 11:56:00 +0100434 ALOGV("AudioCommandThread() processing set volume stream %d, \
Eric Laurentde070132010-07-13 04:45:46 -0700435 volume %f, output %d", data->mStream, data->mVolume, data->mIO);
436 command->mStatus = AudioSystem::setStreamVolume(data->mStream,
437 data->mVolume,
438 data->mIO);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700439 }break;
440 case SET_PARAMETERS: {
Eric Laurent0ede8922014-05-09 18:04:42 -0700441 ParametersData *data = (ParametersData *)command->mParam.get();
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700442 ALOGV("AudioCommandThread() processing set parameters string %s, io %d",
443 data->mKeyValuePairs.string(), data->mIO);
444 command->mStatus = AudioSystem::setParameters(data->mIO, data->mKeyValuePairs);
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700445 }break;
Mathias Agopian65ab4712010-07-14 17:59:35 -0700446 case SET_VOICE_VOLUME: {
Eric Laurent0ede8922014-05-09 18:04:42 -0700447 VoiceVolumeData *data = (VoiceVolumeData *)command->mParam.get();
Steve Block3856b092011-10-20 11:56:00 +0100448 ALOGV("AudioCommandThread() processing set voice volume volume %f",
Eric Laurentde070132010-07-13 04:45:46 -0700449 data->mVolume);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700450 command->mStatus = AudioSystem::setVoiceVolume(data->mVolume);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700451 }break;
Eric Laurentbfb1b832013-01-07 09:53:42 -0800452 case STOP_OUTPUT: {
Eric Laurent0ede8922014-05-09 18:04:42 -0700453 StopOutputData *data = (StopOutputData *)command->mParam.get();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800454 ALOGV("AudioCommandThread() processing stop output %d",
455 data->mIO);
Eric Laurent59a89232014-06-08 14:14:17 -0700456 svc = mService.promote();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800457 if (svc == 0) {
458 break;
459 }
460 mLock.unlock();
461 svc->doStopOutput(data->mIO, data->mStream, data->mSession);
462 mLock.lock();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800463 }break;
464 case RELEASE_OUTPUT: {
Eric Laurent0ede8922014-05-09 18:04:42 -0700465 ReleaseOutputData *data = (ReleaseOutputData *)command->mParam.get();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800466 ALOGV("AudioCommandThread() processing release output %d",
467 data->mIO);
Eric Laurent59a89232014-06-08 14:14:17 -0700468 svc = mService.promote();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800469 if (svc == 0) {
470 break;
471 }
472 mLock.unlock();
473 svc->doReleaseOutput(data->mIO);
474 mLock.lock();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800475 }break;
Eric Laurent951f4552014-05-20 10:48:17 -0700476 case CREATE_AUDIO_PATCH: {
477 CreateAudioPatchData *data = (CreateAudioPatchData *)command->mParam.get();
478 ALOGV("AudioCommandThread() processing create audio patch");
479 sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
480 if (af == 0) {
481 command->mStatus = PERMISSION_DENIED;
482 } else {
483 command->mStatus = af->createAudioPatch(&data->mPatch, &data->mHandle);
484 }
485 } break;
486 case RELEASE_AUDIO_PATCH: {
487 ReleaseAudioPatchData *data = (ReleaseAudioPatchData *)command->mParam.get();
488 ALOGV("AudioCommandThread() processing release audio patch");
489 sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
490 if (af == 0) {
491 command->mStatus = PERMISSION_DENIED;
492 } else {
493 command->mStatus = af->releaseAudioPatch(data->mHandle);
494 }
495 } break;
Eric Laurentb52c1522014-05-20 11:27:36 -0700496 case UPDATE_AUDIOPORT_LIST: {
497 ALOGV("AudioCommandThread() processing update audio port list");
Eric Laurent59a89232014-06-08 14:14:17 -0700498 svc = mService.promote();
Eric Laurentb52c1522014-05-20 11:27:36 -0700499 if (svc == 0) {
500 break;
501 }
502 mLock.unlock();
503 svc->doOnAudioPortListUpdate();
504 mLock.lock();
505 }break;
506 case UPDATE_AUDIOPATCH_LIST: {
507 ALOGV("AudioCommandThread() processing update audio patch list");
Eric Laurent59a89232014-06-08 14:14:17 -0700508 svc = mService.promote();
Eric Laurentb52c1522014-05-20 11:27:36 -0700509 if (svc == 0) {
510 break;
511 }
512 mLock.unlock();
513 svc->doOnAudioPatchListUpdate();
514 mLock.lock();
515 }break;
Eric Laurente1715a42014-05-20 11:30:42 -0700516 case SET_AUDIOPORT_CONFIG: {
517 SetAudioPortConfigData *data = (SetAudioPortConfigData *)command->mParam.get();
518 ALOGV("AudioCommandThread() processing set port config");
519 sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
520 if (af == 0) {
521 command->mStatus = PERMISSION_DENIED;
522 } else {
523 command->mStatus = af->setAudioPortConfig(&data->mConfig);
524 }
525 } break;
Mathias Agopian65ab4712010-07-14 17:59:35 -0700526 default:
Steve Block5ff1dd52012-01-05 23:22:43 +0000527 ALOGW("AudioCommandThread() unknown command %d", command->mCommand);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700528 }
Eric Laurent0ede8922014-05-09 18:04:42 -0700529 {
530 Mutex::Autolock _l(command->mLock);
531 if (command->mWaitStatus) {
532 command->mWaitStatus = false;
533 command->mCond.signal();
534 }
535 }
Mathias Agopian65ab4712010-07-14 17:59:35 -0700536 waitTime = INT64_MAX;
537 } else {
538 waitTime = mAudioCommands[0]->mTime - curTime;
539 break;
540 }
541 }
542 // release delayed commands wake lock
Eric Laurentbfb1b832013-01-07 09:53:42 -0800543 if (mAudioCommands.isEmpty()) {
Mathias Agopian65ab4712010-07-14 17:59:35 -0700544 release_wake_lock(mName.string());
545 }
Eric Laurent59a89232014-06-08 14:14:17 -0700546 // release mLock before releasing strong reference on the service as
547 // AudioPolicyService destructor calls AudioCommandThread::exit() which acquires mLock.
548 mLock.unlock();
549 svc.clear();
550 mLock.lock();
551 if (!exitPending()) {
552 ALOGV("AudioCommandThread() going to sleep");
553 mWaitWorkCV.waitRelative(mLock, waitTime);
554 ALOGV("AudioCommandThread() waking up");
555 }
Mathias Agopian65ab4712010-07-14 17:59:35 -0700556 }
557 mLock.unlock();
558 return false;
559}
560
561status_t AudioPolicyService::AudioCommandThread::dump(int fd)
562{
563 const size_t SIZE = 256;
564 char buffer[SIZE];
565 String8 result;
566
567 snprintf(buffer, SIZE, "AudioCommandThread %p Dump\n", this);
568 result.append(buffer);
569 write(fd, result.string(), result.size());
570
571 bool locked = tryLock(mLock);
572 if (!locked) {
573 String8 result2(kCmdDeadlockedString);
574 write(fd, result2.string(), result2.size());
575 }
576
577 snprintf(buffer, SIZE, "- Commands:\n");
578 result = String8(buffer);
579 result.append(" Command Time Wait pParam\n");
Glenn Kasten8d6a2442012-02-08 14:04:28 -0800580 for (size_t i = 0; i < mAudioCommands.size(); i++) {
Mathias Agopian65ab4712010-07-14 17:59:35 -0700581 mAudioCommands[i]->dump(buffer, SIZE);
582 result.append(buffer);
583 }
584 result.append(" Last Command\n");
Eric Laurent0ede8922014-05-09 18:04:42 -0700585 if (mLastCommand != 0) {
586 mLastCommand->dump(buffer, SIZE);
587 result.append(buffer);
588 } else {
589 result.append(" none\n");
590 }
Mathias Agopian65ab4712010-07-14 17:59:35 -0700591
592 write(fd, result.string(), result.size());
593
594 if (locked) mLock.unlock();
595
596 return NO_ERROR;
597}
598
Glenn Kasten3d2f8772012-01-27 15:25:25 -0800599void AudioPolicyService::AudioCommandThread::startToneCommand(ToneGenerator::tone_type type,
600 audio_stream_type_t stream)
Mathias Agopian65ab4712010-07-14 17:59:35 -0700601{
Eric Laurent0ede8922014-05-09 18:04:42 -0700602 sp<AudioCommand> command = new AudioCommand();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700603 command->mCommand = START_TONE;
Eric Laurent0ede8922014-05-09 18:04:42 -0700604 sp<ToneData> data = new ToneData();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700605 data->mType = type;
606 data->mStream = stream;
Jesper Tragardh48412dc2014-03-24 14:12:43 +0100607 command->mParam = data;
Steve Block3856b092011-10-20 11:56:00 +0100608 ALOGV("AudioCommandThread() adding tone start type %d, stream %d", type, stream);
Eric Laurent0ede8922014-05-09 18:04:42 -0700609 sendCommand(command);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700610}
611
612void AudioPolicyService::AudioCommandThread::stopToneCommand()
613{
Eric Laurent0ede8922014-05-09 18:04:42 -0700614 sp<AudioCommand> command = new AudioCommand();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700615 command->mCommand = STOP_TONE;
Steve Block3856b092011-10-20 11:56:00 +0100616 ALOGV("AudioCommandThread() adding tone stop");
Eric Laurent0ede8922014-05-09 18:04:42 -0700617 sendCommand(command);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700618}
619
Glenn Kastenfff6d712012-01-12 16:38:12 -0800620status_t AudioPolicyService::AudioCommandThread::volumeCommand(audio_stream_type_t stream,
Eric Laurentde070132010-07-13 04:45:46 -0700621 float volume,
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800622 audio_io_handle_t output,
Eric Laurentde070132010-07-13 04:45:46 -0700623 int delayMs)
Mathias Agopian65ab4712010-07-14 17:59:35 -0700624{
Eric Laurent0ede8922014-05-09 18:04:42 -0700625 sp<AudioCommand> command = new AudioCommand();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700626 command->mCommand = SET_VOLUME;
Eric Laurent0ede8922014-05-09 18:04:42 -0700627 sp<VolumeData> data = new VolumeData();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700628 data->mStream = stream;
629 data->mVolume = volume;
630 data->mIO = output;
631 command->mParam = data;
Eric Laurent0ede8922014-05-09 18:04:42 -0700632 command->mWaitStatus = true;
Steve Block3856b092011-10-20 11:56:00 +0100633 ALOGV("AudioCommandThread() adding set volume stream %d, volume %f, output %d",
Eric Laurentde070132010-07-13 04:45:46 -0700634 stream, volume, output);
Eric Laurent0ede8922014-05-09 18:04:42 -0700635 return sendCommand(command, delayMs);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700636}
637
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800638status_t AudioPolicyService::AudioCommandThread::parametersCommand(audio_io_handle_t ioHandle,
Dima Zavinfce7a472011-04-19 22:30:36 -0700639 const char *keyValuePairs,
Eric Laurentde070132010-07-13 04:45:46 -0700640 int delayMs)
Mathias Agopian65ab4712010-07-14 17:59:35 -0700641{
Eric Laurent0ede8922014-05-09 18:04:42 -0700642 sp<AudioCommand> command = new AudioCommand();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700643 command->mCommand = SET_PARAMETERS;
Eric Laurent0ede8922014-05-09 18:04:42 -0700644 sp<ParametersData> data = new ParametersData();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700645 data->mIO = ioHandle;
Dima Zavinfce7a472011-04-19 22:30:36 -0700646 data->mKeyValuePairs = String8(keyValuePairs);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700647 command->mParam = data;
Eric Laurent0ede8922014-05-09 18:04:42 -0700648 command->mWaitStatus = true;
Steve Block3856b092011-10-20 11:56:00 +0100649 ALOGV("AudioCommandThread() adding set parameter string %s, io %d ,delay %d",
Dima Zavinfce7a472011-04-19 22:30:36 -0700650 keyValuePairs, ioHandle, delayMs);
Eric Laurent0ede8922014-05-09 18:04:42 -0700651 return sendCommand(command, delayMs);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700652}
653
654status_t AudioPolicyService::AudioCommandThread::voiceVolumeCommand(float volume, int delayMs)
655{
Eric Laurent0ede8922014-05-09 18:04:42 -0700656 sp<AudioCommand> command = new AudioCommand();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700657 command->mCommand = SET_VOICE_VOLUME;
Eric Laurent0ede8922014-05-09 18:04:42 -0700658 sp<VoiceVolumeData> data = new VoiceVolumeData();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700659 data->mVolume = volume;
660 command->mParam = data;
Eric Laurent0ede8922014-05-09 18:04:42 -0700661 command->mWaitStatus = true;
Steve Block3856b092011-10-20 11:56:00 +0100662 ALOGV("AudioCommandThread() adding set voice volume volume %f", volume);
Eric Laurent0ede8922014-05-09 18:04:42 -0700663 return sendCommand(command, delayMs);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700664}
665
Eric Laurentbfb1b832013-01-07 09:53:42 -0800666void AudioPolicyService::AudioCommandThread::stopOutputCommand(audio_io_handle_t output,
667 audio_stream_type_t stream,
668 int session)
669{
Eric Laurent0ede8922014-05-09 18:04:42 -0700670 sp<AudioCommand> command = new AudioCommand();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800671 command->mCommand = STOP_OUTPUT;
Eric Laurent0ede8922014-05-09 18:04:42 -0700672 sp<StopOutputData> data = new StopOutputData();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800673 data->mIO = output;
674 data->mStream = stream;
675 data->mSession = session;
Jesper Tragardh48412dc2014-03-24 14:12:43 +0100676 command->mParam = data;
Eric Laurentbfb1b832013-01-07 09:53:42 -0800677 ALOGV("AudioCommandThread() adding stop output %d", output);
Eric Laurent0ede8922014-05-09 18:04:42 -0700678 sendCommand(command);
Eric Laurentbfb1b832013-01-07 09:53:42 -0800679}
680
681void AudioPolicyService::AudioCommandThread::releaseOutputCommand(audio_io_handle_t output)
682{
Eric Laurent0ede8922014-05-09 18:04:42 -0700683 sp<AudioCommand> command = new AudioCommand();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800684 command->mCommand = RELEASE_OUTPUT;
Eric Laurent0ede8922014-05-09 18:04:42 -0700685 sp<ReleaseOutputData> data = new ReleaseOutputData();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800686 data->mIO = output;
Jesper Tragardh48412dc2014-03-24 14:12:43 +0100687 command->mParam = data;
Eric Laurentbfb1b832013-01-07 09:53:42 -0800688 ALOGV("AudioCommandThread() adding release output %d", output);
Eric Laurent0ede8922014-05-09 18:04:42 -0700689 sendCommand(command);
690}
691
Eric Laurent951f4552014-05-20 10:48:17 -0700692status_t AudioPolicyService::AudioCommandThread::createAudioPatchCommand(
693 const struct audio_patch *patch,
694 audio_patch_handle_t *handle,
695 int delayMs)
696{
697 status_t status = NO_ERROR;
698
699 sp<AudioCommand> command = new AudioCommand();
700 command->mCommand = CREATE_AUDIO_PATCH;
701 CreateAudioPatchData *data = new CreateAudioPatchData();
702 data->mPatch = *patch;
703 data->mHandle = *handle;
704 command->mParam = data;
705 command->mWaitStatus = true;
706 ALOGV("AudioCommandThread() adding create patch delay %d", delayMs);
707 status = sendCommand(command, delayMs);
708 if (status == NO_ERROR) {
709 *handle = data->mHandle;
710 }
711 return status;
712}
713
714status_t AudioPolicyService::AudioCommandThread::releaseAudioPatchCommand(audio_patch_handle_t handle,
715 int delayMs)
716{
717 sp<AudioCommand> command = new AudioCommand();
718 command->mCommand = RELEASE_AUDIO_PATCH;
719 ReleaseAudioPatchData *data = new ReleaseAudioPatchData();
720 data->mHandle = handle;
721 command->mParam = data;
722 command->mWaitStatus = true;
723 ALOGV("AudioCommandThread() adding release patch delay %d", delayMs);
724 return sendCommand(command, delayMs);
725}
726
Eric Laurentb52c1522014-05-20 11:27:36 -0700727void AudioPolicyService::AudioCommandThread::updateAudioPortListCommand()
728{
729 sp<AudioCommand> command = new AudioCommand();
730 command->mCommand = UPDATE_AUDIOPORT_LIST;
731 ALOGV("AudioCommandThread() adding update audio port list");
732 sendCommand(command);
733}
734
735void AudioPolicyService::AudioCommandThread::updateAudioPatchListCommand()
736{
737 sp<AudioCommand>command = new AudioCommand();
738 command->mCommand = UPDATE_AUDIOPATCH_LIST;
739 ALOGV("AudioCommandThread() adding update audio patch list");
740 sendCommand(command);
741}
742
Eric Laurente1715a42014-05-20 11:30:42 -0700743status_t AudioPolicyService::AudioCommandThread::setAudioPortConfigCommand(
744 const struct audio_port_config *config, int delayMs)
745{
746 sp<AudioCommand> command = new AudioCommand();
747 command->mCommand = SET_AUDIOPORT_CONFIG;
748 SetAudioPortConfigData *data = new SetAudioPortConfigData();
749 data->mConfig = *config;
750 command->mParam = data;
751 command->mWaitStatus = true;
752 ALOGV("AudioCommandThread() adding set port config delay %d", delayMs);
753 return sendCommand(command, delayMs);
754}
755
Eric Laurent0ede8922014-05-09 18:04:42 -0700756status_t AudioPolicyService::AudioCommandThread::sendCommand(sp<AudioCommand>& command, int delayMs)
757{
758 {
759 Mutex::Autolock _l(mLock);
760 insertCommand_l(command, delayMs);
761 mWaitWorkCV.signal();
762 }
763 Mutex::Autolock _l(command->mLock);
764 while (command->mWaitStatus) {
765 nsecs_t timeOutNs = kAudioCommandTimeoutNs + milliseconds(delayMs);
766 if (command->mCond.waitRelative(command->mLock, timeOutNs) != NO_ERROR) {
767 command->mStatus = TIMED_OUT;
768 command->mWaitStatus = false;
769 }
770 }
771 return command->mStatus;
Eric Laurentbfb1b832013-01-07 09:53:42 -0800772}
773
Mathias Agopian65ab4712010-07-14 17:59:35 -0700774// insertCommand_l() must be called with mLock held
Eric Laurent0ede8922014-05-09 18:04:42 -0700775void AudioPolicyService::AudioCommandThread::insertCommand_l(sp<AudioCommand>& command, int delayMs)
Mathias Agopian65ab4712010-07-14 17:59:35 -0700776{
Glenn Kasten8d6a2442012-02-08 14:04:28 -0800777 ssize_t i; // not size_t because i will count down to -1
Eric Laurent0ede8922014-05-09 18:04:42 -0700778 Vector < sp<AudioCommand> > removedCommands;
Mathias Agopian65ab4712010-07-14 17:59:35 -0700779 command->mTime = systemTime() + milliseconds(delayMs);
780
781 // acquire wake lock to make sure delayed commands are processed
Eric Laurentbfb1b832013-01-07 09:53:42 -0800782 if (mAudioCommands.isEmpty()) {
Mathias Agopian65ab4712010-07-14 17:59:35 -0700783 acquire_wake_lock(PARTIAL_WAKE_LOCK, mName.string());
784 }
785
786 // check same pending commands with later time stamps and eliminate them
787 for (i = mAudioCommands.size()-1; i >= 0; i--) {
Eric Laurent0ede8922014-05-09 18:04:42 -0700788 sp<AudioCommand> command2 = mAudioCommands[i];
Mathias Agopian65ab4712010-07-14 17:59:35 -0700789 // commands are sorted by increasing time stamp: no need to scan the rest of mAudioCommands
790 if (command2->mTime <= command->mTime) break;
791 if (command2->mCommand != command->mCommand) continue;
792
793 switch (command->mCommand) {
794 case SET_PARAMETERS: {
Eric Laurent0ede8922014-05-09 18:04:42 -0700795 ParametersData *data = (ParametersData *)command->mParam.get();
796 ParametersData *data2 = (ParametersData *)command2->mParam.get();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700797 if (data->mIO != data2->mIO) break;
Steve Block3856b092011-10-20 11:56:00 +0100798 ALOGV("Comparing parameter command %s to new command %s",
Eric Laurentde070132010-07-13 04:45:46 -0700799 data2->mKeyValuePairs.string(), data->mKeyValuePairs.string());
Mathias Agopian65ab4712010-07-14 17:59:35 -0700800 AudioParameter param = AudioParameter(data->mKeyValuePairs);
801 AudioParameter param2 = AudioParameter(data2->mKeyValuePairs);
802 for (size_t j = 0; j < param.size(); j++) {
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700803 String8 key;
804 String8 value;
805 param.getAt(j, key, value);
806 for (size_t k = 0; k < param2.size(); k++) {
807 String8 key2;
808 String8 value2;
809 param2.getAt(k, key2, value2);
810 if (key2 == key) {
811 param2.remove(key2);
812 ALOGV("Filtering out parameter %s", key2.string());
813 break;
814 }
815 }
Mathias Agopian65ab4712010-07-14 17:59:35 -0700816 }
817 // if all keys have been filtered out, remove the command.
818 // otherwise, update the key value pairs
819 if (param2.size() == 0) {
820 removedCommands.add(command2);
821 } else {
822 data2->mKeyValuePairs = param2.toString();
823 }
Eric Laurent21e54562013-09-23 12:08:05 -0700824 command->mTime = command2->mTime;
825 // force delayMs to non 0 so that code below does not request to wait for
826 // command status as the command is now delayed
827 delayMs = 1;
Mathias Agopian65ab4712010-07-14 17:59:35 -0700828 } break;
829
830 case SET_VOLUME: {
Eric Laurent0ede8922014-05-09 18:04:42 -0700831 VolumeData *data = (VolumeData *)command->mParam.get();
832 VolumeData *data2 = (VolumeData *)command2->mParam.get();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700833 if (data->mIO != data2->mIO) break;
834 if (data->mStream != data2->mStream) break;
Steve Block3856b092011-10-20 11:56:00 +0100835 ALOGV("Filtering out volume command on output %d for stream %d",
Eric Laurentde070132010-07-13 04:45:46 -0700836 data->mIO, data->mStream);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700837 removedCommands.add(command2);
Eric Laurent21e54562013-09-23 12:08:05 -0700838 command->mTime = command2->mTime;
839 // force delayMs to non 0 so that code below does not request to wait for
840 // command status as the command is now delayed
841 delayMs = 1;
Mathias Agopian65ab4712010-07-14 17:59:35 -0700842 } break;
843 case START_TONE:
844 case STOP_TONE:
845 default:
846 break;
847 }
848 }
849
850 // remove filtered commands
851 for (size_t j = 0; j < removedCommands.size(); j++) {
852 // removed commands always have time stamps greater than current command
853 for (size_t k = i + 1; k < mAudioCommands.size(); k++) {
Eric Laurent0ede8922014-05-09 18:04:42 -0700854 if (mAudioCommands[k].get() == removedCommands[j].get()) {
Steve Block3856b092011-10-20 11:56:00 +0100855 ALOGV("suppressing command: %d", mAudioCommands[k]->mCommand);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700856 mAudioCommands.removeAt(k);
857 break;
858 }
859 }
860 }
861 removedCommands.clear();
862
Eric Laurent0ede8922014-05-09 18:04:42 -0700863 // Disable wait for status if delay is not 0
864 if (delayMs != 0) {
Eric Laurentcec4abb2012-07-03 12:23:02 -0700865 command->mWaitStatus = false;
866 }
Eric Laurentcec4abb2012-07-03 12:23:02 -0700867
Mathias Agopian65ab4712010-07-14 17:59:35 -0700868 // insert command at the right place according to its time stamp
Steve Block3856b092011-10-20 11:56:00 +0100869 ALOGV("inserting command: %d at index %d, num commands %d",
Eric Laurentde070132010-07-13 04:45:46 -0700870 command->mCommand, (int)i+1, mAudioCommands.size());
Mathias Agopian65ab4712010-07-14 17:59:35 -0700871 mAudioCommands.insertAt(command, i + 1);
872}
873
874void AudioPolicyService::AudioCommandThread::exit()
875{
Steve Block3856b092011-10-20 11:56:00 +0100876 ALOGV("AudioCommandThread::exit");
Mathias Agopian65ab4712010-07-14 17:59:35 -0700877 {
878 AutoMutex _l(mLock);
879 requestExit();
880 mWaitWorkCV.signal();
881 }
882 requestExitAndWait();
883}
884
885void AudioPolicyService::AudioCommandThread::AudioCommand::dump(char* buffer, size_t size)
886{
887 snprintf(buffer, size, " %02d %06d.%03d %01u %p\n",
888 mCommand,
889 (int)ns2s(mTime),
890 (int)ns2ms(mTime)%1000,
891 mWaitStatus,
Eric Laurent0ede8922014-05-09 18:04:42 -0700892 mParam.get());
Mathias Agopian65ab4712010-07-14 17:59:35 -0700893}
894
Dima Zavinfce7a472011-04-19 22:30:36 -0700895/******* helpers for the service_ops callbacks defined below *********/
896void AudioPolicyService::setParameters(audio_io_handle_t ioHandle,
897 const char *keyValuePairs,
898 int delayMs)
899{
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800900 mAudioCommandThread->parametersCommand(ioHandle, keyValuePairs,
Dima Zavinfce7a472011-04-19 22:30:36 -0700901 delayMs);
902}
903
904int AudioPolicyService::setStreamVolume(audio_stream_type_t stream,
905 float volume,
906 audio_io_handle_t output,
907 int delayMs)
908{
Glenn Kastenfff6d712012-01-12 16:38:12 -0800909 return (int)mAudioCommandThread->volumeCommand(stream, volume,
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800910 output, delayMs);
Dima Zavinfce7a472011-04-19 22:30:36 -0700911}
912
913int AudioPolicyService::startTone(audio_policy_tone_t tone,
914 audio_stream_type_t stream)
915{
Glenn Kasten6e2ebe92013-08-13 09:14:51 -0700916 if (tone != AUDIO_POLICY_TONE_IN_CALL_NOTIFICATION) {
Steve Block29357bc2012-01-06 19:20:56 +0000917 ALOGE("startTone: illegal tone requested (%d)", tone);
Glenn Kasten6e2ebe92013-08-13 09:14:51 -0700918 }
919 if (stream != AUDIO_STREAM_VOICE_CALL) {
Steve Block29357bc2012-01-06 19:20:56 +0000920 ALOGE("startTone: illegal stream (%d) requested for tone %d", stream,
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700921 tone);
Glenn Kasten6e2ebe92013-08-13 09:14:51 -0700922 }
Dima Zavinfce7a472011-04-19 22:30:36 -0700923 mTonePlaybackThread->startToneCommand(ToneGenerator::TONE_SUP_CALL_WAITING,
924 AUDIO_STREAM_VOICE_CALL);
925 return 0;
926}
927
928int AudioPolicyService::stopTone()
929{
930 mTonePlaybackThread->stopToneCommand();
931 return 0;
932}
933
934int AudioPolicyService::setVoiceVolume(float volume, int delayMs)
935{
936 return (int)mAudioCommandThread->voiceVolumeCommand(volume, delayMs);
937}
938
Eric Laurent7c7f10b2011-06-17 21:29:58 -0700939// ----------------------------------------------------------------------------
940// Audio pre-processing configuration
941// ----------------------------------------------------------------------------
942
Glenn Kasten8dad0e32012-01-09 08:41:22 -0800943/*static*/ const char * const AudioPolicyService::kInputSourceNames[AUDIO_SOURCE_CNT -1] = {
Eric Laurent7c7f10b2011-06-17 21:29:58 -0700944 MIC_SRC_TAG,
945 VOICE_UL_SRC_TAG,
946 VOICE_DL_SRC_TAG,
947 VOICE_CALL_SRC_TAG,
948 CAMCORDER_SRC_TAG,
949 VOICE_REC_SRC_TAG,
950 VOICE_COMM_SRC_TAG
951};
952
953// returns the audio_source_t enum corresponding to the input source name or
954// AUDIO_SOURCE_CNT is no match found
955audio_source_t AudioPolicyService::inputSourceNameToEnum(const char *name)
956{
957 int i;
958 for (i = AUDIO_SOURCE_MIC; i < AUDIO_SOURCE_CNT; i++) {
959 if (strcmp(name, kInputSourceNames[i - AUDIO_SOURCE_MIC]) == 0) {
Steve Block3856b092011-10-20 11:56:00 +0100960 ALOGV("inputSourceNameToEnum found source %s %d", name, i);
Eric Laurent7c7f10b2011-06-17 21:29:58 -0700961 break;
962 }
963 }
964 return (audio_source_t)i;
965}
966
967size_t AudioPolicyService::growParamSize(char *param,
968 size_t size,
969 size_t *curSize,
970 size_t *totSize)
971{
972 // *curSize is at least sizeof(effect_param_t) + 2 * sizeof(int)
973 size_t pos = ((*curSize - 1 ) / size + 1) * size;
974
975 if (pos + size > *totSize) {
976 while (pos + size > *totSize) {
977 *totSize += ((*totSize + 7) / 8) * 4;
978 }
979 param = (char *)realloc(param, *totSize);
980 }
981 *curSize = pos + size;
982 return pos;
983}
984
985size_t AudioPolicyService::readParamValue(cnode *node,
986 char *param,
987 size_t *curSize,
988 size_t *totSize)
989{
990 if (strncmp(node->name, SHORT_TAG, sizeof(SHORT_TAG) + 1) == 0) {
991 size_t pos = growParamSize(param, sizeof(short), curSize, totSize);
992 *(short *)((char *)param + pos) = (short)atoi(node->value);
Steve Block3856b092011-10-20 11:56:00 +0100993 ALOGV("readParamValue() reading short %d", *(short *)((char *)param + pos));
Eric Laurent7c7f10b2011-06-17 21:29:58 -0700994 return sizeof(short);
995 } else if (strncmp(node->name, INT_TAG, sizeof(INT_TAG) + 1) == 0) {
996 size_t pos = growParamSize(param, sizeof(int), curSize, totSize);
997 *(int *)((char *)param + pos) = atoi(node->value);
Steve Block3856b092011-10-20 11:56:00 +0100998 ALOGV("readParamValue() reading int %d", *(int *)((char *)param + pos));
Eric Laurent7c7f10b2011-06-17 21:29:58 -0700999 return sizeof(int);
1000 } else if (strncmp(node->name, FLOAT_TAG, sizeof(FLOAT_TAG) + 1) == 0) {
1001 size_t pos = growParamSize(param, sizeof(float), curSize, totSize);
1002 *(float *)((char *)param + pos) = (float)atof(node->value);
Steve Block3856b092011-10-20 11:56:00 +01001003 ALOGV("readParamValue() reading float %f",*(float *)((char *)param + pos));
Eric Laurent7c7f10b2011-06-17 21:29:58 -07001004 return sizeof(float);
1005 } else if (strncmp(node->name, BOOL_TAG, sizeof(BOOL_TAG) + 1) == 0) {
1006 size_t pos = growParamSize(param, sizeof(bool), curSize, totSize);
1007 if (strncmp(node->value, "false", strlen("false") + 1) == 0) {
1008 *(bool *)((char *)param + pos) = false;
1009 } else {
1010 *(bool *)((char *)param + pos) = true;
1011 }
Steve Block3856b092011-10-20 11:56:00 +01001012 ALOGV("readParamValue() reading bool %s",*(bool *)((char *)param + pos) ? "true" : "false");
Eric Laurent7c7f10b2011-06-17 21:29:58 -07001013 return sizeof(bool);
1014 } else if (strncmp(node->name, STRING_TAG, sizeof(STRING_TAG) + 1) == 0) {
1015 size_t len = strnlen(node->value, EFFECT_STRING_LEN_MAX);
1016 if (*curSize + len + 1 > *totSize) {
1017 *totSize = *curSize + len + 1;
1018 param = (char *)realloc(param, *totSize);
1019 }
1020 strncpy(param + *curSize, node->value, len);
1021 *curSize += len;
1022 param[*curSize] = '\0';
Steve Block3856b092011-10-20 11:56:00 +01001023 ALOGV("readParamValue() reading string %s", param + *curSize - len);
Eric Laurent7c7f10b2011-06-17 21:29:58 -07001024 return len;
1025 }
Steve Block5ff1dd52012-01-05 23:22:43 +00001026 ALOGW("readParamValue() unknown param type %s", node->name);
Eric Laurent7c7f10b2011-06-17 21:29:58 -07001027 return 0;
1028}
1029
1030effect_param_t *AudioPolicyService::loadEffectParameter(cnode *root)
1031{
1032 cnode *param;
1033 cnode *value;
1034 size_t curSize = sizeof(effect_param_t);
1035 size_t totSize = sizeof(effect_param_t) + 2 * sizeof(int);
1036 effect_param_t *fx_param = (effect_param_t *)malloc(totSize);
1037
1038 param = config_find(root, PARAM_TAG);
1039 value = config_find(root, VALUE_TAG);
1040 if (param == NULL && value == NULL) {
1041 // try to parse simple parameter form {int int}
1042 param = root->first_child;
Glenn Kastena0d68332012-01-27 16:47:15 -08001043 if (param != NULL) {
Eric Laurent7c7f10b2011-06-17 21:29:58 -07001044 // Note: that a pair of random strings is read as 0 0
1045 int *ptr = (int *)fx_param->data;
1046 int *ptr2 = (int *)((char *)param + sizeof(effect_param_t));
Steve Block5ff1dd52012-01-05 23:22:43 +00001047 ALOGW("loadEffectParameter() ptr %p ptr2 %p", ptr, ptr2);
Eric Laurent7c7f10b2011-06-17 21:29:58 -07001048 *ptr++ = atoi(param->name);
1049 *ptr = atoi(param->value);
1050 fx_param->psize = sizeof(int);
1051 fx_param->vsize = sizeof(int);
1052 return fx_param;
1053 }
1054 }
1055 if (param == NULL || value == NULL) {
Steve Block5ff1dd52012-01-05 23:22:43 +00001056 ALOGW("loadEffectParameter() invalid parameter description %s", root->name);
Eric Laurent7c7f10b2011-06-17 21:29:58 -07001057 goto error;
1058 }
1059
1060 fx_param->psize = 0;
1061 param = param->first_child;
1062 while (param) {
Steve Block3856b092011-10-20 11:56:00 +01001063 ALOGV("loadEffectParameter() reading param of type %s", param->name);
Eric Laurent7c7f10b2011-06-17 21:29:58 -07001064 size_t size = readParamValue(param, (char *)fx_param, &curSize, &totSize);
1065 if (size == 0) {
1066 goto error;
1067 }
1068 fx_param->psize += size;
1069 param = param->next;
1070 }
1071
1072 // align start of value field on 32 bit boundary
1073 curSize = ((curSize - 1 ) / sizeof(int) + 1) * sizeof(int);
1074
1075 fx_param->vsize = 0;
1076 value = value->first_child;
1077 while (value) {
Steve Block3856b092011-10-20 11:56:00 +01001078 ALOGV("loadEffectParameter() reading value of type %s", value->name);
Eric Laurent7c7f10b2011-06-17 21:29:58 -07001079 size_t size = readParamValue(value, (char *)fx_param, &curSize, &totSize);
1080 if (size == 0) {
1081 goto error;
1082 }
1083 fx_param->vsize += size;
1084 value = value->next;
1085 }
1086
1087 return fx_param;
1088
1089error:
You Kimdb358af2013-09-12 20:48:08 +09001090 free(fx_param);
Eric Laurent7c7f10b2011-06-17 21:29:58 -07001091 return NULL;
1092}
1093
1094void AudioPolicyService::loadEffectParameters(cnode *root, Vector <effect_param_t *>& params)
1095{
1096 cnode *node = root->first_child;
1097 while (node) {
Steve Block3856b092011-10-20 11:56:00 +01001098 ALOGV("loadEffectParameters() loading param %s", node->name);
Eric Laurent7c7f10b2011-06-17 21:29:58 -07001099 effect_param_t *param = loadEffectParameter(node);
1100 if (param == NULL) {
1101 node = node->next;
1102 continue;
1103 }
1104 params.add(param);
1105 node = node->next;
1106 }
1107}
1108
1109AudioPolicyService::InputSourceDesc *AudioPolicyService::loadInputSource(
1110 cnode *root,
1111 const Vector <EffectDesc *>& effects)
1112{
1113 cnode *node = root->first_child;
1114 if (node == NULL) {
Steve Block5ff1dd52012-01-05 23:22:43 +00001115 ALOGW("loadInputSource() empty element %s", root->name);
Eric Laurent7c7f10b2011-06-17 21:29:58 -07001116 return NULL;
1117 }
1118 InputSourceDesc *source = new InputSourceDesc();
1119 while (node) {
1120 size_t i;
1121 for (i = 0; i < effects.size(); i++) {
1122 if (strncmp(effects[i]->mName, node->name, EFFECT_STRING_LEN_MAX) == 0) {
Steve Block3856b092011-10-20 11:56:00 +01001123 ALOGV("loadInputSource() found effect %s in list", node->name);
Eric Laurent7c7f10b2011-06-17 21:29:58 -07001124 break;
1125 }
1126 }
1127 if (i == effects.size()) {
Steve Block3856b092011-10-20 11:56:00 +01001128 ALOGV("loadInputSource() effect %s not in list", node->name);
Eric Laurent7c7f10b2011-06-17 21:29:58 -07001129 node = node->next;
1130 continue;
1131 }
Glenn Kasten9fda4b82012-02-02 14:04:37 -08001132 EffectDesc *effect = new EffectDesc(*effects[i]); // deep copy
Eric Laurent7c7f10b2011-06-17 21:29:58 -07001133 loadEffectParameters(node, effect->mParams);
Steve Block3856b092011-10-20 11:56:00 +01001134 ALOGV("loadInputSource() adding effect %s uuid %08x", effect->mName, effect->mUuid.timeLow);
Eric Laurent7c7f10b2011-06-17 21:29:58 -07001135 source->mEffects.add(effect);
1136 node = node->next;
1137 }
1138 if (source->mEffects.size() == 0) {
Steve Block5ff1dd52012-01-05 23:22:43 +00001139 ALOGW("loadInputSource() no valid effects found in source %s", root->name);
Eric Laurent7c7f10b2011-06-17 21:29:58 -07001140 delete source;
1141 return NULL;
1142 }
1143 return source;
1144}
1145
1146status_t AudioPolicyService::loadInputSources(cnode *root, const Vector <EffectDesc *>& effects)
1147{
1148 cnode *node = config_find(root, PREPROCESSING_TAG);
1149 if (node == NULL) {
1150 return -ENOENT;
1151 }
1152 node = node->first_child;
1153 while (node) {
1154 audio_source_t source = inputSourceNameToEnum(node->name);
1155 if (source == AUDIO_SOURCE_CNT) {
Steve Block5ff1dd52012-01-05 23:22:43 +00001156 ALOGW("loadInputSources() invalid input source %s", node->name);
Eric Laurent7c7f10b2011-06-17 21:29:58 -07001157 node = node->next;
1158 continue;
1159 }
Steve Block3856b092011-10-20 11:56:00 +01001160 ALOGV("loadInputSources() loading input source %s", node->name);
Eric Laurent7c7f10b2011-06-17 21:29:58 -07001161 InputSourceDesc *desc = loadInputSource(node, effects);
1162 if (desc == NULL) {
1163 node = node->next;
1164 continue;
1165 }
1166 mInputSources.add(source, desc);
1167 node = node->next;
1168 }
1169 return NO_ERROR;
1170}
1171
1172AudioPolicyService::EffectDesc *AudioPolicyService::loadEffect(cnode *root)
1173{
1174 cnode *node = config_find(root, UUID_TAG);
1175 if (node == NULL) {
1176 return NULL;
1177 }
1178 effect_uuid_t uuid;
1179 if (AudioEffect::stringToGuid(node->value, &uuid) != NO_ERROR) {
Steve Block5ff1dd52012-01-05 23:22:43 +00001180 ALOGW("loadEffect() invalid uuid %s", node->value);
Eric Laurent7c7f10b2011-06-17 21:29:58 -07001181 return NULL;
1182 }
Glenn Kasten9fda4b82012-02-02 14:04:37 -08001183 return new EffectDesc(root->name, uuid);
Eric Laurent7c7f10b2011-06-17 21:29:58 -07001184}
1185
1186status_t AudioPolicyService::loadEffects(cnode *root, Vector <EffectDesc *>& effects)
1187{
1188 cnode *node = config_find(root, EFFECTS_TAG);
1189 if (node == NULL) {
1190 return -ENOENT;
1191 }
1192 node = node->first_child;
1193 while (node) {
Steve Block3856b092011-10-20 11:56:00 +01001194 ALOGV("loadEffects() loading effect %s", node->name);
Eric Laurent7c7f10b2011-06-17 21:29:58 -07001195 EffectDesc *effect = loadEffect(node);
1196 if (effect == NULL) {
1197 node = node->next;
1198 continue;
1199 }
1200 effects.add(effect);
1201 node = node->next;
1202 }
1203 return NO_ERROR;
1204}
1205
1206status_t AudioPolicyService::loadPreProcessorConfig(const char *path)
1207{
1208 cnode *root;
1209 char *data;
1210
1211 data = (char *)load_file(path, NULL);
1212 if (data == NULL) {
1213 return -ENODEV;
1214 }
1215 root = config_node("", "");
1216 config_load(root, data);
1217
1218 Vector <EffectDesc *> effects;
1219 loadEffects(root, effects);
1220 loadInputSources(root, effects);
1221
Yu Yezhonge6056ba2013-10-15 14:32:34 +08001222 // delete effects to fix memory leak.
1223 // as effects is local var and valgrind would treat this as memory leak
1224 // and although it only did in mediaserver init, but free it in case mediaserver reboot
1225 size_t i;
1226 for (i = 0; i < effects.size(); i++) {
1227 delete effects[i];
1228 }
1229
Eric Laurent7c7f10b2011-06-17 21:29:58 -07001230 config_free(root);
1231 free(root);
1232 free(data);
1233
1234 return NO_ERROR;
1235}
1236
Dima Zavinfce7a472011-04-19 22:30:36 -07001237extern "C" {
Eric Laurent2d388ec2014-03-07 13:25:54 -08001238audio_module_handle_t aps_load_hw_module(void *service __unused,
1239 const char *name);
1240audio_io_handle_t aps_open_output(void *service __unused,
Eric Laurenta4c5a552012-03-29 10:12:40 -07001241 audio_devices_t *pDevices,
1242 uint32_t *pSamplingRate,
1243 audio_format_t *pFormat,
1244 audio_channel_mask_t *pChannelMask,
1245 uint32_t *pLatencyMs,
Eric Laurent2d388ec2014-03-07 13:25:54 -08001246 audio_output_flags_t flags);
Eric Laurenta4c5a552012-03-29 10:12:40 -07001247
Eric Laurent2d388ec2014-03-07 13:25:54 -08001248audio_io_handle_t aps_open_output_on_module(void *service __unused,
Eric Laurenta4c5a552012-03-29 10:12:40 -07001249 audio_module_handle_t module,
1250 audio_devices_t *pDevices,
1251 uint32_t *pSamplingRate,
1252 audio_format_t *pFormat,
1253 audio_channel_mask_t *pChannelMask,
1254 uint32_t *pLatencyMs,
Richard Fitzgeraldad3af332013-03-25 16:54:37 +00001255 audio_output_flags_t flags,
Eric Laurent2d388ec2014-03-07 13:25:54 -08001256 const audio_offload_info_t *offloadInfo);
1257audio_io_handle_t aps_open_dup_output(void *service __unused,
Dima Zavinfce7a472011-04-19 22:30:36 -07001258 audio_io_handle_t output1,
Eric Laurent2d388ec2014-03-07 13:25:54 -08001259 audio_io_handle_t output2);
1260int aps_close_output(void *service __unused, audio_io_handle_t output);
1261int aps_suspend_output(void *service __unused, audio_io_handle_t output);
1262int aps_restore_output(void *service __unused, audio_io_handle_t output);
1263audio_io_handle_t aps_open_input(void *service __unused,
Eric Laurenta4c5a552012-03-29 10:12:40 -07001264 audio_devices_t *pDevices,
1265 uint32_t *pSamplingRate,
1266 audio_format_t *pFormat,
1267 audio_channel_mask_t *pChannelMask,
Eric Laurent2d388ec2014-03-07 13:25:54 -08001268 audio_in_acoustics_t acoustics __unused);
1269audio_io_handle_t aps_open_input_on_module(void *service __unused,
Eric Laurenta4c5a552012-03-29 10:12:40 -07001270 audio_module_handle_t module,
1271 audio_devices_t *pDevices,
1272 uint32_t *pSamplingRate,
1273 audio_format_t *pFormat,
Eric Laurent2d388ec2014-03-07 13:25:54 -08001274 audio_channel_mask_t *pChannelMask);
1275int aps_close_input(void *service __unused, audio_io_handle_t input);
1276int aps_invalidate_stream(void *service __unused, audio_stream_type_t stream);
1277int aps_move_effects(void *service __unused, int session,
Dima Zavinfce7a472011-04-19 22:30:36 -07001278 audio_io_handle_t src_output,
Eric Laurent2d388ec2014-03-07 13:25:54 -08001279 audio_io_handle_t dst_output);
1280char * aps_get_parameters(void *service __unused, audio_io_handle_t io_handle,
1281 const char *keys);
1282void aps_set_parameters(void *service, audio_io_handle_t io_handle,
1283 const char *kv_pairs, int delay_ms);
1284int aps_set_stream_volume(void *service, audio_stream_type_t stream,
Dima Zavinfce7a472011-04-19 22:30:36 -07001285 float volume, audio_io_handle_t output,
Eric Laurent2d388ec2014-03-07 13:25:54 -08001286 int delay_ms);
1287int aps_start_tone(void *service, audio_policy_tone_t tone,
1288 audio_stream_type_t stream);
1289int aps_stop_tone(void *service);
1290int aps_set_voice_volume(void *service, float volume, int delay_ms);
1291};
Dima Zavinfce7a472011-04-19 22:30:36 -07001292
1293namespace {
1294 struct audio_policy_service_ops aps_ops = {
Glenn Kasten01d3acb2014-02-06 08:24:07 -08001295 .open_output = aps_open_output,
1296 .open_duplicate_output = aps_open_dup_output,
1297 .close_output = aps_close_output,
1298 .suspend_output = aps_suspend_output,
1299 .restore_output = aps_restore_output,
1300 .open_input = aps_open_input,
1301 .close_input = aps_close_input,
1302 .set_stream_volume = aps_set_stream_volume,
Glenn Kastend2304db2014-02-03 07:40:31 -08001303 .invalidate_stream = aps_invalidate_stream,
Glenn Kasten01d3acb2014-02-06 08:24:07 -08001304 .set_parameters = aps_set_parameters,
1305 .get_parameters = aps_get_parameters,
1306 .start_tone = aps_start_tone,
1307 .stop_tone = aps_stop_tone,
1308 .set_voice_volume = aps_set_voice_volume,
1309 .move_effects = aps_move_effects,
1310 .load_hw_module = aps_load_hw_module,
1311 .open_output_on_module = aps_open_output_on_module,
1312 .open_input_on_module = aps_open_input_on_module,
Dima Zavinfce7a472011-04-19 22:30:36 -07001313 };
1314}; // namespace <unnamed>
1315
Mathias Agopian65ab4712010-07-14 17:59:35 -07001316}; // namespace android