mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-30 12:10:37 +00:00
waylandsink: remove the buffer from the surface when going PAUSED -> READY
This essentially hides the video and allows the application to potentially draw a black background or whatever else it wants. This allows to differentiate the "paused" and "stopped" modes from the user's point of view. Also reworded a comment there to make my thinking more clear, since the "reason for keeping the display around" is not really the exposed() calls, as there is no buffer shown in READY/NULL anymore.
This commit is contained in:
parent
76c0007778
commit
c4616a550a
1 changed files with 22 additions and 7 deletions
|
@ -332,17 +332,32 @@ gst_wayland_sink_change_state (GstElement * element, GstStateChange transition)
|
||||||
|
|
||||||
switch (transition) {
|
switch (transition) {
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||||
if (sink->window && gst_wl_window_is_toplevel (sink->window)) {
|
|
||||||
gst_buffer_replace (&sink->last_buffer, NULL);
|
gst_buffer_replace (&sink->last_buffer, NULL);
|
||||||
|
if (sink->window) {
|
||||||
|
if (gst_wl_window_is_toplevel (sink->window)) {
|
||||||
g_clear_object (&sink->window);
|
g_clear_object (&sink->window);
|
||||||
|
} else {
|
||||||
|
/* remove buffer from surface, show nothing */
|
||||||
|
wl_surface_attach (sink->window->surface, NULL, 0, 0);
|
||||||
|
wl_surface_damage (sink->window->surface, 0, 0,
|
||||||
|
sink->window->surface_width, sink->window->surface_height);
|
||||||
|
wl_surface_commit (sink->window->surface);
|
||||||
|
wl_display_flush (sink->display->display);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_READY_TO_NULL:
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
||||||
g_mutex_lock (&sink->display_lock);
|
g_mutex_lock (&sink->display_lock);
|
||||||
/* We don't need to keep the display around, unless we are embedded
|
/* If we had a toplevel window, we most likely have our own connection
|
||||||
* in another window as a subsurface, in which case we should continue
|
* to the display too, and it is a good idea to disconnect and allow
|
||||||
* to respond to expose() and therefore both the window and the display
|
* potentially the application to embed us with GstVideoOverlay
|
||||||
* are kept alive */
|
* (which requires to re-use the same display connection as the parent
|
||||||
|
* surface). If we didn't have a toplevel window, then the display
|
||||||
|
* connection that we have is definitely shared with the application
|
||||||
|
* and it's better to keep it around (together with the window handle)
|
||||||
|
* to avoid requesting them again from the application if/when we are
|
||||||
|
* restarted (GstVideoOverlay behaves like that in other sinks)
|
||||||
|
*/
|
||||||
if (sink->display && !sink->window) { /* -> the window was toplevel */
|
if (sink->display && !sink->window) { /* -> the window was toplevel */
|
||||||
/* Force all buffers to return to the pool, regardless of
|
/* Force all buffers to return to the pool, regardless of
|
||||||
* whether the compositor has released them or not. We are
|
* whether the compositor has released them or not. We are
|
||||||
|
|
Loading…
Reference in a new issue