mirror of
https://github.com/libretro/RetroArch
synced 2025-03-28 19:20:35 +00:00
Create callback only when needed, and correct brace style.
This commit is contained in:
parent
155d2c9ada
commit
dd4148773d
@ -528,38 +528,44 @@ static void gfx_ctx_wl_swap_buffers(void *data)
|
||||
|
||||
settings_t *settings = config_get_ptr();
|
||||
unsigned max_swapchain_images = settings->uints.video_max_swapchain_images;
|
||||
struct wl_callback *cb;
|
||||
|
||||
struct wl_callback *cb = wl_surface_frame(wl->surface);
|
||||
|
||||
if (max_swapchain_images <= 2) {
|
||||
if (max_swapchain_images <= 2)
|
||||
{
|
||||
/* Set Wayland frame callback. */
|
||||
cb = wl_surface_frame(wl->surface);
|
||||
wl_callback_add_listener(cb, &wl_surface_frame_listener, wl);
|
||||
}
|
||||
|
||||
egl_swap_buffers(&wl->egl);
|
||||
|
||||
if (max_swapchain_images <= 2) {
|
||||
if (max_swapchain_images <= 2)
|
||||
{
|
||||
/* Wait for the frame callback we set earlier. */
|
||||
struct pollfd pollfd = {.fd = wl->input.fd, .events = POLLIN};
|
||||
uint64_t deadline = cpu_features_get_time_usec() + 50000;
|
||||
wl->swap_complete = false;
|
||||
|
||||
while (!wl->swap_complete) {
|
||||
while (!wl->swap_complete)
|
||||
{
|
||||
uint64_t current_time = cpu_features_get_time_usec();
|
||||
if (current_time >= deadline) {
|
||||
if (current_time >= deadline)
|
||||
{
|
||||
/* Deadline met. */
|
||||
wl_callback_destroy(cb);
|
||||
return;
|
||||
}
|
||||
uint64_t remaining_time = deadline - current_time;
|
||||
int ret = (wl_display_dispatch_pending(wl->input.dpy));
|
||||
if (ret == 0) {
|
||||
if (ret == 0)
|
||||
{
|
||||
ret = wl_display_prepare_read(wl->input.dpy);
|
||||
if (ret == -1)
|
||||
continue; /* Retry dispatch_pending. */
|
||||
|
||||
ret = poll(&pollfd, 1, remaining_time / 1000);
|
||||
if (ret <= 0) {
|
||||
if (ret <= 0)
|
||||
{
|
||||
/* Timeout met, or polling error. */
|
||||
wl_display_cancel_read(wl->input.dpy);
|
||||
wl_callback_destroy(cb);
|
||||
|
Loading…
x
Reference in New Issue
Block a user