Skip to content

Commit

Permalink
buffer: Don't open render node for shm
Browse files Browse the repository at this point in the history
  • Loading branch information
any1 committed Nov 13, 2024
1 parent 59c81ef commit 838bc0e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
2 changes: 1 addition & 1 deletion include/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void wv_buffer_damage_clear(struct wv_buffer* self);
struct wv_buffer_pool* wv_buffer_pool_create(
const struct wv_buffer_config* config);
void wv_buffer_pool_destroy(struct wv_buffer_pool* pool);
void wv_buffer_pool_reconfig(struct wv_buffer_pool* pool,
bool wv_buffer_pool_reconfig(struct wv_buffer_pool* pool,
const struct wv_buffer_config* config);
struct wv_buffer* wv_buffer_pool_acquire(struct wv_buffer_pool* pool);
void wv_buffer_pool_release(struct wv_buffer_pool* pool,
Expand Down
44 changes: 31 additions & 13 deletions src/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,21 +573,16 @@ static void open_render_node(struct wv_buffer_pool* pool)
pool->gbm = NULL;
}
}
#endif // ENABLE_SCREENCOPY_DMABUF

void wv_buffer_pool_reconfig(struct wv_buffer_pool* pool,
const struct wv_buffer_config* config)
bool reconfig_render_node(struct wv_buffer_pool* pool,
const struct wv_buffer_config* config, dev_t old_node)
{
if (buffer_configs_match(&pool->config, config))
return;

nvnc_log(NVNC_LOG_DEBUG, "Reconfiguring buffer pool");

wv_buffer_pool_clear(pool);
dev_t old_node __attribute__((unused)) = pool->config.node;
copy_buffer_config(&pool->config, config);
if (config->type != WV_BUFFER_DMABUF) {
wv_gbm_device_unref(pool->gbm);
pool->gbm = NULL;
return true;
}

#ifdef ENABLE_SCREENCOPY_DMABUF
if (old_node != config->node) {
wv_gbm_device_unref(pool->gbm);
pool->gbm = NULL;
Expand All @@ -598,7 +593,30 @@ void wv_buffer_pool_reconfig(struct wv_buffer_pool* pool,
if (!pool->config.node && !pool->gbm)
open_render_node(pool);

assert(pool->gbm);
return !!pool->gbm;
}
#endif // ENABLE_SCREENCOPY_DMABUF

bool wv_buffer_pool_reconfig(struct wv_buffer_pool* pool,
const struct wv_buffer_config* config)
{
if (buffer_configs_match(&pool->config, config))
return true;

nvnc_log(NVNC_LOG_DEBUG, "Reconfiguring buffer pool");

wv_buffer_pool_clear(pool);

#ifdef ENABLE_SCREENCOPY_DMABUF
dev_t old_node = pool->config.node;
#endif

copy_buffer_config(&pool->config, config);

#ifdef ENABLE_SCREENCOPY_DMABUF
return reconfig_render_node(pool, config, old_node);
#else
return true;
#endif
}

Expand Down

0 comments on commit 838bc0e

Please sign in to comment.