pw: set type for all planes

This commit is contained in:
vaxerski 2023-04-14 17:29:17 +01:00
parent a7b7880172
commit bf035bf3d5

View file

@ -333,6 +333,7 @@ fixate_format:
static void pwr_handle_stream_add_buffer(void *data, struct pw_buffer *buffer) { static void pwr_handle_stream_add_buffer(void *data, struct pw_buffer *buffer) {
struct xdpw_screencast_instance *cast = data; struct xdpw_screencast_instance *cast = data;
struct spa_data *d; struct spa_data *d;
enum spa_data_type t;
logprint(DEBUG, "pipewire: add buffer event handle"); logprint(DEBUG, "pipewire: add buffer event handle");
@ -341,17 +342,17 @@ static void pwr_handle_stream_add_buffer(void *data, struct pw_buffer *buffer) {
// Select buffer type from negotiation result // Select buffer type from negotiation result
if ((d[0].type & (1u << SPA_DATA_MemFd)) > 0) { if ((d[0].type & (1u << SPA_DATA_MemFd)) > 0) {
assert(cast->buffer_type == WL_SHM); assert(cast->buffer_type == WL_SHM);
d[0].type = SPA_DATA_MemFd; t = SPA_DATA_MemFd;
} else if ((d[0].type & (1u << SPA_DATA_DmaBuf)) > 0) { } else if ((d[0].type & (1u << SPA_DATA_DmaBuf)) > 0) {
assert(cast->buffer_type == DMABUF); assert(cast->buffer_type == DMABUF);
d[0].type = SPA_DATA_DmaBuf; t = SPA_DATA_DmaBuf;
} else { } else {
logprint(ERROR, "pipewire: unsupported buffer type"); logprint(ERROR, "pipewire: unsupported buffer type");
cast->err = 1; cast->err = 1;
return; return;
} }
logprint(TRACE, "pipewire: selected buffertype %u", d[0].type); logprint(TRACE, "pipewire: selected buffertype %u", t);
struct xdpw_buffer *xdpw_buffer = xdpw_buffer_create(cast, cast->buffer_type, &cast->screencopy_frame_info[cast->buffer_type]); struct xdpw_buffer *xdpw_buffer = xdpw_buffer_create(cast, cast->buffer_type, &cast->screencopy_frame_info[cast->buffer_type]);
if (xdpw_buffer == NULL) { if (xdpw_buffer == NULL) {
@ -364,6 +365,7 @@ static void pwr_handle_stream_add_buffer(void *data, struct pw_buffer *buffer) {
assert(xdpw_buffer->plane_count >= 0 && buffer->buffer->n_datas == (uint32_t)xdpw_buffer->plane_count); assert(xdpw_buffer->plane_count >= 0 && buffer->buffer->n_datas == (uint32_t)xdpw_buffer->plane_count);
for (uint32_t plane = 0; plane < buffer->buffer->n_datas; plane++) { for (uint32_t plane = 0; plane < buffer->buffer->n_datas; plane++) {
d[plane].type = t;
d[plane].maxsize = xdpw_buffer->size[plane]; d[plane].maxsize = xdpw_buffer->size[plane];
d[plane].mapoffset = 0; d[plane].mapoffset = 0;
d[plane].chunk->size = xdpw_buffer->size[plane]; d[plane].chunk->size = xdpw_buffer->size[plane];