Commit 415749bf authored by Clément Stenac's avatar Clément Stenac

Don't use find for the playlist

parent 5adf43c6
...@@ -186,10 +186,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -186,10 +186,7 @@ static int Open( vlc_object_t *p_this )
if( p_sys->i_track < 0 && i_mrl_tracknum <= 0 ) if( p_sys->i_track < 0 && i_mrl_tracknum <= 0 )
{ {
p_playlist = (playlist_t *) vlc_object_find( p_access, p_playlist = pl_Yield( p_access );
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( !p_playlist ) return VLC_EGENERIC;
if( p_playlist->status.p_item->p_input == if( p_playlist->status.p_item->p_input ==
((input_thread_t *)p_access->p_parent)->input.p_item ) ((input_thread_t *)p_access->p_parent)->input.p_item )
p_item = p_playlist->status.p_item; p_item = p_playlist->status.p_item;
......
...@@ -930,14 +930,7 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda, ...@@ -930,14 +930,7 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,
#endif #endif
if (! p_cdda->b_nav_mode ) { if (! p_cdda->b_nav_mode ) {
p_playlist = (playlist_t *) vlc_object_find( p_access, p_playlist = pl_Yield( p_access );
VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( !p_playlist )
{
msg_Warn( p_access, "can't find playlist" );
return VLC_EGENERIC;
}
} }
if( b_single_track || p_cdda->b_nav_mode ) { if( b_single_track || p_cdda->b_nav_mode ) {
......
...@@ -203,17 +203,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len) ...@@ -203,17 +203,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len)
int i_mode, i_activity; int i_mode, i_activity;
playlist_item_t *p_item, *p_root_category; playlist_item_t *p_item, *p_root_category;
vlc_bool_t b_play = VLC_FALSE; playlist_t *p_playlist = pl_Yield( p_access );
playlist_t *p_playlist =
(playlist_t *) vlc_object_find( p_access,
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( !p_playlist )
{
msg_Err( p_access, "can't find playlist" );
goto end;
}
psz_name = ToLocale( p_access->psz_path ); psz_name = ToLocale( p_access->psz_path );
ptr = strdup( psz_name ); ptr = strdup( psz_name );
...@@ -249,23 +239,17 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len) ...@@ -249,23 +239,17 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len)
if( p_playlist->status.p_item && p_playlist->status.p_item->p_input == if( p_playlist->status.p_item && p_playlist->status.p_item->p_input ==
((input_thread_t *)p_access->p_parent)->input.p_item ) ((input_thread_t *)p_access->p_parent)->input.p_item )
{
p_item = p_playlist->status.p_item; p_item = p_playlist->status.p_item;
b_play = VLC_TRUE;
msg_Dbg( p_access, "starting directory playback");
}
else else
{ {
input_item_t *p_current = ( (input_thread_t*)p_access->p_parent)-> input_item_t *p_current = ( (input_thread_t*)p_access->p_parent)->
input.p_item; input.p_item;
p_item = playlist_LockItemGetByInput( p_playlist, p_current ); p_item = playlist_LockItemGetByInput( p_playlist, p_current );
msg_Dbg( p_access, "not starting directory playback");
if( !p_item ) if( !p_item )
{ {
msg_Dbg( p_playlist, "unable to find item in playlist"); msg_Dbg( p_playlist, "unable to find item in playlist");
return -1; return VLC_ENOOBJ;
} }
b_play = VLC_FALSE;
} }
p_item->p_input->i_type = ITEM_TYPE_DIRECTORY; p_item->p_input->i_type = ITEM_TYPE_DIRECTORY;
...@@ -281,16 +265,6 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len) ...@@ -281,16 +265,6 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len)
var_SetInteger( p_playlist, "activity", i_activity - var_SetInteger( p_playlist, "activity", i_activity -
DIRECTORY_ACTIVITY ); DIRECTORY_ACTIVITY );
end: end:
/* Begin to read the directory */
if( b_play )
{
#if 0
/// \bug we can start playing an already deleted item. Fix ?*/
playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, 1242,
p_playlist->status.p_item, NULL );
#endif
}
if( psz_name ) free( psz_name ); if( psz_name ) free( psz_name );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
......
...@@ -323,16 +323,10 @@ connect: ...@@ -323,16 +323,10 @@ connect:
goto error; goto error;
} }
p_playlist = vlc_object_find( p_access, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( !p_playlist )
{
msg_Err( p_access, "redirection failed: can't find playlist" );
goto error;
}
/* Change the URI */ /* Change the URI */
vlc_mutex_lock( &p_playlist->object_lock ); p_playlist = pl_Yield( p_access );
PL_LOCK;
p_input_item = p_playlist->status.p_item->p_input; p_input_item = p_playlist->status.p_item->p_input;
vlc_mutex_lock( &p_input_item->lock ); vlc_mutex_lock( &p_input_item->lock );
free( p_input_item->psz_uri ); free( p_input_item->psz_uri );
...@@ -340,8 +334,9 @@ connect: ...@@ -340,8 +334,9 @@ connect:
p_input_item->psz_uri = strdup( p_sys->psz_location ); p_input_item->psz_uri = strdup( p_sys->psz_location );
p_access->psz_path = strdup( p_sys->psz_location ); p_access->psz_path = strdup( p_sys->psz_location );
vlc_mutex_unlock( &p_input_item->lock ); vlc_mutex_unlock( &p_input_item->lock );
vlc_mutex_unlock( &p_playlist->object_lock );
vlc_object_release( p_playlist ); PL_UNLOCK;
pl_Release( p_access );
/* Clean up current Open() run */ /* Clean up current Open() run */
vlc_UrlClean( &p_sys->url ); vlc_UrlClean( &p_sys->url );
......
...@@ -108,16 +108,9 @@ int E_(MMSHOpen)( access_t *p_access ) ...@@ -108,16 +108,9 @@ int E_(MMSHOpen)( access_t *p_access )
/* Handle redirection */ /* Handle redirection */
if( psz_location && *psz_location ) if( psz_location && *psz_location )
{ {
playlist_t * p_playlist = vlc_object_find( p_access, VLC_OBJECT_PLAYLIST, FIND_PARENT ); playlist_t * p_playlist = pl_Yield( p_access );
msg_Dbg( p_access, "redirection to %s", psz_location ); msg_Dbg( p_access, "redirection to %s", psz_location );
if( !p_playlist )
{
msg_Err( p_access, "redirection failed: can't find playlist" );
free( psz_location );
return VLC_EGENERIC;
}
/** \bug we do not autodelete here */ /** \bug we do not autodelete here */
playlist_PlaylistAdd( p_playlist, psz_location, psz_location, playlist_PlaylistAdd( p_playlist, psz_location, psz_location,
PLAYLIST_INSERT | PLAYLIST_GO, PLAYLIST_END ); PLAYLIST_INSERT | PLAYLIST_GO, PLAYLIST_END );
......
...@@ -296,20 +296,8 @@ static int Open( vlc_object_t *p_this ) ...@@ -296,20 +296,8 @@ static int Open( vlc_object_t *p_this )
#ifdef HAVE_AVAHI_CLIENT #ifdef HAVE_AVAHI_CLIENT
if( config_GetInt(p_this, SOUT_CFG_PREFIX "bonjour") ) if( config_GetInt(p_this, SOUT_CFG_PREFIX "bonjour") )
{ {
playlist_t *p_playlist;
char *psz_txt, *psz_name; char *psz_txt, *psz_name;
playlist_t *p_playlist = pl_Yield( p_access );
p_playlist = (playlist_t *)vlc_object_find( p_access,
VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist == NULL )
{
msg_Err( p_access, "unable to find playlist" );
httpd_StreamDelete( p_sys->p_httpd_stream );
httpd_HostDelete( p_sys->p_httpd_host );
free( (void *)p_sys );
return VLC_EGENERIC;
}
psz_name = strrchr( p_playlist->status.p_item->p_input->psz_uri, psz_name = strrchr( p_playlist->status.p_item->p_input->psz_uri,
DIRECTORY_SEPARATOR ); DIRECTORY_SEPARATOR );
...@@ -325,9 +313,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -325,9 +313,7 @@ static int Open( vlc_object_t *p_this )
free( (void *)psz_txt ); free( (void *)psz_txt );
if( p_sys->p_bonjour == NULL ) if( p_sys->p_bonjour == NULL )
{ msg_Err( p_access, "unable to start requested Bonjour announce" );
msg_Err( p_access, "Avahi stream announcing was requested, but no avahi service could be started" );
}
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
} }
else else
......
...@@ -181,16 +181,12 @@ static void Run( intf_thread_t *p_intf ) ...@@ -181,16 +181,12 @@ static void Run( intf_thread_t *p_intf )
/* Update the input */ /* Update the input */
if( p_intf->p_sys->p_input == NULL ) if( p_intf->p_sys->p_input == NULL )
{ {
p_playlist = (playlist_t *)vlc_object_find( p_intf, p_playlist = pl_Yield( p_intf );
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( p_playlist )
{
p_intf->p_sys->p_input = p_playlist->p_input; p_intf->p_sys->p_input = p_playlist->p_input;
if( p_intf->p_sys->p_input ) if( p_intf->p_sys->p_input )
vlc_object_yield( p_intf->p_sys->p_input ); vlc_object_yield( p_intf->p_sys->p_input );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
} }
}
else if( p_intf->p_sys->p_input->b_dead ) else if( p_intf->p_sys->p_input->b_dead )
{ {
vlc_object_release( p_intf->p_sys->p_input ); vlc_object_release( p_intf->p_sys->p_input );
...@@ -245,14 +241,6 @@ static void Run( intf_thread_t *p_intf ) ...@@ -245,14 +241,6 @@ static void Run( intf_thread_t *p_intf )
if( i_action == ACTIONID_QUIT ) if( i_action == ACTIONID_QUIT )
{ {
p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist )
{
playlist_Stop( p_playlist );
vlc_object_release( p_playlist );
}
/* Playlist is stopped now kill vlc. */
p_intf->p_libvlc->b_die = VLC_TRUE; p_intf->p_libvlc->b_die = VLC_TRUE;
ClearChannels( p_intf, p_vout ); ClearChannels( p_intf, p_vout );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Quit" ) ); vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Quit" ) );
...@@ -291,14 +279,10 @@ static void Run( intf_thread_t *p_intf ) ...@@ -291,14 +279,10 @@ static void Run( intf_thread_t *p_intf )
else if( i_action == ACTIONID_INTF_SHOW ) else if( i_action == ACTIONID_INTF_SHOW )
{ {
val.b_bool = VLC_TRUE; val.b_bool = VLC_TRUE;
p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, p_playlist = pl_Yield( p_intf );
FIND_ANYWHERE );
if( p_playlist )
{
var_Set( p_playlist, "intf-show", val ); var_Set( p_playlist, "intf-show", val );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
} }
}
else if( i_action == ACTIONID_INTF_HIDE ) else if( i_action == ACTIONID_INTF_HIDE )
{ {
val.b_bool = VLC_FALSE; val.b_bool = VLC_FALSE;
......
...@@ -1321,16 +1321,9 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd, ...@@ -1321,16 +1321,9 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data ) vlc_value_t oldval, vlc_value_t newval, void *p_data )
{ {
intf_thread_t *p_intf = (intf_thread_t*)p_this; intf_thread_t *p_intf = (intf_thread_t*)p_this;
playlist_t *p_playlist; playlist_t *p_playlist = pl_Yield( p_this );
p_playlist = vlc_object_find( p_this, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( !p_playlist )
{
msg_Err( p_this, "no playlist" );
return VLC_ENOOBJ;
}
PL_LOCK;
if( p_playlist->p_input ) if( p_playlist->p_input )
{ {
vlc_value_t val; vlc_value_t val;
...@@ -1339,9 +1332,11 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd, ...@@ -1339,9 +1332,11 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
{ {
msg_rc( _("Type 'menu select' or 'pause' to continue.") ); msg_rc( _("Type 'menu select' or 'pause' to continue.") );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
PL_UNLOCK;
return VLC_EGENERIC; return VLC_EGENERIC;
} }
} }
PL_UNLOCK;
/* Parse commands that require a playlist */ /* Parse commands that require a playlist */
if( !strcmp( psz_cmd, "prev" ) ) if( !strcmp( psz_cmd, "prev" ) )
...@@ -1359,6 +1354,7 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd, ...@@ -1359,6 +1354,7 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
} }
else if (!strcmp( psz_cmd, "goto" ) ) else if (!strcmp( psz_cmd, "goto" ) )
{ {
msg_rc( _("goto is deprecated" ) );
msg_Err( p_playlist, "goto is deprecated" ); msg_Err( p_playlist, "goto is deprecated" );
} }
else if( !strcmp( psz_cmd, "stop" ) ) else if( !strcmp( psz_cmd, "stop" ) )
......
...@@ -123,17 +123,9 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -123,17 +123,9 @@ static void RunIntf( intf_thread_t *p_intf )
/* Notify the interfaces */ /* Notify the interfaces */
if( p_intf->p_sys->b_triggered ) if( p_intf->p_sys->b_triggered )
{ {
playlist_t *p_playlist = playlist_t *p_playlist = pl_Yield( p_intf );
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, var_SetBool( p_playlist, "intf-show", VLC_TRUE );
FIND_ANYWHERE );
if( p_playlist != NULL )
{
vlc_value_t val;
val.b_bool = VLC_TRUE;
var_Set( p_playlist, "intf-show", val );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
}
p_intf->p_sys->b_triggered = VLC_FALSE; p_intf->p_sys->b_triggered = VLC_FALSE;
} }
......
...@@ -196,18 +196,14 @@ void MainInputManager::updateInput() ...@@ -196,18 +196,14 @@ void MainInputManager::updateInput()
if( !p_input ) if( !p_input )
{ {
playlist_t *p_playlist = (playlist_t *) vlc_object_find( p_intf, QPL_LOCK;
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); p_input = THEPL->p_input;
assert( p_playlist );
PL_LOCK;
p_input = p_playlist->p_input;
if( p_input ) if( p_input )
{ {
vlc_object_yield( p_input ); vlc_object_yield( p_input );
emit inputChanged( p_input ); emit inputChanged( p_input );
} }
PL_UNLOCK; QPL_UNLOCK;
vlc_object_release( p_playlist );
} }
vlc_mutex_unlock( &p_intf->change_lock ); vlc_mutex_unlock( &p_intf->change_lock );
} }
......
...@@ -71,14 +71,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -71,14 +71,7 @@ static int Open( vlc_object_t *p_this )
p_intf->p_sys = (intf_sys_t *)malloc(sizeof( intf_sys_t ) ); p_intf->p_sys = (intf_sys_t *)malloc(sizeof( intf_sys_t ) );
memset( p_intf->p_sys, 0, sizeof( intf_sys_t ) ); memset( p_intf->p_sys, 0, sizeof( intf_sys_t ) );
p_intf->p_sys->p_playlist = (playlist_t *)vlc_object_find( p_intf, p_intf->p_sys->p_playlist = pl_Yield( p_intf );
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( !p_intf->p_sys->p_playlist )
{
free( p_intf->p_sys );
return VLC_EGENERIC;
}
p_intf->p_sys->p_sub = msg_Subscribe( p_intf, MSG_QUEUE_NORMAL ); p_intf->p_sys->p_sub = msg_Subscribe( p_intf, MSG_QUEUE_NORMAL );
return VLC_SUCCESS; return VLC_SUCCESS;
......
...@@ -47,6 +47,9 @@ struct intf_sys_t ...@@ -47,6 +47,9 @@ struct intf_sys_t
}; };
#define THEPL p_intf->p_sys->p_playlist #define THEPL p_intf->p_sys->p_playlist
#define QPL_LOCK vlc_mutex_lock( &THEPL->object_lock );
#define QPL_UNLOCK vlc_mutex_unlock( &THEPL->object_lock );
#define THEDP DialogsProvider::getInstance() #define THEDP DialogsProvider::getInstance()
#define THEMIM MainInputManager::getInstance( NULL ) #define THEMIM MainInputManager::getInstance( NULL )
......
...@@ -91,17 +91,9 @@ static int Open( vlc_object_t *p_this ) ...@@ -91,17 +91,9 @@ static int Open( vlc_object_t *p_this )
{ {
intf_thread_t *p_intf = (intf_thread_t *)p_this; intf_thread_t *p_intf = (intf_thread_t *)p_this;
playlist_t *p_playlist = (playlist_t *)vlc_object_find( playlist_t *p_playlist = pl_Yield( p_intf );
p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( !p_playlist )
{
msg_Err( p_intf, "could not find playlist object" );
return VLC_ENOOBJ;
}
var_AddCallback( p_playlist, "playlist-current", ItemChange, p_intf ); var_AddCallback( p_playlist, "playlist-current", ItemChange, p_intf );
vlc_object_release( p_playlist ); pl_Release( p_intf );
RegisterToGrowl( p_this ); RegisterToGrowl( p_this );
p_intf->pf_run = Run; p_intf->pf_run = Run;
...@@ -114,14 +106,9 @@ static int Open( vlc_object_t *p_this ) ...@@ -114,14 +106,9 @@ static int Open( vlc_object_t *p_this )
*****************************************************************************/ *****************************************************************************/
static void Close( vlc_object_t *p_this ) static void Close( vlc_object_t *p_this )
{ {
playlist_t *p_playlist = (playlist_t *)vlc_object_find( playlist_t *p_playlist = pl_Yield( p_this );
p_this, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( p_playlist )
{
var_DelCallback( p_playlist, "playlist-current", ItemChange, p_this ); var_DelCallback( p_playlist, "playlist-current", ItemChange, p_this );
vlc_object_release( p_playlist ); pl_Release( p_this );
}
} }
/***************************************************************************** /*****************************************************************************
......
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