Skip to content

Commit

Permalink
portals: limit amount of retries for screencopy
Browse files Browse the repository at this point in the history
  • Loading branch information
lennoxlotl committed Aug 19, 2024
1 parent 0a9eeec commit cccfe77
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/portals/Screencopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,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;
g_pPortalManager->m_sPortals.screencopy->m_pPipewire->updateStreamParam(PSTREAM);
g_pPortalManager->m_sPortals.screencopy->queueNextShareFrame(PSESSION);
if (PSESSION->sharingData.copyRetries++ < 6) {
Debug::log(LOG, "[sc] Retrying screencopy ({}/6)", PSESSION->sharingData.copyRetries);
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");
}
Expand Down
1 change: 1 addition & 0 deletions src/portals/Screencopy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit cccfe77

Please sign in to comment.