Commit 5e857623 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

Revert "libvlc_event_*: fix locking"

This reverts commit 13b7d257.

This is incorrect as it introduces locking the release when this should not be needed.
parent ba4e6762
...@@ -107,9 +107,7 @@ void libvlc_event_manager_release( libvlc_event_manager_t * p_em ) ...@@ -107,9 +107,7 @@ void libvlc_event_manager_release( libvlc_event_manager_t * p_em )
free( p_lg ); free( p_lg );
} }
vlc_array_clear( &p_em->listeners_groups ); vlc_array_clear( &p_em->listeners_groups );
libvlc_release( p_em->p_libvlc_instance ); libvlc_release( p_em->p_libvlc_instance );
free( p_em ); free( p_em );
} }
...@@ -124,14 +122,9 @@ void libvlc_event_manager_register_event_type( ...@@ -124,14 +122,9 @@ void libvlc_event_manager_register_event_type(
libvlc_exception_t * p_e ) libvlc_exception_t * p_e )
{ {
libvlc_event_listeners_group_t * listeners_group; libvlc_event_listeners_group_t * listeners_group;
vlc_mutex_lock( &p_em->object_lock );
listeners_group = malloc(sizeof(libvlc_event_listeners_group_t)); listeners_group = malloc(sizeof(libvlc_event_listeners_group_t));
if( !listeners_group ) if( !listeners_group )
{ {
vlc_mutex_unlock( &p_em->object_lock );
libvlc_exception_raise( p_e, "No Memory left" ); libvlc_exception_raise( p_e, "No Memory left" );
return; return;
} }
...@@ -139,6 +132,7 @@ void libvlc_event_manager_register_event_type( ...@@ -139,6 +132,7 @@ void libvlc_event_manager_register_event_type(
listeners_group->event_type = event_type; listeners_group->event_type = event_type;
vlc_array_init( &listeners_group->listeners ); vlc_array_init( &listeners_group->listeners );
vlc_mutex_lock( &p_em->object_lock );
vlc_array_append( &p_em->listeners_groups, listeners_group ); vlc_array_append( &p_em->listeners_groups, listeners_group );
vlc_mutex_unlock( &p_em->object_lock ); vlc_mutex_unlock( &p_em->object_lock );
} }
...@@ -177,7 +171,6 @@ void libvlc_event_send( libvlc_event_manager_t * p_em, ...@@ -177,7 +171,6 @@ void libvlc_event_send( libvlc_event_manager_t * p_em,
if( !array_listeners_cached ) if( !array_listeners_cached )
{ {
fprintf(stderr, "Can't alloc memory in libvlc_event_send" ); fprintf(stderr, "Can't alloc memory in libvlc_event_send" );
vlc_mutex_unlock( &p_em->object_lock );
return; return;
} }
...@@ -194,7 +187,6 @@ void libvlc_event_send( libvlc_event_manager_t * p_em, ...@@ -194,7 +187,6 @@ void libvlc_event_send( libvlc_event_manager_t * p_em,
if( !listeners_group ) if( !listeners_group )
{ {
vlc_mutex_unlock( &p_em->object_lock );
free( array_listeners_cached ); free( array_listeners_cached );
return; return;
} }
...@@ -223,10 +215,9 @@ void libvlc_event_send( libvlc_event_manager_t * p_em, ...@@ -223,10 +215,9 @@ void libvlc_event_send( libvlc_event_manager_t * p_em,
listener_cached->pf_callback( p_event, listener_cached->p_user_data ); listener_cached->pf_callback( p_event, listener_cached->p_user_data );
listener_cached++; listener_cached++;
} }
vlc_mutex_unlock( &p_em->event_sending_lock );
free( array_listeners_cached ); free( array_listeners_cached );
vlc_mutex_unlock( &p_em->event_sending_lock );
} }
/* /*
...@@ -308,13 +299,9 @@ void libvlc_event_attach( libvlc_event_manager_t * p_event_manager, ...@@ -308,13 +299,9 @@ void libvlc_event_attach( libvlc_event_manager_t * p_event_manager,
libvlc_event_listener_t * listener; libvlc_event_listener_t * listener;
int i; int i;
vlc_mutex_lock( &p_event_manager->object_lock );
listener = malloc(sizeof(libvlc_event_listener_t)); listener = malloc(sizeof(libvlc_event_listener_t));
if( !listener ) if( !listener )
{ {
vlc_mutex_unlock( &p_event_manager->object_lock );
libvlc_exception_raise( p_e, "No Memory left" ); libvlc_exception_raise( p_e, "No Memory left" );
return; return;
} }
...@@ -323,6 +310,7 @@ void libvlc_event_attach( libvlc_event_manager_t * p_event_manager, ...@@ -323,6 +310,7 @@ void libvlc_event_attach( libvlc_event_manager_t * p_event_manager,
listener->p_user_data = p_user_data; listener->p_user_data = p_user_data;
listener->pf_callback = pf_callback; listener->pf_callback = pf_callback;
vlc_mutex_lock( &p_event_manager->object_lock );
for( i = 0; i < vlc_array_count(&p_event_manager->listeners_groups); i++ ) for( i = 0; i < vlc_array_count(&p_event_manager->listeners_groups); i++ )
{ {
listeners_group = vlc_array_item_at_index(&p_event_manager->listeners_groups, i); listeners_group = vlc_array_item_at_index(&p_event_manager->listeners_groups, i);
...@@ -333,11 +321,9 @@ void libvlc_event_attach( libvlc_event_manager_t * p_event_manager, ...@@ -333,11 +321,9 @@ void libvlc_event_attach( libvlc_event_manager_t * p_event_manager,
return; return;
} }
} }
free(listener);
vlc_mutex_unlock( &p_event_manager->object_lock ); vlc_mutex_unlock( &p_event_manager->object_lock );
free(listener);
libvlc_exception_raise( p_e, libvlc_exception_raise( p_e,
"This object event manager doesn't know about '%s' events", "This object event manager doesn't know about '%s' events",
libvlc_event_type_name(event_type)); libvlc_event_type_name(event_type));
...@@ -358,8 +344,8 @@ void libvlc_event_detach( libvlc_event_manager_t *p_event_manager, ...@@ -358,8 +344,8 @@ void libvlc_event_detach( libvlc_event_manager_t *p_event_manager,
libvlc_event_listener_t * listener; libvlc_event_listener_t * listener;
int i, j; int i, j;
vlc_mutex_lock( &p_event_manager->event_sending_lock );
vlc_mutex_lock( &p_event_manager->object_lock ); vlc_mutex_lock( &p_event_manager->object_lock );
for( i = 0; i < vlc_array_count(&p_event_manager->listeners_groups); i++) for( i = 0; i < vlc_array_count(&p_event_manager->listeners_groups); i++)
{ {
listeners_group = vlc_array_item_at_index(&p_event_manager->listeners_groups, i); listeners_group = vlc_array_item_at_index(&p_event_manager->listeners_groups, i);
...@@ -381,13 +367,14 @@ void libvlc_event_detach( libvlc_event_manager_t *p_event_manager, ...@@ -381,13 +367,14 @@ void libvlc_event_detach( libvlc_event_manager_t *p_event_manager,
free( listener ); free( listener );
vlc_array_remove( &listeners_group->listeners, j ); vlc_array_remove( &listeners_group->listeners, j );
vlc_mutex_unlock( &p_event_manager->object_lock ); vlc_mutex_unlock( &p_event_manager->object_lock );
vlc_mutex_unlock( &p_event_manager->event_sending_lock );
return; return;
} }
} }
} }
} }
vlc_mutex_unlock( &p_event_manager->object_lock ); vlc_mutex_unlock( &p_event_manager->object_lock );
vlc_mutex_unlock( &p_event_manager->event_sending_lock );
libvlc_exception_raise( p_e, libvlc_exception_raise( p_e,
"This object event manager doesn't know about '%s,%p,%p' event observer", "This object event manager doesn't know about '%s,%p,%p' event observer",
......
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