Properly clear handle data on close (#4339)

This commit is contained in:
Stephen Miller 2026-04-30 18:55:04 -05:00 committed by GitHub
parent e7d571c8da
commit 1956b791d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -62,10 +62,26 @@ int VideoOutDriver::Open(const ServiceThreadParams* params) {
void VideoOutDriver::Close(s32 handle) {
std::scoped_lock lock{mutex};
// Mark as closed
main_port.is_open = false;
main_port.flip_rate = 0;
main_port.prev_index = -1;
// Clear port information
std::memset(main_port.buffer_labels.data(), 0, sizeof(main_port.buffer_labels));
std::memset(main_port.groups.data(), 0, sizeof(main_port.groups));
std::memset(&main_port.flip_status, 0, sizeof(main_port.flip_status));
std::memset(&main_port.vblank_status, 0, sizeof(main_port.vblank_status));
// Re-initialize buffers
std::memset(main_port.buffer_slots.data(), 0, sizeof(main_port.buffer_slots));
for (auto& buffer : main_port.buffer_slots) {
buffer.group_index = -1;
}
// TODO: Remove events?
ASSERT(main_port.flip_events.empty());
ASSERT(main_port.vblank_events.empty());
}
VideoOutPort* VideoOutDriver::GetPort(int handle) {