Commit b80a4563 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

lib: merge event_internal.h into event.c

parent 062bd6c2
......@@ -32,7 +32,6 @@ lib_LTLIBRARIES = libvlc.la
libvlc_la_SOURCES = \
libvlc_internal.h \
event_internal.h \
media_internal.h \
media_list_internal.h \
media_player_internal.h \
......
......@@ -26,14 +26,79 @@
# include "config.h"
#endif
#define LIBVLC_EVENT_TYPES_KEEP_DEFINE
#include <vlc/libvlc.h>
#include "libvlc_internal.h"
#include "event_internal.h"
#include <assert.h>
#include <errno.h>
#include <vlc/libvlc.h>
#include "libvlc_internal.h"
#include <vlc_common.h>
/*
* Event Handling
*/
/* Example usage
*
* struct libvlc_cool_object_t
* {
* ...
* libvlc_event_manager_t * p_event_manager;
* ...
* }
*
* libvlc_my_cool_object_new()
* {
* ...
* p_self->p_event_manager = libvlc_event_manager_new( p_self )
* libvlc_event_manager_register_event_type(p_self->p_event_manager,
* libvlc_MyCoolObjectDidSomething, p_e)
* ...
* }
*
* libvlc_my_cool_object_release()
* {
* ...
* libvlc_event_manager_release( p_self->p_event_manager );
* ...
* }
*
* libvlc_my_cool_object_do_something()
* {
* ...
* libvlc_event_t event;
* event.type = libvlc_MyCoolObjectDidSomething;
* event.u.my_cool_object_did_something.what_it_did = kSomething;
* libvlc_event_send( p_self->p_event_manager, &event );
* }
* */
typedef struct libvlc_event_listener_t
{
libvlc_event_type_t event_type;
void * p_user_data;
libvlc_callback_t pf_callback;
} libvlc_event_listener_t;
typedef struct libvlc_event_manager_t
{
void * p_obj;
vlc_array_t listeners_groups;
vlc_mutex_t object_lock;
vlc_mutex_t event_sending_lock;
} libvlc_event_sender_t;
static inline bool
listeners_are_equal( libvlc_event_listener_t * listener1,
libvlc_event_listener_t * listener2 )
{
return listener1->event_type == listener2->event_type &&
listener1->pf_callback == listener2->pf_callback &&
listener1->p_user_data == listener2->p_user_data;
}
typedef struct libvlc_event_listeners_group_t
{
libvlc_event_type_t event_type;
......
/*****************************************************************************
* event_internal.h : Definition of opaque structures for libvlc exported API
* Also contains some internal utility functions
*****************************************************************************
* Copyright (C) 2005-2009 VLC authors and VideoLAN
* $Id$
*
* Authors: Clément Stenac <zorglub@videolan.org>
*
* 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.
*****************************************************************************/
#ifndef _LIBVLC_EVENT_H
#define _LIBVLC_EVENT_H 1
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc/libvlc_structures.h>
#include <vlc/libvlc.h>
#include <vlc/libvlc_events.h>
#include <vlc_common.h>
/*
* Event Handling
*/
/* Example usage
*
* struct libvlc_cool_object_t
* {
* ...
* libvlc_event_manager_t * p_event_manager;
* ...
* }
*
* libvlc_my_cool_object_new()
* {
* ...
* p_self->p_event_manager = libvlc_event_manager_new( p_self )
* libvlc_event_manager_register_event_type(p_self->p_event_manager,
* libvlc_MyCoolObjectDidSomething, p_e)
* ...
* }
*
* libvlc_my_cool_object_release()
* {
* ...
* libvlc_event_manager_release( p_self->p_event_manager );
* ...
* }
*
* libvlc_my_cool_object_do_something()
* {
* ...
* libvlc_event_t event;
* event.type = libvlc_MyCoolObjectDidSomething;
* event.u.my_cool_object_did_something.what_it_did = kSomething;
* libvlc_event_send( p_self->p_event_manager, &event );
* }
* */
typedef struct libvlc_event_listener_t
{
libvlc_event_type_t event_type;
void * p_user_data;
libvlc_callback_t pf_callback;
} libvlc_event_listener_t;
typedef struct libvlc_event_manager_t
{
void * p_obj;
vlc_array_t listeners_groups;
vlc_mutex_t object_lock;
vlc_mutex_t event_sending_lock;
} libvlc_event_sender_t;
static inline bool
listeners_are_equal( libvlc_event_listener_t * listener1,
libvlc_event_listener_t * listener2 )
{
return listener1->event_type == listener2->event_type &&
listener1->pf_callback == listener2->pf_callback &&
listener1->p_user_data == listener2->p_user_data;
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment