summaryrefslogtreecommitdiffstats
path: root/services/audiopolicy/AudioPolicyInterfaceImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'services/audiopolicy/AudioPolicyInterfaceImpl.cpp')
-rw-r--r--services/audiopolicy/AudioPolicyInterfaceImpl.cpp140
1 files changed, 59 insertions, 81 deletions
diff --git a/services/audiopolicy/AudioPolicyInterfaceImpl.cpp b/services/audiopolicy/AudioPolicyInterfaceImpl.cpp
index bb62ab3..c57c4fa 100644
--- a/services/audiopolicy/AudioPolicyInterfaceImpl.cpp
+++ b/services/audiopolicy/AudioPolicyInterfaceImpl.cpp
@@ -14,17 +14,13 @@
* limitations under the License.
*/
-#define LOG_TAG "AudioPolicyService"
+#define LOG_TAG "AudioPolicyIntefaceImpl"
//#define LOG_NDEBUG 0
#include <utils/Log.h>
#include "AudioPolicyService.h"
#include "ServiceUtilities.h"
-#include <system/audio.h>
-#include <system/audio_policy.h>
-#include <hardware/audio_policy.h>
-
namespace android {
@@ -34,7 +30,7 @@ status_t AudioPolicyService::setDeviceConnectionState(audio_devices_t device,
audio_policy_dev_state_t state,
const char *device_address)
{
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
return NO_INIT;
}
if (!settingsAllowed()) {
@@ -50,7 +46,7 @@ status_t AudioPolicyService::setDeviceConnectionState(audio_devices_t device,
ALOGV("setDeviceConnectionState()");
Mutex::Autolock _l(mLock);
- return mpAudioPolicy->set_device_connection_state(mpAudioPolicy, device,
+ return mAudioPolicyManager->setDeviceConnectionState(device,
state, device_address);
}
@@ -58,16 +54,16 @@ audio_policy_dev_state_t AudioPolicyService::getDeviceConnectionState(
audio_devices_t device,
const char *device_address)
{
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
return AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE;
}
- return mpAudioPolicy->get_device_connection_state(mpAudioPolicy, device,
+ return mAudioPolicyManager->getDeviceConnectionState(device,
device_address);
}
status_t AudioPolicyService::setPhoneState(audio_mode_t state)
{
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
return NO_INIT;
}
if (!settingsAllowed()) {
@@ -83,14 +79,14 @@ status_t AudioPolicyService::setPhoneState(audio_mode_t state)
AudioSystem::setMode(state);
Mutex::Autolock _l(mLock);
- mpAudioPolicy->set_phone_state(mpAudioPolicy, state);
+ mAudioPolicyManager->setPhoneState(state);
return NO_ERROR;
}
status_t AudioPolicyService::setForceUse(audio_policy_force_use_t usage,
audio_policy_forced_cfg_t config)
{
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
return NO_INIT;
}
if (!settingsAllowed()) {
@@ -104,19 +100,19 @@ status_t AudioPolicyService::setForceUse(audio_policy_force_use_t usage,
}
ALOGV("setForceUse()");
Mutex::Autolock _l(mLock);
- mpAudioPolicy->set_force_use(mpAudioPolicy, usage, config);
+ mAudioPolicyManager->setForceUse(usage, config);
return NO_ERROR;
}
audio_policy_forced_cfg_t AudioPolicyService::getForceUse(audio_policy_force_use_t usage)
{
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
return AUDIO_POLICY_FORCE_NONE;
}
if (usage < 0 || usage >= AUDIO_POLICY_FORCE_USE_CNT) {
return AUDIO_POLICY_FORCE_NONE;
}
- return mpAudioPolicy->get_force_use(mpAudioPolicy, usage);
+ return mAudioPolicyManager->getForceUse(usage);
}
audio_io_handle_t AudioPolicyService::getOutput(audio_stream_type_t stream,
@@ -126,12 +122,12 @@ audio_io_handle_t AudioPolicyService::getOutput(audio_stream_type_t stream,
audio_output_flags_t flags,
const audio_offload_info_t *offloadInfo)
{
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
return 0;
}
ALOGV("getOutput()");
Mutex::Autolock _l(mLock);
- return mpAudioPolicy->get_output(mpAudioPolicy, stream, samplingRate,
+ return mAudioPolicyManager->getOutput(stream, samplingRate,
format, channelMask, flags, offloadInfo);
}
@@ -139,19 +135,19 @@ status_t AudioPolicyService::startOutput(audio_io_handle_t output,
audio_stream_type_t stream,
int session)
{
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
return NO_INIT;
}
ALOGV("startOutput()");
Mutex::Autolock _l(mLock);
- return mpAudioPolicy->start_output(mpAudioPolicy, output, stream, session);
+ return mAudioPolicyManager->startOutput(output, stream, session);
}
status_t AudioPolicyService::stopOutput(audio_io_handle_t output,
audio_stream_type_t stream,
int session)
{
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
return NO_INIT;
}
ALOGV("stopOutput()");
@@ -165,12 +161,12 @@ status_t AudioPolicyService::doStopOutput(audio_io_handle_t output,
{
ALOGV("doStopOutput from tid %d", gettid());
Mutex::Autolock _l(mLock);
- return mpAudioPolicy->stop_output(mpAudioPolicy, output, stream, session);
+ return mAudioPolicyManager->stopOutput(output, stream, session);
}
void AudioPolicyService::releaseOutput(audio_io_handle_t output)
{
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
return;
}
ALOGV("releaseOutput()");
@@ -181,7 +177,7 @@ void AudioPolicyService::doReleaseOutput(audio_io_handle_t output)
{
ALOGV("doReleaseOutput from tid %d", gettid());
Mutex::Autolock _l(mLock);
- mpAudioPolicy->release_output(mpAudioPolicy, output);
+ mAudioPolicyManager->releaseOutput(output);
}
audio_io_handle_t AudioPolicyService::getInput(audio_source_t inputSource,
@@ -190,7 +186,7 @@ audio_io_handle_t AudioPolicyService::getInput(audio_source_t inputSource,
audio_channel_mask_t channelMask,
int audioSession)
{
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
return 0;
}
// already checked by client, but double-check in case the client wrapper is bypassed
@@ -204,7 +200,7 @@ audio_io_handle_t AudioPolicyService::getInput(audio_source_t inputSource,
Mutex::Autolock _l(mLock);
// the audio_in_acoustics_t parameter is ignored by get_input()
- audio_io_handle_t input = mpAudioPolicy->get_input(mpAudioPolicy, inputSource, samplingRate,
+ audio_io_handle_t input = mAudioPolicyManager->getInput(inputSource, samplingRate,
format, channelMask, (audio_in_acoustics_t) 0);
if (input == 0) {
@@ -248,31 +244,31 @@ audio_io_handle_t AudioPolicyService::getInput(audio_source_t inputSource,
status_t AudioPolicyService::startInput(audio_io_handle_t input)
{
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
return NO_INIT;
}
Mutex::Autolock _l(mLock);
- return mpAudioPolicy->start_input(mpAudioPolicy, input);
+ return mAudioPolicyManager->startInput(input);
}
status_t AudioPolicyService::stopInput(audio_io_handle_t input)
{
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
return NO_INIT;
}
Mutex::Autolock _l(mLock);
- return mpAudioPolicy->stop_input(mpAudioPolicy, input);
+ return mAudioPolicyManager->stopInput(input);
}
void AudioPolicyService::releaseInput(audio_io_handle_t input)
{
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
return;
}
Mutex::Autolock _l(mLock);
- mpAudioPolicy->release_input(mpAudioPolicy, input);
+ mAudioPolicyManager->releaseInput(input);
ssize_t index = mInputs.indexOfKey(input);
if (index < 0) {
@@ -288,7 +284,7 @@ status_t AudioPolicyService::initStreamVolume(audio_stream_type_t stream,
int indexMin,
int indexMax)
{
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
return NO_INIT;
}
if (!settingsAllowed()) {
@@ -298,7 +294,7 @@ status_t AudioPolicyService::initStreamVolume(audio_stream_type_t stream,
return BAD_VALUE;
}
Mutex::Autolock _l(mLock);
- mpAudioPolicy->init_stream_volume(mpAudioPolicy, stream, indexMin, indexMax);
+ mAudioPolicyManager->initStreamVolume(stream, indexMin, indexMax);
return NO_ERROR;
}
@@ -306,7 +302,7 @@ status_t AudioPolicyService::setStreamVolumeIndex(audio_stream_type_t stream,
int index,
audio_devices_t device)
{
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
return NO_INIT;
}
if (!settingsAllowed()) {
@@ -316,63 +312,53 @@ status_t AudioPolicyService::setStreamVolumeIndex(audio_stream_type_t stream,
return BAD_VALUE;
}
Mutex::Autolock _l(mLock);
- if (mpAudioPolicy->set_stream_volume_index_for_device) {
- return mpAudioPolicy->set_stream_volume_index_for_device(mpAudioPolicy,
- stream,
- index,
- device);
- } else {
- return mpAudioPolicy->set_stream_volume_index(mpAudioPolicy, stream, index);
- }
+ return mAudioPolicyManager->setStreamVolumeIndex(stream,
+ index,
+ device);
}
status_t AudioPolicyService::getStreamVolumeIndex(audio_stream_type_t stream,
int *index,
audio_devices_t device)
{
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
return NO_INIT;
}
if (uint32_t(stream) >= AUDIO_STREAM_CNT) {
return BAD_VALUE;
}
Mutex::Autolock _l(mLock);
- if (mpAudioPolicy->get_stream_volume_index_for_device) {
- return mpAudioPolicy->get_stream_volume_index_for_device(mpAudioPolicy,
- stream,
- index,
- device);
- } else {
- return mpAudioPolicy->get_stream_volume_index(mpAudioPolicy, stream, index);
- }
+ return mAudioPolicyManager->getStreamVolumeIndex(stream,
+ index,
+ device);
}
uint32_t AudioPolicyService::getStrategyForStream(audio_stream_type_t stream)
{
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
return 0;
}
- return mpAudioPolicy->get_strategy_for_stream(mpAudioPolicy, stream);
+ return mAudioPolicyManager->getStrategyForStream(stream);
}
//audio policy: use audio_device_t appropriately
audio_devices_t AudioPolicyService::getDevicesForStream(audio_stream_type_t stream)
{
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
return (audio_devices_t)0;
}
- return mpAudioPolicy->get_devices_for_stream(mpAudioPolicy, stream);
+ return mAudioPolicyManager->getDevicesForStream(stream);
}
audio_io_handle_t AudioPolicyService::getOutputForEffect(const effect_descriptor_t *desc)
{
// FIXME change return type to status_t, and return NO_INIT here
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
return 0;
}
Mutex::Autolock _l(mLock);
- return mpAudioPolicy->get_output_for_effect(mpAudioPolicy, desc);
+ return mAudioPolicyManager->getOutputForEffect(desc);
}
status_t AudioPolicyService::registerEffect(const effect_descriptor_t *desc,
@@ -381,56 +367,53 @@ status_t AudioPolicyService::registerEffect(const effect_descriptor_t *desc,
int session,
int id)
{
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
return NO_INIT;
}
- return mpAudioPolicy->register_effect(mpAudioPolicy, desc, io, strategy, session, id);
+ return mAudioPolicyManager->registerEffect(desc, io, strategy, session, id);
}
status_t AudioPolicyService::unregisterEffect(int id)
{
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
return NO_INIT;
}
- return mpAudioPolicy->unregister_effect(mpAudioPolicy, id);
+ return mAudioPolicyManager->unregisterEffect(id);
}
status_t AudioPolicyService::setEffectEnabled(int id, bool enabled)
{
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
return NO_INIT;
}
- return mpAudioPolicy->set_effect_enabled(mpAudioPolicy, id, enabled);
+ return mAudioPolicyManager->setEffectEnabled(id, enabled);
}
bool AudioPolicyService::isStreamActive(audio_stream_type_t stream, uint32_t inPastMs) const
{
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
return 0;
}
Mutex::Autolock _l(mLock);
- return mpAudioPolicy->is_stream_active(mpAudioPolicy, stream, inPastMs);
+ return mAudioPolicyManager->isStreamActive(stream, inPastMs);
}
bool AudioPolicyService::isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs) const
{
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
return 0;
}
Mutex::Autolock _l(mLock);
- return mpAudioPolicy->is_stream_active_remotely(mpAudioPolicy, stream, inPastMs);
+ return mAudioPolicyManager->isStreamActiveRemotely(stream, inPastMs);
}
bool AudioPolicyService::isSourceActive(audio_source_t source) const
{
- if (mpAudioPolicy == NULL) {
- return false;
- }
- if (mpAudioPolicy->is_source_active == 0) {
+ if (mAudioPolicyManager == NULL) {
return false;
}
Mutex::Autolock _l(mLock);
- return mpAudioPolicy->is_source_active(mpAudioPolicy, source);
+ return mAudioPolicyManager->isSourceActive(source);
}
status_t AudioPolicyService::queryDefaultPreProcessing(int audioSession,
@@ -438,7 +421,7 @@ status_t AudioPolicyService::queryDefaultPreProcessing(int audioSession,
uint32_t *count)
{
- if (mpAudioPolicy == NULL) {
+ if (mAudioPolicyManager == NULL) {
*count = 0;
return NO_INIT;
}
@@ -472,17 +455,12 @@ status_t AudioPolicyService::queryDefaultPreProcessing(int audioSession,
bool AudioPolicyService::isOffloadSupported(const audio_offload_info_t& info)
{
- if (mpAudioPolicy == NULL) {
- ALOGV("mpAudioPolicy == NULL");
- return false;
- }
-
- if (mpAudioPolicy->is_offload_supported == NULL) {
- ALOGV("HAL does not implement is_offload_supported");
+ if (mAudioPolicyManager == NULL) {
+ ALOGV("mAudioPolicyManager == NULL");
return false;
}
- return mpAudioPolicy->is_offload_supported(mpAudioPolicy, &info);
+ return mAudioPolicyManager->isOffloadSupported(info);
}