Coverage Report

Created: 2025-12-14 06:40

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/vlc/src/misc/exit.c
Line
Count
Source
1
/*****************************************************************************
2
 * exit.c: LibVLC termination event
3
 *****************************************************************************
4
 * Copyright (C) 2009-2010 VLC authors and VideoLAN
5
 *
6
 * This program is free software; you can redistribute it and/or modify it
7
 * under the terms of the GNU Lesser General Public License as published by
8
 * the Free Software Foundation; either version 2.1 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public License
17
 * along with this program; if not, write to the Free Software Foundation,
18
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19
 *****************************************************************************/
20
21
#ifdef HAVE_CONFIG_H
22
# include "config.h"
23
#endif
24
25
#include <vlc_common.h>
26
#include <vlc_interface.h>
27
#include "../libvlc.h"
28
#include "../lib/libvlc_internal.h"
29
30
void vlc_ExitInit( vlc_exit_t *exit )
31
54
{
32
54
    vlc_mutex_init( &exit->lock );
33
54
    exit->handler = NULL;
34
54
    exit->opaque = NULL;
35
54
}
36
37
/**
38
 * Registers a callback for the LibVLC exit event.
39
 */
40
void libvlc_SetExitHandler( libvlc_int_t *p_libvlc, void (*handler) (void *),
41
                            void *opaque )
42
0
{
43
0
    vlc_exit_t *exit = &libvlc_priv( p_libvlc )->exit;
44
45
0
    vlc_mutex_lock( &exit->lock );
46
0
    exit->handler = handler;
47
0
    exit->opaque = opaque;
48
0
    vlc_mutex_unlock( &exit->lock );
49
0
}
50
51
/**
52
 * Posts an exit signal to LibVLC instance.
53
 * This function should only be called on behalf of the user.
54
 */
55
void libvlc_Quit( libvlc_int_t *p_libvlc )
56
0
{
57
0
    vlc_exit_t *exit = &libvlc_priv( p_libvlc )->exit;
58
59
0
    msg_Dbg( p_libvlc, "exiting" );
60
0
    vlc_mutex_lock( &exit->lock );
61
0
    if( exit->handler != NULL )
62
0
        exit->handler( exit->opaque );
63
0
    else
64
0
        msg_Dbg( p_libvlc, "no exit handler" );
65
0
    vlc_mutex_unlock( &exit->lock );
66
0
}