mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-26 00:58:12 +00:00
wpevideosrc: Clear cached SHM buffers after caps re-negotiation
Otherwise buffers not corresponding to the negotiated caps might be pushed downstream. Fixes #4094 Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8212>
This commit is contained in:
parent
0f667d140d
commit
14f6d9a53f
3 changed files with 37 additions and 0 deletions
|
@ -711,6 +711,37 @@ void GstWPEThreadedView::resize(int width, int height)
|
|||
});
|
||||
}
|
||||
|
||||
void GstWPEThreadedView::clearBuffers()
|
||||
{
|
||||
bool dispatchFrameComplete = false;
|
||||
{
|
||||
GMutexHolder lock(images_mutex);
|
||||
|
||||
if (shm.pending) {
|
||||
auto meta = gst_buffer_get_video_meta(shm.pending);
|
||||
if (static_cast<int>(meta->width) != wpe.width || static_cast<int>(meta->height) != wpe.height) {
|
||||
gst_clear_buffer(&shm.pending);
|
||||
dispatchFrameComplete = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (shm.committed) {
|
||||
auto meta = gst_buffer_get_video_meta(shm.committed);
|
||||
if (static_cast<int>(meta->width) != wpe.width || static_cast<int>(meta->height) != wpe.height) {
|
||||
gst_clear_buffer(&shm.committed);
|
||||
dispatchFrameComplete = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dispatchFrameComplete) {
|
||||
frameComplete();
|
||||
// Wait until the next SHM buffer has been received.
|
||||
threading.ready = false;
|
||||
waitLoadCompletion();
|
||||
}
|
||||
}
|
||||
|
||||
void GstWPEThreadedView::frameComplete()
|
||||
{
|
||||
GST_TRACE("frame complete");
|
||||
|
|
|
@ -45,6 +45,7 @@ public:
|
|||
void loadData(GBytes*);
|
||||
void runJavascript(const gchar*);
|
||||
void setDrawBackground(gboolean);
|
||||
void clearBuffers();
|
||||
|
||||
GstEGLImage* image();
|
||||
GstBuffer* buffer();
|
||||
|
|
|
@ -329,6 +329,11 @@ gst_wpe_video_src_start (GstWpeVideoSrc * src)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!created_view) {
|
||||
GST_INFO_OBJECT (src, "Re-starting after re-negotiation, clearing cached SHM buffers");
|
||||
src->view->clearBuffers ();
|
||||
}
|
||||
|
||||
GST_OBJECT_LOCK (src);
|
||||
bytes = src->bytes;
|
||||
src->bytes = NULL;
|
||||
|
|
Loading…
Reference in a new issue