[vlc-devel] [PATCH] inhibit: add UIKit-based inhibiter

Alexandre Janniaux ajanni at videolabs.io
Thu Apr 15 07:28:12 UTC 2021


Hi,

As expected, you're right and that's a good catch. :)
Thanks for review.

Regards,
--
Alexandre Janniaux
Videolabs

On Thu, Apr 15, 2021 at 06:25:21AM +0200, Felix Paul Kühne wrote:
> Hello Alexandre,
>
> > Am 14.04.2021 um 14:13 schrieb Alexandre Janniaux <ajanni at videolabs.io>:
> >
> > The inhibiter code is taken from VLCKit inhibiter's handling, and is
> > meant to replace this handling.
> > ---
> > modules/misc/Makefile.am             | 12 ++++-
> > modules/misc/inhibit/uikit-inhibit.m | 73 ++++++++++++++++++++++++++++
> > 2 files changed, 84 insertions(+), 1 deletion(-)
> > create mode 100644 modules/misc/inhibit/uikit-inhibit.m
> >
> > diff --git a/modules/misc/Makefile.am b/modules/misc/Makefile.am
> > index bc3252ab22..ef024f3a20 100644
> > --- a/modules/misc/Makefile.am
> > +++ b/modules/misc/Makefile.am
> > @@ -52,6 +52,17 @@ libiokit_inhibit_plugin_la_LDFLAGS = $(AM_LDFLAGS) -Wl,-framework,CoreFoundation
> > misc_LTLIBRARIES += libiokit_inhibit_plugin.la
> > endif
> >
> > +libuikit_inhibit_plugin_la_SOURCES = misc/inhibit/uikit-inhibit.m
> > +libuikit_inhibit_plugin_la_LDFLAGS = $(AM_LDFLAGS) -Wl,-framework,UIKit,-framework,Foundation
> > +libuikit_inhibit_plugin_la_OBJCFLAGS = $(AM_OBJCFLAGS) -fobjc-arc
> > +if HAVE_IOS
> > +misc_LTLIBRARIES += libuikit_inhibit_plugin.la
> > +endif
> > +
> > +if HAVE_TVOS
> > +misc_LTLIBRARIES += libuikit_inhibit_plugin.la
> > +endif
> > +
> > libxdg_screensaver_plugin_la_SOURCES = misc/inhibit/xdg.c
> > if HAVE_XCB
> > if !HAVE_WIN32
> > @@ -129,4 +140,3 @@ libmedialibrary_plugin_la_LIBADD = $(MEDIALIBRARY_LIBS)
> > libmedialibrary_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(miscdir)'
> > EXTRA_LTLIBRARIES += libmedialibrary_plugin.la
> > misc_LTLIBRARIES += $(LTLIBmedialibrary)
> > -
> > diff --git a/modules/misc/inhibit/uikit-inhibit.m b/modules/misc/inhibit/uikit-inhibit.m
> > new file mode 100644
> > index 0000000000..06c95077b5
> > --- /dev/null
> > +++ b/modules/misc/inhibit/uikit-inhibit.m
> > @@ -0,0 +1,73 @@
> > +/*****************************************************************************
> > + * Copyright © 2021 Videolabs
> > + *
> > + * 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.
> > + *****************************************************************************/
> > +
> > +/**
> > + * \file uikit-inhibit.m
> > + * \brief iOS display and idle sleep inhibitor using UIKit
> > + */
> > +
> > +#ifdef HAVE_CONFIG_H
> > +# include "config.h"
> > +#endif
> > +
> > +#include <vlc_common.h>
> > +#include <vlc_plugin.h>
> > +#include <vlc_inhibit.h>
> > +#include <vlc_vout_window.h>
> > +
> > +#include <UIKit/UIKit.h>
> > +
> > +static void UpdateInhibit(vlc_inhibit_t *ih, unsigned mask)
> > +{
> > +    [UIApplication sharedApplication].idleTimerDisabled =
> > +        (mask & VLC_INHIBIT_DISPLAY) == VLC_INHIBIT_DISPLAY;
> > +}
> > +
> > +static int OpenInhibit(vlc_object_t *obj)
> > +{
> > +    vlc_inhibit_t *ih = (vlc_inhibit_t *)obj;
> > +    vout_window_t *wnd = vlc_inhibit_GetWindow(ih);
> > +    if (wnd->type != VOUT_WINDOW_TYPE_NSOBJECT)
> > +        return VLC_EGENERIC;
> > +
> > +    UIView * view = (__bridge UIView*)wnd->handle.nsobject;
> > +
> > +    if (unlikely(![view respondsToSelector:@selector(isKindOfClass:)]))
> > +        return VLC_EGENERIC;
> > +
> > +    if (![view isKindOfClass:[UIView class]])
> > +        return VLC_EGENERIC;
> > +
> > +    ih->inhibit = UpdateInhibit;
> > +    return VLC_SUCCESS;
> > +}
> > +
> > +static void CloseInhibit(vlc_object_t *obj)
> > +{
> > +    vlc_inhibit_t *ih = (vlc_inhibit_t*)obj;
> > +    [UIApplication sharedApplication].idleTimerDisabled = NO;
> > +}
> > +
> > +vlc_module_begin()
> > +    set_shortname(N_("iOS sleep inhibition"))
> > +    set_description(N_("iSO screen sleep inhibition"))
>
> Minor typo. Additionally, does this really need localization?
>
> Rest of the patch is LGTM.
>
> Best regards,
>
> Felix
>
> _______________________________________________
> 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