Discussion:
[vlc-commits] vout: allow display not to provide a pool
Rémi Denis-Courmont
2018-12-09 19:46:09 UTC
Permalink
vlc | branch: master | Rémi Denis-Courmont <***@remlab.net> | Sun Dec 9 21:37:17 2018 +0200| [e266b6e1b2262714853cf3d56c7f50840e010710] | committer: Rémi Denis-Courmont

vout: allow display not to provide a pool
http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e266b6e1b2262714853cf3d56c7f50840e010710
---

src/video_output/display.c | 30 ++++++++++++++++++++++++++++--
src/video_output/vout_wrapper.c | 4 ++--
src/video_output/vout_wrapper.h | 8 +-------
3 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/src/video_output/display.c b/src/video_output/display.c
index 3b91a82edc..dd807bc893 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -59,7 +59,7 @@ static picture_t *VideoBufferNew(filter_t *filter)
vd->fmt.i_width == fmt->i_width &&
vd->fmt.i_height == fmt->i_height);

- picture_pool_t *pool = vout_display_Pool(vd, 3);
+ picture_pool_t *pool = vout_GetPool(vd, 3);
if (!pool)
return NULL;
return picture_pool_Get(pool);
@@ -390,6 +390,7 @@ typedef struct {
} mouse;

atomic_bool reset_pictures;
+ picture_pool_t *pool;
} vout_display_owner_sys_t;

static const struct filter_video_callbacks vout_display_filter_cbs = {
@@ -631,6 +632,21 @@ static void VoutDisplayCropRatio(int *left, int *top, int *right, int *bottom,
}
}

+/**
+ * It retreives a picture pool from the display
+ */
+picture_pool_t *vout_GetPool(vout_display_t *vd, unsigned count)
+{
+ vout_display_owner_sys_t *osys = vd->owner.sys;
+
+ if (vd->pool != NULL)
+ return vd->pool(vd, count);
+
+ if (osys->pool == NULL)
+ osys->pool = picture_pool_NewFromFormat(&vd->fmt, count);
+ return osys->pool;
+}
+
bool vout_ManageDisplay(vout_display_t *vd)
{
vout_display_owner_sys_t *osys = vd->owner.sys;
@@ -671,6 +687,11 @@ bool vout_ManageDisplay(vout_display_t *vd)
#endif

if (atomic_exchange(&osys->reset_pictures, false)) {
+ if (osys->pool != NULL) {
+ picture_pool_Release(osys->pool);
+ osys->pool = NULL;
+ }
+
if (vout_display_Control(vd, VOUT_DISPLAY_RESET_PICTURES, &osys->cfg,
&vd->fmt)) {
/* FIXME what to do here ? */
@@ -941,6 +962,7 @@ static vout_display_t *DisplayNew(vout_thread_t *vout,
osys->is_splitter = is_splitter;

atomic_init(&osys->reset_pictures, false);
+ osys->pool = NULL;
vlc_mutex_init(&osys->lock);

vlc_mouse_Init(&osys->mouse.state);
@@ -998,6 +1020,10 @@ void vout_DeleteDisplay(vout_display_t *vd, vout_display_cfg_t *cfg)
VoutDisplayDestroyRender(vd);
if (osys->is_splitter)
SplitterClose(vd);
+
+ if (osys->pool != NULL)
+ picture_pool_Release(osys->pool);
+
vout_display_Delete(vd);
vlc_mutex_destroy(&osys->lock);
free(osys);
@@ -1113,7 +1139,7 @@ static int SplitterPictureNew(video_splitter_t *splitter, picture_t *picture[])
/* TODO use a pool ? */
picture[i] = picture_NewFromFormat(&wsys->display[i]->source);
} else {
- picture_pool_t *pool = vout_display_Pool(wsys->display[i], 3);
+ picture_pool_t *pool = vout_GetPool(wsys->display[i], 3);
picture[i] = pool ? picture_pool_Get(pool) : NULL;
}
if (!picture[i]) {
diff --git a/src/video_output/vout_wrapper.c b/src/video_output/vout_wrapper.c
index 8a723c5e2b..3e1615a2b5 100644
--- a/src/video_output/vout_wrapper.c
+++ b/src/video_output/vout_wrapper.c
@@ -49,7 +49,7 @@ static int Forward(vlc_object_t *, char const *,
static void NoDrInit(vout_thread_sys_t *sys)
{
if (sys->display.use_dr)
- sys->display_pool = vout_display_Pool(sys->display.vd, 3);
+ sys->display_pool = vout_GetPool(sys->display.vd, 3);
else
sys->display_pool = NULL;
}
@@ -89,7 +89,7 @@ int vout_OpenWrapper(vout_thread_t *vout,
kept_picture;
const unsigned display_pool_size = allow_dr ? __MAX(VOUT_MAX_PICTURES,
reserved_picture + decoder_picture) : 3;
- picture_pool_t *display_pool = vout_display_Pool(vd, display_pool_size);
+ picture_pool_t *display_pool = vout_GetPool(vd, display_pool_size);
if (display_pool == NULL)
goto error;

diff --git a/src/video_output/vout_wrapper.h b/src/video_output/vout_wrapper.h
index 78bc38e3a2..429408be8e 100644
--- a/src/video_output/vout_wrapper.h
+++ b/src/video_output/vout_wrapper.h
@@ -28,13 +28,7 @@

/* XXX DO NOT use it outside the vout module wrapper XXX */

-/**
- * It retreives a picture pool from the display
- */
-static inline picture_pool_t *vout_display_Pool(vout_display_t *vd, unsigned count)
-{
- return vd->pool(vd, count);
-}
+picture_pool_t *vout_GetPool(vout_display_t *vd, unsigned count);

/**
* It preparse a picture for display.

Loading...