mirror of
https://github.com/brl/mutter.git
synced 2024-11-29 03:20:46 -05:00
screen-cast: Move DMA buffer allocation to MetaScreenCast
The aim with centralizing it is to be able to apply global policy to DMA buffer allocations, e.g. disabling due to various hueristics. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1318
This commit is contained in:
parent
60c8d227ea
commit
d725acb267
@ -720,10 +720,10 @@ on_stream_add_buffer (void *data,
|
|||||||
MetaScreenCastStreamSrc *src = data;
|
MetaScreenCastStreamSrc *src = data;
|
||||||
MetaScreenCastStreamSrcPrivate *priv =
|
MetaScreenCastStreamSrcPrivate *priv =
|
||||||
meta_screen_cast_stream_src_get_instance_private (src);
|
meta_screen_cast_stream_src_get_instance_private (src);
|
||||||
CoglContext *context =
|
MetaScreenCastStream *stream = meta_screen_cast_stream_src_get_stream (src);
|
||||||
clutter_backend_get_cogl_context (clutter_get_default_backend ());
|
MetaScreenCastSession *session = meta_screen_cast_stream_get_session (stream);
|
||||||
CoglRenderer *renderer = cogl_context_get_renderer (context);
|
MetaScreenCast *screen_cast =
|
||||||
g_autoptr (GError) error = NULL;
|
meta_screen_cast_session_get_screen_cast (session);
|
||||||
CoglDmaBufHandle *dmabuf_handle;
|
CoglDmaBufHandle *dmabuf_handle;
|
||||||
struct spa_buffer *spa_buffer = buffer->buffer;
|
struct spa_buffer *spa_buffer = buffer->buffer;
|
||||||
struct spa_data *spa_data = spa_buffer->datas;
|
struct spa_data *spa_data = spa_buffer->datas;
|
||||||
@ -735,13 +735,9 @@ on_stream_add_buffer (void *data,
|
|||||||
spa_data[0].mapoffset = 0;
|
spa_data[0].mapoffset = 0;
|
||||||
spa_data[0].maxsize = stride * priv->video_format.size.height;
|
spa_data[0].maxsize = stride * priv->video_format.size.height;
|
||||||
|
|
||||||
dmabuf_handle = cogl_renderer_create_dma_buf (renderer,
|
dmabuf_handle = meta_screen_cast_create_dma_buf_handle (screen_cast,
|
||||||
priv->stream_width,
|
priv->stream_width,
|
||||||
priv->stream_height,
|
priv->stream_height);
|
||||||
&error);
|
|
||||||
|
|
||||||
if (error)
|
|
||||||
g_debug ("Error exporting DMA buffer handle: %s", error->message);
|
|
||||||
|
|
||||||
if (dmabuf_handle)
|
if (dmabuf_handle)
|
||||||
{
|
{
|
||||||
|
@ -94,6 +94,34 @@ meta_screen_cast_get_backend (MetaScreenCast *screen_cast)
|
|||||||
return screen_cast->backend;
|
return screen_cast->backend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CoglDmaBufHandle *
|
||||||
|
meta_screen_cast_create_dma_buf_handle (MetaScreenCast *screen_cast,
|
||||||
|
int width,
|
||||||
|
int height)
|
||||||
|
{
|
||||||
|
ClutterBackend *clutter_backend =
|
||||||
|
meta_backend_get_clutter_backend (screen_cast->backend);
|
||||||
|
CoglContext *cogl_context =
|
||||||
|
clutter_backend_get_cogl_context (clutter_backend);
|
||||||
|
CoglRenderer *cogl_renderer = cogl_context_get_renderer (cogl_context);
|
||||||
|
g_autoptr (GError) error = NULL;
|
||||||
|
CoglDmaBufHandle *dmabuf_handle;
|
||||||
|
|
||||||
|
dmabuf_handle = cogl_renderer_create_dma_buf (cogl_renderer,
|
||||||
|
width, height,
|
||||||
|
&error);
|
||||||
|
if (!dmabuf_handle)
|
||||||
|
{
|
||||||
|
g_warning ("Failed to allocate DMA buffer, "
|
||||||
|
"disabling DMA buffer based screen casting: %s",
|
||||||
|
error->message);
|
||||||
|
screen_cast->disable_dma_bufs = TRUE;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dmabuf_handle;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
register_remote_desktop_screen_cast_session (MetaScreenCastSession *session,
|
register_remote_desktop_screen_cast_session (MetaScreenCastSession *session,
|
||||||
const char *remote_desktop_session_id,
|
const char *remote_desktop_session_id,
|
||||||
|
@ -56,6 +56,10 @@ GDBusConnection * meta_screen_cast_get_connection (MetaScreenCast *screen_cast);
|
|||||||
|
|
||||||
MetaBackend * meta_screen_cast_get_backend (MetaScreenCast *screen_cast);
|
MetaBackend * meta_screen_cast_get_backend (MetaScreenCast *screen_cast);
|
||||||
|
|
||||||
|
CoglDmaBufHandle * meta_screen_cast_create_dma_buf_handle (MetaScreenCast *screen_cast,
|
||||||
|
int width,
|
||||||
|
int height);
|
||||||
|
|
||||||
MetaScreenCast * meta_screen_cast_new (MetaBackend *backend,
|
MetaScreenCast * meta_screen_cast_new (MetaBackend *backend,
|
||||||
MetaDbusSessionWatcher *session_watcher);
|
MetaDbusSessionWatcher *session_watcher);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user