<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7654.12">
<TITLE>RE: [vlc-devel] commit: libvlc_event_*: fix locking (Jean-PaulSaman )</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<P><FONT SIZE=2>Pierre,<BR>
<BR>
This approach to listen to a stop event from libvlc crashes the application. So either:<BR>
1) this approach is invalid or<BR>
2) there is a bug in the event code.<BR>
<BR>
I hope this helps you.<BR>
<BR>
-----Original Message-----<BR>
From: vlc-devel-bounces@videolan.org on behalf of Pierre d'Herbemont<BR>
Sent: Mon 5/25/2009 11:55 AM<BR>
To: Mailing list for VLC media player developers<BR>
Subject: Re: [vlc-devel] commit: libvlc_event_*: fix locking (Jean-PaulSaman )<BR>
<BR>
What were you trying to fix. This should break event handling.<BR>
<BR>
Could you add a test case for the specific thing you were trying to fix?<BR>
<BR>
On Sun, May 24, 2009 at 3:36 PM, git version control <git@videolan.org> wrote:<BR>
> vlc | branch: 1.0-bugfix | Jean-Paul Saman <jpsaman@videolan.org> | Tue May 12 12:39:50 2009 +0200| [d600db5f113edd122ec12be9c589e27fcbed4917] | committer: Jean-Paul Saman<BR>
><BR>
> libvlc_event_*: fix locking<BR>
> (cherry picked from commit 13b7d257de1eced08708034186e290c0a5f5628a)<BR>
><BR>
> Reverted change to libvlc_event_manger_release().<BR>
><BR>
>> <A HREF="http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d600db5f113edd122ec12be9c589e27fcbed4917">http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d600db5f113edd122ec12be9c589e27fcbed4917</A><BR>
> ---<BR>
><BR>
> src/control/event.c | 27 ++++++++++++++++++++-------<BR>
> 1 files changed, 20 insertions(+), 7 deletions(-)<BR>
><BR>
> diff --git a/src/control/event.c b/src/control/event.c<BR>
> index d7f0b41..87251db 100644<BR>
> --- a/src/control/event.c<BR>
> +++ b/src/control/event.c<BR>
> @@ -107,7 +107,9 @@ void libvlc_event_manager_release( libvlc_event_manager_t * p_em )<BR>
> free( p_lg );<BR>
> }<BR>
> vlc_array_clear( &p_em->listeners_groups );<BR>
> +<BR>
> libvlc_release( p_em->p_libvlc_instance );<BR>
> +<BR>
> free( p_em );<BR>
> }<BR>
><BR>
> @@ -122,9 +124,14 @@ void libvlc_event_manager_register_event_type(<BR>
> libvlc_exception_t * p_e )<BR>
> {<BR>
> libvlc_event_listeners_group_t * listeners_group;<BR>
> +<BR>
> + vlc_mutex_lock( &p_em->object_lock );<BR>
> +<BR>
> listeners_group = malloc(sizeof(libvlc_event_listeners_group_t));<BR>
> if( !listeners_group )<BR>
> {<BR>
> + vlc_mutex_unlock( &p_em->object_lock );<BR>
> +<BR>
> libvlc_exception_raise( p_e, "No Memory left" );<BR>
> return;<BR>
> }<BR>
> @@ -132,7 +139,6 @@ void libvlc_event_manager_register_event_type(<BR>
> listeners_group->event_type = event_type;<BR>
> vlc_array_init( &listeners_group->listeners );<BR>
><BR>
> - vlc_mutex_lock( &p_em->object_lock );<BR>
> vlc_array_append( &p_em->listeners_groups, listeners_group );<BR>
> vlc_mutex_unlock( &p_em->object_lock );<BR>
> }<BR>
> @@ -171,6 +177,7 @@ void libvlc_event_send( libvlc_event_manager_t * p_em,<BR>
> if( !array_listeners_cached )<BR>
> {<BR>
> fprintf(stderr, "Can't alloc memory in libvlc_event_send" );<BR>
> + vlc_mutex_unlock( &p_em->object_lock );<BR>
> return;<BR>
> }<BR>
><BR>
> @@ -187,6 +194,7 @@ void libvlc_event_send( libvlc_event_manager_t * p_em,<BR>
><BR>
> if( !listeners_group )<BR>
> {<BR>
> + vlc_mutex_unlock( &p_em->object_lock );<BR>
> free( array_listeners_cached );<BR>
> return;<BR>
> }<BR>
> @@ -215,9 +223,10 @@ void libvlc_event_send( libvlc_event_manager_t * p_em,<BR>
> listener_cached->pf_callback( p_event, listener_cached->p_user_data );<BR>
> listener_cached++;<BR>
> }<BR>
> - vlc_mutex_unlock( &p_em->event_sending_lock );<BR>
><BR>
> free( array_listeners_cached );<BR>
> +<BR>
> + vlc_mutex_unlock( &p_em->event_sending_lock );<BR>
> }<BR>
><BR>
> /*<BR>
> @@ -299,9 +308,13 @@ void libvlc_event_attach( libvlc_event_manager_t * p_event_manager,<BR>
> libvlc_event_listener_t * listener;<BR>
> int i;<BR>
><BR>
> + vlc_mutex_lock( &p_event_manager->object_lock );<BR>
> +<BR>
> listener = malloc(sizeof(libvlc_event_listener_t));<BR>
> if( !listener )<BR>
> {<BR>
> + vlc_mutex_unlock( &p_event_manager->object_lock );<BR>
> +<BR>
> libvlc_exception_raise( p_e, "No Memory left" );<BR>
> return;<BR>
> }<BR>
> @@ -310,7 +323,6 @@ void libvlc_event_attach( libvlc_event_manager_t * p_event_manager,<BR>
> listener->p_user_data = p_user_data;<BR>
> listener->pf_callback = pf_callback;<BR>
><BR>
> - vlc_mutex_lock( &p_event_manager->object_lock );<BR>
> for( i = 0; i < vlc_array_count(&p_event_manager->listeners_groups); i++ )<BR>
> {<BR>
> listeners_group = vlc_array_item_at_index(&p_event_manager->listeners_groups, i);<BR>
> @@ -321,9 +333,11 @@ void libvlc_event_attach( libvlc_event_manager_t * p_event_manager,<BR>
> return;<BR>
> }<BR>
> }<BR>
> - vlc_mutex_unlock( &p_event_manager->object_lock );<BR>
><BR>
> free(listener);<BR>
> +<BR>
> + vlc_mutex_unlock( &p_event_manager->object_lock );<BR>
> +<BR>
> libvlc_exception_raise( p_e,<BR>
> "This object event manager doesn't know about '%s' events",<BR>
> libvlc_event_type_name(event_type));<BR>
> @@ -344,8 +358,8 @@ void libvlc_event_detach( libvlc_event_manager_t *p_event_manager,<BR>
> libvlc_event_listener_t * listener;<BR>
> int i, j;<BR>
><BR>
> - vlc_mutex_lock( &p_event_manager->event_sending_lock );<BR>
> vlc_mutex_lock( &p_event_manager->object_lock );<BR>
> +<BR>
> for( i = 0; i < vlc_array_count(&p_event_manager->listeners_groups); i++)<BR>
> {<BR>
> listeners_group = vlc_array_item_at_index(&p_event_manager->listeners_groups, i);<BR>
> @@ -367,14 +381,13 @@ void libvlc_event_detach( libvlc_event_manager_t *p_event_manager,<BR>
> free( listener );<BR>
> vlc_array_remove( &listeners_group->listeners, j );<BR>
> vlc_mutex_unlock( &p_event_manager->object_lock );<BR>
> - vlc_mutex_unlock( &p_event_manager->event_sending_lock );<BR>
> return;<BR>
> }<BR>
> }<BR>
> }<BR>
> }<BR>
> +<BR>
> vlc_mutex_unlock( &p_event_manager->object_lock );<BR>
> - vlc_mutex_unlock( &p_event_manager->event_sending_lock );<BR>
><BR>
> libvlc_exception_raise( p_e,<BR>
> "This object event manager doesn't know about '%s,%p,%p' event observer",<BR>
><BR>
> _______________________________________________<BR>
> vlc-devel mailing list<BR>
> To unsubscribe or modify your subscription options:<BR>
> <A HREF="http://mailman.videolan.org/listinfo/vlc-devel">http://mailman.videolan.org/listinfo/vlc-devel</A><BR>
><BR>
_______________________________________________<BR>
vlc-devel mailing list<BR>
To unsubscribe or modify your subscription options:<BR>
<A HREF="http://mailman.videolan.org/listinfo/vlc-devel">http://mailman.videolan.org/listinfo/vlc-devel</A><BR>
<BR>
<BR>
</FONT>
</P>
</BODY>
</HTML>