[vlc-devel] [PATCH] kms: allocate the picture pool during the module init
Rémi Denis-Courmont
remi at remlab.net
Mon Nov 18 12:18:51 CET 2019
Hi,
It works but can you provide a rationale? Does it really get closer to removing the pool callback, which should presumably be the target?
Le 18 novembre 2019 13:13:33 GMT+02:00, Steve Lhomme <robux4 at ycbcr.xyz> a écrit :
>We already know the size is going to be 1
>
>Moved CustomDestroyPicture to avoid forward declaration.
>---
> modules/video_output/kms.c | 97 ++++++++++++++++++--------------------
> 1 file changed, 47 insertions(+), 50 deletions(-)
>
>diff --git a/modules/video_output/kms.c b/modules/video_output/kms.c
>index 7626254b658..a70ec213d61 100644
>--- a/modules/video_output/kms.c
>+++ b/modules/video_output/kms.c
>@@ -495,6 +495,22 @@ static bool ChromaNegotiation(vout_display_t *vd)
> return false;
> }
>
>+static void CustomDestroyPicture(picture_t *p_picture)
>+{
>+ picture_sys_t *psys = (picture_sys_t*)p_picture->p_sys;
>+ vout_display_sys_t *sys = (vout_display_sys_t *)psys->p_voutsys;
>+ int c;
>+
>+ for (c = 0; c < MAXHWBUF; c++)
>+ DestroyFB(sys, c);
>+
>+ drmSetClientCap(sys->drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 0);
>+ drmDropMaster(sys->drm_fd);
>+ vlc_close(sys->drm_fd);
>+ sys->drm_fd = 0;
>+ free(p_picture->p_sys);
>+}
>+
>
> static int OpenDisplay(vout_display_t *vd)
> {
>@@ -573,6 +589,37 @@ static int OpenDisplay(vout_display_t *vd)
> if (!found_connector)
> goto err_out;
>
>+ picture_resource_t rsc;
>+ memset(&rsc, 0, sizeof(rsc));
>+
>+ for (size_t i = 0; i < PICTURE_PLANE_MAX; i++) {
>+ rsc.p[i].p_pixels = sys->map[0] + sys->offsets[i];
>+ rsc.p[i].i_lines = sys->height;
>+ rsc.p[i].i_pitch = sys->stride;
>+ }
>+
>+ picture_sys_t *psys = calloc(1, sizeof(*psys));
>+ if (psys == NULL)
>+ goto err_out;
>+
>+ psys->p_voutsys = sys;
>+ rsc.p_sys = psys;
>+ rsc.pf_destroy = CustomDestroyPicture;
>+
>+ sys->picture = picture_NewFromResource(&vd->fmt, &rsc);
>+
>+ if (!sys->picture)
>+ {
>+ free(psys);
>+ goto err_out;
>+ }
>+
>+ sys->pool = picture_pool_New(1, &sys->picture);
>+ if (!sys->pool) {
>+ picture_Release(sys->picture);
>+ goto error;
>+ }
>+
> return VLC_SUCCESS;
> err_out:
> drmDropMaster(sys->drm_fd);
>@@ -598,60 +645,10 @@ static int Control(vout_display_t *vd, int query,
>va_list args)
> }
>
>
>-static void CustomDestroyPicture(picture_t *p_picture)
>-{
>- picture_sys_t *psys = (picture_sys_t*)p_picture->p_sys;
>- vout_display_sys_t *sys = (vout_display_sys_t *)psys->p_voutsys;
>- int c;
>-
>- for (c = 0; c < MAXHWBUF; c++)
>- DestroyFB(sys, c);
>-
>- drmSetClientCap(sys->drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 0);
>- drmDropMaster(sys->drm_fd);
>- vlc_close(sys->drm_fd);
>- sys->drm_fd = 0;
>- free(p_picture->p_sys);
>-}
>-
>-
> static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
> {
> VLC_UNUSED(count);
> vout_display_sys_t *sys = vd->sys;
>- picture_sys_t *psys;
>- picture_resource_t rsc;
>- int i;
>-
>- if (!sys->pool && !sys->picture) {
>- memset(&rsc, 0, sizeof(rsc));
>-
>- for (i = 0; i < PICTURE_PLANE_MAX; i++) {
>- rsc.p[i].p_pixels = sys->map[0]+sys->offsets[i];
>- rsc.p[i].i_lines = sys->height;
>- rsc.p[i].i_pitch = sys->stride;
>- }
>-
>- psys = calloc(1, sizeof(*psys));
>- if (psys == NULL)
>- return NULL;
>-
>- psys->p_voutsys = sys;
>- rsc.p_sys = psys;
>- rsc.pf_destroy = CustomDestroyPicture;
>-
>- sys->picture = picture_NewFromResource(&vd->fmt, &rsc);
>-
>- if (!sys->picture) {
>- free((void*)psys);
>- return NULL;
>- }
>-
>- sys->pool = picture_pool_New(1, &sys->picture);
>- if (!sys->pool)
>- picture_Release(sys->picture);
>- }
>-
> return sys->pool;
> }
>
>--
>2.17.1
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel
--
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20191118/ae30639a/attachment.html>
More information about the vlc-devel
mailing list