forked from videolan/vlc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexit.c
66 lines (59 loc) · 2.13 KB
/
exit.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*****************************************************************************
* exit.c: LibVLC termination event
*****************************************************************************
* Copyright (C) 2009-2010 VLC authors and VideoLAN
*
* 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 <vlc_common.h>
#include <vlc_interface.h>
#include "libvlc.h"
#include "../lib/libvlc_internal.h"
void vlc_ExitInit( vlc_exit_t *exit )
{
vlc_mutex_init( &exit->lock );
exit->handler = NULL;
exit->opaque = NULL;
}
/**
* Registers a callback for the LibVLC exit event.
*/
void libvlc_SetExitHandler( libvlc_int_t *p_libvlc, void (*handler) (void *),
void *opaque )
{
vlc_exit_t *exit = &libvlc_priv( p_libvlc )->exit;
vlc_mutex_lock( &exit->lock );
exit->handler = handler;
exit->opaque = opaque;
vlc_mutex_unlock( &exit->lock );
}
/**
* Posts an exit signal to LibVLC instance.
* This function should only be called on behalf of the user.
*/
void libvlc_Quit( libvlc_int_t *p_libvlc )
{
vlc_exit_t *exit = &libvlc_priv( p_libvlc )->exit;
msg_Dbg( p_libvlc, "exiting" );
vlc_mutex_lock( &exit->lock );
if( exit->handler != NULL )
exit->handler( exit->opaque );
else
msg_Dbg( p_libvlc, "no exit handler" );
vlc_mutex_unlock( &exit->lock );
}