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,6 +46,7 @@ static void wlrOnReady(void* data, zwlr_screencopy_frame_v1* frame, uint32_t tv_
g_pPortalManager->m_sPortals.screencopy->m_pPipewire->enqueue(PSESSION);
if (g_pPortalManager->m_sPortals.screencopy->m_pPipewire->streamFromSession(PSESSION))
g_pPortalManager->m_sPortals.screencopy->queueNextShareFrame(PSESSION);
zwlr_screencopy_frame_v1_destroy(frame);
@ -1118,6 +1119,11 @@ CPipewireConnection::SPWStream* CPipewireConnection::streamFromSession(CScreenco
void CPipewireConnection::enqueue(CScreencopyPortal::SSession* 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);
if (!PSTREAM->currentPWBuffer) {
@ -1202,6 +1208,11 @@ void CPipewireConnection::enqueue(CScreencopyPortal::SSession* pSession) {
void CPipewireConnection::dequeue(CScreencopyPortal::SSession* 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);
const auto PWBUF = pw_stream_dequeue_buffer(PSTREAM->stream);