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

Commit 54be356f authored by Andreas Huber's avatar Andreas Huber Committed by Android Git Automerger
Browse files

am 874c508c: am bfb9fb14: Refactor MediaScanner. Some steps on the way towards...

am 874c508c: am bfb9fb14: Refactor MediaScanner. Some steps on the way towards being able to build the tree without OpenCore.

Merge commit '874c508c'

* commit '874c508c':
  Refactor MediaScanner. Some steps on the way towards being able to build the tree without OpenCore.
parents fb6aafd8 874c508c
Loading
Loading
Loading
Loading
+27 −20
Original line number Original line Diff line number Diff line
@@ -28,33 +28,40 @@ namespace android {
class MediaScannerClient;
class MediaScannerClient;
class StringArray;
class StringArray;


class MediaScanner 
struct MediaScanner {
{
public:
    MediaScanner();
    MediaScanner();
    ~MediaScanner();
    virtual ~MediaScanner();

    virtual status_t processFile(
            const char *path, const char *mimeType,
            MediaScannerClient &client) = 0;


    typedef bool (*ExceptionCheck)(void* env);
    typedef bool (*ExceptionCheck)(void* env);
    virtual status_t processDirectory(
            const char *path, const char *extensions,
            MediaScannerClient &client,
            ExceptionCheck exceptionCheck, void *exceptionEnv);


    status_t processFile(const char *path, const char *mimeType, MediaScannerClient& client);
    status_t processDirectory(const char *path, const char* extensions, 
            MediaScannerClient& client, ExceptionCheck exceptionCheck, void* exceptionEnv);
    void setLocale(const char *locale);
    void setLocale(const char *locale);


    // extracts album art as a block of data
    // extracts album art as a block of data
    char* extractAlbumArt(int fd);
    virtual char *extractAlbumArt(int fd) = 0;


    static void uninitializeForThread();
protected:
    const char *locale() const;


private:
private:
    status_t doProcessDirectory(char *path, int pathRemaining, const char* extensions, 
            MediaScannerClient& client, ExceptionCheck exceptionCheck, void* exceptionEnv);
    void initializeForThread();
    
    // current locale (like "ja_JP"), created/destroyed with strdup()/free()
    // current locale (like "ja_JP"), created/destroyed with strdup()/free()
    char *mLocale;
    char *mLocale;
};


    status_t doProcessDirectory(
            char *path, int pathRemaining, const char *extensions,
            MediaScannerClient &client, ExceptionCheck exceptionCheck,
            void *exceptionEnv);

    MediaScanner(const MediaScanner &);
    MediaScanner &operator=(const MediaScanner &);
};


class MediaScannerClient
class MediaScannerClient
{
{
+12 −5
Original line number Original line Diff line number Diff line
ifneq ($(BUILD_WITHOUT_PV),true)
LOCAL_PATH:= $(call my-dir)
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
include $(CLEAR_VARS)


@@ -7,12 +6,9 @@ LOCAL_SRC_FILES:= \
    android_media_MediaRecorder.cpp \
    android_media_MediaRecorder.cpp \
    android_media_MediaScanner.cpp \
    android_media_MediaScanner.cpp \
    android_media_MediaMetadataRetriever.cpp \
    android_media_MediaMetadataRetriever.cpp \
    android_media_AmrInputStream.cpp \
    android_media_ResampleInputStream.cpp
    android_media_ResampleInputStream.cpp


LOCAL_SHARED_LIBRARIES := \
LOCAL_SHARED_LIBRARIES := \
    libopencore_player \
    libomx_amrenc_sharedlibrary \
    libandroid_runtime \
    libandroid_runtime \
    libnativehelper \
    libnativehelper \
    libutils \
    libutils \
@@ -21,11 +17,23 @@ LOCAL_SHARED_LIBRARIES := \
    libskia \
    libskia \
    libui
    libui


ifneq ($(BUILD_WITHOUT_PV),true)
LOCAL_SRC_FILES += \
    android_media_AmrInputStream.cpp

LOCAL_SHARED_LIBRARIES += \
    libopencore_player          \
    libomx_amrenc_sharedlibrary
else
    LOCAL_CFLAGS += -DNO_OPENCORE
endif

LOCAL_STATIC_LIBRARIES :=
LOCAL_STATIC_LIBRARIES :=


LOCAL_C_INCLUDES += \
LOCAL_C_INCLUDES += \
    external/tremor/Tremor \
    external/tremor/Tremor \
    frameworks/base/core/jni \
    frameworks/base/core/jni \
    frameworks/base/media/libmedia \
    $(PV_INCLUDES) \
    $(PV_INCLUDES) \
    $(JNI_H_INCLUDE) \
    $(JNI_H_INCLUDE) \
    $(call include-path-for, corecg graphics)
    $(call include-path-for, corecg graphics)
@@ -40,4 +48,3 @@ include $(BUILD_SHARED_LIBRARY)


# build libsoundpool.so
# build libsoundpool.so
include $(LOCAL_PATH)/soundpool/Android.mk
include $(LOCAL_PATH)/soundpool/Android.mk
endif
+7 −2
Original line number Original line Diff line number Diff line
@@ -648,12 +648,15 @@ static int register_android_media_MediaPlayer(JNIEnv *env)
                "android/media/MediaPlayer", gMethods, NELEM(gMethods));
                "android/media/MediaPlayer", gMethods, NELEM(gMethods));
}
}


