mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-12-22 09:49:49 +01:00
screencopy: attempt retry when pw doesn't return buffers (#249)
* portals: fix output screencopy not capturing after error * portals: limit amount of retries for screencopy * portals: change max retries count
This commit is contained in:
parent
7f2a77ddf6
commit
a08ecbbf33
2 changed files with 9 additions and 0 deletions
|
@ -8,6 +8,8 @@
|
|||
#include <protocols/linux-dmabuf-unstable-v1-protocol.h>
|
||||
#include <unistd.h>
|
||||
|
||||
constexpr static int MAX_RETRIES = 10;
|
||||
|
||||
// --------------- Wayland Protocol Handlers --------------- //
|
||||
|
||||
static void wlrOnBuffer(void* data, zwlr_screencopy_frame_v1* frame, uint32_t format, uint32_t width, uint32_t height, uint32_t stride) {
|
||||
|
@ -128,10 +130,16 @@ static void wlrOnBufferDone(void* data, zwlr_screencopy_frame_v1* frame) {
|
|||
PSESSION->sharingData.frameCallback = nullptr;
|
||||
Debug::log(LOG, "[screencopy/pipewire] Out of buffers");
|
||||
PSESSION->sharingData.status = FRAME_NONE;
|
||||
if (PSESSION->sharingData.copyRetries++ < MAX_RETRIES) {
|
||||
Debug::log(LOG, "[sc] Retrying screencopy ({}/{})", PSESSION->sharingData.copyRetries, MAX_RETRIES);
|
||||
g_pPortalManager->m_sPortals.screencopy->m_pPipewire->updateStreamParam(PSTREAM);
|
||||
g_pPortalManager->m_sPortals.screencopy->queueNextShareFrame(PSESSION);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
zwlr_screencopy_frame_v1_copy_with_damage(frame, PSTREAM->currentPWBuffer->wlBuffer);
|
||||
PSESSION->sharingData.copyRetries = 0;
|
||||
|
||||
Debug::log(TRACE, "[sc] wlr frame copied");
|
||||
}
|
||||
|
|
|
@ -81,6 +81,7 @@ class CScreencopyPortal {
|
|||
uint32_t framerate = 60;
|
||||
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||
std::chrono::system_clock::time_point begunFrame = std::chrono::system_clock::now();
|
||||
uint32_t copyRetries = 0;
|
||||
|
||||
struct {
|
||||
uint32_t w = 0, h = 0, size = 0, stride = 0, fmt = 0;
|
||||
|
|
Loading…
Reference in a new issue