Correct spelling: s/[sS]yncro/[sS]ynchro/
[vlc.git] / lib / event_internal.h
blob5c3ab3e5102f6595ca26f0c7706af111b9b35470
1 /*****************************************************************************
2 * event_internal.h : Definition of opaque structures for libvlc exported API
3 * Also contains some internal utility functions
4 *****************************************************************************
5 * Copyright (C) 2005-2009 VLC authors and VideoLAN
6 * $Id$
8 * Authors: Clément Stenac <zorglub@videolan.org>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2.1 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #ifndef _LIBVLC_EVENT_H
26 #define _LIBVLC_EVENT_H 1
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
32 #include <vlc/libvlc_structures.h>
33 #include <vlc/libvlc.h>
34 #include <vlc/libvlc_events.h>
36 #include <vlc_common.h>
40 * Event Handling
43 /* Example usage
45 * struct libvlc_cool_object_t
46 * {
47 * ...
48 * libvlc_event_manager_t * p_event_manager;
49 * ...
50 * }
52 * libvlc_my_cool_object_new()
53 * {
54 * ...
55 * p_self->p_event_manager = libvlc_event_manager_new( p_self,
56 * p_self->p_libvlc_instance, p_e);
57 * libvlc_event_manager_register_event_type(p_self->p_event_manager,
58 * libvlc_MyCoolObjectDidSomething, p_e)
59 * ...
60 * }
62 * libvlc_my_cool_object_release()
63 * {
64 * ...
65 * libvlc_event_manager_release( p_self->p_event_manager );
66 * ...
67 * }
69 * libvlc_my_cool_object_do_something()
70 * {
71 * ...
72 * libvlc_event_t event;
73 * event.type = libvlc_MyCoolObjectDidSomething;
74 * event.u.my_cool_object_did_something.what_it_did = kSomething;
75 * libvlc_event_send( p_self->p_event_manager, &event );
76 * }
77 * */
79 typedef struct libvlc_event_listener_t
81 libvlc_event_type_t event_type;
82 void * p_user_data;
83 libvlc_callback_t pf_callback;
84 bool is_asynchronous;
85 } libvlc_event_listener_t;
87 typedef struct libvlc_event_manager_t
89 void * p_obj;
90 struct libvlc_instance_t * p_libvlc_instance;
91 vlc_array_t listeners_groups;
92 vlc_mutex_t object_lock;
93 vlc_mutex_t event_sending_lock;
94 struct libvlc_event_async_queue * async_event_queue;
95 } libvlc_event_sender_t;
98 static inline bool
99 listeners_are_equal( libvlc_event_listener_t * listener1,
100 libvlc_event_listener_t * listener2 )
102 return listener1->event_type == listener2->event_type &&
103 listener1->pf_callback == listener2->pf_callback &&
104 listener1->p_user_data == listener2->p_user_data &&
105 listener1->is_asynchronous == listener2->is_asynchronous;
108 /* event_async.c */
109 void libvlc_event_async_fini(libvlc_event_manager_t * p_em);
110 void libvlc_event_async_dispatch(libvlc_event_manager_t * p_em, libvlc_event_listener_t * listener, libvlc_event_t * event);
111 void libvlc_event_async_ensure_listener_removal(libvlc_event_manager_t * p_em, libvlc_event_listener_t * listener);
113 #endif