Commit 8385a59f authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Old RC: use audio output device functions and clean up

parent b8d9f708
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <math.h> #include <math.h>
#include <vlc_interface.h> #include <vlc_interface.h>
#include <vlc_aout.h>
#include <vlc_vout.h> #include <vlc_vout.h>
#include <vlc_osd.h> #include <vlc_osd.h>
#include <vlc_playlist.h> #include <vlc_playlist.h>
...@@ -103,7 +104,9 @@ static int VolumeMove ( vlc_object_t *, char const *, ...@@ -103,7 +104,9 @@ static int VolumeMove ( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * ); vlc_value_t, vlc_value_t, void * );
static int VideoConfig ( vlc_object_t *, char const *, static int VideoConfig ( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * ); vlc_value_t, vlc_value_t, void * );
static int AudioConfig ( vlc_object_t *, char const *, static int AudioDevice ( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static int AudioChannel ( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * ); vlc_value_t, vlc_value_t, void * );
static int Menu ( vlc_object_t *, char const *, static int Menu ( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * ); vlc_value_t, vlc_value_t, void * );
...@@ -430,8 +433,8 @@ static void RegisterCallbacks( intf_thread_t *p_intf ) ...@@ -430,8 +433,8 @@ static void RegisterCallbacks( intf_thread_t *p_intf )
ADD( "volume", STRING, Volume ) ADD( "volume", STRING, Volume )
ADD( "volup", STRING, VolumeMove ) ADD( "volup", STRING, VolumeMove )
ADD( "voldown", STRING, VolumeMove ) ADD( "voldown", STRING, VolumeMove )
ADD( "adev", STRING, AudioConfig ) ADD( "adev", STRING, AudioDevice )
ADD( "achan", STRING, AudioConfig ) ADD( "achan", STRING, AudioChannel )
/* misc menu commands */ /* misc menu commands */
ADD( "stats", BOOL, Statistics ) ADD( "stats", BOOL, Statistics )
...@@ -842,7 +845,7 @@ static void Help( intf_thread_t *p_intf, bool b_longhelp) ...@@ -842,7 +845,7 @@ static void Help( intf_thread_t *p_intf, bool b_longhelp)
msg_rc("%s", _("| volume [X] . . . . . . . . . . set/get audio volume")); msg_rc("%s", _("| volume [X] . . . . . . . . . . set/get audio volume"));
msg_rc("%s", _("| volup [X] . . . . . . . raise audio volume X steps")); msg_rc("%s", _("| volup [X] . . . . . . . raise audio volume X steps"));
msg_rc("%s", _("| voldown [X] . . . . . . lower audio volume X steps")); msg_rc("%s", _("| voldown [X] . . . . . . lower audio volume X steps"));
msg_rc("%s", _("| adev [X] . . . . . . . . . . . set/get audio device")); msg_rc("%s", _("| adev [device] . . . . . . . . set/get audio device"));
msg_rc("%s", _("| achan [X]. . . . . . . . . . set/get audio channels")); msg_rc("%s", _("| achan [X]. . . . . . . . . . set/get audio channels"));
msg_rc("%s", _("| atrack [X] . . . . . . . . . . . set/get audio track")); msg_rc("%s", _("| atrack [X] . . . . . . . . . . . set/get audio track"));
msg_rc("%s", _("| vtrack [X] . . . . . . . . . . . set/get video track")); msg_rc("%s", _("| vtrack [X] . . . . . . . . . . . set/get video track"));
...@@ -1688,53 +1691,74 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd, ...@@ -1688,53 +1691,74 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd,
return i_error; return i_error;
} }
static int AudioConfig( vlc_object_t *p_this, char const *psz_cmd, static int AudioDevice( vlc_object_t *obj, char const *cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data ) vlc_value_t old, vlc_value_t cur, void *dummy )
{ {
VLC_UNUSED(oldval); VLC_UNUSED(p_data); intf_thread_t *p_intf = (intf_thread_t *)obj;
intf_thread_t *p_intf = (intf_thread_t*)p_this; audio_output_t *p_aout = playlist_GetAout( pl_Get(p_intf) );
const char * psz_variable; if( p_aout == NULL )
vlc_value_t val_name; return VLC_ENOOBJ;
int i_error;
vlc_object_t *p_aout = (vlc_object_t *)playlist_GetAout( pl_Get(p_this) ); if( !*cur.psz_string )
if ( p_aout == NULL ) {
return VLC_ENOOBJ; char **ids, **names;
int n = aout_DevicesList( p_aout, &ids, &names );
if( n < 0 )
goto out;
char *dev = aout_DeviceGet( p_aout );
const char *devstr = (dev != NULL) ? dev : "";
msg_rc( "+----[ %s ]", cmd );
for ( int i = 0; i < n; i++ )
{
const char *fmt = "| %s - %s";
if( !strcmp(devstr, ids[i]) )
fmt = "| %s - %s *";
msg_rc( fmt, ids[i], names[i] );
free( names[i] );
free( ids[i] );
}
msg_rc( "+----[ end of %s ]", cmd );
if ( !strcmp( psz_cmd, "adev" ) ) free( dev );
psz_variable = "audio-device"; free( names );
free( ids );
}
else else
psz_variable = "stereo-mode"; aout_DeviceSet( p_aout, cur.psz_string );
out:
vlc_object_release( p_aout );
(void) old; (void) dummy;
return VLC_SUCCESS;
}
static int AudioChannel( vlc_object_t *obj, char const *cmd,
vlc_value_t old, vlc_value_t cur, void *dummy )
{
intf_thread_t *p_intf = (intf_thread_t*)obj;
vlc_object_t *p_aout = (vlc_object_t *)playlist_GetAout( pl_Get(p_intf) );
if ( p_aout == NULL )
return VLC_ENOOBJ;
/* Get the descriptive name of the variable */ int ret = VLC_SUCCESS;
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 ) if ( !*cur.psz_string )
{ {
/* Retrieve all registered ***. */ /* Retrieve all registered ***. */
vlc_value_t val, text; vlc_value_t val, text;
int i, i_value; if ( var_Change( p_aout, "stereo-mode",
if ( var_Get( p_aout, psz_variable, &val ) < 0 )
{
vlc_object_release( p_aout );
free( val_name.psz_string );
return VLC_EGENERIC;
}
i_value = val.i_int;
if ( var_Change( p_aout, psz_variable,
VLC_VAR_GETLIST, &val, &text ) < 0 ) VLC_VAR_GETLIST, &val, &text ) < 0 )
{ {
vlc_object_release( p_aout ); ret = VLC_ENOVAR;
free( val_name.psz_string ); goto out;
return VLC_EGENERIC;
} }
msg_rc( "+----[ %s ]", val_name.psz_string ); int i_value = var_GetInteger( p_aout, "stereo-mode" );
for ( i = 0; i < val.p_list->i_count; i++ )
msg_rc( "+----[ %s ]", cmd );
for ( int i = 0; i < val.p_list->i_count; i++ )
{ {
if ( i_value == val.p_list->p_values[i].i_int ) if ( i_value == val.p_list->p_values[i].i_int )
msg_rc( "| %"PRId64" - %s *", val.p_list->p_values[i].i_int, msg_rc( "| %"PRId64" - %s *", val.p_list->p_values[i].i_int,
...@@ -1744,21 +1768,14 @@ static int AudioConfig( vlc_object_t *p_this, char const *psz_cmd, ...@@ -1744,21 +1768,14 @@ static int AudioConfig( vlc_object_t *p_this, char const *psz_cmd,
text.p_list->p_values[i].psz_string ); text.p_list->p_values[i].psz_string );
} }
var_FreeList( &val, &text ); var_FreeList( &val, &text );
msg_rc( "+----[ end of %s ]", val_name.psz_string ); msg_rc( "+----[ end of %s ]", cmd );
i_error = VLC_SUCCESS;
} }
else else
{ ret = var_SetInteger( p_aout, "stereo-mode", atoi( cur.psz_string ) );
vlc_value_t val; out:
val.i_int = atoi( newval.psz_string );
i_error = var_Set( p_aout, psz_variable, val );
}
free( val_name.psz_string );
vlc_object_release( p_aout ); vlc_object_release( p_aout );
(void) old; (void) dummy;
return i_error; return ret;
} }
/* OSD menu commands */ /* OSD menu commands */
......
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