mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-20 04:42:18 +02:00
linux-pipewire: Replace dynamic arrays with allocations
Replace dynamic arrays added by 27630a8c0e
by allocations
This commit is contained in:
parent
b962daa3c8
commit
7f4fd99f91
@ -811,22 +811,13 @@ static void process_video_sync(obs_pipewire_stream *obs_pw_stream)
|
||||
|
||||
if (buffer->datas[0].type == SPA_DATA_DmaBuf) {
|
||||
uint32_t planes = buffer->n_datas;
|
||||
DARRAY(uint32_t) offsets;
|
||||
DARRAY(uint32_t) strides;
|
||||
DARRAY(uint64_t) modifiers;
|
||||
DARRAY(int) fds;
|
||||
uint32_t *offsets = alloca(sizeof(uint32_t) * planes);
|
||||
uint32_t *strides = alloca(sizeof(uint32_t) * planes);
|
||||
uint64_t *modifiers = alloca(sizeof(uint64_t) * planes);
|
||||
int *fds = alloca(sizeof(int) * planes);
|
||||
bool use_modifiers;
|
||||
bool corrupt = false;
|
||||
|
||||
da_init(offsets);
|
||||
da_reserve(offsets, planes);
|
||||
da_init(strides);
|
||||
da_reserve(strides, planes);
|
||||
da_init(modifiers);
|
||||
da_reserve(modifiers, planes);
|
||||
da_init(fds);
|
||||
da_reserve(fds, planes);
|
||||
|
||||
#ifdef DEBUG_PIPEWIRE
|
||||
blog(LOG_DEBUG,
|
||||
"[pipewire] DMA-BUF info: fd:%ld, stride:%d, offset:%u, size:%dx%d",
|
||||
@ -847,13 +838,11 @@ static void process_video_sync(obs_pipewire_stream *obs_pw_stream)
|
||||
}
|
||||
|
||||
for (uint32_t plane = 0; plane < planes; plane++) {
|
||||
da_push_back(fds, &buffer->datas[plane].fd);
|
||||
da_push_back(offsets,
|
||||
&buffer->datas[plane].chunk->offset);
|
||||
da_push_back(strides,
|
||||
&buffer->datas[plane].chunk->stride);
|
||||
da_push_back(modifiers,
|
||||
&obs_pw_stream->format.info.raw.modifier);
|
||||
fds[plane] = buffer->datas[plane].fd;
|
||||
offsets[plane] = buffer->datas[plane].chunk->offset;
|
||||
strides[plane] = buffer->datas[plane].chunk->stride;
|
||||
modifiers[plane] =
|
||||
obs_pw_stream->format.info.raw.modifier;
|
||||
corrupt |= (buffer->datas[plane].chunk->flags &
|
||||
SPA_CHUNK_FLAG_CORRUPTED) > 0;
|
||||
}
|
||||
@ -861,12 +850,6 @@ static void process_video_sync(obs_pipewire_stream *obs_pw_stream)
|
||||
if (corrupt) {
|
||||
blog(LOG_DEBUG,
|
||||
"[pipewire] buffer contains corrupted data");
|
||||
|
||||
da_free(offsets);
|
||||
da_free(strides);
|
||||
da_free(modifiers);
|
||||
da_free(fds);
|
||||
|
||||
goto read_metadata;
|
||||
}
|
||||
|
||||
@ -877,14 +860,8 @@ static void process_video_sync(obs_pipewire_stream *obs_pw_stream)
|
||||
obs_pw_stream->texture = gs_texture_create_from_dmabuf(
|
||||
obs_pw_stream->format.info.raw.size.width,
|
||||
obs_pw_stream->format.info.raw.size.height,
|
||||
format_data.drm_format, GS_BGRX, planes, fds.array,
|
||||
strides.array, offsets.array,
|
||||
use_modifiers ? modifiers.array : NULL);
|
||||
|
||||
da_free(offsets);
|
||||
da_free(strides);
|
||||
da_free(modifiers);
|
||||
da_free(fds);
|
||||
format_data.drm_format, GS_BGRX, planes, fds, strides,
|
||||
offsets, use_modifiers ? modifiers : NULL);
|
||||
|
||||
if (obs_pw_stream->texture == NULL) {
|
||||
remove_modifier_from_format(
|
||||
|
Loading…
Reference in New Issue
Block a user