screencast: drop imported PipeWire buffer on remove_buffer

PipeWire can request to destroy the allocated buffers anytime. This
isn't a problem for us, since the screencopy protocol can handle
disappearing buffers. The only thing we have to do is not to use a
destroyed buffer.
This commit is contained in:
columbarius 2021-11-03 22:37:56 +01:00
parent 66db43ea0e
commit 35cba50409
1 changed files with 7 additions and 0 deletions

View File

@ -150,9 +150,16 @@ static void pwr_handle_stream_add_buffer(void *data, struct pw_buffer *buffer) {
}
static void pwr_handle_stream_remove_buffer(void *data, struct pw_buffer *buffer) {
struct xdpw_screencast_instance *cast = data;
logprint(TRACE, "pipewire: remove buffer event handle");
struct spa_data *d = buffer->buffer->datas;
if (cast->current_frame.current_pw_buffer == buffer) {
logprint(TRACE, "pipewire: remove buffer currently in use");
cast->current_frame.current_pw_buffer = NULL;
cast->current_frame.buffer = NULL;
}
switch (d[0].type) {
case SPA_DATA_MemFd:
wl_buffer_destroy(buffer->user_data);