extern int register_android_media_MediaMetadataRetriever(JNIEnv *env);
extern int register_android_media_MediaRecorder(JNIEnv *env);
extern int register_android_media_MediaRecorder(JNIEnv *env);
extern int register_android_media_MediaScanner(JNIEnv *env);
extern int register_android_media_MediaScanner(JNIEnv *env);
extern int register_android_media_MediaMetadataRetriever(JNIEnv *env);
extern int register_android_media_AmrInputStream(JNIEnv *env);
extern int register_android_media_ResampleInputStream(JNIEnv *env);
extern int register_android_media_ResampleInputStream(JNIEnv *env);


#ifndef NO_OPENCORE
extern int register_android_media_AmrInputStream(JNIEnv *env);
#endif

jint JNI_OnLoad(JavaVM* vm, void* reserved)
jint JNI_OnLoad(JavaVM* vm, void* reserved)
{
{
    JNIEnv* env = NULL;
    JNIEnv* env = NULL;
@@ -685,10 +688,12 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved)
        goto bail;
        goto bail;
    }
    }


#ifndef NO_OPENCORE
    if (register_android_media_AmrInputStream(env) < 0) {
    if (register_android_media_AmrInputStream(env) < 0) {
        LOGE("ERROR: AmrInputStream native registration failed\n");
        LOGE("ERROR: AmrInputStream native registration failed\n");
        goto bail;
        goto bail;
    }
    }
#endif


    if (register_android_media_ResampleInputStream(env) < 0) {
    if (register_android_media_ResampleInputStream(env) < 0) {
        LOGE("ERROR: ResampleInputStream native registration failed\n");
        LOGE("ERROR: ResampleInputStream native registration failed\n");
+11 −1
Original line number Original line Diff line number Diff line
@@ -30,6 +30,11 @@
#include "JNIHelp.h"
#include "JNIHelp.h"
#include "android_runtime/AndroidRuntime.h"
#include "android_runtime/AndroidRuntime.h"


#ifndef NO_OPENCORE
#include "pvmediascanner.h"
#else
#include "StagefrightMediaScanner.h"
#endif


// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------


@@ -281,7 +286,12 @@ android_media_MediaScanner_native_init(JNIEnv *env)
static void
static void
android_media_MediaScanner_native_setup(JNIEnv *env, jobject thiz)
android_media_MediaScanner_native_setup(JNIEnv *env, jobject thiz)
{
{
    MediaScanner *mp = new MediaScanner();
#ifndef NO_OPENCORE
    MediaScanner *mp = new PVMediaScanner();
#else
    MediaScanner *mp = new StagefrightMediaScanner();
#endif

    if (mp == NULL) {
    if (mp == NULL) {
        jniThrowException(env, "java/lang/RuntimeException", "Out of memory");
        jniThrowException(env, "java/lang/RuntimeException", "Out of memory");
        return;
        return;
+12 −3
Original line number Original line Diff line number Diff line
@@ -21,10 +21,18 @@ LOCAL_SRC_FILES:= \
    ToneGenerator.cpp \
    ToneGenerator.cpp \
    JetPlayer.cpp \
    JetPlayer.cpp \
    IOMX.cpp \
    IOMX.cpp \
 	IAudioPolicyService.cpp
    IAudioPolicyService.cpp \
    MediaScanner.cpp \
    MediaScannerClient.cpp \
    autodetect.cpp

ifneq ($(BUILD_WITHOUT_PV),true)
else
LOCAL_SRC_FILES += StagefrightMediaScanner.cpp
endif


LOCAL_SHARED_LIBRARIES := \
LOCAL_SHARED_LIBRARIES := \
	libui libcutils libutils libbinder libsonivox
	libui libcutils libutils libbinder libsonivox libicuuc


LOCAL_MODULE:= libmedia
LOCAL_MODULE:= libmedia


@@ -41,7 +49,8 @@ LOCAL_C_INCLUDES := \
    $(call include-path-for, graphics corecg) \
    $(call include-path-for, graphics corecg) \
        $(TOP)/external/opencore/extern_libs_v2/khronos/openmax/include \
        $(TOP)/external/opencore/extern_libs_v2/khronos/openmax/include \
        external/speex/include \
        external/speex/include \
        external/speex/libspeex
        external/speex/libspeex \
        external/icu4c/common


LOCAL_STATIC_LIBRARIES := libspeex
LOCAL_STATIC_LIBRARIES := libspeex


Loading