AudioPolicyInterfaceImpl.cpp revision c8fc4803705da79aaaeff909538a976bf0e45852
1/* 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 "AudioPolicyIntefaceImpl" 18//#define LOG_NDEBUG 0 19 20#include <utils/Log.h> 21#include "AudioPolicyService.h" 22#include "ServiceUtilities.h" 23 24namespace android { 25 26 27// ---------------------------------------------------------------------------- 28 29status_t AudioPolicyService::setDeviceConnectionState(audio_devices_t device, 30 audio_policy_dev_state_t state, 31 const char *device_address, 32 const char *device_name) 33{ 34 if (mAudioPolicyManager == NULL) { 35 return NO_INIT; 36 } 37 if (!settingsAllowed()) { 38 return PERMISSION_DENIED; 39 } 40 if (!audio_is_output_device(device) && !audio_is_input_device(device)) { 41 return BAD_VALUE; 42 } 43 if (state != AUDIO_POLICY_DEVICE_STATE_AVAILABLE && 44 state != AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE) { 45 return BAD_VALUE; 46 } 47 48 ALOGV("setDeviceConnectionState()"); 49 Mutex::Autolock _l(mLock); 50 return mAudioPolicyManager->setDeviceConnectionState(device, state, 51 device_address, device_name); 52} 53 54audio_policy_dev_state_t AudioPolicyService::getDeviceConnectionState( 55 audio_devices_t device, 56 const char *device_address) 57{ 58 if (mAudioPolicyManager == NULL) { 59 return AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE; 60 } 61 return mAudioPolicyManager->getDeviceConnectionState(device, 62 device_address); 63} 64 65status_t AudioPolicyService::setPhoneState(audio_mode_t state) 66{ 67 if (mAudioPolicyManager == NULL) { 68 return NO_INIT; 69 } 70 if (!settingsAllowed()) { 71 return PERMISSION_DENIED; 72 } 73 if (uint32_t(state) >= AUDIO_MODE_CNT) { 74 return BAD_VALUE; 75 } 76 77 ALOGV("setPhoneState()"); 78 79 // acquire lock before calling setMode() so that setMode() + setPhoneState() are an atomic 80 // operation from policy manager standpoint (no other operation (e.g track start or stop) 81 // can be interleaved). 82 Mutex::Autolock _l(mLock); 83 84 // TODO: check if it is more appropriate to do it in platform specific policy manager 85 AudioSystem::setMode(state); 86 87 mAudioPolicyManager->setPhoneState(state); 88 mPhoneState = state; 89 return NO_ERROR; 90} 91 92audio_mode_t AudioPolicyService::getPhoneState() 93{ 94 Mutex::Autolock _l(mLock); 95 return mPhoneState; 96} 97 98status_t AudioPolicyService::setForceUse(audio_policy_force_use_t usage, 99 audio_policy_forced_cfg_t config) 100{ 101 if (mAudioPolicyManager == NULL) { 102 return NO_INIT; 103 } 104 if (!settingsAllowed()) { 105 return PERMISSION_DENIED; 106 } 107 if (usage < 0 || usage >= AUDIO_POLICY_FORCE_USE_CNT) { 108 return BAD_VALUE; 109 } 110 if (config < 0 || config >= AUDIO_POLICY_FORCE_CFG_CNT) { 111 return BAD_VALUE; 112 } 113 ALOGV("setForceUse()"); 114 Mutex::Autolock _l(mLock); 115 mAudioPolicyManager->setForceUse(usage, config); 116 return NO_ERROR; 117} 118 119audio_policy_forced_cfg_t AudioPolicyService::getForceUse(audio_policy_force_use_t usage) 120{ 121 if (mAudioPolicyManager == NULL) { 122 return AUDIO_POLICY_FORCE_NONE; 123 } 124 if (usage < 0 || usage >= AUDIO_POLICY_FORCE_USE_CNT) { 125 return AUDIO_POLICY_FORCE_NONE; 126 } 127 return mAudioPolicyManager->getForceUse(usage); 128} 129 130audio_io_handle_t AudioPolicyService::getOutput(audio_stream_type_t stream, 131 uint32_t samplingRate, 132 audio_format_t format, 133 audio_channel_mask_t channelMask, 134 audio_output_flags_t flags, 135 const audio_offload_info_t *offloadInfo) 136{ 137 if (uint32_t(stream) >= AUDIO_STREAM_PUBLIC_CNT) { 138 return AUDIO_IO_HANDLE_NONE; 139 } 140 if (mAudioPolicyManager == NULL) { 141 return AUDIO_IO_HANDLE_NONE; 142 } 143 ALOGV("getOutput()"); 144 Mutex::Autolock _l(mLock); 145 return mAudioPolicyManager->getOutput(stream, samplingRate, 146 format, channelMask, flags, offloadInfo); 147} 148 149status_t AudioPolicyService::getOutputForAttr(const audio_attributes_t *attr, 150 audio_io_handle_t *output, 151 audio_session_t session, 152 audio_stream_type_t *stream, 153 uid_t uid, 154 uint32_t samplingRate, 155 audio_format_t format, 156 audio_channel_mask_t channelMask, 157 audio_output_flags_t flags, 158 audio_port_handle_t selectedDeviceId, 159 const audio_offload_info_t *offloadInfo) 160{ 161 if (mAudioPolicyManager == NULL) { 162 return NO_INIT; 163 } 164 ALOGV("getOutput()"); 165 Mutex::Autolock _l(mLock); 166 167 const uid_t callingUid = IPCThreadState::self()->getCallingUid(); 168 if (!isTrustedCallingUid(callingUid) || uid == (uid_t)-1) { 169 ALOGW_IF(uid != (uid_t)-1 && uid != callingUid, 170 "%s uid %d tried to pass itself off as %d", __FUNCTION__, callingUid, uid); 171 uid = callingUid; 172 } 173 return mAudioPolicyManager->getOutputForAttr(attr, output, session, stream, uid, samplingRate, 174 format, channelMask, flags, selectedDeviceId, offloadInfo); 175} 176 177status_t AudioPolicyService::startOutput(audio_io_handle_t output, 178 audio_stream_type_t stream, 179 audio_session_t session) 180{ 181 if (uint32_t(stream) >= AUDIO_STREAM_CNT) { 182 return BAD_VALUE; 183 } 184 if (mAudioPolicyManager == NULL) { 185 return NO_INIT; 186 } 187 ALOGV("startOutput()"); 188 sp<AudioPolicyEffects>audioPolicyEffects; 189 { 190 Mutex::Autolock _l(mLock); 191 audioPolicyEffects = mAudioPolicyEffects; 192 } 193 if (audioPolicyEffects != 0) { 194 // create audio processors according to stream 195 status_t status = audioPolicyEffects->addOutputSessionEffects(output, stream, session); 196 if (status != NO_ERROR && status != ALREADY_EXISTS) { 197 ALOGW("Failed to add effects on session %d", session); 198 } 199 } 200 Mutex::Autolock _l(mLock); 201 return mAudioPolicyManager->startOutput(output, stream, session); 202} 203 204status_t AudioPolicyService::stopOutput(audio_io_handle_t output, 205 audio_stream_type_t stream, 206 audio_session_t session) 207{ 208 if (uint32_t(stream) >= AUDIO_STREAM_CNT) { 209 return BAD_VALUE; 210 } 211 if (mAudioPolicyManager == NULL) { 212 return NO_INIT; 213 } 214 ALOGV("stopOutput()"); 215 mOutputCommandThread->stopOutputCommand(output, stream, session); 216 return NO_ERROR; 217} 218 219status_t AudioPolicyService::doStopOutput(audio_io_handle_t output, 220 audio_stream_type_t stream, 221 audio_session_t session) 222{ 223 ALOGV("doStopOutput from tid %d", gettid()); 224 sp<AudioPolicyEffects>audioPolicyEffects; 225 { 226 Mutex::Autolock _l(mLock); 227 audioPolicyEffects = mAudioPolicyEffects; 228 } 229 if (audioPolicyEffects != 0) { 230 // release audio processors from the stream 231 status_t status = audioPolicyEffects->releaseOutputSessionEffects(output, stream, session); 232 if (status != NO_ERROR && status != ALREADY_EXISTS) { 233 ALOGW("Failed to release effects on session %d", session); 234 } 235 } 236 Mutex::Autolock _l(mLock); 237 return mAudioPolicyManager->stopOutput(output, stream, session); 238} 239 240void AudioPolicyService::releaseOutput(audio_io_handle_t output, 241 audio_stream_type_t stream, 242 audio_session_t session) 243{ 244 if (mAudioPolicyManager == NULL) { 245 return; 246 } 247 ALOGV("releaseOutput()"); 248 mOutputCommandThread->releaseOutputCommand(output, stream, session); 249} 250 251void AudioPolicyService::doReleaseOutput(audio_io_handle_t output, 252 audio_stream_type_t stream, 253 audio_session_t session) 254{ 255 ALOGV("doReleaseOutput from tid %d", gettid()); 256 Mutex::Autolock _l(mLock); 257 mAudioPolicyManager->releaseOutput(output, stream, session); 258} 259 260status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr, 261 audio_io_handle_t *input, 262 audio_session_t session, 263 uid_t uid, 264 uint32_t samplingRate, 265 audio_format_t format, 266 audio_channel_mask_t channelMask, 267 audio_input_flags_t flags, 268 audio_port_handle_t selectedDeviceId) 269{ 270 if (mAudioPolicyManager == NULL) { 271 return NO_INIT; 272 } 273 // already checked by client, but double-check in case the client wrapper is bypassed 274 if (attr->source >= AUDIO_SOURCE_CNT && attr->source != AUDIO_SOURCE_HOTWORD && 275 attr->source != AUDIO_SOURCE_FM_TUNER) { 276 return BAD_VALUE; 277 } 278 279 if ((attr->source == AUDIO_SOURCE_HOTWORD) && !captureHotwordAllowed()) { 280 return BAD_VALUE; 281 } 282 sp<AudioPolicyEffects>audioPolicyEffects; 283 status_t status; 284 AudioPolicyInterface::input_type_t inputType; 285 const uid_t callingUid = IPCThreadState::self()->getCallingUid(); 286 if (!isTrustedCallingUid(callingUid) || uid == (uid_t)-1) { 287 ALOGW_IF(uid != (uid_t)-1 && uid != callingUid, 288 "%s uid %d tried to pass itself off as %d", __FUNCTION__, callingUid, uid); 289 uid = callingUid; 290 } 291 292 { 293 Mutex::Autolock _l(mLock); 294 // the audio_in_acoustics_t parameter is ignored by get_input() 295 status = mAudioPolicyManager->getInputForAttr(attr, input, session, uid, 296 samplingRate, format, channelMask, 297 flags, selectedDeviceId, 298 &inputType); 299 audioPolicyEffects = mAudioPolicyEffects; 300 301 if (status == NO_ERROR) { 302 // enforce permission (if any) required for each type of input 303 switch (inputType) { 304 case AudioPolicyInterface::API_INPUT_LEGACY: 305 break; 306 case AudioPolicyInterface::API_INPUT_TELEPHONY_RX: 307 // FIXME: use the same permission as for remote submix for now. 308 case AudioPolicyInterface::API_INPUT_MIX_CAPTURE: 309 if (!captureAudioOutputAllowed()) { 310 ALOGE("getInputForAttr() permission denied: capture not allowed"); 311 status = PERMISSION_DENIED; 312 } 313 break; 314 case AudioPolicyInterface::API_INPUT_MIX_EXT_POLICY_REROUTE: 315 if (!modifyAudioRoutingAllowed()) { 316 ALOGE("getInputForAttr() permission denied: modify audio routing not allowed"); 317 status = PERMISSION_DENIED; 318 } 319 break; 320 case AudioPolicyInterface::API_INPUT_INVALID: 321 default: 322 LOG_ALWAYS_FATAL("getInputForAttr() encountered an invalid input type %d", 323 (int)inputType); 324 } 325 } 326 327 if (status != NO_ERROR) { 328 if (status == PERMISSION_DENIED) { 329 mAudioPolicyManager->releaseInput(*input, session); 330 } 331 return status; 332 } 333 } 334 335 if (audioPolicyEffects != 0) { 336 // create audio pre processors according to input source 337 status_t status = audioPolicyEffects->addInputEffects(*input, attr->source, session); 338 if (status != NO_ERROR && status != ALREADY_EXISTS) { 339 ALOGW("Failed to add effects on input %d", *input); 340 } 341 } 342 return NO_ERROR; 343} 344 345status_t AudioPolicyService::startInput(audio_io_handle_t input, 346 audio_session_t session) 347{ 348 if (mAudioPolicyManager == NULL) { 349 return NO_INIT; 350 } 351 Mutex::Autolock _l(mLock); 352 353 return mAudioPolicyManager->startInput(input, session); 354} 355 356status_t AudioPolicyService::stopInput(audio_io_handle_t input, 357 audio_session_t session) 358{ 359 if (mAudioPolicyManager == NULL) { 360 return NO_INIT; 361 } 362 Mutex::Autolock _l(mLock); 363 364 return mAudioPolicyManager->stopInput(input, session); 365} 366 367void AudioPolicyService::releaseInput(audio_io_handle_t input, 368 audio_session_t session) 369{ 370 if (mAudioPolicyManager == NULL) { 371 return; 372 } 373 sp<AudioPolicyEffects>audioPolicyEffects; 374 { 375 Mutex::Autolock _l(mLock); 376 mAudioPolicyManager->releaseInput(input, session); 377 audioPolicyEffects = mAudioPolicyEffects; 378 } 379 if (audioPolicyEffects != 0) { 380 // release audio processors from the input 381 status_t status = audioPolicyEffects->releaseInputEffects(input); 382 if(status != NO_ERROR) { 383 ALOGW("Failed to release effects on input %d", input); 384 } 385 } 386} 387 388status_t AudioPolicyService::initStreamVolume(audio_stream_type_t stream, 389 int indexMin, 390 int indexMax) 391{ 392 if (mAudioPolicyManager == NULL) { 393 return NO_INIT; 394 } 395 if (!settingsAllowed()) { 396 return PERMISSION_DENIED; 397 } 398 if (uint32_t(stream) >= AUDIO_STREAM_PUBLIC_CNT) { 399 return BAD_VALUE; 400 } 401 Mutex::Autolock _l(mLock); 402 mAudioPolicyManager->initStreamVolume(stream, indexMin, indexMax); 403 return NO_ERROR; 404} 405 406status_t AudioPolicyService::setStreamVolumeIndex(audio_stream_type_t stream, 407 int index, 408 audio_devices_t device) 409{ 410 if (mAudioPolicyManager == NULL) { 411 return NO_INIT; 412 } 413 if (!settingsAllowed()) { 414 return PERMISSION_DENIED; 415 } 416 if (uint32_t(stream) >= AUDIO_STREAM_PUBLIC_CNT) { 417 return BAD_VALUE; 418 } 419 Mutex::Autolock _l(mLock); 420 return mAudioPolicyManager->setStreamVolumeIndex(stream, 421 index, 422 device); 423} 424 425status_t AudioPolicyService::getStreamVolumeIndex(audio_stream_type_t stream, 426 int *index, 427 audio_devices_t device) 428{ 429 if (mAudioPolicyManager == NULL) { 430 return NO_INIT; 431 } 432 if (uint32_t(stream) >= AUDIO_STREAM_PUBLIC_CNT) { 433 return BAD_VALUE; 434 } 435 Mutex::Autolock _l(mLock); 436 return mAudioPolicyManager->getStreamVolumeIndex(stream, 437 index, 438 device); 439} 440 441uint32_t AudioPolicyService::getStrategyForStream(audio_stream_type_t stream) 442{ 443 if (uint32_t(stream) >= AUDIO_STREAM_PUBLIC_CNT) { 444 return 0; 445 } 446 if (mAudioPolicyManager == NULL) { 447 return 0; 448 } 449 return mAudioPolicyManager->getStrategyForStream(stream); 450} 451 452//audio policy: use audio_device_t appropriately 453 454audio_devices_t AudioPolicyService::getDevicesForStream(audio_stream_type_t stream) 455{ 456 if (uint32_t(stream) >= AUDIO_STREAM_PUBLIC_CNT) { 457 return AUDIO_DEVICE_NONE; 458 } 459 if (mAudioPolicyManager == NULL) { 460 return AUDIO_DEVICE_NONE; 461 } 462 Mutex::Autolock _l(mLock); 463 return mAudioPolicyManager->getDevicesForStream(stream); 464} 465 466audio_io_handle_t AudioPolicyService::getOutputForEffect(const effect_descriptor_t *desc) 467{ 468 // FIXME change return type to status_t, and return NO_INIT here 469 if (mAudioPolicyManager == NULL) { 470 return 0; 471 } 472 Mutex::Autolock _l(mLock); 473 return mAudioPolicyManager->getOutputForEffect(desc); 474} 475 476status_t AudioPolicyService::registerEffect(const effect_descriptor_t *desc, 477 audio_io_handle_t io, 478 uint32_t strategy, 479 int session, 480 int id) 481{ 482 if (mAudioPolicyManager == NULL) { 483 return NO_INIT; 484 } 485 Mutex::Autolock _l(mEffectsLock); 486 return mAudioPolicyManager->registerEffect(desc, io, strategy, session, id); 487} 488 489status_t AudioPolicyService::unregisterEffect(int id) 490{ 491 if (mAudioPolicyManager == NULL) { 492 return NO_INIT; 493 } 494 Mutex::Autolock _l(mEffectsLock); 495 return mAudioPolicyManager->unregisterEffect(id); 496} 497 498status_t AudioPolicyService::setEffectEnabled(int id, bool enabled) 499{ 500 if (mAudioPolicyManager == NULL) { 501 return NO_INIT; 502 } 503 Mutex::Autolock _l(mEffectsLock); 504 return mAudioPolicyManager->setEffectEnabled(id, enabled); 505} 506 507bool AudioPolicyService::isStreamActive(audio_stream_type_t stream, uint32_t inPastMs) const 508{ 509 if (uint32_t(stream) >= AUDIO_STREAM_PUBLIC_CNT) { 510 return false; 511 } 512 if (mAudioPolicyManager == NULL) { 513 return false; 514 } 515 Mutex::Autolock _l(mLock); 516 return mAudioPolicyManager->isStreamActive(stream, inPastMs); 517} 518 519bool AudioPolicyService::isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs) const 520{ 521 if (uint32_t(stream) >= AUDIO_STREAM_PUBLIC_CNT) { 522 return false; 523 } 524 if (mAudioPolicyManager == NULL) { 525 return false; 526 } 527 Mutex::Autolock _l(mLock); 528 return mAudioPolicyManager->isStreamActiveRemotely(stream, inPastMs); 529} 530 531bool AudioPolicyService::isSourceActive(audio_source_t source) const 532{ 533 if (mAudioPolicyManager == NULL) { 534 return false; 535 } 536 Mutex::Autolock _l(mLock); 537 return mAudioPolicyManager->isSourceActive(source); 538} 539 540status_t AudioPolicyService::queryDefaultPreProcessing(int audioSession, 541 effect_descriptor_t *descriptors, 542 uint32_t *count) 543{ 544 if (mAudioPolicyManager == NULL) { 545 *count = 0; 546 return NO_INIT; 547 } 548 sp<AudioPolicyEffects>audioPolicyEffects; 549 { 550 Mutex::Autolock _l(mLock); 551 audioPolicyEffects = mAudioPolicyEffects; 552 } 553 if (audioPolicyEffects == 0) { 554 *count = 0; 555 return NO_INIT; 556 } 557 return audioPolicyEffects->queryDefaultInputEffects(audioSession, descriptors, count); 558} 559 560bool AudioPolicyService::isOffloadSupported(const audio_offload_info_t& info) 561{ 562 if (mAudioPolicyManager == NULL) { 563 ALOGV("mAudioPolicyManager == NULL"); 564 return false; 565 } 566 Mutex::Autolock _l(mLock); 567 Mutex::Autolock _le(mEffectsLock); // isOffloadSupported queries for 568 // non-offloadable effects 569 return mAudioPolicyManager->isOffloadSupported(info); 570} 571 572status_t AudioPolicyService::listAudioPorts(audio_port_role_t role, 573 audio_port_type_t type, 574 unsigned int *num_ports, 575 struct audio_port *ports, 576 unsigned int *generation) 577{ 578 Mutex::Autolock _l(mLock); 579 if (mAudioPolicyManager == NULL) { 580 return NO_INIT; 581 } 582 583 return mAudioPolicyManager->listAudioPorts(role, type, num_ports, ports, generation); 584} 585 586status_t AudioPolicyService::getAudioPort(struct audio_port *port) 587{ 588 Mutex::Autolock _l(mLock); 589 if (mAudioPolicyManager == NULL) { 590 return NO_INIT; 591 } 592 593 return mAudioPolicyManager->getAudioPort(port); 594} 595 596status_t AudioPolicyService::createAudioPatch(const struct audio_patch *patch, 597 audio_patch_handle_t *handle) 598{ 599 Mutex::Autolock _l(mLock); 600 if(!modifyAudioRoutingAllowed()) { 601 return PERMISSION_DENIED; 602 } 603 if (mAudioPolicyManager == NULL) { 604 return NO_INIT; 605 } 606 return mAudioPolicyManager->createAudioPatch(patch, handle, 607 IPCThreadState::self()->getCallingUid()); 608} 609 610status_t AudioPolicyService::releaseAudioPatch(audio_patch_handle_t handle) 611{ 612 Mutex::Autolock _l(mLock); 613 if(!modifyAudioRoutingAllowed()) { 614 return PERMISSION_DENIED; 615 } 616 if (mAudioPolicyManager == NULL) { 617 return NO_INIT; 618 } 619 620 return mAudioPolicyManager->releaseAudioPatch(handle, 621 IPCThreadState::self()->getCallingUid()); 622} 623 624status_t AudioPolicyService::listAudioPatches(unsigned int *num_patches, 625 struct audio_patch *patches, 626 unsigned int *generation) 627{ 628 Mutex::Autolock _l(mLock); 629 if (mAudioPolicyManager == NULL) { 630 return NO_INIT; 631 } 632 633 return mAudioPolicyManager->listAudioPatches(num_patches, patches, generation); 634} 635 636status_t AudioPolicyService::setAudioPortConfig(const struct audio_port_config *config) 637{ 638 Mutex::Autolock _l(mLock); 639 if(!modifyAudioRoutingAllowed()) { 640 return PERMISSION_DENIED; 641 } 642 if (mAudioPolicyManager == NULL) { 643 return NO_INIT; 644 } 645 646 return mAudioPolicyManager->setAudioPortConfig(config); 647} 648 649status_t AudioPolicyService::acquireSoundTriggerSession(audio_session_t *session, 650 audio_io_handle_t *ioHandle, 651 audio_devices_t *device) 652{ 653 if (mAudioPolicyManager == NULL) { 654 return NO_INIT; 655 } 656 657 return mAudioPolicyManager->acquireSoundTriggerSession(session, ioHandle, device); 658} 659 660status_t AudioPolicyService::releaseSoundTriggerSession(audio_session_t session) 661{ 662 if (mAudioPolicyManager == NULL) { 663 return NO_INIT; 664 } 665 666 return mAudioPolicyManager->releaseSoundTriggerSession(session); 667} 668 669status_t AudioPolicyService::registerPolicyMixes(Vector<AudioMix> mixes, bool registration) 670{ 671 Mutex::Autolock _l(mLock); 672 if(!modifyAudioRoutingAllowed()) { 673 return PERMISSION_DENIED; 674 } 675 if (mAudioPolicyManager == NULL) { 676 return NO_INIT; 677 } 678 if (registration) { 679 return mAudioPolicyManager->registerPolicyMixes(mixes); 680 } else { 681 return mAudioPolicyManager->unregisterPolicyMixes(mixes); 682 } 683} 684 685status_t AudioPolicyService::startAudioSource(const struct audio_port_config *source, 686 const audio_attributes_t *attributes, 687 audio_io_handle_t *handle) 688{ 689 Mutex::Autolock _l(mLock); 690 if (mAudioPolicyManager == NULL) { 691 return NO_INIT; 692 } 693 694 return mAudioPolicyManager->startAudioSource(source, attributes, handle, 695 IPCThreadState::self()->getCallingUid()); 696} 697 698status_t AudioPolicyService::stopAudioSource(audio_io_handle_t handle) 699{ 700 Mutex::Autolock _l(mLock); 701 if (mAudioPolicyManager == NULL) { 702 return NO_INIT; 703 } 704 705 return mAudioPolicyManager->stopAudioSource(handle); 706} 707 708status_t AudioPolicyService::setMasterMono(bool mono) 709{ 710 if (mAudioPolicyManager == NULL) { 711 return NO_INIT; 712 } 713 if (!settingsAllowed()) { 714 return PERMISSION_DENIED; 715 } 716 Mutex::Autolock _l(mLock); 717 return mAudioPolicyManager->setMasterMono(mono); 718} 719 720status_t AudioPolicyService::getMasterMono(bool *mono) 721{ 722 if (mAudioPolicyManager == NULL) { 723 return NO_INIT; 724 } 725 Mutex::Autolock _l(mLock); 726 return mAudioPolicyManager->getMasterMono(mono); 727} 728 729}; // namespace android 730