summaryrefslogtreecommitdiff
path: root/libs/audioflinger/AudioPolicyService.cpp
diff options
context:
space:
mode:
author Eric Laurent <elaurent@google.com> 2009-07-24 06:58:44 -0700
committer Eric Laurent <elaurent@google.com> 2009-07-24 06:58:44 -0700
commit4192cce1f252932b6f3cae43e3da7584f4cb2c28 (patch)
treebfad0bc2d210f173264701e4a8b1c00db91bcb9d /libs/audioflinger/AudioPolicyService.cpp
parent30b06eb8b98b6e6dc685cf65ad4faa25a85008c5 (diff)
Fix issue 2001204: libaudiopolicy.so and libaudiopolicygeneric.so libraries must be pre-linked.
Diffstat (limited to 'libs/audioflinger/AudioPolicyService.cpp')
-rw-r--r--libs/audioflinger/AudioPolicyService.cpp49
1 files changed, 11 insertions, 38 deletions
diff --git a/libs/audioflinger/AudioPolicyService.cpp b/libs/audioflinger/AudioPolicyService.cpp
index 4810a44e9e61..7f6c4ed4eef8 100644
--- a/libs/audioflinger/AudioPolicyService.cpp
+++ b/libs/audioflinger/AudioPolicyService.cpp
@@ -23,6 +23,7 @@
#include <utils/String16.h>
#include <utils/threads.h>
#include "AudioPolicyService.h"
+#include "AudioPolicyManagerGeneric.h"
#include <cutils/properties.h>
#include <dlfcn.h>
@@ -35,9 +36,6 @@
namespace android {
-const char *AudioPolicyService::sAudioPolicyLibrary = "/system/lib/libaudiopolicy.so";
-const char *AudioPolicyService::sAudioPolicyGenericLibrary = "/system/lib/libaudiopolicygeneric.so";
-
static bool checkPermission() {
#ifndef HAVE_ANDROID_OS
return true;
@@ -51,48 +49,30 @@ static bool checkPermission() {
// ----------------------------------------------------------------------------
AudioPolicyService::AudioPolicyService()
- : BnAudioPolicyService() , mpPolicyManager(NULL), mpPolicyManagerLibHandle(NULL)
+ : BnAudioPolicyService() , mpPolicyManager(NULL)
{
- const char *audioPolicyLibrary;
char value[PROPERTY_VALUE_MAX];
+ // start tone playback thread
+ mTonePlaybacThread = new AudioCommandThread();
+ // start audio commands thread
+ mAudioCommandThread = new AudioCommandThread();
+
#if (defined GENERIC_AUDIO) || (defined AUDIO_POLICY_TEST)
- audioPolicyLibrary = sAudioPolicyGenericLibrary;
+ mpPolicyManager = new AudioPolicyManagerGeneric(this);
LOGV("build for GENERIC_AUDIO - using generic audio policy");
#else
// if running in emulation - use the emulator driver
if (property_get("ro.kernel.qemu", value, 0)) {
LOGV("Running in emulation - using generic audio policy");
- audioPolicyLibrary = sAudioPolicyGenericLibrary;
+ mpPolicyManager = new AudioPolicyManagerGeneric(this);
}
else {
LOGV("Using hardware specific audio policy");
- audioPolicyLibrary = sAudioPolicyLibrary;
+ mpPolicyManager = createAudioPolicyManager(this);
}
#endif
-
- mpPolicyManagerLibHandle = dlopen(audioPolicyLibrary, RTLD_NOW | RTLD_LOCAL);
- if (mpPolicyManagerLibHandle == NULL) {
- LOGW("Could not load libaudio policy library");
- return;
- }
-
- AudioPolicyInterface *(*createManager)(AudioPolicyClientInterface *) =
- reinterpret_cast<AudioPolicyInterface* (*)(AudioPolicyClientInterface *)>(dlsym(mpPolicyManagerLibHandle, "createAudioPolicyManager"));
-
- if (createManager == NULL ) {
- LOGW("Could not get createAudioPolicyManager method");
- return;
- }
-
- // start tone playback thread
- mTonePlaybacThread = new AudioCommandThread();
- // start audio commands thread
- mAudioCommandThread = new AudioCommandThread();
-
- mpPolicyManager = (*createManager)(this);
-
// load properties
property_get("ro.camera.sound.forced", value, "0");
mpPolicyManager->setSystemProperty("ro.camera.sound.forced", value);
@@ -106,14 +86,7 @@ AudioPolicyService::~AudioPolicyService()
mAudioCommandThread.clear();
if (mpPolicyManager) {
- void(*destroyManager)(AudioPolicyInterface *) =
- reinterpret_cast<void(*)(AudioPolicyInterface *)>(dlsym(mpPolicyManagerLibHandle, "destroyAudioPolicyManager"));
-
- if (destroyManager == NULL ) {
- LOGW("Could not get destroyAudioPolicyManager method");
- return;
- }
- (*destroyManager)(mpPolicyManager);
+ delete mpPolicyManager;
}
}