wayland/dma-buf: Refactor create_source helper

No functional change intended.

v2:
* Make local source assignment separate from its declaration
  (Ivan Molodetskikh)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3408>
This commit is contained in:
Michel Dänzer 2023-11-18 16:36:39 +01:00 committed by Marge Bot
parent 501d19656e
commit 0e471bcea7

View File

@ -921,6 +921,25 @@ static GSourceFuncs meta_wayland_dma_buf_source_funcs = {
.finalize = meta_wayland_dma_buf_source_finalize .finalize = meta_wayland_dma_buf_source_finalize
}; };
static MetaWaylandDmaBufSource *
create_source (MetaWaylandBuffer *buffer,
MetaWaylandDmaBufSourceDispatch dispatch,
gpointer user_data)
{
MetaWaylandDmaBufSource *source;
source =
(MetaWaylandDmaBufSource *) g_source_new (&meta_wayland_dma_buf_source_funcs,
sizeof (*source));
g_source_set_name ((GSource *) source, "[mutter] DmaBuf readiness source");
source->buffer = g_object_ref (buffer);
source->dispatch = dispatch;
source->user_data = user_data;
return source;
}
/** /**
* meta_wayland_dma_buf_create_source: * meta_wayland_dma_buf_create_source:
* @buffer: A #MetaWaylandBuffer object * @buffer: A #MetaWaylandBuffer object
@ -958,16 +977,7 @@ meta_wayland_dma_buf_create_source (MetaWaylandBuffer *buffer,
continue; continue;
if (!source) if (!source)
{ source = create_source (buffer, dispatch, user_data);
source =
(MetaWaylandDmaBufSource *) g_source_new (&meta_wayland_dma_buf_source_funcs,
sizeof (*source));
g_source_set_name ((GSource *) source, "[mutter] DmaBuf readiness source");
source->buffer = g_object_ref (buffer);
source->dispatch = dispatch;
source->user_data = user_data;
}
source->fd_tags[i] = g_source_add_unix_fd (&source->base, fd, G_IO_IN); source->fd_tags[i] = g_source_add_unix_fd (&source->base, fd, G_IO_IN);
} }