session: destroy screencast_instance directly when paused

A PipeWire client might pause the stream which enables us to stop
requesting buffers from the compositor. In this case the the quit bool
won't be enacted on and thus we should destroy it directly from here.
This commit is contained in:
columbarius 2022-03-03 01:02:12 +01:00
parent 10a07f7e90
commit 21d26fe23e

View file

@ -68,9 +68,15 @@ void xdpw_session_destroy(struct xdpw_session *sess) {
logprint(DEBUG, "xdpw: screencast instance %p now has %d references", logprint(DEBUG, "xdpw: screencast instance %p now has %d references",
cast, cast->refcount); cast, cast->refcount);
if (cast->refcount < 1) { if (cast->refcount < 1) {
if (cast->frame_state == XDPW_FRAME_STATE_NONE) {
logprint(TRACE, "xdpw: screencast instance not streaming, destroy it");
xdpw_screencast_instance_destroy(cast);
} else {
logprint(TRACE, "xdpw: screencast instance still streaming, set quit flag");
cast->quit = true; cast->quit = true;
} }
} }
}
sd_bus_slot_unref(sess->slot); sd_bus_slot_unref(sess->slot);
wl_list_remove(&sess->link); wl_list_remove(&sess->link);