#include "http.h"
#include "macros.h"
-#include "vlc_url.h"
+#include <vlc_url.h>
static int MacroParse( macro_t *m, char *psz_src )
{
{
intf_thread_t *p_intf = p_args->p_intf;
intf_sys_t *p_sys = p_args->p_intf->p_sys;
+ playlist_t *p_playlist = p_sys->p_playlist;
char control[512];
#define ALLOC( l ) \
{ \
int __i__ = *pp_dst - *pp_data; \
*pi_data += (l); \
- *pp_data = realloc( *pp_data, *pi_data ); \
+ *pp_data = xrealloc( *pp_data, *pi_data ); \
*pp_dst = (*pp_data) + __i__; \
}
#define PRINT( str ) \
break;
}
playlist_Control( p_sys->p_playlist, PLAYLIST_VIEWPLAY,
- true, NULL,
+ pl_Unlocked, NULL,
playlist_ItemGetById( p_sys->p_playlist,
- i_item, true ) );
+ i_item ) );
msg_Dbg( p_intf, "requested playlist item: %i", i_item );
break;
}
case MVLC_STOP:
playlist_Control( p_sys->p_playlist, PLAYLIST_STOP,
- true );
+ pl_Unlocked );
msg_Dbg( p_intf, "requested playlist stop" );
break;
case MVLC_PAUSE:
playlist_Control( p_sys->p_playlist, PLAYLIST_PAUSE,
- true );
+ pl_Unlocked );
msg_Dbg( p_intf, "requested playlist pause" );
break;
case MVLC_NEXT:
playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP,
- true, 1 );
+ pl_Unlocked, 1 );
msg_Dbg( p_intf, "requested playlist next" );
break;
case MVLC_PREVIOUS:
playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP,
- true, -1 );
+ pl_Unlocked, -1 );
msg_Dbg( p_intf, "requested playlist previous" );
break;
case MVLC_FULLSCREEN:
if( p_sys->p_input )
{
- vout_thread_t *p_vout;
- p_vout = vlc_object_find( p_sys->p_input,
- VLC_OBJECT_VOUT, FIND_CHILD );
-
+ bool fs = var_ToggleBool( p_sys->p_playlist,
+ "fullscreen" );
+ vout_thread_t *p_vout = input_GetVout( p_sys->p_input );
if( p_vout )
{
- p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
+ var_SetBool( p_vout, "fullscreen", fs );
vlc_object_release( p_vout );
msg_Dbg( p_intf, "requested fullscreen toggle" );
}
int i_value;
ExtractURIValue( p_request, "value", vol, 8 );
- aout_VolumeGet( p_intf, &i_volume );
+ aout_VolumeGet( p_sys->p_playlist, &i_volume );
decode_URI( vol );
if( vol[0] == '+' )
i_value = atoi( vol + 1 );
if( (i_volume + i_value) > AOUT_VOLUME_MAX )
{
- aout_VolumeSet( p_intf , AOUT_VOLUME_MAX );
+ aout_VolumeSet( p_sys->p_playlist, AOUT_VOLUME_MAX );
msg_Dbg( p_intf, "requested volume set: max" );
}
else
{
- aout_VolumeSet( p_intf , (i_volume + i_value) );
+ aout_VolumeSet( p_sys->p_playlist, (i_volume + i_value) );
msg_Dbg( p_intf, "requested volume set: +%i", (i_volume + i_value) );
}
}
i_value = atoi( vol + 1 );
if( (i_volume - i_value) < AOUT_VOLUME_MIN )
{
- aout_VolumeSet( p_intf , AOUT_VOLUME_MIN );
+ aout_VolumeSet( p_sys->p_playlist, AOUT_VOLUME_MIN );
msg_Dbg( p_intf, "requested volume set: min" );
}
else
{
- aout_VolumeSet( p_intf , (i_volume - i_value) );
+ aout_VolumeSet( p_sys->p_playlist, (i_volume - i_value) );
msg_Dbg( p_intf, "requested volume set: -%i", (i_volume - i_value) );
}
}
{
i_value = atoi( vol );
if( (i_value <= 400) && (i_value>=0) ){
- aout_VolumeSet( p_intf, (i_value * (AOUT_VOLUME_MAX - AOUT_VOLUME_MIN))/400+AOUT_VOLUME_MIN);
+ aout_VolumeSet( p_sys->p_playlist, (i_value * (AOUT_VOLUME_MAX - AOUT_VOLUME_MIN))/400+AOUT_VOLUME_MIN);
msg_Dbg( p_intf, "requested volume set: %i%%", atoi( vol ));
}
}
i_value = atoi( vol );
if( ( i_value <= AOUT_VOLUME_MAX ) && ( i_value >= AOUT_VOLUME_MIN ) )
{
- aout_VolumeSet( p_intf , atoi( vol ) );
+ aout_VolumeSet( p_sys->p_playlist, atoi( vol ) );
msg_Dbg( p_intf, "requested volume set: %i", atoi( vol ) );
}
}
p_input = MRLParse( p_intf, mrl, psz_name );
- char *psz_uri = input_item_GetURI( p_input );
- if( !p_input || !psz_uri || !*psz_uri )
- {
- msg_Dbg( p_intf, "invalid requested mrl: %s", mrl );
- }
+ char *psz_uri = p_input ? input_item_GetURI( p_input ) : NULL;
+ if( psz_uri && *psz_uri &&
+ playlist_AddInput( p_sys->p_playlist, p_input,
+ PLAYLIST_APPEND, PLAYLIST_END,
+ true, pl_Unlocked) == VLC_SUCCESS )
+ msg_Dbg( p_intf, "requested mrl add: %s", mrl );
else
- {
- int i_ret = playlist_AddInput( p_sys->p_playlist,
- p_input,
- PLAYLIST_APPEND, PLAYLIST_END, true,
- false);
- vlc_gc_decref( p_input );
- if( i_ret == VLC_SUCCESS )
- msg_Dbg( p_intf, "requested mrl add: %s", mrl );
- else
- msg_Warn( p_intf, "adding mrl %s failed", mrl );
- }
+ msg_Warn( p_intf, "adding mrl failed: %s", mrl );
free( psz_uri );
-
+ if( p_input )
+ vlc_gc_decref( p_input );
break;
}
case MVLC_DEL:
{
- int i_item, *p_items = NULL, i_nb_items = 0;
- char item[512], *p_parser = p_request;
+ int *p_items = NULL;
+ size_t i_nb_items = 0;
+ char item[512];
+ const char *p_parser = p_request;
/* Get the list of items to delete */
while( (p_parser =
{
if( !*item ) continue;
- i_item = atoi( item );
- p_items = realloc( p_items, (i_nb_items + 1) *
- sizeof(int) );
+ int i_item = atoi( item );
+ p_items = xrealloc( p_items,
+ (i_nb_items + 1) * sizeof(*p_items) );
p_items[i_nb_items] = i_item;
i_nb_items++;
}
- if( i_nb_items )
+ for( size_t i = 0; i < i_nb_items; i++ )
{
- int i;
- for( i = 0; i < i_nb_items; i++ )
- {
+ PL_LOCK;
+ playlist_item_t *p_item;
+
+ msg_Dbg( p_intf, "requested playlist delete: %d",
+ p_items[i] );
+ p_item = playlist_ItemGetById( p_sys->p_playlist,
+ p_items[i] );
+ if( p_item )
playlist_DeleteFromInput( p_sys->p_playlist,
- p_items[i], false );
- msg_Dbg( p_intf, "requested playlist delete: %d",
- p_items[i] );
- p_items[i] = -1;
- }
+ p_item->p_input,
+ false );
+ PL_UNLOCK;
}
free( p_items );
}
case MVLC_KEEP:
{
- int i_item, *p_items = NULL, i_nb_items = 0;
- char item[512], *p_parser = p_request;
- int i,j;
+ int *p_items = NULL;
+ size_t i_nb_items = 0, i;
+ char item[512];
+ const char *p_parser = p_request;
/* Get the list of items to keep */
while( (p_parser =
{
if( !*item ) continue;
- i_item = atoi( item );
- p_items = realloc( p_items, (i_nb_items + 1) *
- sizeof(int) );
+ int i_item = atoi( item );
+ p_items = xrealloc( p_items,
+ (i_nb_items + 1) * sizeof(*p_items) );
p_items[i_nb_items] = i_item;
i_nb_items++;
}
- for( i = p_sys->p_playlist->items.i_size - 1 ; i >= 0; i-- )
+ PL_LOCK;
+ size_t size = p_sys->p_playlist->items.i_size;
+ for( i = 0; i < size; i++ )
{
+ size_t j;
+
/* Check if the item is in the keep list */
for( j = 0 ; j < i_nb_items ; j++ )
{
if( p_items[j] ==
- ARRAY_VAL(p_sys->p_playlist->items,i)
- ->i_id)
+ ARRAY_VAL(p_sys->p_playlist->items,i)->i_id)
break;
}
if( j == i_nb_items )
{
+ msg_Dbg( p_intf, "requested playlist delete: %d",
+ p_sys->p_playlist->items.p_elems[i]->i_id );
playlist_DeleteFromInput( p_sys->p_playlist,
- p_sys->p_playlist->items.p_elems[i]->i_id,
+ p_sys->p_playlist->items.p_elems[i]->p_input,
false );
- msg_Dbg( p_intf, "requested playlist delete: %d",
- i );
}
}
+ PL_UNLOCK;
free( p_items );
break;
}
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" );
break;
}
if( !strcmp( type , "title" ) )
{
+ PL_LOCK;
playlist_RecursiveNodeSort( p_sys->p_playlist,
/* Ugly hack,but not worse than before ... */
p_sys->p_playlist->p_root_onelevel,
SORT_TITLE_NODES_FIRST,
( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
+ PL_UNLOCK;
msg_Dbg( p_intf, "requested playlist sort by title (%d)" , i_order );
}
else if( !strcmp( type , "author" ) )
{
+ PL_LOCK;
playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
p_sys->p_playlist->p_root_onelevel,
SORT_ARTIST,
( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
+ PL_UNLOCK;
msg_Dbg( p_intf, "requested playlist sort by author (%d)" , i_order );
}
else if( !strcmp( type , "shuffle" ) )
{
+ PL_LOCK;
playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
p_sys->p_playlist->p_root_onelevel,
SORT_RANDOM,
( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
+ PL_UNLOCK;
msg_Dbg( p_intf, "requested playlist shuffle");
}
case MVLC_SHUTDOWN:
{
msg_Dbg( p_intf, "requested shutdown" );
- vlc_object_kill( p_intf->p_libvlc );
+ libvlc_Quit( p_intf->p_libvlc );
break;
}
+#ifdef ENABLE_VLM
/* vlm */
case MVLC_VLM_NEW:
case MVLC_VLM_SETUP:
{
- static const char *vlm_properties[] =
+ static const char vlm_properties[][9] =
{
/* no args */
"enabled", "disabled", "loop", "unloop",
};
vlm_message_t *vlm_answer;
char name[512];
- char *psz = malloc( strlen( p_request ) + 1000 );
+ char *psz = xmalloc( strlen( p_request ) + 1000 );
char *p = psz;
char *vlm_error;
int i;
if( p_intf->p_sys->p_vlm == NULL )
p_intf->p_sys->p_vlm = vlm_New( p_intf );
- if( p_intf->p_sys->p_vlm == NULL ) break;
+ if( p_intf->p_sys->p_vlm == NULL )
+ {
+ free( psz );
+ break;
+ }
ExtractURIValue( p_request, "name", name, 512 );
if( StrToMacroType( control ) == MVLC_VLM_NEW )
}
else
{
- vlm_error = malloc( strlen(vlm_answer->psz_name) +
- strlen(vlm_answer->psz_value) +
- strlen( " : ") + 1 );
- sprintf( vlm_error , "%s : %s" , vlm_answer->psz_name,
- vlm_answer->psz_value );
+ if( asprintf( &vlm_error , "%s : %s" ,
+ vlm_answer->psz_name,
+ vlm_answer->psz_value ) == -1 )
+ vlm_error = NULL;
}
mvar_AppendNewVar( p_args->vars, "vlm_error", vlm_error );
vlm_MessageDelete( vlm_answer );
break;
}
-
+#endif /* ENABLE_VLM */
default:
if( *control )
{
}
case MVLC_VALUE:
{
- char *s, *v;
+ char *s;
+ const char *v;
if( m->param1 )
{
char *p_request, int i_request,
char **pp_data, int *pi_data,
char **pp_dst,
- char *_src, char *_end )
+ const char *_src, const char *_end )
{
intf_thread_t *p_intf = p_args->p_intf;
char *src, *dup, *end;
char *dst = *pp_dst;
- src = dup = malloc( _end - _src + 1 );
+ src = dup = xmalloc( _end - _src + 1 );
end = src +( _end - _src );
memcpy( src, _src, _end - _src );
char *p;
int i_copy;
- p = (char *)strstr( (char *)src, "<vlc" );
+ p = strstr( src, "<vlc" );
if( p < end && p == src )
{
macro_t m;
index = mvar_FileSetNew( p_intf, m.param1, arg );
free( arg );
}
- else if( !strcmp( m.param2, "object" ) )
+ else if( !strcmp( m.param2, "services" ) )
{
- char *arg = SSPop( &p_args->stack );
- index = mvar_ObjectSetNew( p_intf, m.param1, arg );
- free( arg );
+ index = mvar_ServicesSetNew( p_intf, m.param1 );
}
else if( !strcmp( m.param2, "playlist" ) )
{
p_intf->p_sys->p_input,
m.param2 );
}
+#ifdef ENABLE_VLM
else if( !strcmp( m.param2, "vlm" ) )
{
if( p_intf->p_sys->p_vlm == NULL )
p_intf->p_sys->p_vlm = vlm_New( p_intf );
index = mvar_VlmSetNew( m.param1, p_intf->p_sys->p_vlm );
}
+#endif
#if 0
else if( !strcmp( m.param2, "hosts" ) )
{
int i_index = dst - *pp_data;
*pi_data += i_copy;
- *pp_data = realloc( *pp_data, *pi_data );
+ *pp_data = xrealloc( *pp_data, *pi_data );
dst = (*pp_data) + i_index;
memcpy( dst, src, i_copy );