static inline libvlc_event_manager_t * mlist_em(libvlc_media_list_player_t * p_mlp)
{
assert_locked(p_mlp);
- return libvlc_media_list_event_manager(p_mlp->p_mlist, NULL);
+ return libvlc_media_list_event_manager(p_mlp->p_mlist);
}
static inline libvlc_event_manager_t * mplayer_em(libvlc_media_list_player_t * p_mlp)
if (!p_mlp->current_playing_item_path)
{
- if (!libvlc_media_list_count(p_mlp->p_mlist, NULL))
+ if (!libvlc_media_list_count(p_mlp->p_mlist))
return NULL;
return libvlc_media_list_path_with_root_index(0);
}
ret[depth - 1]++; /* set to next element */
/* If this goes beyond the end of the list */
- while(ret[depth-1] >= libvlc_media_list_count(p_parent_of_playing_item, NULL))
+ while(ret[depth-1] >= libvlc_media_list_count(p_parent_of_playing_item))
{
depth--;
if (depth <= 0)
if(p_sublist)
{
- int i_count = libvlc_media_list_count(p_sublist, NULL);
+ int i_count = libvlc_media_list_count(p_sublist);
if(i_count > 0)
{
/* Add the last sublist item to the path. */
if (!p_mlp->current_playing_item_path)
{
- if (!libvlc_media_list_count(p_mlp->p_mlist, NULL))
+ if (!libvlc_media_list_count(p_mlp->p_mlist))
return NULL;
return libvlc_media_list_path_with_root_index(0);
}
// Is looping enabled?
if(b_loop)
{
- int i_count = libvlc_media_list_count(p_parent_of_playing_item, NULL);
+ int i_count = libvlc_media_list_count(p_parent_of_playing_item);
/* Set current play item to the last element in the list */
ret[0] = i_count - 1;
install_playlist_observer(libvlc_media_list_player_t * p_mlp)
{
assert_locked(p_mlp);
- libvlc_event_attach(mlist_em(p_mlp), libvlc_MediaListItemDeleted, mlist_item_deleted, p_mlp, NULL);
+ libvlc_event_attach(mlist_em(p_mlp), libvlc_MediaListItemDeleted, mlist_item_deleted, p_mlp);
}
/**************************************************************************
{
assert_locked(p_mlp);
if (!p_mlp->p_mlist) return;
- libvlc_event_detach(mlist_em(p_mlp), libvlc_MediaListItemDeleted, mlist_item_deleted, p_mlp, NULL);
+ libvlc_event_detach(mlist_em(p_mlp), libvlc_MediaListItemDeleted, mlist_item_deleted, p_mlp);
}
/**************************************************************************
install_media_player_observer(libvlc_media_list_player_t * p_mlp)
{
assert_locked(p_mlp);
- libvlc_event_attach_async(mplayer_em(p_mlp), libvlc_MediaPlayerEndReached, media_player_reached_end, p_mlp, NULL);
+ libvlc_event_attach_async(mplayer_em(p_mlp), libvlc_MediaPlayerEndReached, media_player_reached_end, p_mlp);
}
// Allow callbacks to run, because detach() will wait until all callbacks are processed.
// This is safe because only callbacks are allowed, and there execution will be cancelled.
vlc_mutex_unlock(&p_mlp->mp_callback_lock);
- libvlc_event_detach(mplayer_em(p_mlp), libvlc_MediaPlayerEndReached, media_player_reached_end, p_mlp, NULL);
+ libvlc_event_detach(mplayer_em(p_mlp), libvlc_MediaPlayerEndReached, media_player_reached_end, p_mlp);
// Now, lock back the callback lock. No more callback will be present from this point.
vlc_mutex_lock(&p_mlp->mp_callback_lock);
(void)p_e;
libvlc_media_list_player_t * p_mlp;
p_mlp = calloc( 1, sizeof(libvlc_media_list_player_t) );
- if (!p_mlp)
+ if (unlikely(p_mlp == NULL))
+ {
+ libvlc_printerr("Not enough memory");
return NULL;
+ }
+
+ p_mlp->p_event_manager = libvlc_event_manager_new(p_mlp, p_instance);
+ if (unlikely(p_mlp->p_event_manager == NULL))
+ {
+ free (p_mlp);
+ return NULL;
+ }
libvlc_retain(p_instance);
p_mlp->p_libvlc_instance = p_instance;
p_mlp->i_refcount = 1;
vlc_mutex_init(&p_mlp->object_lock);
vlc_mutex_init(&p_mlp->mp_callback_lock);
- p_mlp->p_event_manager = libvlc_event_manager_new(p_mlp, p_instance, p_e);
- libvlc_event_manager_register_event_type(p_mlp->p_event_manager, libvlc_MediaListPlayerNextItemSet, p_e);
+ libvlc_event_manager_register_event_type(p_mlp->p_event_manager, libvlc_MediaListPlayerNextItemSet);
p_mlp->e_playback_mode = libvlc_playback_mode_default;
return p_mlp;