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

lib: media: allocate event manager in-place

parent d241be43
...@@ -172,7 +172,7 @@ static void input_item_subitem_added( const vlc_event_t *p_event, ...@@ -172,7 +172,7 @@ static void input_item_subitem_added( const vlc_event_t *p_event,
event.u.media_subitem_added.new_child = p_md_child; event.u.media_subitem_added.new_child = p_md_child;
/* Send the event */ /* Send the event */
libvlc_event_send( p_md->p_event_manager, &event ); libvlc_event_send( &p_md->event_manager, &event );
libvlc_media_release( p_md_child ); libvlc_media_release( p_md_child );
} }
...@@ -191,7 +191,7 @@ static void input_item_subitemtree_added( const vlc_event_t * p_event, ...@@ -191,7 +191,7 @@ static void input_item_subitemtree_added( const vlc_event_t * p_event,
event.u.media_subitemtree_added.item = p_md; event.u.media_subitemtree_added.item = p_md;
/* Send the event */ /* Send the event */
libvlc_event_send( p_md->p_event_manager, &event ); libvlc_event_send( &p_md->event_manager, &event );
} }
/************************************************************************** /**************************************************************************
...@@ -209,7 +209,7 @@ static void input_item_meta_changed( const vlc_event_t *p_event, ...@@ -209,7 +209,7 @@ static void input_item_meta_changed( const vlc_event_t *p_event,
vlc_to_libvlc_meta[p_event->u.input_item_meta_changed.meta_type]; vlc_to_libvlc_meta[p_event->u.input_item_meta_changed.meta_type];
/* Send the event */ /* Send the event */
libvlc_event_send( p_md->p_event_manager, &event ); libvlc_event_send( &p_md->event_manager, &event );
} }
/************************************************************************** /**************************************************************************
...@@ -227,7 +227,7 @@ static void input_item_duration_changed( const vlc_event_t *p_event, ...@@ -227,7 +227,7 @@ static void input_item_duration_changed( const vlc_event_t *p_event,
from_mtime(p_event->u.input_item_duration_changed.new_duration); from_mtime(p_event->u.input_item_duration_changed.new_duration);
/* Send the event */ /* Send the event */
libvlc_event_send( p_md->p_event_manager, &event ); libvlc_event_send( &p_md->event_manager, &event );
} }
static void send_parsed_changed( libvlc_media_t *p_md, static void send_parsed_changed( libvlc_media_t *p_md,
...@@ -272,7 +272,7 @@ static void send_parsed_changed( libvlc_media_t *p_md, ...@@ -272,7 +272,7 @@ static void send_parsed_changed( libvlc_media_t *p_md,
event.u.media_parsed_changed.new_status = new_status; event.u.media_parsed_changed.new_status = new_status;
/* Send the event */ /* Send the event */
libvlc_event_send( p_md->p_event_manager, &event ); libvlc_event_send( &p_md->event_manager, &event );
} }
/************************************************************************** /**************************************************************************
...@@ -396,12 +396,7 @@ libvlc_media_t * libvlc_media_new_from_input_item( ...@@ -396,12 +396,7 @@ libvlc_media_t * libvlc_media_new_from_input_item(
* It can give a bunch of item to read. */ * It can give a bunch of item to read. */
p_md->p_subitems = NULL; p_md->p_subitems = NULL;
p_md->p_event_manager = libvlc_event_manager_new( p_md ); libvlc_event_manager_init( &p_md->event_manager, p_md );
if( unlikely(p_md->p_event_manager == NULL) )
{
free(p_md);
return NULL;
}
input_item_Hold( p_md->p_input_item ); input_item_Hold( p_md->p_input_item );
...@@ -567,9 +562,9 @@ void libvlc_media_release( libvlc_media_t *p_md ) ...@@ -567,9 +562,9 @@ void libvlc_media_release( libvlc_media_t *p_md )
event.u.media_freed.md = p_md; event.u.media_freed.md = p_md;
/* Send the event */ /* Send the event */
libvlc_event_send( p_md->p_event_manager, &event ); libvlc_event_send( &p_md->event_manager, &event );
libvlc_event_manager_release( p_md->p_event_manager ); libvlc_event_manager_destroy( &p_md->event_manager );
libvlc_release( p_md->p_libvlc_instance ); libvlc_release( p_md->p_libvlc_instance );
free( p_md ); free( p_md );
} }
...@@ -673,7 +668,7 @@ libvlc_media_set_state( libvlc_media_t *p_md, ...@@ -673,7 +668,7 @@ libvlc_media_set_state( libvlc_media_t *p_md,
event.u.media_state_changed.new_state = state; event.u.media_state_changed.new_state = state;
/* Send the event */ /* Send the event */
libvlc_event_send( p_md->p_event_manager, &event ); libvlc_event_send( &p_md->event_manager, &event );
} }
/************************************************************************** /**************************************************************************
...@@ -731,7 +726,7 @@ libvlc_media_event_manager( libvlc_media_t * p_md ) ...@@ -731,7 +726,7 @@ libvlc_media_event_manager( libvlc_media_t * p_md )
{ {
assert( p_md ); assert( p_md );
return p_md->p_event_manager; return &p_md->event_manager;
} }
/************************************************************************** /**************************************************************************
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
struct libvlc_media_t struct libvlc_media_t
{ {
libvlc_event_manager_t * p_event_manager; libvlc_event_manager_t event_manager;
input_item_t *p_input_item; input_item_t *p_input_item;
int i_refcount; int i_refcount;
libvlc_instance_t *p_libvlc_instance; libvlc_instance_t *p_libvlc_instance;
......
...@@ -133,7 +133,7 @@ static void input_item_preparsed_changed( const vlc_event_t *p_event, ...@@ -133,7 +133,7 @@ static void input_item_preparsed_changed( const vlc_event_t *p_event,
libvlc_event_t event; libvlc_event_t event;
event.type = libvlc_MediaParsedChanged; event.type = libvlc_MediaParsedChanged;
event.u.media_parsed_changed.new_status = libvlc_media_parsed_status_done; event.u.media_parsed_changed.new_status = libvlc_media_parsed_status_done;
libvlc_event_send( p_md->p_event_manager, &event ); libvlc_event_send( &p_md->event_manager, &event );
} }
} }
......
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