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

Commit ae9834fc authored by Carlos Martinez Romero's avatar Carlos Martinez Romero
Browse files

Use SurfaceListener instead of IProducerListener

IProducerListener is being deprecated outside of libgui, we are limiting IGBP/IGBC usage outside of libgui to allow for future changes. See go/warren-buffers for more information.

Bug: 342199105
Test: Camera CTS tests
FLAG: EXEMPT no op refactor
Change-Id: I050b2070e7ce2144fa9fe3bb0d0655507e303167
parent d623175b
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -46,7 +46,6 @@
#include <media/stagefright/Utils.h>

#include <gui/GLConsumer.h>
#include <gui/IProducerListener.h>
#include <gui/Surface.h>
#include <gui/SurfaceComposerClient.h>

@@ -91,7 +90,7 @@ private:
    std::shared_ptr<Listener> mListener;
    std::shared_ptr<C2Component> mComponent;

    sp<IProducerListener> mProducerListener;
    sp<SurfaceListener> mSurfaceListener;

    std::atomic_int mLinearPoolId;

@@ -138,7 +137,7 @@ private:

SimplePlayer::SimplePlayer()
    : mListener(new Listener(this)),
      mProducerListener(new StubProducerListener),
      mSurfaceListener(new StubSurfaceListener),
      mLinearPoolId(C2BlockPool::PLATFORM_START),
      mComposerClient(new SurfaceComposerClient) {
    CHECK_EQ(mComposerClient->initCheck(), (status_t)OK);
@@ -164,7 +163,7 @@ SimplePlayer::SimplePlayer()

    mSurface = mControl->getSurface();
    CHECK(mSurface != nullptr);
    mSurface->connect(NATIVE_WINDOW_API_CPU, mProducerListener);
    mSurface->connect(NATIVE_WINDOW_API_CPU, mSurfaceListener);
}

SimplePlayer::~SimplePlayer() {
+5 −2
Original line number Diff line number Diff line
@@ -840,7 +840,7 @@ private:
    const sp<AMessage> mNotify;
};

class OnBufferReleasedListener : public ::android::BnProducerListener{
class OnBufferReleasedListener : public ::android::SurfaceListener{
private:
    uint32_t mGeneration;
    std::weak_ptr<BufferChannelBase> mBufferChannel;
@@ -864,6 +864,9 @@ public:
        notifyBufferReleased();
    }

    void onBuffersDiscarded([[maybe_unused]] const std::vector<sp<GraphicBuffer>>& buffers)
        override { }

    void onBufferDetached([[maybe_unused]] int slot) override {
        notifyBufferReleased();
    }
@@ -6722,7 +6725,7 @@ status_t MediaCodec::connectToSurface(const sp<Surface> &surface, uint32_t *gene
            // to this surface after disconnect/connect, and those free frames would inherit the new
            // generation number. Disconnecting after setting a unique generation prevents this.
            nativeWindowDisconnect(surface.get(), "connectToSurface(reconnect)");
            sp<IProducerListener> listener =
            sp<SurfaceListener> listener =
                    new OnBufferReleasedListener(*generation, mBufferChannel);
            err = surfaceConnectWithListener(
                    surface, listener, "connectToSurface(reconnect-with-listener)");
+1 −1
Original line number Diff line number Diff line
@@ -335,7 +335,7 @@ status_t nativeWindowConnect(ANativeWindow *surface, const char *reason) {
}

status_t surfaceConnectWithListener(
        const sp<Surface> &surface, sp<IProducerListener> listener, const char *reason) {
        const sp<Surface> &surface, sp<SurfaceListener> listener, const char *reason) {
    ALOGD("connecting to surface %p, reason %s", surface.get(), reason);

    status_t err = surface->connect(NATIVE_WINDOW_API_MEDIA, listener);
+2 −2
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ class Surface;
namespace android {

struct HDRStaticInfo;
class IProducerListener;
class SurfaceListener;

/**
 * Configures |nativeWindow| for given |width|x|height|, pixel |format|, |rotation| and |usage|.
@@ -45,7 +45,7 @@ status_t pushBlankBuffersToNativeWindow(ANativeWindow *nativeWindow /* nonnull *
status_t nativeWindowConnect(ANativeWindow *surface, const char *reason);
status_t nativeWindowDisconnect(ANativeWindow *surface, const char *reason);
status_t surfaceConnectWithListener(const sp<Surface> &surface,
        sp<IProducerListener> listener, const char *reason);
        sp<SurfaceListener> listener, const char *reason);

/**
 * Disable buffer dropping behavior of BufferQueue if target sdk of application
+6 −3
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@
#include <android/hardware/camera2/ICameraDeviceCallbacks.h>
#include <camera/CameraMetadata.h>
#include <camera/camera2/OutputConfiguration.h>
#include <gui/IProducerListener.h>
#include <gui/Surface.h>
#include "common/CameraDeviceBase.h"
#include "device3/Camera3StreamInterface.h"

@@ -96,9 +96,12 @@ public:
            const CameraMetadata& settings) override;

protected:
    struct ProducerListener : public BnProducerListener {
        // ProducerListener impementation
    struct StreamSurfaceListener : public SurfaceListener {
        // StreamSurfaceListener implementation
        void onBufferReleased() override { /*No impl. for now*/ };
        bool needsReleaseNotify() override { return true; };
        void onBuffersDiscarded(const std::vector<sp<GraphicBuffer>>& /*buffers*/) override {};
        void onBufferDetached(int /*slot*/) override {};
    };

    status_t registerCompositeStreamListener(int32_t streamId);
Loading