Commit 966feba1 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

playlist: Use a set/release accessor for playlist->p_input.

(To better track when to attach/detach events).
parent c75d563f
......@@ -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 );
......
......@@ -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 )
......
......@@ -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;
}
}
/**
* @}
*/
......
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