]> git.sesse.net Git - vlc/blobdiff - lib/event.c
mediacodec: fix warning
[vlc] / lib / event.c
index 2ce0a23970d5bf8eb25fba5993bf02efd13835d3..2ed7c5ba88a6ef03dd599a5e7f62bfb470b4caf3 100644 (file)
@@ -1,25 +1,25 @@
 /*****************************************************************************
  * event.c: New libvlc event control API
  *****************************************************************************
- * Copyright (C) 2007-2010 the VideoLAN team
+ * Copyright (C) 2007-2010 VLC authors and VideoLAN
  * $Id $
  *
  * Authors: Filippo Carone <filippo@carone.org>
  *          Pierre d'Herbemont <pdherbemont # videolan.org>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * 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 General Public License for more details.
+ * 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 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.
+ * 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
@@ -157,8 +157,7 @@ void libvlc_event_send( libvlc_event_manager_t * p_em,
     /* Fill event with the sending object now */
     p_event->p_obj = p_em->p_obj;
 
-    /* Here a read/write lock would be nice */
-
+    vlc_mutex_lock( &p_em->event_sending_lock );
     vlc_mutex_lock( &p_em->object_lock );
     for( i = 0; i < vlc_array_count(&p_em->listeners_groups); i++)
     {
@@ -175,6 +174,7 @@ void libvlc_event_send( libvlc_event_manager_t * p_em,
             if( !array_listeners_cached )
             {
                 vlc_mutex_unlock( &p_em->object_lock );
+                vlc_mutex_unlock( &p_em->event_sending_lock );
                 fprintf(stderr, "Can't alloc memory in libvlc_event_send" );
                 return;
             }
@@ -194,14 +194,18 @@ void libvlc_event_send( libvlc_event_manager_t * p_em,
     {
         free( array_listeners_cached );
         vlc_mutex_unlock( &p_em->object_lock );
+        vlc_mutex_unlock( &p_em->event_sending_lock );
         return;
     }
 
+    /* Track item removed from *this* thread, with a simple flag. Indeed
+     * event_sending_lock is a recursive lock. This has the advantage of
+     * allowing to remove an event listener from within a callback */
+    listeners_group->b_sublistener_removed = false;
+
     vlc_mutex_unlock( &p_em->object_lock );
 
-    vlc_mutex_lock( &p_em->event_sending_lock );
     listener_cached = array_listeners_cached;
-    listeners_group->b_sublistener_removed = false;
     for( i = 0; i < i_cached_listeners; i++ )
     {
         if(listener_cached->is_asynchronous)
@@ -255,6 +259,7 @@ static const event_name_t event_list[] = {
     DEF(MediaParsedChanged)
     DEF(MediaFreed)
     DEF(MediaStateChanged)
+    DEF(MediaSubItemTreeAdded)
 
     DEF(MediaPlayerMediaChanged)
     DEF(MediaPlayerNothingSpecial)
@@ -274,6 +279,11 @@ static const event_name_t event_list[] = {
     DEF(MediaPlayerTitleChanged)
     DEF(MediaPlayerSnapshotTaken)
     DEF(MediaPlayerLengthChanged)
+    DEF(MediaPlayerVout)
+    DEF(MediaPlayerScrambledChanged)
+    DEF(MediaPlayerESAdded)
+    DEF(MediaPlayerESDeleted)
+    DEF(MediaPlayerESSelected)
 
     DEF(MediaListItemAdded)
     DEF(MediaListWillAddItem)
@@ -299,6 +309,10 @@ static const event_name_t event_list[] = {
     DEF(VlmMediaInstanceStopped)
     DEF(VlmMediaInstanceStatusInit)
     DEF(VlmMediaInstanceStatusOpening)
+    DEF(VlmMediaInstanceStatusPlaying)
+    DEF(VlmMediaInstanceStatusPause)
+    DEF(VlmMediaInstanceStatusEnd)
+    DEF(VlmMediaInstanceStatusError)
 };
 #undef DEF
 
@@ -359,7 +373,7 @@ int event_attach( libvlc_event_manager_t * p_event_manager,
     free(listener);
     fprintf( stderr, "This object event manager doesn't know about '%s' events",
              libvlc_event_type_name(event_type) );
-    assert(0);
+    vlc_assert_unreachable();
     return -1;
 }
 
@@ -424,7 +438,7 @@ void libvlc_event_detach( libvlc_event_manager_t *p_event_manager,
 
                     /* Mark this group as edited so that libvlc_event_send
                      * will recheck what listener to call */
-                    listeners_group->b_sublistener_removed = false;
+                    listeners_group->b_sublistener_removed = true;
 
                     free( listener );
                     vlc_array_remove( &listeners_group->listeners, j );