#include <assert.h>
#include <vlc_interface.h>
-#include <vlc_aout.h>
+#include <vlc_aout_intf.h>
#include <vlc_vout.h>
#include <vlc_osd.h>
#include <vlc_playlist.h>
static bool ReadCommand( intf_thread_t *, char *, int * );
-static input_item_t *parse_MRL( intf_thread_t *, char * );
+static input_item_t *parse_MRL( const char * );
static int Input ( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
#endif
};
-#define msg_rc( ... ) __msg_rc( p_intf, __VA_ARGS__ )
-
-LIBVLC_FORMAT(2, 3)
-static void __msg_rc( intf_thread_t *p_intf, const char *psz_fmt, ... )
+VLC_FORMAT(2, 3)
+static void msg_rc( intf_thread_t *p_intf, const char *psz_fmt, ... )
{
va_list args;
char fmt_eol[strlen (psz_fmt) + 3];
net_vaPrintf( p_intf, p_intf->p_sys->i_socket, NULL, fmt_eol, args );
va_end( args );
}
+#define msg_rc( ... ) msg_rc( p_intf, __VA_ARGS__ )
/*****************************************************************************
* Module descriptor
/* status callbacks */
/* Listen to audio volume updates */
- var_AddCallback( p_playlist, "volume-change", VolumeChanged, p_intf );
+ var_AddCallback( p_playlist, "volume", VolumeChanged, p_intf );
#ifdef WIN32
/* Get the file descriptor of the console input */
vlc_object_release( p_input );
}
- var_DelCallback( p_playlist, "volume-change", VolumeChanged, p_intf );
+ var_DelCallback( p_playlist, "volume", VolumeChanged, p_intf );
vlc_restorecancel( canc );
}
static int VolumeChanged( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
+ (void) p_this;
VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(newval);
intf_thread_t *p_intf = (intf_thread_t*)p_data;
vlc_mutex_lock( &p_intf->p_sys->status_lock );
- msg_rc( STATUS_CHANGE "( audio volume: %d )",
- (int)config_GetInt( p_this, "volume") );
+ msg_rc( STATUS_CHANGE "( audio volume: %"PRId64" )", newval.i_int );
vlc_mutex_unlock( &p_intf->p_sys->status_lock );
return VLC_SUCCESS;
}
if( strlen( newval.psz_string ) > 0 )
{
- if ( ( !strncmp( newval.psz_string, "on", 2 ) && ( val.b_bool == true ) ) ||
- ( !strncmp( newval.psz_string, "off", 3 ) && ( val.b_bool == false ) ) )
+ if ( ( !strncmp( newval.psz_string, "on", 2 ) && val.b_bool ) ||
+ ( !strncmp( newval.psz_string, "off", 3 ) && !val.b_bool ) )
{
b_update = false;
}
if( strlen( newval.psz_string ) > 0 )
{
- if ( ( !strncmp( newval.psz_string, "on", 2 ) && ( val.b_bool == true ) ) ||
- ( !strncmp( newval.psz_string, "off", 3 ) && ( val.b_bool == false ) ) )
+ if ( ( !strncmp( newval.psz_string, "on", 2 ) && val.b_bool ) ||
+ ( !strncmp( newval.psz_string, "off", 3 ) && !val.b_bool ) )
{
b_update = false;
}
if( strlen( newval.psz_string ) > 0 )
{
- if ( ( !strncmp( newval.psz_string, "on", 2 ) && ( val.b_bool == true ) ) ||
- ( !strncmp( newval.psz_string, "off", 3 ) && ( val.b_bool == false ) ) )
+ if ( ( !strncmp( newval.psz_string, "on", 2 ) && val.b_bool ) ||
+ ( !strncmp( newval.psz_string, "off", 3 ) && !val.b_bool ) )
{
b_update = false;
}
else if( !strcmp( psz_cmd, "add" ) &&
newval.psz_string && *newval.psz_string )
{
- input_item_t *p_item = parse_MRL( p_intf, newval.psz_string );
+ input_item_t *p_item = parse_MRL( newval.psz_string );
if( p_item )
{
else if( !strcmp( psz_cmd, "enqueue" ) &&
newval.psz_string && *newval.psz_string )
{
- input_item_t *p_item = parse_MRL( p_intf, newval.psz_string );
+ input_item_t *p_item = parse_MRL( newval.psz_string );
if( p_item )
{
{
/* Set. */
audio_volume_t i_volume = atoi( newval.psz_string );
- if ( (i_volume > (audio_volume_t)AOUT_VOLUME_MAX) )
- {
- msg_rc( "Volume must be in the range %d-%d.", AOUT_VOLUME_MIN,
- AOUT_VOLUME_MAX );
- i_error = VLC_EBADVAR;
- }
- else
- {
- if( i_volume == AOUT_VOLUME_MIN )
- aout_ToggleMute( p_playlist, NULL );
- if( !aout_VolumeSet( p_playlist, i_volume ) )
- i_error = VLC_SUCCESS;
- osd_Volume( p_this );
- msg_rc( STATUS_CHANGE "( audio volume: %d )", i_volume );
- }
+ if( i_volume == 0 )
+ aout_ToggleMute( p_playlist, NULL );
+ if( !aout_VolumeSet( p_playlist, i_volume ) )
+ i_error = VLC_SUCCESS;
+ osd_Volume( p_this );
+ msg_rc( STATUS_CHANGE "( audio volume: %d )", i_volume );
}
else
{
/* Get. */
- audio_volume_t i_volume;
- if ( !aout_VolumeGet( p_playlist, &i_volume ) )
- {
- msg_rc( STATUS_CHANGE "( audio volume: %d )", i_volume );
- i_error = VLC_SUCCESS;
- }
+ audio_volume_t i_volume = aout_VolumeGet( p_playlist );
+ msg_rc( STATUS_CHANGE "( audio volume: %d )", i_volume );
+ i_error = VLC_SUCCESS;
}
return i_error;
playlist_CurrentInput( p_intf->p_sys->p_playlist );
int i_nb_steps = atoi(newval.psz_string);
int i_error = VLC_SUCCESS;
- int i_volume_step = 0;
if( !p_input )
return VLC_ENOOBJ;
return VLC_EGENERIC;
}
- i_volume_step = config_GetInt( p_intf->p_libvlc, "volume-step" );
- if ( i_nb_steps <= 0 || i_nb_steps > (AOUT_VOLUME_MAX/i_volume_step) )
- {
- i_nb_steps = 1;
- }
-
- if ( !strcmp(psz_cmd, "volup") )
- {
- if ( aout_VolumeUp( p_intf->p_sys->p_playlist, i_nb_steps, &i_volume ) < 0 )
- i_error = VLC_EGENERIC;
- }
- else
- {
- if ( aout_VolumeDown( p_intf->p_sys->p_playlist, i_nb_steps, &i_volume ) < 0 )
- i_error = VLC_EGENERIC;
- }
+ if( !strcmp(psz_cmd, "voldown") )
+ i_nb_steps *= -1;
+ if( aout_VolumeUp( p_intf->p_sys->p_playlist, i_nb_steps, &i_volume ) < 0 )
+ i_error = VLC_EGENERIC;
osd_Volume( p_this );
if ( !i_error ) msg_rc( STATUS_CHANGE "( audio volume: %d )", i_volume );
intf_thread_t *p_intf = (intf_thread_t*)p_this;
input_thread_t *p_input =
playlist_CurrentInput( p_intf->p_sys->p_playlist );
- aout_instance_t * p_aout;
const char * psz_variable;
vlc_value_t val_name;
int i_error;
return VLC_EGENERIC;
}
- p_aout = input_GetAout( p_input );
+ vlc_object_t * p_aout = (vlc_object_t *)input_GetAout( p_input );
vlc_object_release( p_input );
if ( p_aout == NULL )
return VLC_ENOOBJ;
}
/* Get the descriptive name of the variable */
- var_Change( (vlc_object_t *)p_aout, psz_variable, VLC_VAR_GETTEXT,
- &val_name, NULL );
+ var_Change( p_aout, psz_variable, VLC_VAR_GETTEXT,
+ &val_name, NULL );
if( !val_name.psz_string ) val_name.psz_string = strdup(psz_variable);
if ( !*newval.psz_string )
vlc_value_t val, text;
int i, i_value;
- if ( var_Get( (vlc_object_t *)p_aout, psz_variable, &val ) < 0 )
+ if ( var_Get( p_aout, psz_variable, &val ) < 0 )
{
- vlc_object_release( (vlc_object_t *)p_aout );
+ vlc_object_release( p_aout );
return VLC_EGENERIC;
}
i_value = val.i_int;
- if ( var_Change( (vlc_object_t *)p_aout, psz_variable,
+ if ( var_Change( p_aout, psz_variable,
VLC_VAR_GETLIST, &val, &text ) < 0 )
{
- vlc_object_release( (vlc_object_t *)p_aout );
+ vlc_object_release( p_aout );
return VLC_EGENERIC;
}
vlc_value_t val;
val.i_int = atoi( newval.psz_string );
- i_error = var_Set( (vlc_object_t *)p_aout, psz_variable, val );
+ i_error = var_Set( p_aout, psz_variable, val );
}
- vlc_object_release( (vlc_object_t *)p_aout );
+ vlc_object_release( p_aout );
return i_error;
}
}
#ifdef WIN32
-bool ReadWin32( intf_thread_t *p_intf, char *p_buffer, int *pi_size )
+static bool ReadWin32( intf_thread_t *p_intf, char *p_buffer, int *pi_size )
{
INPUT_RECORD input_record;
DWORD i_dw;
* We don't check for '"' or '\'', we just assume that a ':' that follows a
* space is a new option. Should be good enough for our purpose.
*****************************************************************************/
-static input_item_t *parse_MRL( intf_thread_t *p_intf, char *psz_mrl )
+static input_item_t *parse_MRL( const char *mrl )
{
#define SKIPSPACE( p ) { while( *p == ' ' || *p == '\t' ) p++; }
#define SKIPTRAILINGSPACE( p, d ) \
{ char *e=d; while( e > p && (*(e-1)==' ' || *(e-1)=='\t') ){e--;*e=0;} }
input_item_t *p_item = NULL;
- char *psz_item = NULL, *psz_item_mrl = NULL, *psz_orig;
+ char *psz_item = NULL, *psz_item_mrl = NULL, *psz_orig, *psz_mrl;
char **ppsz_options = NULL;
int i, i_options = 0;
- if( !psz_mrl ) return 0;
+ if( !mrl ) return 0;
- psz_mrl = psz_orig = strdup( psz_mrl );
+ psz_mrl = psz_orig = strdup( mrl );
if( !psz_mrl )
return NULL;
while( *psz_mrl )
/* Now create a playlist item */
if( psz_item_mrl )
{
- p_item = input_item_New( p_intf, psz_item_mrl, NULL );
+ p_item = input_item_New( psz_item_mrl, NULL );
for( i = 0; i < i_options; i++ )
{
input_item_AddOption( p_item, ppsz_options[i], VLC_INPUT_OPTION_TRUSTED );