inhibit.c 1.84 KB
Newer Older
1 2 3 4 5
/*****************************************************************************
 * inhibit.c: screen saver inhibition
 *****************************************************************************
 * Copyright (C) 2009 Rémi Denis-Courmont
 *
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
6 7
 * 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
8 9 10 11 12
 * 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
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
13 14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
15 16
 *
 * You should have received a copy of the GNU Lesser General Public License
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
17 18
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 20 21 22 23 24 25
 *****************************************************************************/

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <vlc_common.h>
26
#include <vlc_modules.h>
27 28 29 30 31 32 33 34 35 36
#include "inhibit.h"
#include <libvlc.h>
#include <assert.h>

typedef struct
{
    vlc_inhibit_t ih;
    module_t *module;
} inhibit_t;

37
vlc_inhibit_t *vlc_inhibit_Create (vlc_object_t *parent)
38
{
39
    inhibit_t *priv = vlc_custom_create (parent, sizeof (*priv), "inhibit" );
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
    if (priv == NULL)
        return NULL;

    vlc_inhibit_t *ih = &priv->ih;
    ih->p_sys = NULL;
    ih->inhibit = NULL;

    priv->module = module_need (ih, "inhibit", NULL, false);
    if (priv->module == NULL)
    {
        vlc_object_release (ih);
        ih = NULL;
    }
    return ih;
}

void vlc_inhibit_Destroy (vlc_inhibit_t *ih)
{
    assert (ih != NULL);

    module_unneed (ih, ((inhibit_t *)ih)->module);
    vlc_object_release (ih);
}