summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/nvflinger/consumer_base.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/hle/service/nvflinger/consumer_base.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/core/hle/service/nvflinger/consumer_base.cpp b/src/core/hle/service/nvflinger/consumer_base.cpp
index be65a3f88..30fc21acc 100644
--- a/src/core/hle/service/nvflinger/consumer_base.cpp
+++ b/src/core/hle/service/nvflinger/consumer_base.cpp
@@ -18,7 +18,7 @@ ConsumerBase::ConsumerBase(std::unique_ptr<BufferQueueConsumer> consumer_)
: consumer{std::move(consumer_)} {}
ConsumerBase::~ConsumerBase() {
- std::scoped_lock lock(mutex);
+ std::scoped_lock lock{mutex};
ASSERT_MSG(is_abandoned, "consumer is not abandoned!");
}
@@ -36,38 +36,41 @@ void ConsumerBase::FreeBufferLocked(s32 slot_index) {
}
void ConsumerBase::OnFrameAvailable(const BufferItem& item) {
- std::scoped_lock lock(mutex);
LOG_DEBUG(Service_NVFlinger, "called");
}
void ConsumerBase::OnFrameReplaced(const BufferItem& item) {
- std::scoped_lock lock(mutex);
LOG_DEBUG(Service_NVFlinger, "called");
}
void ConsumerBase::OnBuffersReleased() {
- std::scoped_lock lock(mutex);
- LOG_DEBUG(Service_NVFlinger, "called");
-}
+ std::scoped_lock lock{mutex};
-void ConsumerBase::OnSidebandStreamChanged() {}
+ LOG_DEBUG(Service_NVFlinger, "called");
-Status ConsumerBase::AcquireBufferLocked(BufferItem* item, std::chrono::nanoseconds present_when,
- u64 max_frame_number) {
if (is_abandoned) {
- LOG_ERROR(Service_NVFlinger, "consumer is abandoned!");
- return Status::NoInit;
+ // Nothing to do if we're already abandoned.
+ return;
}
- Status err = consumer->AcquireBuffer(item, present_when, max_frame_number);
+ u64 mask = 0;
+ consumer->GetReleasedBuffers(&mask);
+ for (int i = 0; i < BufferQueueDefs::NUM_BUFFER_SLOTS; i++) {
+ if (mask & (1ULL << i)) {
+ FreeBufferLocked(i);
+ }
+ }
+}
+
+void ConsumerBase::OnSidebandStreamChanged() {}
+
+Status ConsumerBase::AcquireBufferLocked(BufferItem* item, std::chrono::nanoseconds present_when) {
+ Status err = consumer->AcquireBuffer(item, present_when);
if (err != Status::NoError) {
return err;
}
if (item->graphic_buffer != nullptr) {
- if (slots[item->slot].graphic_buffer != nullptr) {
- FreeBufferLocked(item->slot);
- }
slots[item->slot].graphic_buffer = item->graphic_buffer;
}