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

Commit d1bbbe3d authored by Chong Zhang's avatar Chong Zhang
Browse files

Remove libbinder from media.swcodec

Also split client-side usage of libstagefright_bufferqueue_helper
into a separate lib libstagefright_bufferqueue_helper_client, and
let it link libgui directly, there is no point static link the bq.
Make sure this is only used by system, not vendor.

b/147759770
b/139201422

Change-Id: Ib8b0d27f23e7be41081b58ef586537a80ebedffc
parent 7e101988
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -160,12 +160,12 @@ struct InputSurfaceConnection::Impl : public ComponentWrapper {
            return false;
            return false;
        }
        }
        for (int32_t i = 0; i < kBufferCount; ++i) {
        for (int32_t i = 0; i < kBufferCount; ++i) {
            if (!mSource->onInputBufferAdded(i).isOk()) {
            if (mSource->onInputBufferAdded(i) != OK) {
                LOG(WARNING) << "Impl::init: failed to populate GBS slots.";
                LOG(WARNING) << "Impl::init: failed to populate GBS slots.";
                return false;
                return false;
            }
            }
        }
        }
        if (!mSource->start().isOk()) {
        if (mSource->start() != OK) {
            LOG(WARNING) << "Impl::init -- GBS failed to start.";
            LOG(WARNING) << "Impl::init -- GBS failed to start.";
            return false;
            return false;
        }
        }
+1 −1
Original line number Original line Diff line number Diff line
@@ -45,7 +45,7 @@ cc_library_shared {
        "libmedia_codeclist",
        "libmedia_codeclist",
        "libmedia_omx",
        "libmedia_omx",
        "libsfplugin_ccodec_utils",
        "libsfplugin_ccodec_utils",
        "libstagefright_bufferqueue_helper",
        "libstagefright_bufferqueue_helper_client",
        "libstagefright_codecbase",
        "libstagefright_codecbase",
        "libstagefright_foundation",
        "libstagefright_foundation",
        "libstagefright_omx",
        "libstagefright_omx",
+38 −19
Original line number Original line Diff line number Diff line
cc_library_shared {
cc_defaults {
    name: "libstagefright_bufferqueue_helper",
    name: "libstagefright_bufferqueue-defaults",
    vendor_available: true,
    vndk: {
        enabled: true,
    },
    double_loadable: true,
    double_loadable: true,
    srcs: [
    srcs: [
        "FrameDropper.cpp",
        "FrameDropper.cpp",
@@ -23,7 +19,7 @@ cc_library_shared {
    ],
    ],


    shared_libs: [
    shared_libs: [
        "libbinder",
        "libbase",
        "libcutils",
        "libcutils",
        "libhidlbase",
        "libhidlbase",
        "libhidlmemory",
        "libhidlmemory",
@@ -33,24 +29,12 @@ cc_library_shared {
        "libutils",
        "libutils",


        "android.hardware.graphics.bufferqueue@1.0",
        "android.hardware.graphics.bufferqueue@1.0",
        // Following libs are from libgui_bufferqueue_static
        "android.hardware.graphics.bufferqueue@2.0",
        "android.hidl.token@1.0-utils",
        "libbase",
        "libEGL",
        "libnativewindow",
        "libvndksupport",
    ],
    
    static_libs: [
        "libgui_bufferqueue_static"
    ],
    ],


    export_shared_lib_headers: [
    export_shared_lib_headers: [
        "libhidlmemory",
        "libhidlmemory",
        "libstagefright_foundation",
        "libstagefright_foundation",
        "android.hardware.graphics.bufferqueue@1.0",
        "android.hardware.graphics.bufferqueue@1.0",
        "android.hardware.graphics.bufferqueue@2.0",
    ],
    ],


    cflags: [
    cflags: [
@@ -68,3 +52,38 @@ cc_library_shared {
        cfi: true,
        cfi: true,
    },
    },
}
}

cc_library_shared {
    name: "libstagefright_bufferqueue_helper",
    defaults: ["libstagefright_bufferqueue-defaults"],
    vendor_available: true,
    vndk: {
        enabled: true,
    },
    static_libs: [
        "libgui_bufferqueue_static"
    ],
    shared_libs: [
        "android.hardware.graphics.bufferqueue@2.0",
        "android.hidl.token@1.0-utils",
        "libEGL",
        "libnativewindow",
        "libvndksupport",
    ],
    export_shared_lib_headers: [
        "android.hardware.graphics.bufferqueue@2.0",
    ],
    cflags: [
        "-DNO_BINDER",
    ],
}

cc_library_shared {
    name: "libstagefright_bufferqueue_helper_client",
    defaults: ["libstagefright_bufferqueue-defaults"],
    vendor_available: false,
    shared_libs: [
        "libgui"
    ],
}
+14 −14
Original line number Original line Diff line number Diff line
@@ -412,7 +412,7 @@ GraphicBufferSource::getHGraphicBufferProducer() const {
                    B2HGraphicBufferProducer(getIGraphicBufferProducer());
                    B2HGraphicBufferProducer(getIGraphicBufferProducer());
}
}


Status GraphicBufferSource::start() {
status_t GraphicBufferSource::start() {
    Mutex::Autolock autoLock(mMutex);
    Mutex::Autolock autoLock(mMutex);
    ALOGV("--> start; available=%zu, submittable=%zd",
    ALOGV("--> start; available=%zu, submittable=%zd",
            mAvailableBuffers.size(), mFreeCodecBuffers.size());
            mAvailableBuffers.size(), mFreeCodecBuffers.size());
@@ -459,10 +459,10 @@ Status GraphicBufferSource::start() {
        }
        }
    }
    }


    return Status::ok();
    return OK;
}
}


