[vlc-devel] commit: playlist: Use a set/release accessor for playlist->p_input. ( Pierre d'Herbemont )
git version control
git at videolan.org
Sat Jun 14 15:17:00 CEST 2008
vlc | branch: master | Pierre d'Herbemont <pdherbemont at videolan.org> | Sat Jun 14 15:03:15 2008 +0200| [966feba166c6a6abe77fc2660da9da4549b4d104]
playlist: Use a set/release accessor for playlist->p_input.
(To better track when to attach/detach events).
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=966feba166c6a6abe77fc2660da9da4549b4d104
---
src/playlist/control.c | 6 +++++-
src/playlist/engine.c | 23 +++++++----------------
src/playlist/playlist_internal.h | 32 ++++++++++++++++++++++++++++++++
3 files changed, 44 insertions(+), 17 deletions(-)
diff --git a/src/playlist/control.c b/src/playlist/control.c
index 9a0ba6d..de7342d 100644
--- a/src/playlist/control.c
+++ b/src/playlist/control.c
@@ -476,8 +476,12 @@ int playlist_PlayItem( playlist_t *p_playlist, playlist_item_t *p_item )
var_SetInteger( p_playlist, "activity", i_activity +
DEFAULT_INPUT_ACTIVITY );
- p_playlist->p_input =
+
+ input_thread_t * p_input_thread =
input_CreateThreadExtended( p_playlist, p_input, NULL, *pp_sout );
+ playlist_set_current_input( p_playlist, p_input_thread );
+ vlc_object_release( p_input_thread );
+
*pp_sout = NULL;
char *psz_uri = input_item_GetURI( p_item->p_input );
diff --git a/src/playlist/engine.c b/src/playlist/engine.c
index 94dda74..0313acd 100644
--- a/src/playlist/engine.c
+++ b/src/playlist/engine.c
@@ -39,6 +39,7 @@
*****************************************************************************/
static void VariablesInit( playlist_t *p_playlist );
static void playlist_Destructor( vlc_object_t * p_this );
+static void playlist_Destructor( vlc_object_t * p_this );
static int RandomCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *a )
@@ -244,19 +245,13 @@ check_input:
PL_DEBUG( "dead input" );
p_input = p_playlist->p_input;
- p_playlist->p_input = NULL;
+
assert( *pp_sout == NULL );
if( var_CreateGetBool( p_input, "sout-keep" ) )
*pp_sout = input_DetachSout( p_input );
- /* Release the playlist lock, because we may get stuck
- * in vlc_object_release() for some time. */
- PL_UNLOCK;
-
/* Destroy input */
- vlc_object_release( p_input );
-
- PL_LOCK;
+ playlist_release_current_input( p_playlist );
p_playlist->gc_date = mdate();
p_playlist->b_cant_sleep = true;
@@ -275,6 +270,7 @@ check_input:
i_activity= var_GetInteger( p_playlist, "activity" );
var_SetInteger( p_playlist, "activity", i_activity -
DEFAULT_INPUT_ACTIVITY );
+
goto check_input;
}
/* This input is dying, let it do */
@@ -378,18 +374,13 @@ void playlist_LastLoop( playlist_t *p_playlist )
if( p_playlist->p_input->b_dead )
{
- input_thread_t *p_input;
-
- /* Unlink current input */
- p_input = p_playlist->p_input;
- p_playlist->p_input = NULL;
- PL_UNLOCK;
+ /* remove input */
+ playlist_release_current_input( p_playlist );
/* sout-keep: no need to anything here.
* The last input will destroy its sout, if any, by itself */
- /* Destroy input */
- vlc_object_release( p_input );
+ PL_UNLOCK;
continue;
}
else if( p_playlist->p_input->b_die )
diff --git a/src/playlist/playlist_internal.h b/src/playlist/playlist_internal.h
index 5c50ba1..9729137 100644
--- a/src/playlist/playlist_internal.h
+++ b/src/playlist/playlist_internal.h
@@ -35,6 +35,7 @@
*/
#include "input/input_internal.h"
+#include <assert.h>
struct playlist_preparse_t
{
@@ -109,6 +110,37 @@ playlist_item_t *playlist_ItemFindFromInputAndRoot( playlist_t *p_playlist,
int playlist_DeleteFromItemId( playlist_t*, int );
int playlist_ItemDelete ( playlist_item_t * );
+static inline void playlist_release_current_input( playlist_t * p_playlist )
+{
+ vlc_assert_locked( &p_playlist->object_lock );
+
+ if( !p_playlist->p_input ) return;
+
+ input_thread_t * p_input = p_playlist->p_input;
+ p_playlist->p_input = NULL;
+
+ /* Release the playlist lock, because we may get stuck
+ * in vlc_object_release() for some time. */
+ PL_UNLOCK;
+ vlc_object_release( p_input );
+ PL_LOCK;
+}
+
+static inline void playlist_set_current_input(
+ playlist_t * p_playlist, input_thread_t * p_input )
+{
+ vlc_assert_locked( &p_playlist->object_lock );
+
+ playlist_release_current_input( p_playlist );
+
+ if( p_input )
+ {
+ vlc_object_yield( p_input );
+ p_playlist->p_input = p_input;
+ }
+}
+
+
/**
* @}
*/
More information about the vlc-devel
mailing list