Merge change 8495

* changes:
  Fix issue 2001204: libaudiopolicy.so and libaudiopolicygeneric.so libraries must be pre-linked.
This commit is contained in:
Android (Google) Code Review
2009-07-25 00:54:36 -07:00
4 changed files with 26 additions and 61 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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,47 +49,29 @@ static bool checkPermission() {
// ----------------------------------------------------------------------------
AudioPolicyService::AudioPolicyService()
: BnAudioPolicyService() , mpPolicyManager(NULL), mpPolicyManagerLibHandle(NULL)
: BnAudioPolicyService() , mpPolicyManager(NULL)
{
const char *audioPolicyLibrary;
char value[PROPERTY_VALUE_MAX];
#if (defined GENERIC_AUDIO) || (defined AUDIO_POLICY_TEST)
audioPolicyLibrary = sAudioPolicyGenericLibrary;
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;
}
else {
LOGV("Using hardware specific audio policy");
audioPolicyLibrary = sAudioPolicyLibrary;
}
#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);
#if (defined GENERIC_AUDIO) || (defined AUDIO_POLICY_TEST)
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");
mpPolicyManager = new AudioPolicyManagerGeneric(this);
}
else {
LOGV("Using hardware specific audio policy");
mpPolicyManager = createAudioPolicyManager(this);
}
#endif
// load properties
property_get("ro.camera.sound.forced", value, "0");
@@ -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;
}
}

View File

@@ -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