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

Commit a6ccc188 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Codec2: Add sys-prop to allow dmabuf heap usage to be forced"

parents ead02edf 3a069359
Loading
Loading
Loading
Loading
+20 −6
Original line number Diff line number Diff line
@@ -102,16 +102,30 @@ C2PlatformAllocatorStoreImpl::C2PlatformAllocatorStoreImpl() {
}

static bool using_ion(void) {
    static int cached_result = -1;

    if (cached_result == -1) {
    static int cached_result = []()->int {
        struct stat buffer;
        cached_result = (stat("/dev/ion", &buffer) == 0);
        if (cached_result)
        int ret = (stat("/dev/ion", &buffer) == 0);

        if (property_get_int32("debug.c2.use_dmabufheaps", 0)) {
            /*
             * Double check that the system heap is present so we
             * can gracefully fail back to ION if we cannot satisfy
             * the override
             */
            ret = (stat("/dev/dma_heap/system", &buffer) != 0);
            if (ret)
                ALOGE("debug.c2.use_dmabufheaps set, but no system heap. Ignoring override!");
            else
                ALOGD("debug.c2.use_dmabufheaps set, forcing DMABUF Heaps");
        }

        if (ret)
            ALOGD("Using ION\n");
        else
            ALOGD("Using DMABUF Heaps\n");
    }
        return ret;
    }();

    return (cached_result == 1);
}