diff options
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 |
commit | a2e32699f4d0a967b271cb5d3ef141b3be4c1125 (patch) | |
tree | 6d52446ee6169c057344ec402386ae914b04ba44 /libs/audioflinger | |
parent | 009396037135aea962050dbf967fe31537018df1 (diff) | |
download | frameworks_native-a2e32699f4d0a967b271cb5d3ef141b3be4c1125.zip frameworks_native-a2e32699f4d0a967b271cb5d3ef141b3be4c1125.tar.gz frameworks_native-a2e32699f4d0a967b271cb5d3ef141b3be4c1125.tar.bz2 |
Fix issue 2001204: libaudiopolicy.so and libaudiopolicygeneric.so libraries must be pre-linked.
Diffstat (limited to 'libs/audioflinger')
-rw-r--r-- | libs/audioflinger/Android.mk | 12 | ||||
-rw-r--r-- | libs/audioflinger/AudioPolicyManagerGeneric.cpp | 11 | ||||
-rw-r--r-- | libs/audioflinger/AudioPolicyService.cpp | 49 | ||||
-rw-r--r-- | libs/audioflinger/AudioPolicyService.h | 3 |
4 files changed, 20 insertions, 55 deletions
diff --git a/libs/audioflinger/Android.mk b/libs/audioflinger/Android.mk index 7ed6a5f..ec9e332 100644 --- a/libs/audioflinger/Android.mk +++ b/libs/audioflinger/Android.mk @@ -54,6 +54,12 @@ LOCAL_SHARED_LIBRARIES := \ libutils \ libmedia +ifeq ($(TARGET_SIMULATOR),true) + LOCAL_LDLIBS += -ldl +else + LOCAL_SHARED_LIBRARIES += libdl +endif + LOCAL_MODULE:= libaudiopolicygeneric ifeq ($(BOARD_HAVE_BLUETOOTH),true) @@ -64,8 +70,6 @@ ifeq ($(AUDIO_POLICY_TEST),true) LOCAL_CFLAGS += -DAUDIO_POLICY_TEST endif -LOCAL_PRELINK_MODULE := false - include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) @@ -83,7 +87,9 @@ LOCAL_SHARED_LIBRARIES := \ libutils \ libbinder \ libmedia \ - libhardware_legacy + libhardware_legacy \ + libaudiopolicygeneric \ + libaudiopolicy ifeq ($(strip $(BOARD_USES_GENERIC_AUDIO)),true) LOCAL_STATIC_LIBRARIES += libaudiointerface diff --git a/libs/audioflinger/AudioPolicyManagerGeneric.cpp b/libs/audioflinger/AudioPolicyManagerGeneric.cpp index cf9ab88..4b31815 100644 --- a/libs/audioflinger/AudioPolicyManagerGeneric.cpp +++ b/libs/audioflinger/AudioPolicyManagerGeneric.cpp @@ -460,17 +460,6 @@ status_t AudioPolicyManagerGeneric::getStreamVolumeIndex(AudioSystem::stream_typ // --- class factory - -extern "C" AudioPolicyInterface* createAudioPolicyManager(AudioPolicyClientInterface *clientInterface) -{ - return new AudioPolicyManagerGeneric(clientInterface); -} - -extern "C" void destroyAudioPolicyManager(AudioPolicyInterface *interface) -{ - delete interface; -} - AudioPolicyManagerGeneric::AudioPolicyManagerGeneric(AudioPolicyClientInterface *clientInterface) : #ifdef AUDIO_POLICY_TEST diff --git a/libs/audioflinger/AudioPolicyService.cpp b/libs/audioflinger/AudioPolicyService.cpp index 4810a44..7f6c4ed 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; } } diff --git a/libs/audioflinger/AudioPolicyService.h b/libs/audioflinger/AudioPolicyService.h index 47173dd..1c46975 100644 --- a/libs/audioflinger/AudioPolicyService.h +++ b/libs/audioflinger/AudioPolicyService.h @@ -109,8 +109,6 @@ private: AudioPolicyService(); virtual ~AudioPolicyService(); - static const char *sAudioPolicyLibrary; - static const char *sAudioPolicyGenericLibrary; // Thread used for tone playback and to send audio config commands to audio flinger // For tone playback, using a separate thread is necessary to avoid deadlock with mLock because startTone() // and stopTone() are normally called with mLock locked and requesting a tone start or stop will cause @@ -185,7 +183,6 @@ private: AudioPolicyInterface* mpPolicyManager; // the platform specific policy manager sp <AudioCommandThread> mAudioCommandThread; // audio commands thread sp <AudioCommandThread> mTonePlaybacThread; // tone playback thread - void *mpPolicyManagerLibHandle; }; }; // namespace android |