diff --git a/plugins/linux-pipewire/pipewire.c b/plugins/linux-pipewire/pipewire.c index ada92cfe700073..cf9ad9a4cc6b66 100644 --- a/plugins/linux-pipewire/pipewire.c +++ b/plugins/linux-pipewire/pipewire.c @@ -719,27 +719,33 @@ static void on_process_cb(void *user_data) bitmap = SPA_MEMBER(cursor, cursor->bitmap_offset, struct spa_meta_bitmap); - if (bitmap && bitmap->size.width > 0 && - bitmap->size.height > 0 && - lookup_format_info_from_spa_format( - bitmap->format, NULL, &gs_format, &swap_red_blue)) { - const uint8_t *bitmap_data; - - bitmap_data = - SPA_MEMBER(bitmap, bitmap->offset, uint8_t); - obs_pw->cursor.hotspot_x = cursor->hotspot.x; - obs_pw->cursor.hotspot_y = cursor->hotspot.y; - obs_pw->cursor.width = bitmap->size.width; - obs_pw->cursor.height = bitmap->size.height; - + if (bitmap) { g_clear_pointer(&obs_pw->cursor.texture, gs_texture_destroy); - obs_pw->cursor.texture = gs_texture_create( - obs_pw->cursor.width, obs_pw->cursor.height, - gs_format, 1, &bitmap_data, GS_DYNAMIC); - if (swap_red_blue) - swap_texture_red_blue(obs_pw->cursor.texture); + if (bitmap->size.width > 0 && bitmap->size.height > 0 && + lookup_format_info_from_spa_format( + bitmap->format, NULL, &gs_format, + &swap_red_blue)) { + const uint8_t *bitmap_data; + + bitmap_data = SPA_MEMBER(bitmap, bitmap->offset, + uint8_t); + obs_pw->cursor.hotspot_x = cursor->hotspot.x; + obs_pw->cursor.hotspot_y = cursor->hotspot.y; + obs_pw->cursor.width = bitmap->size.width; + obs_pw->cursor.height = bitmap->size.height; + + obs_pw->cursor.texture = gs_texture_create( + obs_pw->cursor.width, + obs_pw->cursor.height, gs_format, 1, + &bitmap_data, GS_DYNAMIC); + + if (swap_red_blue) { + swap_texture_red_blue( + obs_pw->cursor.texture); + } + } } obs_pw->cursor.x = cursor->position.x;