Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 03032f5a authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 8495

* changes:
  Fix issue 2001204: libaudiopolicy.so and libaudiopolicygeneric.so libraries must be pre-linked.
parents 07b13379 a2e32699
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -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
+0 −11
Original line number Diff line number Diff line
@@ -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
+11 −38
Original line number Diff line number Diff line
@@ -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;
    }
}

+0 −3
Original line number Diff line number Diff line
@@ -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