[vlc-commits] inhibit/xdg: further simplify
Rémi Denis-Courmont
git at videolan.org
Sun Sep 20 11:53:10 CEST 2020
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Sep 19 13:12:36 2020 +0300| [78f2c3c4469f69139245e8f2a0e81b78d7c7bcc2] | committer: Rémi Denis-Courmont
inhibit/xdg: further simplify
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=78f2c3c4469f69139245e8f2a0e81b78d7c7bcc2
---
modules/misc/inhibit/xdg.c | 25 +++++++------------------
1 file changed, 7 insertions(+), 18 deletions(-)
diff --git a/modules/misc/inhibit/xdg.c b/modules/misc/inhibit/xdg.c
index 13d051fdf1..016d014394 100644
--- a/modules/misc/inhibit/xdg.c
+++ b/modules/misc/inhibit/xdg.c
@@ -39,11 +39,6 @@ vlc_module_begin ()
set_subcategory (SUBCAT_ADVANCED_MISC)
vlc_module_end ()
-struct vlc_inhibit_sys
-{
- vlc_timer_t timer;
-};
-
static void Timer (void *data)
{
static const char *const argv[] = { "xdg-screensaver", "reset", NULL };
@@ -62,27 +57,22 @@ static void Timer (void *data)
static void Inhibit (vlc_inhibit_t *ih, unsigned mask)
{
- vlc_inhibit_sys_t *sys = ih->p_sys;
+ vlc_timer_t timer = (void *)ih->p_sys;
bool suspend = (mask & VLC_INHIBIT_DISPLAY) != 0;
vlc_tick_t delay = suspend ? VLC_TICK_FROM_SEC(30): VLC_TIMER_DISARM;
- vlc_timer_schedule (sys->timer, false, delay, delay);
+ vlc_timer_schedule(timer, false, delay, delay);
}
static int Open (vlc_object_t *obj)
{
vlc_inhibit_t *ih = (vlc_inhibit_t *)obj;
- vlc_inhibit_sys_t *p_sys = malloc (sizeof (*p_sys));
- if (p_sys == NULL)
- return VLC_ENOMEM;
+ vlc_timer_t timer;
- ih->p_sys = p_sys;
- if (vlc_timer_create (&p_sys->timer, Timer, ih))
- {
- free (p_sys);
+ if (vlc_timer_create(&timer, Timer, ih))
return VLC_ENOMEM;
- }
+ ih->p_sys = (void *)timer;
ih->inhibit = Inhibit;
return VLC_SUCCESS;
}
@@ -90,8 +80,7 @@ static int Open (vlc_object_t *obj)
static void Close (vlc_object_t *obj)
{
vlc_inhibit_t *ih = (vlc_inhibit_t *)obj;
- vlc_inhibit_sys_t *p_sys = ih->p_sys;
+ vlc_timer_t timer = (void *)ih->p_sys;
- vlc_timer_destroy (p_sys->timer);
- free (p_sys);
+ vlc_timer_destroy(timer);
}
More information about the vlc-commits
mailing list