screencast: guard pipewire stream validity for queue

This commit is contained in:
Vaxry 2023-12-11 22:48:39 +00:00
parent c23f738673
commit f5c3576c3b

View file

@ -46,7 +46,8 @@ static void wlrOnReady(void* data, zwlr_screencopy_frame_v1* frame, uint32_t tv_
g_pPortalManager->m_sPortals.screencopy->m_pPipewire->enqueue(PSESSION); g_pPortalManager->m_sPortals.screencopy->m_pPipewire->enqueue(PSESSION);
g_pPortalManager->m_sPortals.screencopy->queueNextShareFrame(PSESSION); if (g_pPortalManager->m_sPortals.screencopy->m_pPipewire->streamFromSession(PSESSION))
g_pPortalManager->m_sPortals.screencopy->queueNextShareFrame(PSESSION);
zwlr_screencopy_frame_v1_destroy(frame); zwlr_screencopy_frame_v1_destroy(frame);
PSESSION->sharingData.frameCallback = nullptr; PSESSION->sharingData.frameCallback = nullptr;
@ -1118,6 +1119,11 @@ CPipewireConnection::SPWStream* CPipewireConnection::streamFromSession(CScreenco
void CPipewireConnection::enqueue(CScreencopyPortal::SSession* pSession) { void CPipewireConnection::enqueue(CScreencopyPortal::SSession* pSession) {
const auto PSTREAM = streamFromSession(pSession); const auto PSTREAM = streamFromSession(pSession);
if (!PSTREAM) {
Debug::log(ERR, "[pw] Attempted enqueue on invalid session??");
return;
}
Debug::log(TRACE, "[pw] enqueue on {}", (void*)PSTREAM); Debug::log(TRACE, "[pw] enqueue on {}", (void*)PSTREAM);
if (!PSTREAM->currentPWBuffer) { if (!PSTREAM->currentPWBuffer) {
@ -1202,6 +1208,11 @@ void CPipewireConnection::enqueue(CScreencopyPortal::SSession* pSession) {
void CPipewireConnection::dequeue(CScreencopyPortal::SSession* pSession) { void CPipewireConnection::dequeue(CScreencopyPortal::SSession* pSession) {
const auto PSTREAM = streamFromSession(pSession); const auto PSTREAM = streamFromSession(pSession);
if (!PSTREAM) {
Debug::log(ERR, "[pw] Attempted dequeue on invalid session??");
return;
}
Debug::log(TRACE, "[pw] dequeue on {}", (void*)PSTREAM); Debug::log(TRACE, "[pw] dequeue on {}", (void*)PSTREAM);
const auto PWBUF = pw_stream_dequeue_buffer(PSTREAM->stream); const auto PWBUF = pw_stream_dequeue_buffer(PSTREAM->stream);