]> git.sesse.net Git - vlc/blobdiff - src/control/media_list_player.c
good
[vlc] / src / control / media_list_player.c
index 45222fcb2a50752973eb73ebeaccc91f8155899d..dcf38ca1e4f398ab3b2d448aed9f3cb8de73d6f5 100644 (file)
@@ -116,7 +116,7 @@ static inline void assert_locked(libvlc_media_list_player_t * p_mlp)
 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)
@@ -144,7 +144,7 @@ get_next_path(libvlc_media_list_player_t * p_mlp, bool b_loop)
 
     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);
     }
@@ -172,7 +172,7 @@ get_next_path(libvlc_media_list_player_t * p_mlp, bool b_loop)
     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)
@@ -218,7 +218,7 @@ find_last_item( libvlc_media_list_t * p_mlist, libvlc_media_list_path_t current_
 
     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. */
@@ -252,7 +252,7 @@ get_previous_path(libvlc_media_list_player_t * p_mlp, bool b_loop)
 
     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);
     }
@@ -285,7 +285,7 @@ get_previous_path(libvlc_media_list_player_t * p_mlp, bool b_loop)
             // 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;
@@ -358,7 +358,7 @@ static void
 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);
 }
 
 /**************************************************************************
@@ -379,7 +379,7 @@ static void
 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);
 }
 
 
@@ -438,7 +438,7 @@ set_current_playing_item(libvlc_media_list_player_t * p_mlp, libvlc_media_list_p
 
     /* Create a new media_player if there is none */
     if (!p_mlp->p_mi)
-        p_mlp->p_mi = libvlc_media_player_new_from_media(p_md, NULL);
+        p_mlp->p_mi = libvlc_media_player_new_from_media(p_md);
 
     libvlc_media_player_set_media(p_mlp->p_mi, p_md);
 
@@ -454,21 +454,29 @@ set_current_playing_item(libvlc_media_list_player_t * p_mlp, libvlc_media_list_p
  *         new (Public)
  **************************************************************************/
 libvlc_media_list_player_t *
-libvlc_media_list_player_new(libvlc_instance_t * p_instance, libvlc_exception_t * p_e)
+libvlc_media_list_player_new(libvlc_instance_t * p_instance)
 {
-    (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;