Fortunes about QT and "hearing" video codecs
[vlc.git] / src / misc / exit.c
blob27985a4afbd72e8d200f1d5ee0d88b014e7475db
1 /*****************************************************************************
2 * exit.c: LibVLC termination event
3 *****************************************************************************
4 * Copyright (C) 2009-2010 VLC authors and VideoLAN
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.
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.
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 *****************************************************************************/
21 #ifdef HAVE_CONFIG_H
22 # include "config.h"
23 #endif
25 #include <vlc_common.h>
26 #include <vlc_interface.h>
27 #include "libvlc.h"
28 #include "../lib/libvlc_internal.h"
30 void vlc_ExitInit( vlc_exit_t *exit )
32 vlc_mutex_init( &exit->lock );
33 exit->handler = NULL;
34 exit->opaque = NULL;
37 void vlc_ExitDestroy( vlc_exit_t *exit )
39 vlc_mutex_destroy( &exit->lock );
43 /**
44 * Registers a callback for the LibVLC exit event.
46 void libvlc_SetExitHandler( libvlc_int_t *p_libvlc, void (*handler) (void *),
47 void *opaque )
49 vlc_exit_t *exit = &libvlc_priv( p_libvlc )->exit;
51 vlc_mutex_lock( &exit->lock );
52 exit->handler = handler;
53 exit->opaque = opaque;
54 vlc_mutex_unlock( &exit->lock );
57 /**
58 * Posts an exit signal to LibVLC instance.
59 * This function should only be called on behalf of the user.
61 void libvlc_Quit( libvlc_int_t *p_libvlc )
63 vlc_exit_t *exit = &libvlc_priv( p_libvlc )->exit;
65 msg_Dbg( p_libvlc, "exiting" );
66 vlc_mutex_lock( &exit->lock );
67 if( exit->handler != NULL )
68 exit->handler( exit->opaque );
69 else
70 msg_Dbg( p_libvlc, "no exit handler" );
71 vlc_mutex_unlock( &exit->lock );