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 )
if( p_sys->i_track < 0 && i_mrl_tracknum <= 0 )
{
p_playlist = (playlist_t *) vlc_object_find( p_access,
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( !p_playlist ) return VLC_EGENERIC;
p_playlist = pl_Yield( p_access );
if( p_playlist->status.p_item->p_input ==
((input_thread_t *)p_access->p_parent)->input.p_item )
p_item = p_playlist->status.p_item;
......
......@@ -930,14 +930,7 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,
#endif
if (! p_cdda->b_nav_mode ) {
p_playlist = (playlist_t *) vlc_object_find( p_access,
VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( !p_playlist )
{
msg_Warn( p_access, "can't find playlist" );
return VLC_EGENERIC;
}
p_playlist = pl_Yield( p_access );
}
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)
int i_mode, i_activity;
playlist_item_t *p_item, *p_root_category;
vlc_bool_t b_play = VLC_FALSE;
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;
}
playlist_t *p_playlist = pl_Yield( p_access );
psz_name = ToLocale( p_access->psz_path );
ptr = strdup( psz_name );
......@@ -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 ==
((input_thread_t *)p_access->p_parent)->input.p_item )
{
p_item = p_playlist->status.p_item;
b_play = VLC_TRUE;
msg_Dbg( p_access, "starting directory playback");
}
else
{
input_item_t *p_current = ( (input_thread_t*)p_access->p_parent)->
input.p_item;
p_item = playlist_LockItemGetByInput( p_playlist, p_current );
msg_Dbg( p_access, "not starting directory playback");
if( !p_item )
{
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;
......@@ -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 -
DIRECTORY_ACTIVITY );
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 );
vlc_object_release( p_playlist );
......
......@@ -323,16 +323,10 @@ connect:
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 */
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;
vlc_mutex_lock( &p_input_item->lock );
free( p_input_item->psz_uri );
......@@ -340,8 +334,9 @@ connect:
p_input_item->psz_uri = 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_playlist->object_lock );
vlc_object_release( p_playlist );
PL_UNLOCK;
pl_Release( p_access );
/* Clean up current Open() run */
vlc_UrlClean( &p_sys->url );
......
......@@ -108,16 +108,9 @@ int E_(MMSHOpen)( access_t *p_access )
/* Handle redirection */
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 );
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 */
playlist_PlaylistAdd( p_playlist, psz_location, psz_location,
PLAYLIST_INSERT | PLAYLIST_GO, PLAYLIST_END );
......
......@@ -296,20 +296,8 @@ static int Open( vlc_object_t *p_this )
#ifdef HAVE_AVAHI_CLIENT
if( config_GetInt(p_this, SOUT_CFG_PREFIX "bonjour") )
{
playlist_t *p_playlist;
char *psz_txt, *psz_name;
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;
}
playlist_t *p_playlist = pl_Yield( p_access );
psz_name = strrchr( p_playlist->status.p_item->p_input->psz_uri,
DIRECTORY_SEPARATOR );
......@@ -325,9 +313,7 @@ static int Open( vlc_object_t *p_this )
free( (void *)psz_txt );
if( p_sys->p_bonjour == NULL )
{
msg_Err( p_access, "Avahi stream announcing was requested, but no avahi service could be started" );
}
msg_Err( p_access, "unable to start requested Bonjour announce" );
vlc_object_release( p_playlist );
}
else
......
......@@ -181,16 +181,12 @@ static void Run( intf_thread_t *p_intf )
/* Update the input */
if( p_intf->p_sys->p_input == NULL )
{
p_playlist = (playlist_t *)vlc_object_find( p_intf,
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( p_playlist )
{
p_playlist = pl_Yield( p_intf );
p_intf->p_sys->p_input = p_playlist->p_input;
if( p_intf->p_sys->p_input )
vlc_object_yield( p_intf->p_sys->p_input );
vlc_object_release( p_playlist );
}
}
else if( p_intf->p_sys->p_input->b_dead )
{
vlc_object_release( p_intf->p_sys->p_input );
......@@ -245,14 +241,6 @@ static void Run( intf_thread_t *p_intf )
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;
ClearChannels( p_intf, p_vout );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Quit" ) );
......@@ -291,14 +279,10 @@ static void Run( intf_thread_t *p_intf )
else if( i_action == ACTIONID_INTF_SHOW )
{
val.b_bool = VLC_TRUE;
p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist )
{
p_playlist = pl_Yield( p_intf );
var_Set( p_playlist, "intf-show", val );
vlc_object_release( p_playlist );
}
}
else if( i_action == ACTIONID_INTF_HIDE )
{
val.b_bool = VLC_FALSE;
......
......@@ -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 )
{
intf_thread_t *p_intf = (intf_thread_t*)p_this;
playlist_t *p_playlist;
p_playlist = vlc_object_find( p_this, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( !p_playlist )
{
msg_Err( p_this, "no playlist" );
return VLC_ENOOBJ;
}
playlist_t *p_playlist = pl_Yield( p_this );
PL_LOCK;
if( p_playlist->p_input )
{
vlc_value_t val;
......@@ -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.") );
vlc_object_release( p_playlist );
PL_UNLOCK;
return VLC_EGENERIC;
}
}
PL_UNLOCK;
/* Parse commands that require a playlist */
if( !strcmp( psz_cmd, "prev" ) )
......@@ -1359,6 +1354,7 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
}
else if (!strcmp( psz_cmd, "goto" ) )
{
msg_rc( _("goto is deprecated" ) );
msg_Err( p_playlist, "goto is deprecated" );
}
else if( !strcmp( psz_cmd, "stop" ) )
......
......@@ -123,17 +123,9 @@ static void RunIntf( intf_thread_t *p_intf )
/* Notify the interfaces */
if( p_intf->p_sys->b_triggered )
{
playlist_t *p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist != NULL )
{
vlc_value_t val;
val.b_bool = VLC_TRUE;
var_Set( p_playlist, "intf-show", val );
playlist_t *p_playlist = pl_Yield( p_intf );
var_SetBool( p_playlist, "intf-show", VLC_TRUE );
vlc_object_release( p_playlist );
}
p_intf->p_sys->b_triggered = VLC_FALSE;
}
......
......@@ -196,18 +196,14 @@ void MainInputManager::updateInput()
if( !p_input )
{
playlist_t *p_playlist = (playlist_t *) vlc_object_find( p_intf,
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
assert( p_playlist );
PL_LOCK;
p_input = p_playlist->p_input;
QPL_LOCK;
p_input = THEPL->p_input;
if( p_input )
{
vlc_object_yield( p_input );
emit inputChanged( p_input );
}
PL_UNLOCK;
vlc_object_release( p_playlist );
QPL_UNLOCK;
}
vlc_mutex_unlock( &p_intf->change_lock );
}
......
......@@ -71,14 +71,7 @@ static int Open( vlc_object_t *p_this )
p_intf->p_sys = (intf_sys_t *)malloc(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,
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_playlist = pl_Yield( p_intf );
p_intf->p_sys->p_sub = msg_Subscribe( p_intf, MSG_QUEUE_NORMAL );
return VLC_SUCCESS;
......
......@@ -47,6 +47,9 @@ struct intf_sys_t
};
#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 THEMIM MainInputManager::getInstance( NULL )
......
......@@ -91,17 +91,9 @@ static int Open( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
playlist_t *p_playlist = (playlist_t *)vlc_object_find(
p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( !p_playlist )
{
msg_Err( p_intf, "could not find playlist object" );
return VLC_ENOOBJ;
}
playlist_t *p_playlist = pl_Yield( p_intf );
var_AddCallback( p_playlist, "playlist-current", ItemChange, p_intf );
vlc_object_release( p_playlist );
pl_Release( p_intf );
RegisterToGrowl( p_this );
p_intf->pf_run = Run;
......@@ -114,14 +106,9 @@ static int Open( vlc_object_t *p_this )
*****************************************************************************/
static void Close( vlc_object_t *p_this )
{
playlist_t *p_playlist = (playlist_t *)vlc_object_find(
p_this, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( p_playlist )
{
playlist_t *p_playlist = pl_Yield( 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