Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frameworks_native: MIUI Camera fix #8

Open
wants to merge 2 commits into
base: pyro-next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions libs/gui/IProducerListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ enum {
ON_BUFFER_RELEASED = IBinder::FIRST_CALL_TRANSACTION,
NEEDS_RELEASE_NOTIFY,
ON_BUFFERS_DISCARDED,
// MIUI ADD
ON_BUFFER_DETACHED,
};

class BpProducerListener : public BpInterface<IProducerListener>
Expand Down Expand Up @@ -64,6 +66,15 @@ class BpProducerListener : public BpInterface<IProducerListener>
data.writeInt32Vector(discardedSlots);
remote()->transact(ON_BUFFERS_DISCARDED, data, &reply, IBinder::FLAG_ONEWAY);
}

// MIUI ADD: START
virtual void onBufferDetached(int slot) {
Parcel data, reply;
data.writeInterfaceToken(IProducerListener::getInterfaceDescriptor());
data.writeInt32(slot);
remote()->transact(ON_BUFFER_DETACHED, data, &reply, IBinder::FLAG_ONEWAY);
}
// MIUI ADD: END
};

// Out-of-line virtual method definition to trigger vtable emission in this
Expand All @@ -88,6 +99,12 @@ class HpProducerListener : public HpInterface<
virtual void onBuffersDiscarded(const std::vector<int32_t>& discardedSlots) override {
return mBase->onBuffersDiscarded(discardedSlots);
}

// MIUI ADD: START
virtual void onBufferDetached(int slot) {
mBase->onBufferDetached(slot);
}
// MIUI ADD: END
};

IMPLEMENT_HYBRID_META_INTERFACE(ProducerListener,
Expand Down Expand Up @@ -115,6 +132,14 @@ status_t BnProducerListener::onTransact(uint32_t code, const Parcel& data,
onBuffersDiscarded(discardedSlots);
return NO_ERROR;
}
// MIUI ADD: START
case ON_BUFFER_DETACHED:
int slot = 0;
CHECK_INTERFACE(IProducerListener, data, reply);
data.readInt32(&slot);
onBufferDetached(slot);
return NO_ERROR;
// MIUI ADD: END
}
return BBinder::onTransact(code, data, reply, flags);
}
Expand All @@ -128,4 +153,9 @@ bool BnProducerListener::needsReleaseNotify() {
void BnProducerListener::onBuffersDiscarded(const std::vector<int32_t>& /*discardedSlots*/) {
}

// MIUI ADD: START
void BnProducerListener::onBufferDetached(int slot) {
ALOGE("BnProducerListener::onBufferDetached slot: %d",slot);
}
// MIUI ADD: END
} // namespace android
13 changes: 13 additions & 0 deletions libs/gui/Surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1958,6 +1958,19 @@ int Surface::disconnect(int api, IGraphicBufferProducer::DisconnectMode mode) {
return err;
}

// MIUI ADD: START
void Surface::releaseSlot(int slot) {
Mutex::Autolock lock(mMutex);
if(mDequeuedSlots.count(slot) <= 0) {
ALOGV("Surface releaseSlot %d",slot);
if (mReportRemovedBuffers && (mSlots[slot].buffer != nullptr)) {
mRemovedBuffers.push_back(mSlots[slot].buffer);
}
mSlots[slot].buffer = nullptr;
}
}
// MIUI ADD: END

int Surface::detachNextBuffer(sp<GraphicBuffer>* outBuffer,
sp<Fence>* outFence) {
ATRACE_CALL();
Expand Down
5 changes: 5 additions & 0 deletions libs/gui/bufferqueue/1.0/WProducerListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,9 @@ bool LWProducerListener::needsReleaseNotify() {
void LWProducerListener::onBuffersDiscarded(const std::vector<int32_t>& /*slots*/) {
}

// MIUI ADD: START
void LWProducerListener::onBufferDetached(int /*slot*/) {
}
// MIUI ADD: END

} // namespace android
5 changes: 5 additions & 0 deletions libs/gui/bufferqueue/2.0/H2BProducerListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ bool H2BProducerListener::needsReleaseNotify() {
void H2BProducerListener::onBuffersDiscarded(const std::vector<int32_t>& /*slots*/) {
}

// MIUI ADD: START
void H2BProducerListener::onBufferDetached(int /*slot*/) {
}
// MIUI ADD: END

} // namespace utils
} // namespace V2_0
} // namespace bufferqueue
Expand Down
7 changes: 7 additions & 0 deletions libs/gui/include/gui/IProducerListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class ProducerListener : public virtual RefBase
// onBuffersFreed is called from IGraphicBufferConsumer::discardFreeBuffers
// to notify the producer that certain free buffers are discarded by the consumer.
virtual void onBuffersDiscarded(const std::vector<int32_t>& slots) = 0; // Asynchronous

// MIUI ADD
virtual void onBufferDetached(int slot) = 0;
};

#ifndef NO_BINDER
Expand All @@ -72,6 +75,8 @@ class BnProducerListener : public BnInterface<IProducerListener>
Parcel* reply, uint32_t flags = 0);
virtual bool needsReleaseNotify();
virtual void onBuffersDiscarded(const std::vector<int32_t>& slots);
// MIUI ADD
virtual void onBufferDetached(int slot);
};

#else
Expand All @@ -85,6 +90,8 @@ class StubProducerListener : public BnProducerListener {
virtual ~StubProducerListener();
virtual void onBufferReleased() {}
virtual bool needsReleaseNotify() { return false; }
// MIUI ADD
virtual void onBufferDetached(int /**slot**/) {}
};

} // namespace android
Expand Down
13 changes: 13 additions & 0 deletions libs/gui/include/gui/Surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ class SurfaceListener : public virtual RefBase
virtual bool needsReleaseNotify() = 0;

virtual void onBuffersDiscarded(const std::vector<sp<GraphicBuffer>>& buffers) = 0;
// MIUI ADD: START
virtual void onBufferDetached(int /**slot**/) {
//default do nothing
}
// MIUI ADD: END
};

/*
Expand Down Expand Up @@ -333,6 +338,8 @@ class Surface
bool reportBufferRemoval);
virtual int detachNextBuffer(sp<GraphicBuffer>* outBuffer,
sp<Fence>* outFence);
// MIUI ADD
virtual void releaseSlot(int slot);
virtual int attachBuffer(ANativeWindowBuffer*);

virtual int connect(
Expand Down Expand Up @@ -388,6 +395,12 @@ class Surface
}

virtual void onBuffersDiscarded(const std::vector<int32_t>& slots);

// MIUI ADD: START
virtual void onBufferDetached(int slot) {
mSurfaceListener->onBufferDetached(slot);
}
// MIUI ADD: END
private:
wp<Surface> mParent;
sp<SurfaceListener> mSurfaceListener;
Expand Down
2 changes: 2 additions & 0 deletions libs/gui/include/gui/bufferqueue/1.0/WProducerListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class LWProducerListener : public BnProducerListener {
void onBufferReleased() override;
bool needsReleaseNotify() override;
void onBuffersDiscarded(const std::vector<int32_t>& slots) override;
// MIUI ADD
void onBufferDetached(int slot) override;
};

} // namespace android
Expand Down
2 changes: 2 additions & 0 deletions libs/gui/include/gui/bufferqueue/2.0/H2BProducerListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class H2BProducerListener
virtual void onBufferReleased() override;
virtual bool needsReleaseNotify() override;
virtual void onBuffersDiscarded(const std::vector<int32_t>& slots) override;
// MIUI ADD
virtual void onBufferDetached(int slot) override;
};

} // namespace utils
Expand Down