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

Commit 9c47c97e authored by Pawin Vongmasa's avatar Pawin Vongmasa
Browse files

Enable full migration of OMX to Treble.

1. Toggling between Treble and non-Treble OMX will now be controlled by
two properties: "persist.hal.binderization" and
"persist.media.treble_omx". (Before this CL, this was controlled by
"debug.treble_omx".)
- If persist.media.treble_omx is not set, it will assume a default value
of -1.
- If persist.media.treble_omx is -1, persist.hal.binderization will be
used to determine whether OMX will be created as a Treble or non-Treble
service.
- If persist.media.treble_omx is 1, OMX will be created as a Treble
service.
- If persist.media.treble_omx has any other value, OMX will be created
as a non-Treble service.
- persist.media.treble_omx can be changed without rebooting, but it will
only take effect after media.codec and mediaserver processes are killed.

2. Remove all dependencies on non-Treble service. This was not done for
MediaCodec, MediaPlayerService::Client, MediaRecorderClient, stagefright
command, and omx_tests command. OMXClient and media.codec process will
now pick the right version of OMX based on properties mentioned above.
Before this CL, media.codec would always present the non-Treble version
of OMX regardless of the flag.

3. Provide workarounds for some HIDL issues.
- A sequence of nested binder and hwbinder calls require many threads to
handle. (b/35283480) The workaround is to increase the number of threads
in the thread pool of media.codec process.
- android.hidl.base@1.0::IBase::unlinkToDeath takes a strong pointer
instead of a weak pointer. (b/35233970) This causes an infinite
recursion in the destructor of ServiceDeathNotifier in
MediaPlayerService::Client and MediaRecorderClient. The workaround moves
calls to unlinkToDeath() outside of the destructor.

Test: Recorded and played videos with Camera app. Ran stagefright and
omx_tests commands.
Bug: 31399200

Change-Id: Id1940ed982838e10bf10fe8ed5b7bb912a5a2d3a
parent 6ab60611
Loading
Loading
Loading
Loading
+61 −59
Original line number Diff line number Diff line
@@ -9,7 +9,9 @@ LOCAL_SRC_FILES:= \

LOCAL_SHARED_LIBRARIES := \
        libstagefright libmedia libutils libbinder libstagefright_foundation \
	libjpeg libgui libcutils liblog
        libjpeg libgui libcutils liblog \
        android.hardware.media.omx@1.0 \
        android.hardware.media.omx@1.0-utils

LOCAL_C_INCLUDES:= \
        frameworks/av/media/libstagefright \
+20 −5
Original line number Diff line number Diff line
@@ -64,6 +64,9 @@
#include <gui/Surface.h>
#include <gui/SurfaceComposerClient.h>

#include <android/hardware/media/omx/1.0/IOmx.h>
#include <omx/hal/1.0/utils/WOmx.h>

using namespace android;

static long gNumRepetitions;
@@ -904,13 +907,25 @@ int main(int argc, char **argv) {
    }

    if (listComponents) {
        sp<IOMX> omx;
        int32_t trebleOmx = property_get_int32("persist.media.treble_omx", -1);
        if ((trebleOmx == 1) || ((trebleOmx == -1) &&
                property_get_bool("persist.hal.binderization", 0))) {
            using namespace ::android::hardware::media::omx::V1_0;
            sp<IOmx> tOmx = IOmx::getService();

            CHECK(tOmx.get() != NULL);

            omx = new utils::LWOmx(tOmx);
        } else {
            sp<IServiceManager> sm = defaultServiceManager();
            sp<IBinder> binder = sm->getService(String16("media.codec"));
            sp<IMediaCodecService> service = interface_cast<IMediaCodecService>(binder);

            CHECK(service.get() != NULL);

        sp<IOMX> omx = service->getOMX();
            omx = service->getOMX();
        }
        CHECK(omx.get() != NULL);

        List<IOMX::ComponentInfo> list;
+2 −3
Original line number Diff line number Diff line
@@ -94,9 +94,8 @@ struct ACodec : public AHierarchicalStateMachine, public CodecBase {

    static status_t getOMXChannelMapping(size_t numChannels, OMX_AUDIO_CHANNELTYPE map[]);

    // Read the flag from "media.use_treble_omx", save it locally, and return
    // it.
    bool updateTrebleFlag();
    // Save the flag.
    void setTrebleFlag(bool trebleFlag);
    // Return the saved flag.
    bool getTrebleFlag() const;

+2 −1
Original line number Diff line number Diff line
@@ -26,7 +26,8 @@ class OMXClient {
public:
    OMXClient();

    status_t connect();
    status_t connect(bool* trebleFlag = nullptr);
    status_t connectLegacy();
    status_t connectTreble();
    void disconnect();

+2 −0
Original line number Diff line number Diff line
@@ -36,6 +36,8 @@ LOCAL_SHARED_LIBRARIES := \
    libstagefright_omx          \
    libstagefright_wfd          \
    libutils                    \
    libhidlbase                 \
    android.hardware.media.omx@1.0 \

LOCAL_STATIC_LIBRARIES :=       \
    libstagefright_nuplayer     \
Loading