Commit d228fdd2 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

playlist: Move more members as private.

parent 696f3a43
......@@ -158,14 +158,6 @@ struct playlist_t
{
VLC_COMMON_MEMBERS
struct playlist_services_discovery_support_t {
/* the playlist items for category and onelevel */
playlist_item_t* p_cat;
playlist_item_t* p_one;
services_discovery_t * p_sd; /**< Loaded service discovery modules */
} ** pp_sds;
int i_sds; /**< Number of service discovery modules */
playlist_item_array_t items; /**< Arrays of items */
playlist_item_array_t all_items; /**< Array of items and nodes */
playlist_item_array_t items_to_delete; /**< Array of items and nodes to
......@@ -194,34 +186,11 @@ struct playlist_t
bool b_auto_preparse;
/* Runtime */
input_thread_t * p_input; /**< the input thread associated
* with the current item */
int i_sort; /**< Last sorting applied to the playlist */
int i_order; /**< Last ordering applied to the playlist */
mtime_t gc_date;
bool b_cant_sleep;
struct {
/* Current status. These fields are readonly, only the playlist
* main loop can touch it*/
playlist_status_t i_status; /**< Current status of playlist */
playlist_item_t * p_item; /**< Currently playing/active item */
playlist_item_t * p_node; /**< Current node to play from */
} status;
struct {
/* Request. Use this to give orders to the playlist main loop */
playlist_status_t i_status; /**< requested playlist status */
playlist_item_t * p_node; /**< requested node to play from */
playlist_item_t * p_item; /**< requested item to play in the node */
int i_skip; /**< Number of items to skip */
bool b_request;/**< Set to true by the requester
The playlist sets it back to false
when processing the request */
vlc_mutex_t lock; /**< Lock to protect request */
} request;
};
/** Helper to add an item */
......@@ -316,19 +285,15 @@ VLC_EXPORT( int, playlist_PreparseEnqueueItem, (playlist_t *, playlist_item_t *)
/** Request the art for an input item to be fetched */
VLC_EXPORT( int, playlist_AskForArtEnqueue, (playlist_t *, input_item_t *) );
/********************** Services discovery ***********************/
/** Add a list of comma-separated service discovery modules */
VLC_EXPORT( int, playlist_ServicesDiscoveryAdd, (playlist_t *, const char *));
/** Remove a services discovery module by name */
VLC_EXPORT( int, playlist_ServicesDiscoveryRemove, (playlist_t *, const char *));
/** Check whether a given SD is loaded */
VLC_EXPORT( bool, playlist_IsServicesDiscoveryLoaded, ( playlist_t *,const char *));
/* Playlist sorting */
VLC_EXPORT( int, playlist_TreeMove, ( playlist_t *, playlist_item_t *, playlist_item_t *, int ) );
VLC_EXPORT( int, playlist_RecursiveNodeSort, ( playlist_t *, playlist_item_t *,int, int ) );
VLC_EXPORT( playlist_item_t *, playlist_CurrentPlayingItem, ( playlist_t * ) );
VLC_EXPORT( int, playlist_CurrentId, ( playlist_t * ) );
VLC_EXPORT( bool, playlist_IsPlaying, ( playlist_t * ) );
VLC_EXPORT( int, playlist_Status, ( playlist_t * ) );
/**
* Export a node of the playlist to a certain type of playlistfile
* \param p_playlist the playlist to export
......@@ -339,6 +304,17 @@ VLC_EXPORT( int, playlist_RecursiveNodeSort, ( playlist_t *, playlist_item_t *,
*/
VLC_EXPORT( int, playlist_Export, ( playlist_t *p_playlist, const char *psz_name, playlist_item_t *p_export_root, const char *psz_type ) );
/********************** Services discovery ***********************/
/** Add a list of comma-separated service discovery modules */
VLC_EXPORT( int, playlist_ServicesDiscoveryAdd, (playlist_t *, const char *));
/** Remove a services discovery module by name */
VLC_EXPORT( int, playlist_ServicesDiscoveryRemove, (playlist_t *, const char *));
/** Check whether a given SD is loaded */
VLC_EXPORT( bool, playlist_IsServicesDiscoveryLoaded, ( playlist_t *,const char *));
/********************************************************
* Item management
********************************************************/
......@@ -427,22 +403,12 @@ static inline input_thread_t * __pl_CurrentInput( vlc_object_t * p_this )
return p_input;
}
/** Tell if the playlist is currently running */
#define playlist_IsPlaying( pl ) ( pl->status.i_status == PLAYLIST_RUNNING && \
!(pl->request.b_request && pl->request.i_status == PLAYLIST_STOPPED) )
#define playlist_IsStopped( pl ) ( pl->status.i_status == PLAYLIST_STOPPED || \
(pl->request.b_request && pl->request.i_status == PLAYLIST_STOPPED) )
/** Tell if the playlist is empty */
#define playlist_IsEmpty( pl ) ( pl->items.i_size == 0 )
/** Tell the number of items in the current playing context */
#define playlist_CurrentSize( pl ) pl->current.i_size
/** Tell the current item id in current playing context */
#define playlist_CurrentId( pl ) pl->status.p_item->i_id
/** Ask the playlist to do some work */
#define playlist_Signal( p_playlist ) vlc_object_signal( p_playlist )
......
......@@ -198,8 +198,8 @@ static int Open( vlc_object_t *p_this )
input_item_t *p_current = input_GetItem( p_input );
playlist_item_t *p_item;
if( p_playlist->status.p_item->p_input == p_current )
p_item = p_playlist->status.p_item;
if( playlist_CurrentPlayingItem(p_playlist)->p_input == p_current )
p_item = playlist_CurrentPlayingItem(p_playlist);
else
p_item = playlist_ItemGetByInput( p_playlist, p_current, pl_Unlocked );
......
......@@ -884,7 +884,7 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,
{
p_item = playlist_ItemGetByInput( p_playlist, input_GetItem(p_input), pl_Unlocked );
if( p_item == p_playlist->status.p_item && !b_single_track )
if( p_item == playlist_CurrentPlayingItem(p_playlist) && !b_single_track )
b_play = true;
else
b_play = false;
......@@ -964,7 +964,7 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,
if( b_play )
{
playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Unlocked,
p_playlist->status.p_item, NULL );
playlist_CurrentPlayingItem(p_playlist), NULL );
}
if (p_playlist) pl_Release( p_access );
......
......@@ -440,7 +440,7 @@ static void FollowAnchor ( intf_thread_t *p_intf )
p_playlist = pl_Hold( p_intf );
/* Get new URL */
p_current_item = p_playlist->status.p_item;
p_current_item = playlist_CurrentPlayingItem( p_playlist );
char *psz_uri = input_item_GetURI( p_current_item->p_input );
#ifdef CMML_INTF_DEBUG
msg_Dbg( p_intf, "Current playlist item URL is \"%s\"", psz_uri );
......@@ -668,7 +668,7 @@ void GoBack( intf_thread_t *p_intf )
return;
}
p_current_item = p_playlist->status.p_item;
p_current_item = playlist_CurrentPlayingItem( p_playlist );
/* Save the currently-playing media in a new history item */
psz_timed_url = GetTimedURLFromPlaylistItem( p_intf, p_current_item );
......@@ -750,7 +750,7 @@ void GoForward( intf_thread_t *p_intf )
vlc_object_release( p_playlist );
return;
}
p_current_item = p_playlist->status.p_item;
p_current_item = playlist_CurrentPlayingItem( p_playlist );
p_new_history_item->psz_uri = GetTimedURLFromPlaylistItem( p_intf,
p_current_item );
p_new_history_item->psz_name = p_new_history_item->psz_uri;
......
......@@ -139,15 +139,7 @@ static int gesture( int i_pattern, int i_num )
*****************************************************************************/
static input_thread_t * input_from_playlist ( playlist_t *p_playlist )
{
input_thread_t * p_input;
PL_LOCK;
p_input = p_playlist->p_input;
if( p_input )
vlc_object_hold( p_input );
PL_UNLOCK;
return p_input;
return playlist_CurrentInput( p_playlist );
}
/*****************************************************************************
......
......@@ -174,11 +174,7 @@ static void Run( intf_thread_t *p_intf )
canc = vlc_savecancel();
/* Update the input */
PL_LOCK;
p_input = p_playlist->p_input;
if( p_input )
vlc_object_hold( p_input );
PL_UNLOCK;
p_input = playlist_CurrentInput( p_playlist );
/* Update the vout */
p_last_vout = p_vout;
......@@ -978,9 +974,10 @@ static void SetBookmark( intf_thread_t *p_intf, int i_num )
sprintf( psz_bookmark_name, "bookmark%i", i_num );
var_Create( p_intf, psz_bookmark_name,
VLC_VAR_STRING|VLC_VAR_DOINHERIT );
if( p_playlist->status.p_item )
playlist_item_t * p_item = playlist_CurrentPlayingItem( p_playlist );
if( p_item )
{
char *psz_uri = input_item_GetURI( p_playlist->status.p_item->p_input );
char *psz_uri = input_item_GetURI( p_item->p_input );
config_PutPsz( p_intf, psz_bookmark_name, psz_uri);
msg_Info( p_intf, "setting playlist bookmark %i to %s", i_num, psz_uri);
free( psz_uri );
......
......@@ -384,10 +384,9 @@ static void ParseExecute( httpd_file_sys_t *p_args, char *p_buffer,
assert( p_sys->p_input == NULL );
/* FIXME: proper locking anyone? */
p_sys->p_input = p_sys->p_playlist->p_input;
p_sys->p_input = playlist_CurrentInput( p_sys->p_playlist );
if( p_sys->p_input )
{
vlc_object_hold( p_sys->p_input );
var_Get( p_sys->p_input, "position", &val);
sprintf( position, "%d" , (int)((val.f_float) * 100.0));
var_Get( p_sys->p_input, "time", &val);
......
......@@ -352,10 +352,10 @@ void PlaylistListNode( intf_thread_t *p_intf, playlist_t *p_pl,
char value[512];
char *psz;
mvar_t *itm = mvar_New( name, "set" );
if( p_pl->status.p_item && p_node &&
p_pl->status.p_item->p_input && p_node->p_input &&
p_pl->status.p_item->p_input->i_id == p_node->p_input->i_id )
playlist_item_t * p_item = playlist_CurrentPlayingItem(p_pl);
if( p_item && p_node &&
p_item->p_input && p_node->p_input &&
p_item->p_input->i_id == p_node->p_input->i_id )
{
mvar_AppendNewVar( itm, "current", "1" );
}
......
......@@ -553,24 +553,25 @@ static void Run( intf_thread_t *p_intf )
(p_playlist != NULL) )
{
PL_LOCK;
if( (p_intf->p_sys->i_last_state != p_playlist->status.i_status) &&
(p_playlist->status.i_status == PLAYLIST_STOPPED) )
int status = playlist_Status( p_playlist );
if( (p_intf->p_sys->i_last_state != status) &&
(status == PLAYLIST_STOPPED) )
{
p_intf->p_sys->i_last_state = PLAYLIST_STOPPED;
msg_rc( STATUS_CHANGE "( stop state: 5 )" );
}
else if(
(p_intf->p_sys->i_last_state != p_playlist->status.i_status) &&
(p_playlist->status.i_status == PLAYLIST_RUNNING) )
(p_intf->p_sys->i_last_state != status) &&
(status == PLAYLIST_RUNNING) )
{
p_intf->p_sys->i_last_state = p_playlist->status.i_status;
p_intf->p_sys->i_last_state = PLAYLIST_RUNNING;
msg_rc( STATUS_CHANGE "( play state: 3 )" );
}
else if(
(p_intf->p_sys->i_last_state != p_playlist->status.i_status) &&
(p_playlist->status.i_status == PLAYLIST_PAUSED) )
(p_intf->p_sys->i_last_state != status) &&
(status == PLAYLIST_PAUSED) )
{
p_intf->p_sys->i_last_state = p_playlist->status.i_status;
p_intf->p_sys->i_last_state = PLAYLIST_PAUSED;
msg_rc( STATUS_CHANGE "( pause state: 4 )" );
}
PL_UNLOCK;
......@@ -993,7 +994,7 @@ static int StateChanged( vlc_object_t *p_this, char const *psz_cmd,
{
p_playlist = pl_Hold( p_input );
char cmd[6];
switch( p_playlist->status.i_status )
switch( playlist_Status( p_playlist ) )
{
case PLAYLIST_STOPPED:
strcpy( cmd, "stop" );
......@@ -1304,20 +1305,20 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
intf_thread_t *p_intf = (intf_thread_t*)p_this;
playlist_t *p_playlist = pl_Hold( p_this );
input_thread_t * p_input = playlist_CurrentInput( p_playlist );
PL_LOCK;
if( p_playlist->p_input )
if( p_input )
{
var_Get( p_playlist->p_input, "state", &val );
var_Get( p_input, "state", &val );
vlc_object_release( p_input );
if( ( val.i_int == PAUSE_S ) || ( val.i_int == PLAYLIST_PAUSED ) )
{
msg_rc( _("Type 'menu select' or 'pause' to continue.") );
vlc_object_release( p_playlist );
PL_UNLOCK;
pl_Release( p_this );
return VLC_EGENERIC;
}
}
PL_UNLOCK;
/* Parse commands that require a playlist */
if( !strcmp( psz_cmd, "prev" ) )
......@@ -1476,18 +1477,19 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
}
else if( !strcmp( psz_cmd, "status" ) )
{
if( p_playlist->p_input )
input_thread_t * p_input = playlist_CurrentInput( p_playlist );
if( p_input )
{
/* Replay the current state of the system. */
char *psz_uri =
input_item_GetURI( input_GetItem( p_playlist->p_input ) );
input_item_GetURI( input_GetItem( p_input ) );
msg_rc( STATUS_CHANGE "( new input: %s )", psz_uri );
free( psz_uri );
msg_rc( STATUS_CHANGE "( audio volume: %d )",
config_GetInt( p_intf, "volume" ));
PL_LOCK;
switch( p_playlist->status.i_status )
switch( playlist_Status(p_playlist) )
{
case PLAYLIST_STOPPED:
msg_rc( STATUS_CHANGE "( stop state: 5 )" );
......@@ -1503,6 +1505,7 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
break;
}
PL_UNLOCK;
vlc_object_release( p_input );
}
}
......@@ -1514,7 +1517,7 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
msg_rc( "unknown command!" );
}
vlc_object_release( p_playlist );
pl_Release( p_this );
return VLC_SUCCESS;
}
......@@ -1913,19 +1916,22 @@ static int Menu( vlc_object_t *p_this, char const *psz_cmd,
}
p_playlist = pl_Hold( p_this );
input_thread_t * p_input = playlist_CurrentInput( p_playlist );
if( p_playlist->p_input )
if( p_input )
{
var_Get( p_playlist->p_input, "state", &val );
var_Get( p_input, "state", &val );
vlc_object_release( p_input );
if( ( ( val.i_int == PAUSE_S ) || ( val.i_int == PLAYLIST_PAUSED ) ) &&
( strcmp( newval.psz_string, "select" ) != 0 ) )
{
msg_rc( _("Type 'menu select' or 'pause' to continue.") );
vlc_object_release( p_playlist );
pl_Release( p_this );
return VLC_EGENERIC;
}
}
vlc_object_release( p_playlist );
pl_Release( p_this );
val.psz_string = strdup( newval.psz_string );
if( !val.psz_string )
......
......@@ -1802,12 +1802,11 @@ end:
if( p_input && vlc_object_alive (p_input) )
{
NSString *o_temp;
if( input_item_GetNowPlaying ( p_playlist->status.p_item->p_input ) )
o_temp = [NSString stringWithUTF8String:
input_item_GetNowPlaying ( p_playlist->status.p_item->p_input )];
playlist_item_t * p_item = playlist_CurrentPlayingItem( p_playlist );
if( input_item_GetNowPlaying( p_item->p_input ) )
o_temp = [NSString stringWithUTF8String:input_item_GetNowPlaying( p_item->p_input )];
else
o_temp = [NSString stringWithUTF8String:
p_playlist->status.p_item->p_input->psz_name];
o_temp = [NSString stringWithUTF8String:p_item->p_input->psz_name];
[self setScrollField: o_temp stopAfter:-1];
[[[self getControls] getFSPanel] setStreamTitle: o_temp];
vlc_object_release( p_input );
......
......@@ -565,10 +565,10 @@
playlist_item_t *p_item, *p_temp_item;
NSMutableArray *o_array = [NSMutableArray array];
p_item = p_playlist->status.p_item;
p_item = playlist_CurrentPlayingItem( p_playlist );
if( p_item == NULL )
{
vlc_object_release(p_playlist);
pl_Release( VLCIntf );
return;
}
......@@ -591,8 +591,7 @@
}
vlc_object_release( p_playlist );
pl_Release( VLCIntf );
}
/* Check if p_item is a child of p_node recursively. We need to check the item
......@@ -904,8 +903,8 @@
if( p_item->i_children != -1 )
//is a node and not an item
{
if( p_playlist->status.i_status != PLAYLIST_STOPPED &&
[self isItem: p_playlist->status.p_item inNode:
if( playlist_Status( p_playlist ) != PLAYLIST_STOPPED &&
[self isItem: playlist_CurrentPlayingItem( p_playlist ) inNode:
((playlist_item_t *)[o_item pointerValue])
checkItemExistence: NO locked:YES] == YES )
// if current item is in selected node and is playing then stop playlist
......@@ -1378,7 +1377,7 @@
id o_playing_item;
o_playing_item = [o_outline_dict objectForKey:
[NSString stringWithFormat:@"%p", p_playlist->status.p_item]];
[NSString stringWithFormat:@"%p", playlist_CurrentPlayingItem( p_playlist )]];
if( [self isItem: [o_playing_item pointerValue] inNode:
[item pointerValue] checkItemExistence: YES]
......
......@@ -412,14 +412,7 @@ static void Run( intf_thread_t *p_intf )
PL_LOCK;
if( p_sys->p_input == NULL )
{
p_sys->p_input = p_playlist->p_input;
if( p_sys->p_input )
{
if( !p_sys->p_input->b_dead )
{
vlc_object_hold( p_sys->p_input );
}
}
p_sys->p_input = playlist_CurrentInput( p_playlist );
}
else if( p_sys->p_input->b_dead )
{
......@@ -430,7 +423,7 @@ static void Run( intf_thread_t *p_intf )
}
PL_UNLOCK;
if( p_sys->b_box_plidx_follow && p_playlist->status.p_item )
if( p_sys->b_box_plidx_follow && playlist_CurrentPlayingItem(p_playlist) )
{
FindIndex( p_intf );
}
......@@ -794,7 +787,7 @@ static int HandleKey( intf_thread_t *p_intf, int i_key )
playlist_item_t *p_parent = p_sys->p_node;
if( !p_parent )
p_parent = p_playlist->status.p_node;
p_parent = playlist_CurrentPlayingItem(p_playlist) ? playlist_CurrentPlayingItem(p_playlist)->p_parent : NULL;
if( !p_parent )
p_parent = p_playlist->p_local_onelevel;
......@@ -996,7 +989,7 @@ static int HandleKey( intf_thread_t *p_intf, int i_key )
playlist_item_t *p_parent = p_sys->p_node;
if( !p_parent )
p_parent = p_playlist->status.p_node;
p_parent = playlist_CurrentPlayingItem(p_playlist) ? playlist_CurrentPlayingItem(p_playlist)->p_parent : NULL;
if( !p_parent )
p_parent = p_playlist->p_local_onelevel;
......@@ -2187,7 +2180,7 @@ static void Redraw( intf_thread_t *p_intf, time_t *t_last_refresh )
int c = ' ';
if( ( p_node && p_item->p_input == p_node->p_input ) ||
( !p_node && p_item->p_input ==
p_playlist->status.p_node->p_input ) )
playlist_CurrentPlayingItem(p_playlist)->p_input ) )
c = '*';
else if( p_item == p_node || ( p_item != p_node &&
PlaylistIsPlaying( p_intf, p_item ) ) )
......@@ -2350,7 +2343,7 @@ static int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
intf_thread_t *p_intf = (intf_thread_t *)param;
playlist_t *p_playlist = pl_Hold( p_intf );
p_intf->p_sys->b_need_update = true;
p_intf->p_sys->p_node = p_playlist->status.p_node;
p_intf->p_sys->p_node = playlist_CurrentPlayingItem(p_playlist) ? playlist_CurrentPlayingItem(p_playlist)->p_parent : NULL;
vlc_object_release( p_playlist );
return VLC_SUCCESS;
}
......@@ -2360,7 +2353,7 @@ static inline bool PlaylistIsPlaying( intf_thread_t *p_intf,
playlist_item_t *p_item )
{
playlist_t *p_playlist = pl_Hold( p_intf );
playlist_item_t *p_played_item = p_playlist->status.p_item;
playlist_item_t *p_played_item = playlist_CurrentPlayingItem(p_playlist);
vlc_object_release( p_playlist );
return( p_item != NULL && p_played_item != NULL &&
p_item->p_input != NULL && p_played_item->p_input != NULL &&
......@@ -2419,14 +2412,14 @@ static void Eject( intf_thread_t *p_intf )
playlist_t * p_playlist = pl_Hold( p_intf );
PL_LOCK;
if( p_playlist->status.p_item == NULL )
if( playlist_CurrentPlayingItem(p_playlist) == NULL )
{
PL_UNLOCK;
vlc_object_release( p_playlist );
return;
}
psz_name = p_playlist->status.p_item->p_input->psz_name;
psz_name = playlist_CurrentPlayingItem(p_playlist)->p_input->psz_name;
if( psz_name )
{
......
......@@ -208,22 +208,18 @@ static void Close( vlc_object_t *p_this )
p_playlist = pl_Hold( p_intf );
if( p_playlist )
{
PL_LOCK;
var_DelCallback( p_playlist, "playlist-current", ItemChange, p_intf );
p_input = p_playlist->p_input;
p_input = playlist_CurrentInput( p_playlist );
if ( p_input )
{
vlc_object_hold( p_input );
if( p_sys->b_state_cb )
var_DelCallback( p_input, "state", PlayingChange, p_intf );
vlc_object_release( p_input );
}
PL_UNLOCK;
pl_Release( p_intf );
}
......@@ -506,18 +502,14 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
p_sys->b_submit = false;
p_playlist = pl_Hold( p_intf );
PL_LOCK;
p_input = p_playlist->p_input;
p_input = playlist_CurrentInput( p_playlist );
if( !p_input || p_input->b_dead )
{
PL_UNLOCK;
pl_Release( p_intf );
return VLC_SUCCESS;
}
vlc_object_hold( p_input );
PL_UNLOCK;
pl_Release( p_intf );
p_item = input_GetItem( p_input );
......@@ -921,17 +913,13 @@ static int ReadMetaData( intf_thread_t *p_this )
intf_sys_t *p_sys = p_this->p_sys;
p_playlist = pl_Hold( p_this );
PL_LOCK;
p_input = p_playlist->p_input;
p_input = playlist_CurrentInput( p_playlist );
if( !p_input )
{
PL_UNLOCK;
pl_Release( p_this );
return( VLC_SUCCESS );
}
vlc_object_hold( p_input );
PL_UNLOCK;
pl_Release( p_this );
p_item = input_GetItem( p_input );
......
......@@ -49,10 +49,7 @@
input_thread_t * vlclua_get_input_internal( lua_State *L )
{
playlist_t *p_playlist = vlclua_get_playlist_internal( L );
PL_LOCK;
input_thread_t *p_input = p_playlist->p_input;
if( p_input ) vlc_object_hold( p_input );
PL_UNLOCK;
input_thread_t *p_input = playlist_CurrentInput( p_playlist );
vlclua_release_playlist_internal( p_playlist );
return p_input;
}
......
......@@ -268,6 +268,7 @@ static int vlclua_playlist_get( lua_State *L )
else
{
int i;
#ifdef FIX_THAT_CODE_NOT_TO_MESS_WITH_PLAYLIST_INTERNALS
for( i = 0; i < p_playlist->i_sds; i++ )
{
if( !strcasecmp( psz_what,
......@@ -278,6 +279,10 @@ static int vlclua_playlist_get( lua_State *L )
break;
}
}
#else
# warning Don't access playlist iternal, broken code here.
abort();
#endif
if( !p_item )
{
PL_UNLOCK;
......@@ -372,7 +377,8 @@ static int vlclua_playlist_status( lua_State *L )
/*
int i_count = 0;
lua_settop( L, 0 );*/
if( p_playlist->p_input )
input_thread_t * p_input = playlist_CurrentInput( p_playlist );
if( p_input )
{
/*char *psz_uri =
input_item_GetURI( input_GetItem( p_playlist->p_input ) );
......@@ -380,7 +386,7 @@ static int vlclua_playlist_status( lua_State *L )
free( psz_uri );
lua_pushnumber( L, config_GetInt( p_intf, "volume" ) );*/
PL_LOCK;
switch( p_playlist->status.i_status )
switch( playlist_Status( p_playlist ) )
{
case PLAYLIST_STOPPED:
lua_pushstring( L, "stopped" );
......@@ -397,6 +403,7 @@ static int vlclua_playlist_status( lua_State *L )
}
PL_UNLOCK;
/*i_count += 3;*/
vlc_object_release( p_input );
}
else
{
......
......@@ -80,7 +80,7 @@ void libvlc_playlist_play( libvlc_instance_t *p_instance, int i_id,
}
p_item = playlist_ItemGetByInputId( PL, i_id,
PL->status.p_node );
PL->p_root_category );
if( !p_item )
{
if( did_lock == 1 )
......@@ -92,7 +92,7 @@ void libvlc_playlist_play( libvlc_instance_t *p_instance, int i_id,
}
playlist_Control( PL, PLAYLIST_VIEWPLAY, pl_Locked,
PL->status.p_node, p_item );
PL->p_root_category, p_item );
if( did_lock == 1 )
{
vlc_object_unlock( PL );
......@@ -214,8 +214,6 @@ int libvlc_playlist_get_current_index ( libvlc_instance_t *p_instance,
VLC_UNUSED(p_e);
assert( PL );
if( !PL->status.p_item )
return -1;
return playlist_CurrentId( PL );
}
......@@ -239,12 +237,12 @@ libvlc_media_player_t * libvlc_playlist_get_media_player(
{
libvlc_media_player_t *p_mi;
assert( PL );
vlc_object_lock( PL );
if( PL->p_input )
input_thread_t * input = playlist_CurrentInput( PL );
if( input )
{
p_mi = libvlc_media_player_new_from_input_thread(
p_instance, PL->p_input, p_e );
p_instance, input, p_e );
vlc_object_release( input );
}
else
{
......@@ -252,7 +250,6 @@ libvlc_media_player_t * libvlc_playlist_get_media_player(
p_mi = NULL;
libvlc_exception_raise( p_e, "No active input" );
}
vlc_object_unlock( PL );
return p_mi;
}
......
......@@ -276,13 +276,16 @@ playlist_BothAddInput
playlist_ChildSearchName
playlist_Clear
playlist_Control
playlist_CurrentId
playlist_CurrentInput
playlist_CurrentPlayingItem
playlist_DeleteFromInput
playlist_Export
playlist_GetLastLeaf
playlist_GetNextLeaf
playlist_GetPreferredNode
playlist_GetPrevLeaf
playlist_IsPlaying
playlist_IsServicesDiscoveryLoaded
playlist_ItemGetById
playlist_ItemGetByInput
......@@ -304,6 +307,7 @@ playlist_PreparseEnqueueItem
playlist_RecursiveNodeSort
playlist_ServicesDiscoveryAdd
playlist_ServicesDiscoveryRemove
playlist_Status
playlist_TreeMove
__pl_Hold
__pl_Release
......
......@@ -97,9 +97,9 @@ static int PlaylistVAControl( playlist_t * p_playlist, int i_query, va_list args
switch( i_query )
{
case PLAYLIST_STOP:
p_playlist->request.i_status = PLAYLIST_STOPPED;
p_playlist->request.b_request = true;
p_playlist->request.p_item = NULL;
pl_priv(p_playlist)->request.i_status = PLAYLIST_STOPPED;
pl_priv(p_playlist)->request.b_request = true;
pl_priv(p_playlist)->request.p_item = NULL;
break;
// Node can be null, it will keep the same. Use with care ...
......@@ -112,65 +112,65 @@ static int PlaylistVAControl( playlist_t * p_playlist, int i_query, va_list args
p_node = get_current_status_node( p_playlist );
assert( p_node );
}
p_playlist->request.i_status = PLAYLIST_RUNNING;
p_playlist->request.i_skip = 0;
p_playlist->request.b_request = true;
p_playlist->request.p_node = p_node;
p_playlist->request.p_item = p_item;
pl_priv(p_playlist)->request.i_status = PLAYLIST_RUNNING;
pl_priv(p_playlist)->request.i_skip = 0;
pl_priv(p_playlist)->request.b_request = true;
pl_priv(p_playlist)->request.p_node = p_node;
pl_priv(p_playlist)->request.p_item = p_item;
if( p_item && var_GetBool( p_playlist, "random" ) )
p_playlist->b_reset_currently_playing = true;
break;
case PLAYLIST_PLAY:
if( p_playlist->p_input )
if( pl_priv(p_playlist)->p_input )
{
val.i_int = PLAYING_S;
var_Set( p_playlist->p_input, "state", val );
var_Set( pl_priv(p_playlist)->p_input, "state", val );
break;
}
else
{
p_playlist->request.i_status = PLAYLIST_RUNNING;
p_playlist->request.b_request = true;
p_playlist->request.p_node = get_current_status_node( p_playlist );
p_playlist->request.p_item = get_current_status_item( p_playlist );
p_playlist->request.i_skip = 0;
pl_priv(p_playlist)->request.i_status = PLAYLIST_RUNNING;
pl_priv(p_playlist)->request.b_request = true;
pl_priv(p_playlist)->request.p_node = get_current_status_node( p_playlist );
pl_priv(p_playlist)->request.p_item = get_current_status_item( p_playlist );
pl_priv(p_playlist)->request.i_skip = 0;
}
break;
case PLAYLIST_PAUSE:
val.i_int = 0;
if( p_playlist->p_input )
var_Get( p_playlist->p_input, "state", &val );
if( pl_priv(p_playlist)->p_input )
var_Get( pl_priv(p_playlist)->p_input, "state", &val );
if( val.i_int == PAUSE_S )
{
p_playlist->status.i_status = PLAYLIST_RUNNING;
if( p_playlist->p_input )
pl_priv(p_playlist)->status.i_status = PLAYLIST_RUNNING;
if( pl_priv(p_playlist)->p_input )
{
val.i_int = PLAYING_S;
var_Set( p_playlist->p_input, "state", val );
var_Set( pl_priv(p_playlist)->p_input, "state", val );
}
}
else
{
p_playlist->status.i_status = PLAYLIST_PAUSED;
if( p_playlist->p_input )
pl_priv(p_playlist)->status.i_status = PLAYLIST_PAUSED;
if( pl_priv(p_playlist)->p_input )
{
val.i_int = PAUSE_S;
var_Set( p_playlist->p_input, "state", val );
var_Set( pl_priv(p_playlist)->p_input, "state", val );
}
}
break;
case PLAYLIST_SKIP:
p_playlist->request.p_node = get_current_status_node( p_playlist );
p_playlist->request.p_item = get_current_status_item( p_playlist );
p_playlist->request.i_skip = (int) va_arg( args, int );
pl_priv(p_playlist)->request.p_node = get_current_status_node( p_playlist );
pl_priv(p_playlist)->request.p_item = get_current_status_item( p_playlist );
pl_priv(p_playlist)->request.i_skip = (int) va_arg( args, int );
/* if already running, keep running */
if( p_playlist->status.i_status != PLAYLIST_STOPPED )
p_playlist->request.i_status = p_playlist->status.i_status;
p_playlist->request.b_request = true;
if( pl_priv(p_playlist)->status.i_status != PLAYLIST_STOPPED )
pl_priv(p_playlist)->request.i_status = pl_priv(p_playlist)->status.i_status;
pl_priv(p_playlist)->request.b_request = true;
break;
default:
......@@ -291,14 +291,14 @@ void ResetCurrentlyPlaying( playlist_t *p_playlist, bool b_random,
stats_TimerStart( p_playlist, "Items array build",
STATS_TIMER_PLAYLIST_BUILD );
PL_DEBUG( "rebuilding array of current - root %s",
PLI_NAME( p_playlist->status.p_node ) );
PLI_NAME( pl_priv(p_playlist)->status.p_node ) );
ARRAY_RESET( p_playlist->current );
p_playlist->i_current_index = -1;
while( 1 )
{
/** FIXME: this is *slow* */
p_next = playlist_GetNextLeaf( p_playlist,
p_playlist->status.p_node,
pl_priv(p_playlist)->status.p_node,
p_next, true, false );
if( p_next )
{
......@@ -355,19 +355,19 @@ playlist_item_t * playlist_NextItem( playlist_t *p_playlist )
}
/* Repeat and play/stop */
if( !p_playlist->request.b_request && b_repeat == true &&
if( !pl_priv(p_playlist)->request.b_request && b_repeat == true &&
get_current_status_item( p_playlist ) )
{
msg_Dbg( p_playlist,"repeating item" );
return get_current_status_item( p_playlist );
}
if( !p_playlist->request.b_request && b_playstop == true )
if( !pl_priv(p_playlist)->request.b_request && b_playstop == true )
{
msg_Dbg( p_playlist,"stopping (play and stop)" );
return NULL;
}
if( !p_playlist->request.b_request &&
if( !pl_priv(p_playlist)->request.b_request &&
get_current_status_item( p_playlist ) )
{
playlist_item_t *p_parent = get_current_status_item( p_playlist );
......@@ -383,20 +383,20 @@ playlist_item_t * playlist_NextItem( playlist_t *p_playlist )
}
/* Start the real work */
if( p_playlist->request.b_request )
if( pl_priv(p_playlist)->request.b_request )
{
p_new = p_playlist->request.p_item;
i_skip = p_playlist->request.i_skip;
p_new = pl_priv(p_playlist)->request.p_item;
i_skip = pl_priv(p_playlist)->request.i_skip;
PL_DEBUG( "processing request item %s node %s skip %i",
PLI_NAME( p_playlist->request.p_item ),
PLI_NAME( p_playlist->request.p_node ), i_skip );
PLI_NAME( pl_priv(p_playlist)->request.p_item ),
PLI_NAME( pl_priv(p_playlist)->request.p_node ), i_skip );
if( p_playlist->request.p_node &&
p_playlist->request.p_node != get_current_status_node( p_playlist ) )
if( pl_priv(p_playlist)->request.p_node &&
pl_priv(p_playlist)->request.p_node != get_current_status_node( p_playlist ) )
{
set_current_status_node( p_playlist, p_playlist->request.p_node );
p_playlist->request.p_node = NULL;
set_current_status_node( p_playlist, pl_priv(p_playlist)->request.p_node );
pl_priv(p_playlist)->request.p_node = NULL;
p_playlist->b_reset_currently_playing = true;
}
......@@ -457,7 +457,7 @@ playlist_item_t * playlist_NextItem( playlist_t *p_playlist )
p_playlist->i_current_index );
}
/* Clear the request */
p_playlist->request.b_request = false;
pl_priv(p_playlist)->request.b_request = false;
}
/* "Automatic" item change ( next ) */
else
......@@ -509,7 +509,7 @@ int playlist_PlayItem( playlist_t *p_playlist, playlist_item_t *p_item )
p_input->i_nb_played++;
set_current_status_item( p_playlist, p_item );
p_playlist->status.i_status = PLAYLIST_RUNNING;
pl_priv(p_playlist)->status.i_status = PLAYLIST_RUNNING;
var_SetInteger( p_playlist, "activity", i_activity +
DEFAULT_INPUT_ACTIVITY );
......
This diff is collapsed.
......@@ -852,12 +852,12 @@ static void GoAndPreparse( playlist_t *p_playlist, int i_mode,
p_parent = p_parent->p_parent;
}
assert( p_toplay );
p_playlist->request.b_request = true;
p_playlist->request.i_skip = 0;
p_playlist->request.p_item = p_toplay;
if( p_playlist->p_input )
input_StopThread( p_playlist->p_input );
p_playlist->request.i_status = PLAYLIST_RUNNING;
pl_priv(p_playlist)->request.b_request = true;
pl_priv(p_playlist)->request.i_skip = 0;
pl_priv(p_playlist)->request.p_item = p_toplay;
if( pl_priv(p_playlist)->p_input )
input_StopThread( pl_priv(p_playlist)->p_input );
pl_priv(p_playlist)->request.i_status = PLAYLIST_RUNNING;
vlc_object_signal_unlocked( p_playlist );
}
/* Preparse if PREPARSE or SPREPARSE & not enough meta */
......@@ -937,9 +937,9 @@ static int DeleteInner( playlist_t * p_playlist, playlist_item_t *p_item,
/* Hack we don't call playlist_Control for lock reasons */
if( b_stop )
{
p_playlist->request.i_status = PLAYLIST_STOPPED;
p_playlist->request.b_request = true;
p_playlist->request.p_item = NULL;
pl_priv(p_playlist)->request.i_status = PLAYLIST_STOPPED;
pl_priv(p_playlist)->request.b_request = true;
pl_priv(p_playlist)->request.p_item = NULL;
msg_Info( p_playlist, "stopping playback" );
vlc_object_signal_unlocked( VLC_OBJECT(p_playlist) );
}
......
......@@ -66,6 +66,38 @@ typedef struct playlist_private_t
playlist_preparse_t preparse; /**< Preparser data */
playlist_fetcher_t fetcher; /**< Meta and art fetcher data */
sout_instance_t *p_sout; /**< Kept sout instance */
struct playlist_services_discovery_support_t {
/* the playlist items for category and onelevel */
playlist_item_t* p_cat;
playlist_item_t* p_one;
services_discovery_t * p_sd; /**< Loaded service discovery modules */
} ** pp_sds;
int i_sds; /**< Number of service discovery modules */
input_thread_t * p_input; /**< the input thread associated
* with the current item */
struct {
/* Current status. These fields are readonly, only the playlist
* main loop can touch it*/
playlist_status_t i_status; /**< Current status of playlist */
playlist_item_t * p_item; /**< Currently playing/active item */
playlist_item_t * p_node; /**< Current node to play from */
} status;
struct {
/* Request. Use this to give orders to the playlist main loop */
playlist_status_t i_status; /**< requested playlist status */
playlist_item_t * p_node; /**< requested node to play from */
playlist_item_t * p_item; /**< requested item to play in the node */
int i_skip; /**< Number of items to skip */
bool b_request;/**< Set to true by the requester
The playlist sets it back to false
when processing the request */
vlc_mutex_t lock; /**< Lock to protect request */
} request;
} playlist_private_t;
#define pl_priv( pl ) ((playlist_private_t *)(pl))
......
......@@ -356,7 +356,7 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, const char *psz_modu
p_sds->p_cat = p_cat;
PL_LOCK;
TAB_APPEND( p_playlist->i_sds, p_playlist->pp_sds, p_sds );
TAB_APPEND( pl_priv(p_playlist)->i_sds, pl_priv(p_playlist)->pp_sds, p_sds );
PL_UNLOCK;
}
......@@ -371,12 +371,12 @@ int playlist_ServicesDiscoveryRemove( playlist_t * p_playlist,
int i;
PL_LOCK;
for( i = 0 ; i< p_playlist->i_sds ; i ++ )
for( i = 0 ; i< pl_priv(p_playlist)->i_sds ; i ++ )
{
if( !strcmp( psz_module, p_playlist->pp_sds[i]->p_sd->psz_module ) )
if( !strcmp( psz_module, pl_priv(p_playlist)->pp_sds[i]->p_sd->psz_module ) )
{
p_sds = p_playlist->pp_sds[i];
REMOVE_ELEM( p_playlist->pp_sds, p_playlist->i_sds, i );
p_sds = pl_priv(p_playlist)->pp_sds[i];
REMOVE_ELEM( pl_priv(p_playlist)->pp_sds, pl_priv(p_playlist)->i_sds, i );
break;
}
}
......@@ -430,9 +430,9 @@ bool playlist_IsServicesDiscoveryLoaded( playlist_t * p_playlist,
int i;
PL_LOCK;
for( i = 0 ; i< p_playlist->i_sds ; i ++ )
for( i = 0 ; i< pl_priv(p_playlist)->i_sds ; i ++ )
{
if( !strcmp( psz_module, p_playlist->pp_sds[i]->p_sd->psz_module ) )
if( !strcmp( psz_module, pl_priv(p_playlist)->pp_sds[i]->p_sd->psz_module ) )
{
PL_UNLOCK;
return true;
......@@ -444,7 +444,7 @@ bool playlist_IsServicesDiscoveryLoaded( playlist_t * p_playlist,
void playlist_ServicesDiscoveryKillAll( playlist_t *p_playlist )
{
while( p_playlist->i_sds > 0 )
while( pl_priv(p_playlist)->i_sds > 0 )
playlist_ServicesDiscoveryRemove( p_playlist,
p_playlist->pp_sds[0]->p_sd->psz_module );
pl_priv(p_playlist)->pp_sds[0]->p_sd->psz_module );
}
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