Skip to content

Commit fb09098

Browse files
YaLTeRRytoEX
authored andcommitted
linux-pipewire: Ensure the release point is always signaled
Since video rendering happens on a separate thread from PipeWire buffer ingestion, it may happen that two buffers are ingested in quick succession without the rendering thread ever getting to them. Since, prior to this commit, the release sync point is only "primed" (set to signal in the future) only on the video rendering thread, this results in the buffer being returned to PipeWire's pool without anything ever signaling the release point, effectively blocking it from ever getting reused in the future. This quickly clogs up the buffer pool and leaves only one buffer to circulate between the screencast source and OBS. This commit adds a flag tracking whether the release point had been primed. If, when ingesting a new PW buffer, the old buffer's release point hadn't been primed, that means the video rendering thread never got to that buffer, so the release point is immediately signaled, marking the buffer reusable by the screencast source.
1 parent a7de3f4 commit fb09098

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

plugins/linux-pipewire/pipewire.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ struct _obs_pipewire_stream {
144144
int release_syncobj_fd;
145145
uint64_t acquire_point;
146146
uint64_t release_point;
147+
bool release_point_will_signal;
147148
bool set;
148149
} sync;
149150
};
@@ -766,6 +767,14 @@ static void process_video_sync(obs_pipewire_stream *obs_pw_stream)
766767
}
767768

768769
#if PW_CHECK_VERSION(1, 2, 0)
770+
if (obs_pw_stream->sync.release_syncobj_fd != -1) {
771+
if (!obs_pw_stream->sync.release_point_will_signal) {
772+
gs_sync_signal_syncobj_timeline_point(obs_pw_stream->sync.release_syncobj_fd,
773+
obs_pw_stream->sync.release_point);
774+
obs_pw_stream->sync.release_point_will_signal = true;
775+
}
776+
}
777+
769778
g_clear_fd(&obs_pw_stream->sync.acquire_syncobj_fd, NULL);
770779
g_clear_fd(&obs_pw_stream->sync.release_syncobj_fd, NULL);
771780

@@ -779,6 +788,7 @@ static void process_video_sync(obs_pipewire_stream *obs_pw_stream)
779788
obs_pw_stream->sync.release_syncobj_fd =
780789
fcntl(buffer->datas[planes + 1].fd, F_DUPFD_CLOEXEC, 5);
781790
obs_pw_stream->sync.release_point = synctimeline->release_point;
791+
obs_pw_stream->sync.release_point_will_signal = false;
782792

783793
obs_pw_stream->sync.set = true;
784794
} else {
@@ -1384,6 +1394,7 @@ void obs_pipewire_stream_video_render(obs_pipewire_stream *obs_pw_stream, gs_eff
13841394
gs_sync_export_syncobj_timeline_point(release_sync, obs_pw_stream->sync.release_syncobj_fd,
13851395
obs_pw_stream->sync.release_point);
13861396
gs_sync_destroy(release_sync);
1397+
obs_pw_stream->sync.release_point_will_signal = true;
13871398
}
13881399
}
13891400

0 commit comments

Comments
 (0)