[vlc-devel] [PATCH 3/6] vout: drawable: restore drawable for OS/2

Steve Lhomme robux4 at ycbcr.xyz
Mon Oct 12 09:13:17 CEST 2020


On 2020-10-11 13:00, KO Myung-Hun wrote:
> This is from commit 72c10ed11fde80.

The current Makefile.am already builds libdrawable_plugin.la for OS/2. 
It's using the win32/drawable.c. So I think the commit title is misleading.

Also the commit you point out just changes one line in RemoveDrawable(). 
I doubt that's the commit that broke the whole thing.

Your version looks a lot like the win32 but without any event loop. In 
particular it doesn't implement vout_window_ReportSize() or 
vout_window_ReportClose() which must be implemented by window modules if 
their size change or when they are closed.

> ---
>   modules/video_output/Makefile.am    |   3 +-
>   modules/video_output/drawable_os2.c | 143 ++++++++++++++++++++++++++++
>   2 files changed, 145 insertions(+), 1 deletion(-)
>   create mode 100644 modules/video_output/drawable_os2.c
> 
> diff --git a/modules/video_output/Makefile.am b/modules/video_output/Makefile.am
> index c42fdc474a..94aff1f4a8 100644
> --- a/modules/video_output/Makefile.am
> +++ b/modules/video_output/Makefile.am
> @@ -195,8 +195,9 @@ endif
>   
>   
>   ### OS/2 ###
> +libdrawable_os2_plugin_la_SOURCES = video_output/drawable_os2.c
>   if HAVE_OS2
> -vout_LTLIBRARIES += libdrawable_plugin.la
> +vout_LTLIBRARIES += libdrawable_os2_plugin.la
>   endif
>   
>   libkva_plugin_la_SOURCES = video_output/kva.c
> diff --git a/modules/video_output/drawable_os2.c b/modules/video_output/drawable_os2.c
> new file mode 100644
> index 0000000000..8d125fb554
> --- /dev/null
> +++ b/modules/video_output/drawable_os2.c
> @@ -0,0 +1,143 @@
> +/**
> + * @file drawable_os2.c
> + * @brief Legacy monolithic LibVLC video window provider
> + */
> +/*****************************************************************************
> + * Copyright © 2009 Rémi Denis-Courmont
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Lesser General Public License as published by
> + * the Free Software Foundation; either version 2.1 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public License
> + * along with this program; if not, write to the Free Software Foundation,
> + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
> + *****************************************************************************/
> +
> +#ifdef HAVE_CONFIG_H
> +# include <config.h>
> +#endif
> +
> +#include <stdarg.h>
> +#include <assert.h>
> +
> +#include <vlc_common.h>
> +#include <vlc_plugin.h>
> +#include <vlc_vout_window.h>
> +
> +#define HWND_TEXT N_("Window handle (HWND)")
> +#define HWND_LONGTEXT N_( \
> +    "Video will be embedded in this pre-existing window. " \
> +    "If zero, a new window will be created.")
> +
> +static int Open(vout_window_t *);
> +static void Close(vout_window_t *);
> +
> +/*
> + * Module descriptor
> + */
> +vlc_module_begin ()
> +    set_shortname (N_("Drawable"))
> +    set_description (N_("Embedded window video"))
> +    set_category (CAT_VIDEO)
> +    set_subcategory (SUBCAT_VIDEO_VOUT)
> +    set_capability ("vout window", 70)
> +    set_callback(Open)
> +    add_shortcut ("embed-hwnd")
> +
> +    add_integer ("drawable-hwnd", 0, HWND_TEXT, HWND_LONGTEXT, true)
> +        change_volatile ()
> +vlc_module_end ()
> +
> +/* Keep a list of busy drawables, so we don't overlap videos if there are
> + * more than one video track in the stream. */
> +static vlc_mutex_t serializer = VLC_STATIC_MUTEX;
> +static uintptr_t *used = NULL;
> +
> +static const struct vout_window_operations ops = {
> +    .destroy = Close,
> +};
> +
> +static void RemoveDrawable(uintptr_t val)
> +{
> +    size_t n = 0;
> +
> +    /* Remove this drawable from the list of busy ones */
> +    vlc_mutex_lock (&serializer);
> +    assert (used != NULL);
> +    while (used[n] != val)
> +    {
> +        assert (used[n]);
> +        n++;
> +    }
> +    do
> +        used[n] = used[n + 1];
> +    while (used[++n] != 0);
> +
> +    if (n == 1)
> +    {
> +        free (used);
> +        used = NULL;
> +    }
> +    vlc_mutex_unlock (&serializer);
> +}
> +
> +/**
> + * Find the drawable set by libvlc application.
> + */
> +static int Open(vout_window_t *wnd)
> +{
> +    uintptr_t val = var_InheritInteger (wnd, "drawable-hwnd");
> +    if (val == 0)
> +        return VLC_EGENERIC;
> +
> +    uintptr_t *tab;
> +    size_t n = 0;
> +
> +    vlc_mutex_lock (&serializer);
> +    if (used != NULL)
> +        for (/*n = 0*/; used[n]; n++)
> +            if (used[n] == val)
> +            {
> +                msg_Warn (wnd, "HWND 0x%" PRIXPTR " is busy", val);
> +                val = 0;
> +                goto skip;
> +            }
> +
> +    tab = realloc (used, sizeof (*used) * (n + 2));
> +    if (likely(tab != NULL))
> +    {
> +        used = tab;
> +        used[n] = val;
> +        used[n + 1] = 0;
> +    }
> +    else
> +        val = 0;
> +skip:
> +    vlc_mutex_unlock (&serializer);
> +
> +    if (val == 0)
> +        return VLC_EGENERIC;
> +
> +    wnd->type = VOUT_WINDOW_TYPE_HWND;
> +    wnd->handle.hwnd = (void *)val;
> +    wnd->ops = &ops;
> +    wnd->sys = (void *)val;
> +    return VLC_SUCCESS;
> +}
> +
> +/**
> + * Release the drawable.
> + */
> +static void Close (vout_window_t *wnd)
> +{
> +    uintptr_t val = (uintptr_t)wnd->sys;
> +
> +    RemoveDrawable(val);
> +}
> -- 
> 2.22.0
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
> 


More information about the vlc-devel mailing list