74 lines
2.3 KiB
Diff
74 lines
2.3 KiB
Diff
From 78c5bcb181fe2b0b9fc17eea696feac8b504df54 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
|
|
Date: Thu, 7 May 2020 15:48:22 +0200
|
|
Subject: [PATCH] vnc/pipewire-stream: Handle stride mismatch
|
|
|
|
The VNC server framebuffer assumes a particular stride; but there is no
|
|
guarantee that we'll get the same from PipeWire. Handle this gracefully
|
|
by coping row by row instead of the whole buffer.
|
|
---
|
|
src/grd-vnc-pipewire-stream.c | 23 +++++++++++++++--------
|
|
1 file changed, 15 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/src/grd-vnc-pipewire-stream.c b/src/grd-vnc-pipewire-stream.c
|
|
index 88c07be..261292a 100644
|
|
--- a/src/grd-vnc-pipewire-stream.c
|
|
+++ b/src/grd-vnc-pipewire-stream.c
|
|
@@ -187,8 +187,6 @@ on_stream_param_changed (void *user_data,
|
|
struct spa_pod_builder pod_builder;
|
|
int width;
|
|
int height;
|
|
- int stride;
|
|
- int size;
|
|
const struct spa_pod *params[3];
|
|
|
|
if (!format || id != SPA_PARAM_Format)
|
|
@@ -203,14 +201,9 @@ on_stream_param_changed (void *user_data,
|
|
|
|
grd_session_vnc_queue_resize_framebuffer (stream->session, width, height);
|
|
|
|
- stride = grd_session_vnc_get_framebuffer_stride (stream->session);
|
|
- size = stride * height;
|
|
-
|
|
params[0] = spa_pod_builder_add_object (
|
|
&pod_builder,
|
|
SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
|
|
- SPA_PARAM_BUFFERS_size, SPA_POD_Int (size),
|
|
- SPA_PARAM_BUFFERS_stride, SPA_POD_Int (stride),
|
|
SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int (8, 1, 8),
|
|
0);
|
|
|
|
@@ -319,6 +312,10 @@ process_buffer (GrdVncPipeWireStream *stream,
|
|
size_t size;
|
|
uint8_t *map;
|
|
void *src_data;
|
|
+ int src_stride;
|
|
+ int dst_stride;
|
|
+ int height;
|
|
+ int y;
|
|
struct spa_meta_cursor *spa_meta_cursor;
|
|
g_autofree GrdVncFrame *frame = NULL;
|
|
|
|
@@ -359,7 +356,17 @@ process_buffer (GrdVncPipeWireStream *stream,
|
|
return NULL;
|
|
}
|
|
|
|
- frame->data = g_memdup (src_data, buffer->datas[0].maxsize);
|
|
+ src_stride = buffer->datas[0].chunk->stride;
|
|
+ dst_stride = grd_session_vnc_get_framebuffer_stride (stream->session);
|
|
+ height = stream->spa_format.size.height;
|
|
+
|
|
+ frame->data = g_malloc (height * dst_stride);
|
|
+ for (y = 0; y < height; y++)
|
|
+ {
|
|
+ memcpy (((uint8_t *) frame->data) + y * dst_stride,
|
|
+ ((uint8_t *) src_data) + y * src_stride,
|
|
+ dst_stride);
|
|
+ }
|
|
|
|
if (map)
|
|
{
|
|
--
|
|
2.26.2
|
|
|