event_internal.h
上传用户:kjfoods
上传日期:2020-07-06
资源大小:29949k
文件大小:4k
源码类别:

midi

开发平台:

Unix_Linux

  1. /*****************************************************************************
  2.  * libvlc_internal.h : Definition of opaque structures for libvlc exported API
  3.  * Also contains some internal utility functions
  4.  *****************************************************************************
  5.  * Copyright (C) 2005-2009 the VideoLAN team
  6.  * $Id: b7df2cbfbfda673df8ab71c88a71080412d82c4a $
  7.  *
  8.  * Authors: Clément Stenac <zorglub@videolan.org>
  9.  *
  10.  * This program is free software; you can redistribute it and/or modify
  11.  * it under the terms of the GNU General Public License as published by
  12.  * the Free Software Foundation; either version 2 of the License, or
  13.  * (at your option) any later version.
  14.  *
  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 General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with this program; if not, write to the Free Software
  22.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  23.  *****************************************************************************/
  24. #ifndef _LIBVLC_EVENT_H
  25. #define _LIBVLC_EVENT_H 1
  26. #ifdef HAVE_CONFIG_H
  27. # include "config.h"
  28. #endif
  29. #include <vlc/libvlc_structures.h>
  30. #include <vlc/libvlc.h>
  31. #include <vlc/libvlc_events.h>
  32. #include <vlc_common.h>
  33. /*
  34.  * Event Handling
  35.  */
  36. /* Example usage
  37.  *
  38.  * struct libvlc_cool_object_t
  39.  * {
  40.  *        ...
  41.  *        libvlc_event_manager_t * p_event_manager;
  42.  *        ...
  43.  * }
  44.  *
  45.  * libvlc_my_cool_object_new()
  46.  * {
  47.  *        ...
  48.  *        p_self->p_event_manager = libvlc_event_manager_new( p_self,
  49.  *                                                   p_self->p_libvlc_instance, p_e);
  50.  *        libvlc_event_manager_register_event_type(p_self->p_event_manager,
  51.  *                libvlc_MyCoolObjectDidSomething, p_e)
  52.  *        ...
  53.  * }
  54.  *
  55.  * libvlc_my_cool_object_release()
  56.  * {
  57.  *         ...
  58.  *         libvlc_event_manager_release( p_self->p_event_manager );
  59.  *         ...
  60.  * }
  61.  *
  62.  * libvlc_my_cool_object_do_something()
  63.  * {
  64.  *        ...
  65.  *        libvlc_event_t event;
  66.  *        event.type = libvlc_MyCoolObjectDidSomething;
  67.  *        event.u.my_cool_object_did_something.what_it_did = kSomething;
  68.  *        libvlc_event_send( p_self->p_event_manager, &event );
  69.  * }
  70.  * */
  71. typedef struct libvlc_event_listener_t
  72. {
  73.     libvlc_event_type_t event_type;
  74.     void *              p_user_data;
  75.     libvlc_callback_t   pf_callback;
  76.     bool                is_asynchronous;
  77. } libvlc_event_listener_t;
  78. typedef struct libvlc_event_manager_t
  79. {
  80.     void * p_obj;
  81.     struct libvlc_instance_t * p_libvlc_instance;
  82.     vlc_array_t listeners_groups;
  83.     vlc_mutex_t object_lock;
  84.     vlc_mutex_t event_sending_lock;
  85.     struct libvlc_event_async_queue * async_event_queue;
  86. } libvlc_event_sender_t;
  87. static inline bool
  88. listeners_are_equal( libvlc_event_listener_t * listener1,
  89.                     libvlc_event_listener_t * listener2 )
  90. {
  91.     return listener1->event_type  == listener2->event_type &&
  92.     listener1->pf_callback == listener2->pf_callback &&
  93.     listener1->p_user_data == listener2->p_user_data &&
  94.     listener1->is_asynchronous == listener2->is_asynchronous;
  95. }
  96. /* event_async.c */
  97. void libvlc_event_async_fini(libvlc_event_manager_t * p_em);
  98. void libvlc_event_async_dispatch(libvlc_event_manager_t * p_em, libvlc_event_listener_t * listener, libvlc_event_t * event);
  99. void libvlc_event_async_ensure_listener_removal(libvlc_event_manager_t * p_em, libvlc_event_listener_t * listener);
  100. #endif