[vlc-devel] commit: media_list_player: Use stop() so that we don't lock twice. ( Pierre d'Herbemont )
git version control
git at videolan.org
Wed Aug 19 17:17:04 CEST 2009
vlc | branch: master | Pierre d'Herbemont <pdherbemont at free.fr> | Wed Aug 19 16:51:54 2009 +0200| [655374882ca10d6811feeb63f9e8b7029e785299] | committer: Pierre d'Herbemont
media_list_player: Use stop() so that we don't lock twice.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=655374882ca10d6811feeb63f9e8b7029e785299
---
src/control/media_list_player.c | 35 ++++++++++++++++++++++++++++-------
1 files changed, 28 insertions(+), 7 deletions(-)
diff --git a/src/control/media_list_player.c b/src/control/media_list_player.c
index 883d4ec..808d1cb 100644
--- a/src/control/media_list_player.c
+++ b/src/control/media_list_player.c
@@ -76,6 +76,7 @@ static inline void vlc_assert_locked(vlc_mutex_t *mutex)
*/
static void next(libvlc_media_list_player_t * p_mlp, libvlc_exception_t * p_e);
+static void stop(libvlc_media_list_player_t * p_mlp, libvlc_exception_t * p_e);
/*
* Private functions
@@ -210,15 +211,19 @@ mlist_item_deleted(const libvlc_event_t * p_event, void * p_user_data)
{
libvlc_media_list_player_t * p_mlp = p_user_data;
libvlc_media_list_t * p_emitting_mlist = p_event->p_obj;
- libvlc_media_t * p_current_md;
- p_current_md = libvlc_media_list_item_at_path(p_mlp->p_mlist, p_mlp->current_playing_item_path);
+ libvlc_media_t * p_current_md = NULL;
+
+ lock(p_mlp);
+ if (p_mlp->current_playing_item_path)
+ p_current_md = libvlc_media_list_item_at_path(p_mlp->p_mlist, p_mlp->current_playing_item_path);
if (p_event->u.media_list_item_deleted.item == p_current_md &&
p_emitting_mlist == p_mlp->p_mlist)
{
/* We are playing this item, let's stop */
- libvlc_media_list_player_stop(p_mlp, NULL);
+ stop(p_mlp, NULL);
}
+ unlock(p_mlp);
}
@@ -296,6 +301,9 @@ set_current_playing_item(libvlc_media_list_player_t * p_mlp, libvlc_media_list_p
p_mlp->current_playing_item_path = path;
}
+ if (!path)
+ return;
+
libvlc_media_t * p_md;
p_md = libvlc_media_list_item_at_path(p_mlp->p_mlist, path);
if (!p_md)
@@ -508,11 +516,13 @@ void libvlc_media_list_player_play_item(libvlc_media_list_player_t * p_mlp, libv
}
/**************************************************************************
- * Stop (Public)
+ * Stop (Private)
+ *
+ * Lock must be held.
**************************************************************************/
-void libvlc_media_list_player_stop(libvlc_media_list_player_t * p_mlp, libvlc_exception_t * p_e)
+static void stop(libvlc_media_list_player_t * p_mlp, libvlc_exception_t * p_e)
{
- lock(p_mlp);
+ assert_locked(p_mlp);
if (p_mlp->p_mi && p_mlp->current_playing_item_path)
{
@@ -524,11 +534,22 @@ void libvlc_media_list_player_stop(libvlc_media_list_player_t * p_mlp, libvlc_ex
free(p_mlp->current_playing_item_path);
p_mlp->current_playing_item_path = NULL;
+}
+
+/**************************************************************************
+ * Stop (Public)
+ **************************************************************************/
+void libvlc_media_list_player_stop(libvlc_media_list_player_t * p_mlp, libvlc_exception_t * p_e)
+{
+ lock(p_mlp);
+ stop(p_mlp, p_e);
unlock(p_mlp);
}
/**************************************************************************
* Next (Private)
+ *
+ * Lock must be held.
**************************************************************************/
static void next(libvlc_media_list_player_t * p_mlp, libvlc_exception_t * p_e)
{
@@ -554,7 +575,7 @@ static void next(libvlc_media_list_player_t * p_mlp, libvlc_exception_t * p_e)
if (!path)
{
libvlc_media_list_unlock(p_mlp->p_mlist);
- libvlc_media_list_player_stop(p_mlp, p_e);
+ stop(p_mlp, p_e);
return;
}
More information about the vlc-devel
mailing list