blob: a6cd50eb3ae5258666f53193d6442cf04b3864c4 [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>
Chih-Hung Hsiehc84d9d22014-11-14 13:33:34 -080038#include <media/AudioParameter.h>
Mathias Agopian65ab4712010-07-14 17:59:35 -070039
Dima Zavinfce7a472011-04-19 22:30:36 -070040#include <hardware/hardware.h>
Dima Zavin64760242011-05-11 14:15:23 -070041#include <system/audio.h>
Dima Zavin7394a4f2011-06-13 18:16:26 -070042#include <system/audio_policy.h>
Dima Zavinfce7a472011-04-19 22:30:36 -070043#include <hardware/audio_policy.h>
Dima Zavinfce7a472011-04-19 22:30:36 -070044
Mathias Agopian65ab4712010-07-14 17:59:35 -070045namespace android {
46
Glenn Kasten8dad0e32012-01-09 08:41:22 -080047static const char kDeadlockedString[] = "AudioPolicyService may be deadlocked\n";
48static const char kCmdDeadlockedString[] = "AudioPolicyService command thread may be deadlocked\n";
Mathias Agopian65ab4712010-07-14 17:59:35 -070049
50static const int kDumpLockRetries = 50;
Glenn Kasten22ecc912012-01-09 08:33:38 -080051static const int kDumpLockSleepUs = 20000;
Mathias Agopian65ab4712010-07-14 17:59:35 -070052
Eric Laurent0ede8922014-05-09 18:04:42 -070053static const nsecs_t kAudioCommandTimeoutNs = seconds(3); // 3 seconds
Christer Fletcher5fa8c4b2013-01-18 15:27:03 +010054
Dima Zavinfce7a472011-04-19 22:30:36 -070055namespace {
56 extern struct audio_policy_service_ops aps_ops;
57};
58
Mathias Agopian65ab4712010-07-14 17:59:35 -070059// ----------------------------------------------------------------------------
60
61AudioPolicyService::AudioPolicyService()
Eric Laurentdce54a12014-03-10 12:19:46 -070062 : BnAudioPolicyService(), mpAudioPolicyDev(NULL), mpAudioPolicy(NULL),
Eric Laurentbb6c9a02014-09-25 14:11:47 -070063 mAudioPolicyManager(NULL), mAudioPolicyClient(NULL), mPhoneState(AUDIO_MODE_INVALID)
Mathias Agopian65ab4712010-07-14 17:59:35 -070064{
Eric Laurentf5ada6e2014-10-09 17:49:00 -070065}
66
67void AudioPolicyService::onFirstRef()
68{
Mathias Agopian65ab4712010-07-14 17:59:35 -070069 char value[PROPERTY_VALUE_MAX];
Dima Zavinfce7a472011-04-19 22:30:36 -070070 const struct hw_module_t *module;
71 int forced_val;
72 int rc;
Mathias Agopian65ab4712010-07-14 17:59:35 -070073
Eric Laurent8b1e80b2014-10-07 09:08:47 -070074 {
75 Mutex::Autolock _l(mLock);
Eric Laurent93575202011-01-18 18:39:02 -080076
Eric Laurent8b1e80b2014-10-07 09:08:47 -070077 // start tone playback thread
78 mTonePlaybackThread = new AudioCommandThread(String8("ApmTone"), this);
79 // start audio commands thread
80 mAudioCommandThread = new AudioCommandThread(String8("ApmAudio"), this);
81 // start output activity command thread
82 mOutputCommandThread = new AudioCommandThread(String8("ApmOutput"), this);
Eric Laurentdce54a12014-03-10 12:19:46 -070083
84#ifdef USE_LEGACY_AUDIO_POLICY
Eric Laurent8b1e80b2014-10-07 09:08:47 -070085 ALOGI("AudioPolicyService CSTOR in legacy mode");
Eric Laurentdce54a12014-03-10 12:19:46 -070086
Eric Laurent8b1e80b2014-10-07 09:08:47 -070087 /* instantiate the audio policy manager */
88 rc = hw_get_module(AUDIO_POLICY_HARDWARE_MODULE_ID, &module);
89 if (rc) {
90 return;
91 }
92 rc = audio_policy_dev_open(module, &mpAudioPolicyDev);
93 ALOGE_IF(rc, "couldn't open audio policy device (%s)", strerror(-rc));
94 if (rc) {
95 return;
96 }
Eric Laurent93575202011-01-18 18:39:02 -080097
Eric Laurent8b1e80b2014-10-07 09:08:47 -070098 rc = mpAudioPolicyDev->create_audio_policy(mpAudioPolicyDev, &aps_ops, this,
99 &mpAudioPolicy);
100 ALOGE_IF(rc, "couldn't create audio policy (%s)", strerror(-rc));
101 if (rc) {
102 return;
103 }
Dima Zavinfce7a472011-04-19 22:30:36 -0700104
Eric Laurent8b1e80b2014-10-07 09:08:47 -0700105 rc = mpAudioPolicy->init_check(mpAudioPolicy);
106 ALOGE_IF(rc, "couldn't init_check the audio policy (%s)", strerror(-rc));
107 if (rc) {
108 return;
109 }
110 ALOGI("Loaded audio policy from %s (%s)", module->name, module->id);
Eric Laurentdce54a12014-03-10 12:19:46 -0700111#else
Eric Laurent8b1e80b2014-10-07 09:08:47 -0700112 ALOGI("AudioPolicyService CSTOR in new mode");
Eric Laurentdce54a12014-03-10 12:19:46 -0700113
Eric Laurent8b1e80b2014-10-07 09:08:47 -0700114 mAudioPolicyClient = new AudioPolicyClient(this);
115 mAudioPolicyManager = createAudioPolicyManager(mAudioPolicyClient);
Eric Laurentdce54a12014-03-10 12:19:46 -0700116#endif
Eric Laurent8b1e80b2014-10-07 09:08:47 -0700117 }
bryant_liuba2b4392014-06-11 16:49:30 +0800118 // load audio processing modules
Eric Laurent8b1e80b2014-10-07 09:08:47 -0700119 sp<AudioPolicyEffects>audioPolicyEffects = new AudioPolicyEffects();
120 {
121 Mutex::Autolock _l(mLock);
122 mAudioPolicyEffects = audioPolicyEffects;
123 }
Mathias Agopian65ab4712010-07-14 17:59:35 -0700124}
125
126AudioPolicyService::~AudioPolicyService()
127{
128 mTonePlaybackThread->exit();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700129 mAudioCommandThread->exit();
Eric Laurent657ff612014-05-07 11:58:24 -0700130 mOutputCommandThread->exit();
Eric Laurent7c7f10b2011-06-17 21:29:58 -0700131
Eric Laurentdce54a12014-03-10 12:19:46 -0700132#ifdef USE_LEGACY_AUDIO_POLICY
Glenn Kasten6e2ebe92013-08-13 09:14:51 -0700133 if (mpAudioPolicy != NULL && mpAudioPolicyDev != NULL) {
Dima Zavinfce7a472011-04-19 22:30:36 -0700134 mpAudioPolicyDev->destroy_audio_policy(mpAudioPolicyDev, mpAudioPolicy);
Glenn Kasten6e2ebe92013-08-13 09:14:51 -0700135 }
136 if (mpAudioPolicyDev != NULL) {
Dima Zavinfce7a472011-04-19 22:30:36 -0700137 audio_policy_dev_close(mpAudioPolicyDev);
Glenn Kasten6e2ebe92013-08-13 09:14:51 -0700138 }
Eric Laurentdce54a12014-03-10 12:19:46 -0700139#else
Eric Laurentf269b8e2014-06-09 20:01:29 -0700140 destroyAudioPolicyManager(mAudioPolicyManager);
Eric Laurentdce54a12014-03-10 12:19:46 -0700141 delete mAudioPolicyClient;
142#endif
Eric Laurentb52c1522014-05-20 11:27:36 -0700143
144 mNotificationClients.clear();
bryant_liuba2b4392014-06-11 16:49:30 +0800145 mAudioPolicyEffects.clear();
Eric Laurentb52c1522014-05-20 11:27:36 -0700146}
147
148// A notification client is always registered by AudioSystem when the client process
149// connects to AudioPolicyService.
150void AudioPolicyService::registerClient(const sp<IAudioPolicyServiceClient>& client)
151{
Eric Laurent12590252015-08-21 18:40:20 -0700152 if (client == 0) {
153 ALOGW("%s got NULL client", __FUNCTION__);
154 return;
155 }
Eric Laurent0ebd5f92014-11-19 19:04:52 -0800156 Mutex::Autolock _l(mNotificationClientsLock);
Eric Laurentb52c1522014-05-20 11:27:36 -0700157
158 uid_t uid = IPCThreadState::self()->getCallingUid();
159 if (mNotificationClients.indexOfKey(uid) < 0) {
160 sp<NotificationClient> notificationClient = new NotificationClient(this,
161 client,
162 uid);
163 ALOGV("registerClient() client %p, uid %d", client.get(), uid);
164
165 mNotificationClients.add(uid, notificationClient);
166
Marco Nelissenf8880202014-11-14 07:58:25 -0800167 sp<IBinder> binder = IInterface::asBinder(client);
Eric Laurentb52c1522014-05-20 11:27:36 -0700168 binder->linkToDeath(notificationClient);
169 }
170}
171
Eric Laurente8726fe2015-06-26 09:39:24 -0700172void AudioPolicyService::setAudioPortCallbacksEnabled(bool enabled)
173{
174 Mutex::Autolock _l(mNotificationClientsLock);
175
176 uid_t uid = IPCThreadState::self()->getCallingUid();
177 if (mNotificationClients.indexOfKey(uid) < 0) {
178 return;
179 }
180 mNotificationClients.valueFor(uid)->setAudioPortCallbacksEnabled(enabled);
181}
182
Eric Laurentb52c1522014-05-20 11:27:36 -0700183// removeNotificationClient() is called when the client process dies.
184void AudioPolicyService::removeNotificationClient(uid_t uid)
185{
Eric Laurent0ebd5f92014-11-19 19:04:52 -0800186 {
187 Mutex::Autolock _l(mNotificationClientsLock);
188 mNotificationClients.removeItem(uid);
189 }
Eric Laurentb52c1522014-05-20 11:27:36 -0700190#ifndef USE_LEGACY_AUDIO_POLICY
Eric Laurent0ebd5f92014-11-19 19:04:52 -0800191 {
192 Mutex::Autolock _l(mLock);
Eric Laurentb52c1522014-05-20 11:27:36 -0700193 if (mAudioPolicyManager) {
Eric Laurent8c7e6da2015-04-21 17:37:00 -0700194 mAudioPolicyManager->releaseResourcesForUid(uid);
Eric Laurentb52c1522014-05-20 11:27:36 -0700195 }
Eric Laurent0ebd5f92014-11-19 19:04:52 -0800196 }
Eric Laurentb52c1522014-05-20 11:27:36 -0700197#endif
198}
199
200void AudioPolicyService::onAudioPortListUpdate()
201{
202 mOutputCommandThread->updateAudioPortListCommand();
203}
204
205void AudioPolicyService::doOnAudioPortListUpdate()
206{
Eric Laurent0ebd5f92014-11-19 19:04:52 -0800207 Mutex::Autolock _l(mNotificationClientsLock);
Eric Laurentb52c1522014-05-20 11:27:36 -0700208 for (size_t i = 0; i < mNotificationClients.size(); i++) {
209 mNotificationClients.valueAt(i)->onAudioPortListUpdate();
210 }
211}
212
213void AudioPolicyService::onAudioPatchListUpdate()
214{
215 mOutputCommandThread->updateAudioPatchListCommand();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700216}
217
Eric Laurentb52c1522014-05-20 11:27:36 -0700218void AudioPolicyService::doOnAudioPatchListUpdate()
219{
Eric Laurent0ebd5f92014-11-19 19:04:52 -0800220 Mutex::Autolock _l(mNotificationClientsLock);
Eric Laurentb52c1522014-05-20 11:27:36 -0700221 for (size_t i = 0; i < mNotificationClients.size(); i++) {
222 mNotificationClients.valueAt(i)->onAudioPatchListUpdate();
223 }
224}
225
Jean-Michel Trivide801052015-04-14 19:10:14 -0700226void AudioPolicyService::onDynamicPolicyMixStateUpdate(String8 regId, int32_t state)
227{
228 ALOGV("AudioPolicyService::onDynamicPolicyMixStateUpdate(%s, %d)",
229 regId.string(), state);
230 mOutputCommandThread->dynamicPolicyMixStateUpdateCommand(regId, state);
231}
232
233void AudioPolicyService::doOnDynamicPolicyMixStateUpdate(String8 regId, int32_t state)
234{
235 Mutex::Autolock _l(mNotificationClientsLock);
236 for (size_t i = 0; i < mNotificationClients.size(); i++) {
237 mNotificationClients.valueAt(i)->onDynamicPolicyMixStateUpdate(regId, state);
238 }
239}
240
Jean-Michel Trivi2f4fe9f2015-12-04 16:20:59 -0800241void AudioPolicyService::onRecordingConfigurationUpdate(int event, audio_session_t session,
Jean-Michel Trivi7281aa92016-02-17 15:33:40 -0800242 audio_source_t source, const audio_config_base_t *clientConfig,
Jean-Michel Trivi8c7cf3b2016-02-25 17:08:24 -0800243 const audio_config_base_t *deviceConfig, audio_patch_handle_t patchHandle)
Jean-Michel Trivi2f4fe9f2015-12-04 16:20:59 -0800244{
Jean-Michel Trivi7281aa92016-02-17 15:33:40 -0800245 mOutputCommandThread->recordingConfigurationUpdateCommand(event, session, source,
Jean-Michel Trivi8c7cf3b2016-02-25 17:08:24 -0800246 clientConfig, deviceConfig, patchHandle);
Jean-Michel Trivi2f4fe9f2015-12-04 16:20:59 -0800247}
248
249void AudioPolicyService::doOnRecordingConfigurationUpdate(int event, audio_session_t session,
Jean-Michel Trivi7281aa92016-02-17 15:33:40 -0800250 audio_source_t source, const audio_config_base_t *clientConfig,
Jean-Michel Trivi8c7cf3b2016-02-25 17:08:24 -0800251 const audio_config_base_t *deviceConfig, audio_patch_handle_t patchHandle)
Jean-Michel Trivi2f4fe9f2015-12-04 16:20:59 -0800252{
253 Mutex::Autolock _l(mNotificationClientsLock);
254 for (size_t i = 0; i < mNotificationClients.size(); i++) {
Jean-Michel Trivi7281aa92016-02-17 15:33:40 -0800255 mNotificationClients.valueAt(i)->onRecordingConfigurationUpdate(event, session, source,
Jean-Michel Trivi8c7cf3b2016-02-25 17:08:24 -0800256 clientConfig, deviceConfig, patchHandle);
Jean-Michel Trivi2f4fe9f2015-12-04 16:20:59 -0800257 }
258}
259
260status_t AudioPolicyService::clientCreateAudioPatch(const struct audio_patch *patch,
261 audio_patch_handle_t *handle,
262 int delayMs)
263{
264 return mAudioCommandThread->createAudioPatchCommand(patch, handle, delayMs);
265}
266
267status_t AudioPolicyService::clientReleaseAudioPatch(audio_patch_handle_t handle,
268 int delayMs)
269{
270 return mAudioCommandThread->releaseAudioPatchCommand(handle, delayMs);
271}
272
Eric Laurente1715a42014-05-20 11:30:42 -0700273status_t AudioPolicyService::clientSetAudioPortConfig(const struct audio_port_config *config,
274 int delayMs)
275{
276 return mAudioCommandThread->setAudioPortConfigCommand(config, delayMs);
277}
278
Eric Laurentb52c1522014-05-20 11:27:36 -0700279AudioPolicyService::NotificationClient::NotificationClient(const sp<AudioPolicyService>& service,
280 const sp<IAudioPolicyServiceClient>& client,
281 uid_t uid)
Eric Laurente8726fe2015-06-26 09:39:24 -0700282 : mService(service), mUid(uid), mAudioPolicyServiceClient(client),
283 mAudioPortCallbacksEnabled(false)
Eric Laurentb52c1522014-05-20 11:27:36 -0700284{
285}
286
287AudioPolicyService::NotificationClient::~NotificationClient()
288{
289}
290
291void AudioPolicyService::NotificationClient::binderDied(const wp<IBinder>& who __unused)
292{
293 sp<NotificationClient> keep(this);
294 sp<AudioPolicyService> service = mService.promote();
295 if (service != 0) {
296 service->removeNotificationClient(mUid);
297 }
298}
299
300void AudioPolicyService::NotificationClient::onAudioPortListUpdate()
301{
Eric Laurente8726fe2015-06-26 09:39:24 -0700302 if (mAudioPolicyServiceClient != 0 && mAudioPortCallbacksEnabled) {
Eric Laurentb52c1522014-05-20 11:27:36 -0700303 mAudioPolicyServiceClient->onAudioPortListUpdate();
304 }
305}
306
307void AudioPolicyService::NotificationClient::onAudioPatchListUpdate()
308{
Eric Laurente8726fe2015-06-26 09:39:24 -0700309 if (mAudioPolicyServiceClient != 0 && mAudioPortCallbacksEnabled) {
Eric Laurentb52c1522014-05-20 11:27:36 -0700310 mAudioPolicyServiceClient->onAudioPatchListUpdate();
311 }
312}
Eric Laurent57dae992011-07-24 13:36:09 -0700313
Jean-Michel Trivide801052015-04-14 19:10:14 -0700314void AudioPolicyService::NotificationClient::onDynamicPolicyMixStateUpdate(
315 String8 regId, int32_t state)
316{
317 if (mAudioPolicyServiceClient != 0) {
Jean-Michel Trivi2f4fe9f2015-12-04 16:20:59 -0800318 mAudioPolicyServiceClient->onDynamicPolicyMixStateUpdate(regId, state);
319 }
320}
321
322void AudioPolicyService::NotificationClient::onRecordingConfigurationUpdate(
Jean-Michel Trivi7281aa92016-02-17 15:33:40 -0800323 int event, audio_session_t session, audio_source_t source,
Jean-Michel Trivi8c7cf3b2016-02-25 17:08:24 -0800324 const audio_config_base_t *clientConfig, const audio_config_base_t *deviceConfig,
325 audio_patch_handle_t patchHandle)
Jean-Michel Trivi2f4fe9f2015-12-04 16:20:59 -0800326{
327 if (mAudioPolicyServiceClient != 0) {
Jean-Michel Trivi7281aa92016-02-17 15:33:40 -0800328 mAudioPolicyServiceClient->onRecordingConfigurationUpdate(event, session, source,
Jean-Michel Trivi8c7cf3b2016-02-25 17:08:24 -0800329 clientConfig, deviceConfig, patchHandle);
Jean-Michel Trivide801052015-04-14 19:10:14 -0700330 }
331}
332
Eric Laurente8726fe2015-06-26 09:39:24 -0700333void AudioPolicyService::NotificationClient::setAudioPortCallbacksEnabled(bool enabled)
334{
335 mAudioPortCallbacksEnabled = enabled;
336}
337
338
Mathias Agopian65ab4712010-07-14 17:59:35 -0700339void AudioPolicyService::binderDied(const wp<IBinder>& who) {
Glenn Kasten411e4472012-11-02 10:00:06 -0700340 ALOGW("binderDied() %p, calling pid %d", who.unsafe_get(),
Eric Laurentde070132010-07-13 04:45:46 -0700341 IPCThreadState::self()->getCallingPid());
Mathias Agopian65ab4712010-07-14 17:59:35 -0700342}
343
344static bool tryLock(Mutex& mutex)
345{
346 bool locked = false;
347 for (int i = 0; i < kDumpLockRetries; ++i) {
348 if (mutex.tryLock() == NO_ERROR) {
349 locked = true;
350 break;
351 }
Glenn Kasten22ecc912012-01-09 08:33:38 -0800352 usleep(kDumpLockSleepUs);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700353 }
354 return locked;
355}
356
357status_t AudioPolicyService::dumpInternals(int fd)
358{
359 const size_t SIZE = 256;
360 char buffer[SIZE];
361 String8 result;
362
Eric Laurentdce54a12014-03-10 12:19:46 -0700363#ifdef USE_LEGACY_AUDIO_POLICY
Dima Zavinfce7a472011-04-19 22:30:36 -0700364 snprintf(buffer, SIZE, "PolicyManager Interface: %p\n", mpAudioPolicy);
Eric Laurentdce54a12014-03-10 12:19:46 -0700365#else
366 snprintf(buffer, SIZE, "AudioPolicyManager: %p\n", mAudioPolicyManager);
367#endif
Mathias Agopian65ab4712010-07-14 17:59:35 -0700368 result.append(buffer);
369 snprintf(buffer, SIZE, "Command Thread: %p\n", mAudioCommandThread.get());
370 result.append(buffer);
371 snprintf(buffer, SIZE, "Tones Thread: %p\n", mTonePlaybackThread.get());
372 result.append(buffer);
373
374 write(fd, result.string(), result.size());
375 return NO_ERROR;
376}
377
Glenn Kasten0f11b512014-01-31 16:18:54 -0800378status_t AudioPolicyService::dump(int fd, const Vector<String16>& args __unused)
Mathias Agopian65ab4712010-07-14 17:59:35 -0700379{
Glenn Kasten44deb052012-02-05 18:09:08 -0800380 if (!dumpAllowed()) {
Mathias Agopian65ab4712010-07-14 17:59:35 -0700381 dumpPermissionDenial(fd);
382 } else {
383 bool locked = tryLock(mLock);
384 if (!locked) {
385 String8 result(kDeadlockedString);
386 write(fd, result.string(), result.size());
387 }
388
389 dumpInternals(fd);
Glenn Kasten9d1f02d2012-02-08 17:47:58 -0800390 if (mAudioCommandThread != 0) {
Mathias Agopian65ab4712010-07-14 17:59:35 -0700391 mAudioCommandThread->dump(fd);
392 }
Glenn Kasten9d1f02d2012-02-08 17:47:58 -0800393 if (mTonePlaybackThread != 0) {
Mathias Agopian65ab4712010-07-14 17:59:35 -0700394 mTonePlaybackThread->dump(fd);
395 }
396
Eric Laurentdce54a12014-03-10 12:19:46 -0700397#ifdef USE_LEGACY_AUDIO_POLICY
Dima Zavinfce7a472011-04-19 22:30:36 -0700398 if (mpAudioPolicy) {
399 mpAudioPolicy->dump(mpAudioPolicy, fd);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700400 }
Eric Laurentdce54a12014-03-10 12:19:46 -0700401#else
402 if (mAudioPolicyManager) {
403 mAudioPolicyManager->dump(fd);
404 }
405#endif
Mathias Agopian65ab4712010-07-14 17:59:35 -0700406
407 if (locked) mLock.unlock();
408 }
409 return NO_ERROR;
410}
411
412status_t AudioPolicyService::dumpPermissionDenial(int fd)
413{
414 const size_t SIZE = 256;
415 char buffer[SIZE];
416 String8 result;
417 snprintf(buffer, SIZE, "Permission Denial: "
418 "can't dump AudioPolicyService from pid=%d, uid=%d\n",
419 IPCThreadState::self()->getCallingPid(),
420 IPCThreadState::self()->getCallingUid());
421 result.append(buffer);
422 write(fd, result.string(), result.size());
423 return NO_ERROR;
424}
425
426status_t AudioPolicyService::onTransact(
427 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
428{
429 return BnAudioPolicyService::onTransact(code, data, reply, flags);
430}
431
432
Mathias Agopian65ab4712010-07-14 17:59:35 -0700433// ----------- AudioPolicyService::AudioCommandThread implementation ----------
434
Eric Laurentbfb1b832013-01-07 09:53:42 -0800435AudioPolicyService::AudioCommandThread::AudioCommandThread(String8 name,
436 const wp<AudioPolicyService>& service)
437 : Thread(false), mName(name), mService(service)
Mathias Agopian65ab4712010-07-14 17:59:35 -0700438{
439 mpToneGenerator = NULL;
440}
441
442
443AudioPolicyService::AudioCommandThread::~AudioCommandThread()
444{
Eric Laurentbfb1b832013-01-07 09:53:42 -0800445 if (!mAudioCommands.isEmpty()) {
Mathias Agopian65ab4712010-07-14 17:59:35 -0700446 release_wake_lock(mName.string());
447 }
448 mAudioCommands.clear();
Glenn Kastene9dd0172012-01-27 18:08:45 -0800449 delete mpToneGenerator;
Mathias Agopian65ab4712010-07-14 17:59:35 -0700450}
451
452void AudioPolicyService::AudioCommandThread::onFirstRef()
453{
Eric Laurentbfb1b832013-01-07 09:53:42 -0800454 run(mName.string(), ANDROID_PRIORITY_AUDIO);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700455}
456
457bool AudioPolicyService::AudioCommandThread::threadLoop()
458{
Eric Laurentd7eda8d2016-02-02 17:18:39 -0800459 nsecs_t waitTime = -1;
Mathias Agopian65ab4712010-07-14 17:59:35 -0700460
461 mLock.lock();
462 while (!exitPending())
463 {
Eric Laurent59a89232014-06-08 14:14:17 -0700464 sp<AudioPolicyService> svc;
465 while (!mAudioCommands.isEmpty() && !exitPending()) {
Mathias Agopian65ab4712010-07-14 17:59:35 -0700466 nsecs_t curTime = systemTime();
467 // commands are sorted by increasing time stamp: execute them from index 0 and up
468 if (mAudioCommands[0]->mTime <= curTime) {
Eric Laurent0ede8922014-05-09 18:04:42 -0700469 sp<AudioCommand> command = mAudioCommands[0];
Mathias Agopian65ab4712010-07-14 17:59:35 -0700470 mAudioCommands.removeAt(0);
Eric Laurent0ede8922014-05-09 18:04:42 -0700471 mLastCommand = command;
Mathias Agopian65ab4712010-07-14 17:59:35 -0700472
473 switch (command->mCommand) {
474 case START_TONE: {
475 mLock.unlock();
Eric Laurent0ede8922014-05-09 18:04:42 -0700476 ToneData *data = (ToneData *)command->mParam.get();
Steve Block3856b092011-10-20 11:56:00 +0100477 ALOGV("AudioCommandThread() processing start tone %d on stream %d",
Mathias Agopian65ab4712010-07-14 17:59:35 -0700478 data->mType, data->mStream);
Glenn Kastene9dd0172012-01-27 18:08:45 -0800479 delete mpToneGenerator;
Mathias Agopian65ab4712010-07-14 17:59:35 -0700480 mpToneGenerator = new ToneGenerator(data->mStream, 1.0);
481 mpToneGenerator->startTone(data->mType);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700482 mLock.lock();
483 }break;
484 case STOP_TONE: {
485 mLock.unlock();
Steve Block3856b092011-10-20 11:56:00 +0100486 ALOGV("AudioCommandThread() processing stop tone");
Mathias Agopian65ab4712010-07-14 17:59:35 -0700487 if (mpToneGenerator != NULL) {
488 mpToneGenerator->stopTone();
489 delete mpToneGenerator;
490 mpToneGenerator = NULL;
491 }
492 mLock.lock();
493 }break;
494 case SET_VOLUME: {
Eric Laurent0ede8922014-05-09 18:04:42 -0700495 VolumeData *data = (VolumeData *)command->mParam.get();
Steve Block3856b092011-10-20 11:56:00 +0100496 ALOGV("AudioCommandThread() processing set volume stream %d, \
Eric Laurentde070132010-07-13 04:45:46 -0700497 volume %f, output %d", data->mStream, data->mVolume, data->mIO);
498 command->mStatus = AudioSystem::setStreamVolume(data->mStream,
499 data->mVolume,
500 data->mIO);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700501 }break;
502 case SET_PARAMETERS: {
Eric Laurent0ede8922014-05-09 18:04:42 -0700503 ParametersData *data = (ParametersData *)command->mParam.get();
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700504 ALOGV("AudioCommandThread() processing set parameters string %s, io %d",
505 data->mKeyValuePairs.string(), data->mIO);
506 command->mStatus = AudioSystem::setParameters(data->mIO, data->mKeyValuePairs);
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700507 }break;
Mathias Agopian65ab4712010-07-14 17:59:35 -0700508 case SET_VOICE_VOLUME: {
Eric Laurent0ede8922014-05-09 18:04:42 -0700509 VoiceVolumeData *data = (VoiceVolumeData *)command->mParam.get();
Steve Block3856b092011-10-20 11:56:00 +0100510 ALOGV("AudioCommandThread() processing set voice volume volume %f",
Eric Laurentde070132010-07-13 04:45:46 -0700511 data->mVolume);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700512 command->mStatus = AudioSystem::setVoiceVolume(data->mVolume);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700513 }break;
Eric Laurentbfb1b832013-01-07 09:53:42 -0800514 case STOP_OUTPUT: {
Eric Laurent0ede8922014-05-09 18:04:42 -0700515 StopOutputData *data = (StopOutputData *)command->mParam.get();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800516 ALOGV("AudioCommandThread() processing stop output %d",
517 data->mIO);
Eric Laurent59a89232014-06-08 14:14:17 -0700518 svc = mService.promote();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800519 if (svc == 0) {
520 break;
521 }
522 mLock.unlock();
523 svc->doStopOutput(data->mIO, data->mStream, data->mSession);
524 mLock.lock();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800525 }break;
526 case RELEASE_OUTPUT: {
Eric Laurent0ede8922014-05-09 18:04:42 -0700527 ReleaseOutputData *data = (ReleaseOutputData *)command->mParam.get();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800528 ALOGV("AudioCommandThread() processing release output %d",
529 data->mIO);
Eric Laurent59a89232014-06-08 14:14:17 -0700530 svc = mService.promote();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800531 if (svc == 0) {
532 break;
533 }
534 mLock.unlock();
Eric Laurente83b55d2014-11-14 10:06:21 -0800535 svc->doReleaseOutput(data->mIO, data->mStream, data->mSession);
Eric Laurentbfb1b832013-01-07 09:53:42 -0800536 mLock.lock();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800537 }break;
Eric Laurent951f4552014-05-20 10:48:17 -0700538 case CREATE_AUDIO_PATCH: {
539 CreateAudioPatchData *data = (CreateAudioPatchData *)command->mParam.get();
540 ALOGV("AudioCommandThread() processing create audio patch");
541 sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
542 if (af == 0) {
543 command->mStatus = PERMISSION_DENIED;
544 } else {
545 command->mStatus = af->createAudioPatch(&data->mPatch, &data->mHandle);
546 }
547 } break;
548 case RELEASE_AUDIO_PATCH: {
549 ReleaseAudioPatchData *data = (ReleaseAudioPatchData *)command->mParam.get();
550 ALOGV("AudioCommandThread() processing release audio patch");
551 sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
552 if (af == 0) {
553 command->mStatus = PERMISSION_DENIED;
554 } else {
555 command->mStatus = af->releaseAudioPatch(data->mHandle);
556 }
557 } break;
Eric Laurentb52c1522014-05-20 11:27:36 -0700558 case UPDATE_AUDIOPORT_LIST: {
559 ALOGV("AudioCommandThread() processing update audio port list");
Eric Laurent59a89232014-06-08 14:14:17 -0700560 svc = mService.promote();
Eric Laurentb52c1522014-05-20 11:27:36 -0700561 if (svc == 0) {
562 break;
563 }
564 mLock.unlock();
565 svc->doOnAudioPortListUpdate();
566 mLock.lock();
567 }break;
568 case UPDATE_AUDIOPATCH_LIST: {
569 ALOGV("AudioCommandThread() processing update audio patch list");
Eric Laurent59a89232014-06-08 14:14:17 -0700570 svc = mService.promote();
Eric Laurentb52c1522014-05-20 11:27:36 -0700571 if (svc == 0) {
572 break;
573 }
574 mLock.unlock();
575 svc->doOnAudioPatchListUpdate();
576 mLock.lock();
577 }break;
Eric Laurente1715a42014-05-20 11:30:42 -0700578 case SET_AUDIOPORT_CONFIG: {
579 SetAudioPortConfigData *data = (SetAudioPortConfigData *)command->mParam.get();
580 ALOGV("AudioCommandThread() processing set port config");
581 sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
582 if (af == 0) {
583 command->mStatus = PERMISSION_DENIED;
584 } else {
585 command->mStatus = af->setAudioPortConfig(&data->mConfig);
586 }
587 } break;
Jean-Michel Trivide801052015-04-14 19:10:14 -0700588 case DYN_POLICY_MIX_STATE_UPDATE: {
589 DynPolicyMixStateUpdateData *data =
590 (DynPolicyMixStateUpdateData *)command->mParam.get();
Jean-Michel Trivide801052015-04-14 19:10:14 -0700591 ALOGV("AudioCommandThread() processing dyn policy mix state update %s %d",
592 data->mRegId.string(), data->mState);
593 svc = mService.promote();
594 if (svc == 0) {
595 break;
596 }
597 mLock.unlock();
598 svc->doOnDynamicPolicyMixStateUpdate(data->mRegId, data->mState);
599 mLock.lock();
600 } break;
Jean-Michel Trivi2f4fe9f2015-12-04 16:20:59 -0800601 case RECORDING_CONFIGURATION_UPDATE: {
602 RecordingConfigurationUpdateData *data =
603 (RecordingConfigurationUpdateData *)command->mParam.get();
604 ALOGV("AudioCommandThread() processing recording configuration update");
605 svc = mService.promote();
606 if (svc == 0) {
607 break;
608 }
609 mLock.unlock();
610 svc->doOnRecordingConfigurationUpdate(data->mEvent, data->mSession,
Jean-Michel Trivi8c7cf3b2016-02-25 17:08:24 -0800611 data->mSource, &data->mClientConfig, &data->mDeviceConfig,
612 data->mPatchHandle);
Jean-Michel Trivi2f4fe9f2015-12-04 16:20:59 -0800613 mLock.lock();
614 } break;
Mathias Agopian65ab4712010-07-14 17:59:35 -0700615 default:
Steve Block5ff1dd52012-01-05 23:22:43 +0000616 ALOGW("AudioCommandThread() unknown command %d", command->mCommand);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700617 }
Eric Laurent0ede8922014-05-09 18:04:42 -0700618 {
619 Mutex::Autolock _l(command->mLock);
620 if (command->mWaitStatus) {
621 command->mWaitStatus = false;
622 command->mCond.signal();
623 }
624 }
Eric Laurentd7eda8d2016-02-02 17:18:39 -0800625 waitTime = -1;
Zach Janga754b4f2015-10-27 01:29:34 +0000626 // release mLock before releasing strong reference on the service as
627 // AudioPolicyService destructor calls AudioCommandThread::exit() which
628 // acquires mLock.
629 mLock.unlock();
630 svc.clear();
631 mLock.lock();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700632 } else {
633 waitTime = mAudioCommands[0]->mTime - curTime;
634 break;
635 }
636 }
Zach Janga754b4f2015-10-27 01:29:34 +0000637
638 // release delayed commands wake lock if the queue is empty
639 if (mAudioCommands.isEmpty()) {
Ricardo Garcia05f2fdc2014-07-24 15:48:24 -0700640 release_wake_lock(mName.string());
Zach Janga754b4f2015-10-27 01:29:34 +0000641 }
642
643 // At this stage we have either an empty command queue or the first command in the queue
644 // has a finite delay. So unless we are exiting it is safe to wait.
645 if (!exitPending()) {
Eric Laurent59a89232014-06-08 14:14:17 -0700646 ALOGV("AudioCommandThread() going to sleep");
Eric Laurentd7eda8d2016-02-02 17:18:39 -0800647 if (waitTime == -1) {
648 mWaitWorkCV.wait(mLock);
649 } else {
650 mWaitWorkCV.waitRelative(mLock, waitTime);
651 }
Eric Laurent59a89232014-06-08 14:14:17 -0700652 }
Mathias Agopian65ab4712010-07-14 17:59:35 -0700653 }
Ricardo Garcia05f2fdc2014-07-24 15:48:24 -0700654 // release delayed commands wake lock before quitting
655 if (!mAudioCommands.isEmpty()) {
656 release_wake_lock(mName.string());
657 }
Mathias Agopian65ab4712010-07-14 17:59:35 -0700658 mLock.unlock();
659 return false;
660}
661
662status_t AudioPolicyService::AudioCommandThread::dump(int fd)
663{
664 const size_t SIZE = 256;
665 char buffer[SIZE];
666 String8 result;
667
668 snprintf(buffer, SIZE, "AudioCommandThread %p Dump\n", this);
669 result.append(buffer);
670 write(fd, result.string(), result.size());
671
672 bool locked = tryLock(mLock);
673 if (!locked) {
674 String8 result2(kCmdDeadlockedString);
675 write(fd, result2.string(), result2.size());
676 }
677
678 snprintf(buffer, SIZE, "- Commands:\n");
679 result = String8(buffer);
680 result.append(" Command Time Wait pParam\n");
Glenn Kasten8d6a2442012-02-08 14:04:28 -0800681 for (size_t i = 0; i < mAudioCommands.size(); i++) {
Mathias Agopian65ab4712010-07-14 17:59:35 -0700682 mAudioCommands[i]->dump(buffer, SIZE);
683 result.append(buffer);
684 }
685 result.append(" Last Command\n");
Eric Laurent0ede8922014-05-09 18:04:42 -0700686 if (mLastCommand != 0) {
687 mLastCommand->dump(buffer, SIZE);
688 result.append(buffer);
689 } else {
690 result.append(" none\n");
691 }
Mathias Agopian65ab4712010-07-14 17:59:35 -0700692
693 write(fd, result.string(), result.size());
694
695 if (locked) mLock.unlock();
696
697 return NO_ERROR;
698}
699
Glenn Kasten3d2f8772012-01-27 15:25:25 -0800700void AudioPolicyService::AudioCommandThread::startToneCommand(ToneGenerator::tone_type type,
701 audio_stream_type_t stream)
Mathias Agopian65ab4712010-07-14 17:59:35 -0700702{
Eric Laurent0ede8922014-05-09 18:04:42 -0700703 sp<AudioCommand> command = new AudioCommand();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700704 command->mCommand = START_TONE;
Eric Laurent0ede8922014-05-09 18:04:42 -0700705 sp<ToneData> data = new ToneData();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700706 data->mType = type;
707 data->mStream = stream;
Jesper Tragardh48412dc2014-03-24 14:12:43 +0100708 command->mParam = data;
Steve Block3856b092011-10-20 11:56:00 +0100709 ALOGV("AudioCommandThread() adding tone start type %d, stream %d", type, stream);
Eric Laurent0ede8922014-05-09 18:04:42 -0700710 sendCommand(command);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700711}
712
713void AudioPolicyService::AudioCommandThread::stopToneCommand()
714{
Eric Laurent0ede8922014-05-09 18:04:42 -0700715 sp<AudioCommand> command = new AudioCommand();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700716 command->mCommand = STOP_TONE;
Steve Block3856b092011-10-20 11:56:00 +0100717 ALOGV("AudioCommandThread() adding tone stop");
Eric Laurent0ede8922014-05-09 18:04:42 -0700718 sendCommand(command);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700719}
720
Glenn Kastenfff6d712012-01-12 16:38:12 -0800721status_t AudioPolicyService::AudioCommandThread::volumeCommand(audio_stream_type_t stream,
Eric Laurentde070132010-07-13 04:45:46 -0700722 float volume,
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800723 audio_io_handle_t output,
Eric Laurentde070132010-07-13 04:45:46 -0700724 int delayMs)
Mathias Agopian65ab4712010-07-14 17:59:35 -0700725{
Eric Laurent0ede8922014-05-09 18:04:42 -0700726 sp<AudioCommand> command = new AudioCommand();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700727 command->mCommand = SET_VOLUME;
Eric Laurent0ede8922014-05-09 18:04:42 -0700728 sp<VolumeData> data = new VolumeData();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700729 data->mStream = stream;
730 data->mVolume = volume;
731 data->mIO = output;
732 command->mParam = data;
Eric Laurent0ede8922014-05-09 18:04:42 -0700733 command->mWaitStatus = true;
Steve Block3856b092011-10-20 11:56:00 +0100734 ALOGV("AudioCommandThread() adding set volume stream %d, volume %f, output %d",
Eric Laurentde070132010-07-13 04:45:46 -0700735 stream, volume, output);
Eric Laurent0ede8922014-05-09 18:04:42 -0700736 return sendCommand(command, delayMs);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700737}
738
Glenn Kasten72ef00d2012-01-17 11:09:42 -0800739status_t AudioPolicyService::AudioCommandThread::parametersCommand(audio_io_handle_t ioHandle,
Dima Zavinfce7a472011-04-19 22:30:36 -0700740 const char *keyValuePairs,
Eric Laurentde070132010-07-13 04:45:46 -0700741 int delayMs)
Mathias Agopian65ab4712010-07-14 17:59:35 -0700742{
Eric Laurent0ede8922014-05-09 18:04:42 -0700743 sp<AudioCommand> command = new AudioCommand();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700744 command->mCommand = SET_PARAMETERS;
Eric Laurent0ede8922014-05-09 18:04:42 -0700745 sp<ParametersData> data = new ParametersData();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700746 data->mIO = ioHandle;
Dima Zavinfce7a472011-04-19 22:30:36 -0700747 data->mKeyValuePairs = String8(keyValuePairs);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700748 command->mParam = data;
Eric Laurent0ede8922014-05-09 18:04:42 -0700749 command->mWaitStatus = true;
Steve Block3856b092011-10-20 11:56:00 +0100750 ALOGV("AudioCommandThread() adding set parameter string %s, io %d ,delay %d",
Dima Zavinfce7a472011-04-19 22:30:36 -0700751 keyValuePairs, ioHandle, delayMs);
Eric Laurent0ede8922014-05-09 18:04:42 -0700752 return sendCommand(command, delayMs);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700753}
754
755status_t AudioPolicyService::AudioCommandThread::voiceVolumeCommand(float volume, int delayMs)
756{
Eric Laurent0ede8922014-05-09 18:04:42 -0700757 sp<AudioCommand> command = new AudioCommand();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700758 command->mCommand = SET_VOICE_VOLUME;
Eric Laurent0ede8922014-05-09 18:04:42 -0700759 sp<VoiceVolumeData> data = new VoiceVolumeData();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700760 data->mVolume = volume;
761 command->mParam = data;
Eric Laurent0ede8922014-05-09 18:04:42 -0700762 command->mWaitStatus = true;
Steve Block3856b092011-10-20 11:56:00 +0100763 ALOGV("AudioCommandThread() adding set voice volume volume %f", volume);
Eric Laurent0ede8922014-05-09 18:04:42 -0700764 return sendCommand(command, delayMs);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700765}
766
Eric Laurentbfb1b832013-01-07 09:53:42 -0800767void AudioPolicyService::AudioCommandThread::stopOutputCommand(audio_io_handle_t output,
768 audio_stream_type_t stream,
Eric Laurente83b55d2014-11-14 10:06:21 -0800769 audio_session_t session)
Eric Laurentbfb1b832013-01-07 09:53:42 -0800770{
Eric Laurent0ede8922014-05-09 18:04:42 -0700771 sp<AudioCommand> command = new AudioCommand();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800772 command->mCommand = STOP_OUTPUT;
Eric Laurent0ede8922014-05-09 18:04:42 -0700773 sp<StopOutputData> data = new StopOutputData();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800774 data->mIO = output;
775 data->mStream = stream;
776 data->mSession = session;
Jesper Tragardh48412dc2014-03-24 14:12:43 +0100777 command->mParam = data;
Eric Laurentbfb1b832013-01-07 09:53:42 -0800778 ALOGV("AudioCommandThread() adding stop output %d", output);
Eric Laurent0ede8922014-05-09 18:04:42 -0700779 sendCommand(command);
Eric Laurentbfb1b832013-01-07 09:53:42 -0800780}
781
Eric Laurente83b55d2014-11-14 10:06:21 -0800782void AudioPolicyService::AudioCommandThread::releaseOutputCommand(audio_io_handle_t output,
783 audio_stream_type_t stream,
784 audio_session_t session)
Eric Laurentbfb1b832013-01-07 09:53:42 -0800785{
Eric Laurent0ede8922014-05-09 18:04:42 -0700786 sp<AudioCommand> command = new AudioCommand();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800787 command->mCommand = RELEASE_OUTPUT;
Eric Laurent0ede8922014-05-09 18:04:42 -0700788 sp<ReleaseOutputData> data = new ReleaseOutputData();
Eric Laurentbfb1b832013-01-07 09:53:42 -0800789 data->mIO = output;
Eric Laurente83b55d2014-11-14 10:06:21 -0800790 data->mStream = stream;
791 data->mSession = session;
Jesper Tragardh48412dc2014-03-24 14:12:43 +0100792 command->mParam = data;
Eric Laurentbfb1b832013-01-07 09:53:42 -0800793 ALOGV("AudioCommandThread() adding release output %d", output);
Eric Laurent0ede8922014-05-09 18:04:42 -0700794 sendCommand(command);
795}
796
Eric Laurent951f4552014-05-20 10:48:17 -0700797status_t AudioPolicyService::AudioCommandThread::createAudioPatchCommand(
798 const struct audio_patch *patch,
799 audio_patch_handle_t *handle,
800 int delayMs)
801{
802 status_t status = NO_ERROR;
803
804 sp<AudioCommand> command = new AudioCommand();
805 command->mCommand = CREATE_AUDIO_PATCH;
806 CreateAudioPatchData *data = new CreateAudioPatchData();
807 data->mPatch = *patch;
808 data->mHandle = *handle;
809 command->mParam = data;
810 command->mWaitStatus = true;
811 ALOGV("AudioCommandThread() adding create patch delay %d", delayMs);
812 status = sendCommand(command, delayMs);
813 if (status == NO_ERROR) {
814 *handle = data->mHandle;
815 }
816 return status;
817}
818
819status_t AudioPolicyService::AudioCommandThread::releaseAudioPatchCommand(audio_patch_handle_t handle,
820 int delayMs)
821{
822 sp<AudioCommand> command = new AudioCommand();
823 command->mCommand = RELEASE_AUDIO_PATCH;
824 ReleaseAudioPatchData *data = new ReleaseAudioPatchData();
825 data->mHandle = handle;
826 command->mParam = data;
827 command->mWaitStatus = true;
828 ALOGV("AudioCommandThread() adding release patch delay %d", delayMs);
829 return sendCommand(command, delayMs);
830}
831
Eric Laurentb52c1522014-05-20 11:27:36 -0700832void AudioPolicyService::AudioCommandThread::updateAudioPortListCommand()
833{
834 sp<AudioCommand> command = new AudioCommand();
835 command->mCommand = UPDATE_AUDIOPORT_LIST;
836 ALOGV("AudioCommandThread() adding update audio port list");
837 sendCommand(command);
838}
839
840void AudioPolicyService::AudioCommandThread::updateAudioPatchListCommand()
841{
842 sp<AudioCommand>command = new AudioCommand();
843 command->mCommand = UPDATE_AUDIOPATCH_LIST;
844 ALOGV("AudioCommandThread() adding update audio patch list");
845 sendCommand(command);
846}
847
Eric Laurente1715a42014-05-20 11:30:42 -0700848status_t AudioPolicyService::AudioCommandThread::setAudioPortConfigCommand(
849 const struct audio_port_config *config, int delayMs)
850{
851 sp<AudioCommand> command = new AudioCommand();
852 command->mCommand = SET_AUDIOPORT_CONFIG;
853 SetAudioPortConfigData *data = new SetAudioPortConfigData();
854 data->mConfig = *config;
855 command->mParam = data;
856 command->mWaitStatus = true;
857 ALOGV("AudioCommandThread() adding set port config delay %d", delayMs);
858 return sendCommand(command, delayMs);
859}
860
Jean-Michel Trivide801052015-04-14 19:10:14 -0700861void AudioPolicyService::AudioCommandThread::dynamicPolicyMixStateUpdateCommand(
862 String8 regId, int32_t state)
863{
864 sp<AudioCommand> command = new AudioCommand();
865 command->mCommand = DYN_POLICY_MIX_STATE_UPDATE;
866 DynPolicyMixStateUpdateData *data = new DynPolicyMixStateUpdateData();
867 data->mRegId = regId;
868 data->mState = state;
869 command->mParam = data;
870 ALOGV("AudioCommandThread() sending dynamic policy mix (id=%s) state update to %d",
871 regId.string(), state);
872 sendCommand(command);
873}
874
Jean-Michel Trivi2f4fe9f2015-12-04 16:20:59 -0800875void AudioPolicyService::AudioCommandThread::recordingConfigurationUpdateCommand(
Jean-Michel Trivi7281aa92016-02-17 15:33:40 -0800876 int event, audio_session_t session, audio_source_t source,
Jean-Michel Trivi8c7cf3b2016-02-25 17:08:24 -0800877 const audio_config_base_t *clientConfig, const audio_config_base_t *deviceConfig,
878 audio_patch_handle_t patchHandle)
Jean-Michel Trivi2f4fe9f2015-12-04 16:20:59 -0800879{
880 sp<AudioCommand>command = new AudioCommand();
881 command->mCommand = RECORDING_CONFIGURATION_UPDATE;
882 RecordingConfigurationUpdateData *data = new RecordingConfigurationUpdateData();
883 data->mEvent = event;
884 data->mSession = session;
885 data->mSource = source;
Jean-Michel Trivi7281aa92016-02-17 15:33:40 -0800886 data->mClientConfig = *clientConfig;
887 data->mDeviceConfig = *deviceConfig;
Jean-Michel Trivi8c7cf3b2016-02-25 17:08:24 -0800888 data->mPatchHandle = patchHandle;
Jean-Michel Trivi2f4fe9f2015-12-04 16:20:59 -0800889 command->mParam = data;
890 ALOGV("AudioCommandThread() adding recording configuration update event %d, source %d",
891 event, source);
892 sendCommand(command);
893}
894
Eric Laurent0ede8922014-05-09 18:04:42 -0700895status_t AudioPolicyService::AudioCommandThread::sendCommand(sp<AudioCommand>& command, int delayMs)
896{
897 {
898 Mutex::Autolock _l(mLock);
899 insertCommand_l(command, delayMs);
900 mWaitWorkCV.signal();
901 }
902 Mutex::Autolock _l(command->mLock);
903 while (command->mWaitStatus) {
904 nsecs_t timeOutNs = kAudioCommandTimeoutNs + milliseconds(delayMs);
905 if (command->mCond.waitRelative(command->mLock, timeOutNs) != NO_ERROR) {
906 command->mStatus = TIMED_OUT;
907 command->mWaitStatus = false;
908 }
909 }
910 return command->mStatus;
Eric Laurentbfb1b832013-01-07 09:53:42 -0800911}
912
Mathias Agopian65ab4712010-07-14 17:59:35 -0700913// insertCommand_l() must be called with mLock held
Eric Laurent0ede8922014-05-09 18:04:42 -0700914void AudioPolicyService::AudioCommandThread::insertCommand_l(sp<AudioCommand>& command, int delayMs)
Mathias Agopian65ab4712010-07-14 17:59:35 -0700915{
Glenn Kasten8d6a2442012-02-08 14:04:28 -0800916 ssize_t i; // not size_t because i will count down to -1
Eric Laurent0ede8922014-05-09 18:04:42 -0700917 Vector < sp<AudioCommand> > removedCommands;
Mathias Agopian65ab4712010-07-14 17:59:35 -0700918 command->mTime = systemTime() + milliseconds(delayMs);
919
920 // acquire wake lock to make sure delayed commands are processed
Eric Laurentbfb1b832013-01-07 09:53:42 -0800921 if (mAudioCommands.isEmpty()) {
Mathias Agopian65ab4712010-07-14 17:59:35 -0700922 acquire_wake_lock(PARTIAL_WAKE_LOCK, mName.string());
923 }
924
925 // check same pending commands with later time stamps and eliminate them
926 for (i = mAudioCommands.size()-1; i >= 0; i--) {
Eric Laurent0ede8922014-05-09 18:04:42 -0700927 sp<AudioCommand> command2 = mAudioCommands[i];
Mathias Agopian65ab4712010-07-14 17:59:35 -0700928 // commands are sorted by increasing time stamp: no need to scan the rest of mAudioCommands
929 if (command2->mTime <= command->mTime) break;
Eric Laurente45b48a2014-09-04 16:40:57 -0700930
931 // create audio patch or release audio patch commands are equivalent
932 // with regard to filtering
933 if ((command->mCommand == CREATE_AUDIO_PATCH) ||
934 (command->mCommand == RELEASE_AUDIO_PATCH)) {
935 if ((command2->mCommand != CREATE_AUDIO_PATCH) &&
936 (command2->mCommand != RELEASE_AUDIO_PATCH)) {
937 continue;
938 }
939 } else if (command2->mCommand != command->mCommand) continue;
Mathias Agopian65ab4712010-07-14 17:59:35 -0700940
941 switch (command->mCommand) {
942 case SET_PARAMETERS: {
Eric Laurent0ede8922014-05-09 18:04:42 -0700943 ParametersData *data = (ParametersData *)command->mParam.get();
944 ParametersData *data2 = (ParametersData *)command2->mParam.get();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700945 if (data->mIO != data2->mIO) break;
Steve Block3856b092011-10-20 11:56:00 +0100946 ALOGV("Comparing parameter command %s to new command %s",
Eric Laurentde070132010-07-13 04:45:46 -0700947 data2->mKeyValuePairs.string(), data->mKeyValuePairs.string());
Mathias Agopian65ab4712010-07-14 17:59:35 -0700948 AudioParameter param = AudioParameter(data->mKeyValuePairs);
949 AudioParameter param2 = AudioParameter(data2->mKeyValuePairs);
950 for (size_t j = 0; j < param.size(); j++) {
Glenn Kastene53b9ea2012-03-12 16:29:55 -0700951 String8 key;
952 String8 value;
953 param.getAt(j, key, value);
954 for (size_t k = 0; k < param2.size(); k++) {
955 String8 key2;
956 String8 value2;
957 param2.getAt(k, key2, value2);
958 if (key2 == key) {
959 param2.remove(key2);
960 ALOGV("Filtering out parameter %s", key2.string());
961 break;
962 }
963 }
Mathias Agopian65ab4712010-07-14 17:59:35 -0700964 }
965 // if all keys have been filtered out, remove the command.
966 // otherwise, update the key value pairs
967 if (param2.size() == 0) {
968 removedCommands.add(command2);
969 } else {
970 data2->mKeyValuePairs = param2.toString();
971 }
Eric Laurent21e54562013-09-23 12:08:05 -0700972 command->mTime = command2->mTime;
973 // force delayMs to non 0 so that code below does not request to wait for
974 // command status as the command is now delayed
975 delayMs = 1;
Mathias Agopian65ab4712010-07-14 17:59:35 -0700976 } break;
977
978 case SET_VOLUME: {
Eric Laurent0ede8922014-05-09 18:04:42 -0700979 VolumeData *data = (VolumeData *)command->mParam.get();
980 VolumeData *data2 = (VolumeData *)command2->mParam.get();
Mathias Agopian65ab4712010-07-14 17:59:35 -0700981 if (data->mIO != data2->mIO) break;
982 if (data->mStream != data2->mStream) break;
Steve Block3856b092011-10-20 11:56:00 +0100983 ALOGV("Filtering out volume command on output %d for stream %d",
Eric Laurentde070132010-07-13 04:45:46 -0700984 data->mIO, data->mStream);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700985 removedCommands.add(command2);
Eric Laurent21e54562013-09-23 12:08:05 -0700986 command->mTime = command2->mTime;
987 // force delayMs to non 0 so that code below does not request to wait for
988 // command status as the command is now delayed
989 delayMs = 1;
Mathias Agopian65ab4712010-07-14 17:59:35 -0700990 } break;
Eric Laurente45b48a2014-09-04 16:40:57 -0700991
992 case CREATE_AUDIO_PATCH:
993 case RELEASE_AUDIO_PATCH: {
994 audio_patch_handle_t handle;
Haynes Mathew Georgea2d4a6d2014-10-13 13:05:22 -0700995 struct audio_patch patch;
Eric Laurente45b48a2014-09-04 16:40:57 -0700996 if (command->mCommand == CREATE_AUDIO_PATCH) {
997 handle = ((CreateAudioPatchData *)command->mParam.get())->mHandle;
Haynes Mathew Georgea2d4a6d2014-10-13 13:05:22 -0700998 patch = ((CreateAudioPatchData *)command->mParam.get())->mPatch;
Eric Laurente45b48a2014-09-04 16:40:57 -0700999 } else {
1000 handle = ((ReleaseAudioPatchData *)command->mParam.get())->mHandle;
1001 }
1002 audio_patch_handle_t handle2;
Haynes Mathew Georgea2d4a6d2014-10-13 13:05:22 -07001003 struct audio_patch patch2;
Eric Laurente45b48a2014-09-04 16:40:57 -07001004 if (command2->mCommand == CREATE_AUDIO_PATCH) {
1005 handle2 = ((CreateAudioPatchData *)command2->mParam.get())->mHandle;
Haynes Mathew Georgea2d4a6d2014-10-13 13:05:22 -07001006 patch2 = ((CreateAudioPatchData *)command2->mParam.get())->mPatch;
Eric Laurente45b48a2014-09-04 16:40:57 -07001007 } else {
1008 handle2 = ((ReleaseAudioPatchData *)command2->mParam.get())->mHandle;
Glenn Kastenf60b6b62015-07-06 10:53:26 -07001009 memset(&patch2, 0, sizeof(patch2));
Eric Laurente45b48a2014-09-04 16:40:57 -07001010 }
1011 if (handle != handle2) break;
Haynes Mathew Georgea2d4a6d2014-10-13 13:05:22 -07001012 /* Filter CREATE_AUDIO_PATCH commands only when they are issued for
1013 same output. */
1014 if( (command->mCommand == CREATE_AUDIO_PATCH) &&
1015 (command2->mCommand == CREATE_AUDIO_PATCH) ) {
1016 bool isOutputDiff = false;
1017 if (patch.num_sources == patch2.num_sources) {
1018 for (unsigned count = 0; count < patch.num_sources; count++) {
1019 if (patch.sources[count].id != patch2.sources[count].id) {
1020 isOutputDiff = true;
1021 break;
1022 }
1023 }
1024 if (isOutputDiff)
1025 break;
1026 }
1027 }
Eric Laurente45b48a2014-09-04 16:40:57 -07001028 ALOGV("Filtering out %s audio patch command for handle %d",
1029 (command->mCommand == CREATE_AUDIO_PATCH) ? "create" : "release", handle);
1030 removedCommands.add(command2);
1031 command->mTime = command2->mTime;
1032 // force delayMs to non 0 so that code below does not request to wait for
1033 // command status as the command is now delayed
1034 delayMs = 1;
1035 } break;
1036
Jean-Michel Trivide801052015-04-14 19:10:14 -07001037 case DYN_POLICY_MIX_STATE_UPDATE: {
1038
1039 } break;
1040
Jean-Michel Trivi2f4fe9f2015-12-04 16:20:59 -08001041 case RECORDING_CONFIGURATION_UPDATE: {
1042
1043 } break;
1044
Mathias Agopian65ab4712010-07-14 17:59:35 -07001045 case START_TONE:
1046 case STOP_TONE:
1047 default:
1048 break;
1049 }
1050 }
1051
1052 // remove filtered commands
1053 for (size_t j = 0; j < removedCommands.size(); j++) {
1054 // removed commands always have time stamps greater than current command
1055 for (size_t k = i + 1; k < mAudioCommands.size(); k++) {
Eric Laurent0ede8922014-05-09 18:04:42 -07001056 if (mAudioCommands[k].get() == removedCommands[j].get()) {
Steve Block3856b092011-10-20 11:56:00 +01001057 ALOGV("suppressing command: %d", mAudioCommands[k]->mCommand);
Mathias Agopian65ab4712010-07-14 17:59:35 -07001058 mAudioCommands.removeAt(k);
1059 break;
1060 }
1061 }
1062 }
1063 removedCommands.clear();
1064
Eric Laurentaa79bef2015-01-15 14:33:51 -08001065 // Disable wait for status if delay is not 0.
1066 // Except for create audio patch command because the returned patch handle
1067 // is needed by audio policy manager
1068 if (delayMs != 0 && command->mCommand != CREATE_AUDIO_PATCH) {
Eric Laurentcec4abb2012-07-03 12:23:02 -07001069 command->mWaitStatus = false;
1070 }
Eric Laurentcec4abb2012-07-03 12:23:02 -07001071
Mathias Agopian65ab4712010-07-14 17:59:35 -07001072 // insert command at the right place according to its time stamp
Eric Laurent1e693b52014-07-09 15:03:28 -07001073 ALOGV("inserting command: %d at index %zd, num commands %zu",
1074 command->mCommand, i+1, mAudioCommands.size());
Mathias Agopian65ab4712010-07-14 17:59:35 -07001075 mAudioCommands.insertAt(command, i + 1);
1076}
1077
1078void AudioPolicyService::AudioCommandThread::exit()
1079{
Steve Block3856b092011-10-20 11:56:00 +01001080 ALOGV("AudioCommandThread::exit");
Mathias Agopian65ab4712010-07-14 17:59:35 -07001081 {
1082 AutoMutex _l(mLock);
1083 requestExit();
1084 mWaitWorkCV.signal();
1085 }
Zach Janga754b4f2015-10-27 01:29:34 +00001086 // Note that we can call it from the thread loop if all other references have been released
1087 // but it will safely return WOULD_BLOCK in this case
Mathias Agopian65ab4712010-07-14 17:59:35 -07001088 requestExitAndWait();
1089}
1090
1091void AudioPolicyService::AudioCommandThread::AudioCommand::dump(char* buffer, size_t size)
1092{
1093 snprintf(buffer, size, " %02d %06d.%03d %01u %p\n",
1094 mCommand,
1095 (int)ns2s(mTime),
1096 (int)ns2ms(mTime)%1000,
1097 mWaitStatus,
Eric Laurent0ede8922014-05-09 18:04:42 -07001098 mParam.get());
Mathias Agopian65ab4712010-07-14 17:59:35 -07001099}
1100
Dima Zavinfce7a472011-04-19 22:30:36 -07001101/******* helpers for the service_ops callbacks defined below *********/
1102void AudioPolicyService::setParameters(audio_io_handle_t ioHandle,
1103 const char *keyValuePairs,
1104 int delayMs)
1105{
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001106 mAudioCommandThread->parametersCommand(ioHandle, keyValuePairs,
Dima Zavinfce7a472011-04-19 22:30:36 -07001107 delayMs);
1108}
1109
1110int AudioPolicyService::setStreamVolume(audio_stream_type_t stream,
1111 float volume,
1112 audio_io_handle_t output,
1113 int delayMs)
1114{
Glenn Kastenfff6d712012-01-12 16:38:12 -08001115 return (int)mAudioCommandThread->volumeCommand(stream, volume,
Glenn Kasten72ef00d2012-01-17 11:09:42 -08001116 output, delayMs);
Dima Zavinfce7a472011-04-19 22:30:36 -07001117}
1118
1119int AudioPolicyService::startTone(audio_policy_tone_t tone,
1120 audio_stream_type_t stream)
1121{
Glenn Kasten6e2ebe92013-08-13 09:14:51 -07001122 if (tone != AUDIO_POLICY_TONE_IN_CALL_NOTIFICATION) {
Steve Block29357bc2012-01-06 19:20:56 +00001123 ALOGE("startTone: illegal tone requested (%d)", tone);
Glenn Kasten6e2ebe92013-08-13 09:14:51 -07001124 }
1125 if (stream != AUDIO_STREAM_VOICE_CALL) {
Steve Block29357bc2012-01-06 19:20:56 +00001126 ALOGE("startTone: illegal stream (%d) requested for tone %d", stream,
Glenn Kastene53b9ea2012-03-12 16:29:55 -07001127 tone);
Glenn Kasten6e2ebe92013-08-13 09:14:51 -07001128 }
Dima Zavinfce7a472011-04-19 22:30:36 -07001129 mTonePlaybackThread->startToneCommand(ToneGenerator::TONE_SUP_CALL_WAITING,
1130 AUDIO_STREAM_VOICE_CALL);
1131 return 0;
1132}
1133
1134int AudioPolicyService::stopTone()
1135{
1136 mTonePlaybackThread->stopToneCommand();
1137 return 0;
1138}
1139
1140int AudioPolicyService::setVoiceVolume(float volume, int delayMs)
1141{
1142 return (int)mAudioCommandThread->voiceVolumeCommand(volume, delayMs);
1143}
1144
Dima Zavinfce7a472011-04-19 22:30:36 -07001145extern "C" {
Eric Laurent2d388ec2014-03-07 13:25:54 -08001146audio_module_handle_t aps_load_hw_module(void *service __unused,
1147 const char *name);
1148audio_io_handle_t aps_open_output(void *service __unused,
Eric Laurenta4c5a552012-03-29 10:12:40 -07001149 audio_devices_t *pDevices,
1150 uint32_t *pSamplingRate,
1151 audio_format_t *pFormat,
1152 audio_channel_mask_t *pChannelMask,
1153 uint32_t *pLatencyMs,
Eric Laurent2d388ec2014-03-07 13:25:54 -08001154 audio_output_flags_t flags);
Eric Laurenta4c5a552012-03-29 10:12:40 -07001155
Eric Laurent2d388ec2014-03-07 13:25:54 -08001156audio_io_handle_t aps_open_output_on_module(void *service __unused,
Eric Laurenta4c5a552012-03-29 10:12:40 -07001157 audio_module_handle_t module,
1158 audio_devices_t *pDevices,
1159 uint32_t *pSamplingRate,
1160 audio_format_t *pFormat,
1161 audio_channel_mask_t *pChannelMask,
1162 uint32_t *pLatencyMs,
Richard Fitzgeraldad3af332013-03-25 16:54:37 +00001163 audio_output_flags_t flags,
Eric Laurent2d388ec2014-03-07 13:25:54 -08001164 const audio_offload_info_t *offloadInfo);
1165audio_io_handle_t aps_open_dup_output(void *service __unused,
Dima Zavinfce7a472011-04-19 22:30:36 -07001166 audio_io_handle_t output1,
Eric Laurent2d388ec2014-03-07 13:25:54 -08001167 audio_io_handle_t output2);
1168int aps_close_output(void *service __unused, audio_io_handle_t output);
1169int aps_suspend_output(void *service __unused, audio_io_handle_t output);
1170int aps_restore_output(void *service __unused, audio_io_handle_t output);
1171audio_io_handle_t aps_open_input(void *service __unused,
Eric Laurenta4c5a552012-03-29 10:12:40 -07001172 audio_devices_t *pDevices,
1173 uint32_t *pSamplingRate,
1174 audio_format_t *pFormat,
1175 audio_channel_mask_t *pChannelMask,
Eric Laurent2d388ec2014-03-07 13:25:54 -08001176 audio_in_acoustics_t acoustics __unused);
1177audio_io_handle_t aps_open_input_on_module(void *service __unused,
Eric Laurenta4c5a552012-03-29 10:12:40 -07001178 audio_module_handle_t module,
1179 audio_devices_t *pDevices,
1180 uint32_t *pSamplingRate,
1181 audio_format_t *pFormat,
Eric Laurent2d388ec2014-03-07 13:25:54 -08001182 audio_channel_mask_t *pChannelMask);
1183int aps_close_input(void *service __unused, audio_io_handle_t input);
1184int aps_invalidate_stream(void *service __unused, audio_stream_type_t stream);
Glenn Kastend848eb42016-03-08 13:42:11 -08001185int aps_move_effects(void *service __unused, audio_session_t session,
Dima Zavinfce7a472011-04-19 22:30:36 -07001186 audio_io_handle_t src_output,
Eric Laurent2d388ec2014-03-07 13:25:54 -08001187 audio_io_handle_t dst_output);
1188char * aps_get_parameters(void *service __unused, audio_io_handle_t io_handle,
1189 const char *keys);
1190void aps_set_parameters(void *service, audio_io_handle_t io_handle,
1191 const char *kv_pairs, int delay_ms);
1192int aps_set_stream_volume(void *service, audio_stream_type_t stream,
Dima Zavinfce7a472011-04-19 22:30:36 -07001193 float volume, audio_io_handle_t output,
Eric Laurent2d388ec2014-03-07 13:25:54 -08001194 int delay_ms);
1195int aps_start_tone(void *service, audio_policy_tone_t tone,
1196 audio_stream_type_t stream);
1197int aps_stop_tone(void *service);
1198int aps_set_voice_volume(void *service, float volume, int delay_ms);
1199};
Dima Zavinfce7a472011-04-19 22:30:36 -07001200
1201namespace {
1202 struct audio_policy_service_ops aps_ops = {
Glenn Kasten01d3acb2014-02-06 08:24:07 -08001203 .open_output = aps_open_output,
1204 .open_duplicate_output = aps_open_dup_output,
1205 .close_output = aps_close_output,
1206 .suspend_output = aps_suspend_output,
1207 .restore_output = aps_restore_output,
1208 .open_input = aps_open_input,
1209 .close_input = aps_close_input,
1210 .set_stream_volume = aps_set_stream_volume,
Glenn Kastend2304db2014-02-03 07:40:31 -08001211 .invalidate_stream = aps_invalidate_stream,
Glenn Kasten01d3acb2014-02-06 08:24:07 -08001212 .set_parameters = aps_set_parameters,
1213 .get_parameters = aps_get_parameters,
1214 .start_tone = aps_start_tone,
1215 .stop_tone = aps_stop_tone,
1216 .set_voice_volume = aps_set_voice_volume,
1217 .move_effects = aps_move_effects,
1218 .load_hw_module = aps_load_hw_module,
1219 .open_output_on_module = aps_open_output_on_module,
1220 .open_input_on_module = aps_open_input_on_module,
Dima Zavinfce7a472011-04-19 22:30:36 -07001221 };
1222}; // namespace <unnamed>
1223
Mathias Agopian65ab4712010-07-14 17:59:35 -07001224}; // namespace android