Commit fe85cd9a authored by Jakob Leben's avatar Jakob Leben

http: playlist locking

untested
parent 5d626d6a
...@@ -143,6 +143,7 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -143,6 +143,7 @@ static void MacroDo( httpd_file_sys_t *p_args,
{ {
intf_thread_t *p_intf = p_args->p_intf; intf_thread_t *p_intf = p_args->p_intf;
intf_sys_t *p_sys = p_args->p_intf->p_sys; intf_sys_t *p_sys = p_args->p_intf->p_sys;
playlist_t *p_playlist = p_sys->p_playlist;
char control[512]; char control[512];
#define ALLOC( l ) \ #define ALLOC( l ) \
...@@ -199,9 +200,8 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -199,9 +200,8 @@ static void MacroDo( httpd_file_sys_t *p_args,
msg_Dbg( p_intf, "requested playlist play" ); msg_Dbg( p_intf, "requested playlist play" );
break; break;
} }
//TODO: really locked here ?
playlist_Control( p_sys->p_playlist, PLAYLIST_VIEWPLAY, playlist_Control( p_sys->p_playlist, PLAYLIST_VIEWPLAY,
true, NULL, pl_Unlocked, NULL,
playlist_ItemGetById( p_sys->p_playlist, playlist_ItemGetById( p_sys->p_playlist,
i_item ) ); i_item ) );
msg_Dbg( p_intf, "requested playlist item: %i", i_item ); msg_Dbg( p_intf, "requested playlist item: %i", i_item );
...@@ -209,22 +209,22 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -209,22 +209,22 @@ static void MacroDo( httpd_file_sys_t *p_args,
} }
case MVLC_STOP: case MVLC_STOP:
playlist_Control( p_sys->p_playlist, PLAYLIST_STOP, playlist_Control( p_sys->p_playlist, PLAYLIST_STOP,
true ); pl_Unlocked );
msg_Dbg( p_intf, "requested playlist stop" ); msg_Dbg( p_intf, "requested playlist stop" );
break; break;
case MVLC_PAUSE: case MVLC_PAUSE:
playlist_Control( p_sys->p_playlist, PLAYLIST_PAUSE, playlist_Control( p_sys->p_playlist, PLAYLIST_PAUSE,
true ); pl_Unlocked );
msg_Dbg( p_intf, "requested playlist pause" ); msg_Dbg( p_intf, "requested playlist pause" );
break; break;
case MVLC_NEXT: case MVLC_NEXT:
playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP,
true, 1 ); pl_Unlocked, 1 );
msg_Dbg( p_intf, "requested playlist next" ); msg_Dbg( p_intf, "requested playlist next" );
break; break;
case MVLC_PREVIOUS: case MVLC_PREVIOUS:
playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP,
true, -1 ); pl_Unlocked, -1 );
msg_Dbg( p_intf, "requested playlist previous" ); msg_Dbg( p_intf, "requested playlist previous" );
break; break;
case MVLC_FULLSCREEN: case MVLC_FULLSCREEN:
...@@ -342,7 +342,7 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -342,7 +342,7 @@ static void MacroDo( httpd_file_sys_t *p_args,
if( psz_uri && *psz_uri && if( psz_uri && *psz_uri &&
playlist_AddInput( p_sys->p_playlist, p_input, playlist_AddInput( p_sys->p_playlist, p_input,
PLAYLIST_APPEND, PLAYLIST_END, PLAYLIST_APPEND, PLAYLIST_END,
true, false) == VLC_SUCCESS ) true, pl_Unlocked) == VLC_SUCCESS )
msg_Dbg( p_intf, "requested mrl add: %s", mrl ); msg_Dbg( p_intf, "requested mrl add: %s", mrl );
else else
msg_Warn( p_intf, "adding mrl failed: %s", mrl ); msg_Warn( p_intf, "adding mrl failed: %s", mrl );
...@@ -373,6 +373,7 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -373,6 +373,7 @@ static void MacroDo( httpd_file_sys_t *p_args,
for( size_t i = 0; i < i_nb_items; i++ ) for( size_t i = 0; i < i_nb_items; i++ )
{ {
PL_LOCK;
playlist_item_t *p_item; playlist_item_t *p_item;
msg_Dbg( p_intf, "requested playlist delete: %d", msg_Dbg( p_intf, "requested playlist delete: %d",
...@@ -383,6 +384,7 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -383,6 +384,7 @@ static void MacroDo( httpd_file_sys_t *p_args,
playlist_DeleteFromInput( p_sys->p_playlist, playlist_DeleteFromInput( p_sys->p_playlist,
p_item->p_input, p_item->p_input,
false ); false );
PL_UNLOCK;
} }
free( p_items ); free( p_items );
...@@ -408,6 +410,7 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -408,6 +410,7 @@ static void MacroDo( httpd_file_sys_t *p_args,
i_nb_items++; i_nb_items++;
} }
PL_LOCK;
size_t size = p_sys->p_playlist->items.i_size; size_t size = p_sys->p_playlist->items.i_size;
for( i = 0; i < size; i++ ) for( i = 0; i < size; i++ )
{ {
...@@ -429,13 +432,14 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -429,13 +432,14 @@ static void MacroDo( httpd_file_sys_t *p_args,
false ); false );
} }
} }
PL_UNLOCK;
free( p_items ); free( p_items );
break; break;
} }
case MVLC_EMPTY: case MVLC_EMPTY:
{ {
playlist_Clear( p_sys->p_playlist, false ); playlist_Clear( p_sys->p_playlist, pl_Unlocked );
msg_Dbg( p_intf, "requested playlist empty" ); msg_Dbg( p_intf, "requested playlist empty" );
break; break;
} }
...@@ -457,27 +461,33 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -457,27 +461,33 @@ static void MacroDo( httpd_file_sys_t *p_args,
if( !strcmp( type , "title" ) ) if( !strcmp( type , "title" ) )
{ {
PL_LOCK;
playlist_RecursiveNodeSort( p_sys->p_playlist, playlist_RecursiveNodeSort( p_sys->p_playlist,
/* Ugly hack,but not worse than before ... */ /* Ugly hack,but not worse than before ... */
p_sys->p_playlist->p_root_onelevel, p_sys->p_playlist->p_root_onelevel,
SORT_TITLE_NODES_FIRST, SORT_TITLE_NODES_FIRST,
( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE ); ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
PL_UNLOCK;
msg_Dbg( p_intf, "requested playlist sort by title (%d)" , i_order ); msg_Dbg( p_intf, "requested playlist sort by title (%d)" , i_order );
} }
else if( !strcmp( type , "author" ) ) else if( !strcmp( type , "author" ) )
{ {
PL_LOCK;
playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/ playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
p_sys->p_playlist->p_root_onelevel, p_sys->p_playlist->p_root_onelevel,
SORT_ARTIST, SORT_ARTIST,
( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE ); ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
PL_UNLOCK;
msg_Dbg( p_intf, "requested playlist sort by author (%d)" , i_order ); msg_Dbg( p_intf, "requested playlist sort by author (%d)" , i_order );
} }
else if( !strcmp( type , "shuffle" ) ) else if( !strcmp( type , "shuffle" ) )
{ {
PL_LOCK;
playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/ playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
p_sys->p_playlist->p_root_onelevel, p_sys->p_playlist->p_root_onelevel,
SORT_RANDOM, SORT_RANDOM,
( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE ); ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
PL_UNLOCK;
msg_Dbg( p_intf, "requested playlist shuffle"); msg_Dbg( p_intf, "requested playlist shuffle");
} }
......
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