Status GraphicBufferSource::stop() {
status_t GraphicBufferSource::stop() {
    ALOGV("stop");
    ALOGV("stop");


    Mutex::Autolock autoLock(mMutex);
    Mutex::Autolock autoLock(mMutex);
@@ -472,10 +472,10 @@ Status GraphicBufferSource::stop() {
        // not loaded->idle.
        // not loaded->idle.
        mExecuting = false;
        mExecuting = false;
    }
    }
    return Status::ok();
    return OK;
}
}


Status GraphicBufferSource::release(){
status_t GraphicBufferSource::release(){
    sp<ALooper> looper;
    sp<ALooper> looper;
    {
    {
        Mutex::Autolock autoLock(mMutex);
        Mutex::Autolock autoLock(mMutex);
@@ -501,26 +501,26 @@ Status GraphicBufferSource::release(){
    if (looper != NULL) {
    if (looper != NULL) {
        looper->stop();
        looper->stop();
    }
    }
    return Status::ok();
    return OK;
}
}


Status GraphicBufferSource::onInputBufferAdded(codec_buffer_id bufferId) {
status_t GraphicBufferSource::onInputBufferAdded(codec_buffer_id bufferId) {
    Mutex::Autolock autoLock(mMutex);
    Mutex::Autolock autoLock(mMutex);


    if (mExecuting) {
    if (mExecuting) {
        // This should never happen -- buffers can only be allocated when
        // This should never happen -- buffers can only be allocated when
        // transitioning from "loaded" to "idle".
        // transitioning from "loaded" to "idle".
        ALOGE("addCodecBuffer: buffer added while executing");
        ALOGE("addCodecBuffer: buffer added while executing");
        return Status::fromServiceSpecificError(INVALID_OPERATION);
        return INVALID_OPERATION;
    }
    }


    ALOGV("addCodecBuffer: bufferId=%u", bufferId);
    ALOGV("addCodecBuffer: bufferId=%u", bufferId);


    mFreeCodecBuffers.push_back(bufferId);
    mFreeCodecBuffers.push_back(bufferId);
    return Status::ok();
    return OK;
}
}


Status GraphicBufferSource::onInputBufferEmptied(codec_buffer_id bufferId, int fenceFd) {
status_t GraphicBufferSource::onInputBufferEmptied(codec_buffer_id bufferId, int fenceFd) {
    Mutex::Autolock autoLock(mMutex);
    Mutex::Autolock autoLock(mMutex);
    FileDescriptor::Autoclose fence(fenceFd);
    FileDescriptor::Autoclose fence(fenceFd);


@@ -528,7 +528,7 @@ Status GraphicBufferSource::onInputBufferEmptied(codec_buffer_id bufferId, int f
    if (cbi < 0) {
    if (cbi < 0) {
        // This should never happen.
        // This should never happen.
        ALOGE("onInputBufferEmptied: buffer not recognized (bufferId=%u)", bufferId);
        ALOGE("onInputBufferEmptied: buffer not recognized (bufferId=%u)", bufferId);
        return Status::fromServiceSpecificError(BAD_VALUE);
        return BAD_VALUE;
    }
    }


    std::shared_ptr<AcquiredBuffer> buffer = mSubmittedCodecBuffers.valueAt(cbi);
    std::shared_ptr<AcquiredBuffer> buffer = mSubmittedCodecBuffers.valueAt(cbi);
@@ -548,13 +548,13 @@ Status GraphicBufferSource::onInputBufferEmptied(codec_buffer_id bufferId, int f
            ALOGV("onInputBufferEmptied: EOS null buffer (bufferId=%u@%zd)", bufferId, cbi);
            ALOGV("onInputBufferEmptied: EOS null buffer (bufferId=%u@%zd)", bufferId, cbi);
        }
        }
        // No GraphicBuffer to deal with, no additional input or output is expected, so just return.
        // No GraphicBuffer to deal with, no additional input or output is expected, so just return.
        return Status::fromServiceSpecificError(BAD_VALUE);
        return BAD_VALUE;
    }
    }


    if (!mExecuting) {
    if (!mExecuting) {
        // this is fine since this could happen when going from Idle to Loaded
        // this is fine since this could happen when going from Idle to Loaded
        ALOGV("onInputBufferEmptied: no longer executing (bufferId=%u@%zd)", bufferId, cbi);
        ALOGV("onInputBufferEmptied: no longer executing (bufferId=%u@%zd)", bufferId, cbi);
        return Status::fromServiceSpecificError(OK);
        return OK;
    }
    }


    ALOGV("onInputBufferEmptied: bufferId=%d@%zd [slot=%d, useCount=%ld, handle=%p] acquired=%d",
    ALOGV("onInputBufferEmptied: bufferId=%d@%zd [slot=%d, useCount=%ld, handle=%p] acquired=%d",
@@ -584,7 +584,7 @@ Status GraphicBufferSource::onInputBufferEmptied(codec_buffer_id bufferId, int f
    }
    }


    // releaseReleasableBuffers_l();
    // releaseReleasableBuffers_l();
    return Status::ok();
    return OK;
}
}


void GraphicBufferSource::onDataspaceChanged_l(
void GraphicBufferSource::onDataspaceChanged_l(
+5 −7
Original line number Original line Diff line number Diff line
@@ -31,8 +31,6 @@


namespace android {
namespace android {


using ::android::binder::Status;

struct FrameDropper;
struct FrameDropper;
class BufferItem;
class BufferItem;
class IGraphicBufferProducer;
class IGraphicBufferProducer;
@@ -99,26 +97,26 @@ public:
    // This is called when component transitions to running state, which means
    // This is called when component transitions to running state, which means
    // we can start handing it buffers.  If we already have buffers of data
    // we can start handing it buffers.  If we already have buffers of data
    // sitting in the BufferQueue, this will send them to the codec.
    // sitting in the BufferQueue, this will send them to the codec.
    Status start();
    status_t start();


    // This is called when component transitions to stopped, indicating that
    // This is called when component transitions to stopped, indicating that
    // the codec is meant to return all buffers back to the client for them
    // the codec is meant to return all buffers back to the client for them
    // to be freed. Do NOT submit any more buffers to the component.
    // to be freed. Do NOT submit any more buffers to the component.
    Status stop();
    status_t stop();


    // This is called when component transitions to released, indicating that
    // This is called when component transitions to released, indicating that
    // we are shutting down.
    // we are shutting down.
    Status release();
    status_t release();


    // A "codec buffer", i.e. a buffer that can be used to pass data into
    // A "codec buffer", i.e. a buffer that can be used to pass data into
    // the encoder, has been allocated.  (This call does not call back into
    // the encoder, has been allocated.  (This call does not call back into
    // component.)
    // component.)
    Status onInputBufferAdded(int32_t bufferId);
    status_t onInputBufferAdded(int32_t bufferId);


    // Called when encoder is no longer using the buffer.  If we have a BQ
    // Called when encoder is no longer using the buffer.  If we have a BQ
    // buffer available, fill it with a new frame of data; otherwise, just mark
    // buffer available, fill it with a new frame of data; otherwise, just mark
    // it as available.
    // it as available.
    Status onInputBufferEmptied(int32_t bufferId, int fenceFd);
    status_t onInputBufferEmptied(int32_t bufferId, int fenceFd);


    // IGraphicBufferSource interface
    // IGraphicBufferSource interface
    // ------------------------------
    // ------------------------------
Loading