Commit f055f01f authored by Christophe Massiot's avatar Christophe Massiot

* aout_Volume* functions now do their own vlc_object_find() on the

  audio output. Consequently, the first argument can be any vlc_object_t.
* modules/gui/macosx/*: greatly simplified volume functions ; you can now
  call aout_Volume* even when there is no audio output, and the volume
  will be saved for later use.
parent 65a15323
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* aout_internal.h : internal defines for audio output * aout_internal.h : internal defines for audio output
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: aout_internal.h,v 1.37 2003/01/23 17:13:28 massiot Exp $ * $Id: aout_internal.h,v 1.38 2003/02/09 01:13:43 massiot Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -200,8 +200,6 @@ typedef struct aout_output_t ...@@ -200,8 +200,6 @@ typedef struct aout_output_t
/* Current volume for the output - it's just a placeholder, the plug-in /* Current volume for the output - it's just a placeholder, the plug-in
* may or may not use it. */ * may or may not use it. */
audio_volume_t i_volume; audio_volume_t i_volume;
/* Saved volume for aout_VolumeMute(). */
audio_volume_t i_saved_volume;
/* If b_error == 1, there is no audio output pipeline. */ /* If b_error == 1, there is no audio output pipeline. */
vlc_bool_t b_error; vlc_bool_t b_error;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* audio_output.h : audio output interface * audio_output.h : audio output interface
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: audio_output.h,v 1.77 2003/02/06 15:14:41 massiot Exp $ * $Id: audio_output.h,v 1.78 2003/02/09 01:13:43 massiot Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -175,12 +175,18 @@ VLC_EXPORT( void, aout_DecDeleteBuffer, ( aout_instance_t *, aout_input_t *, aou ...@@ -175,12 +175,18 @@ VLC_EXPORT( void, aout_DecDeleteBuffer, ( aout_instance_t *, aout_input_t *, aou
VLC_EXPORT( int, aout_DecPlay, ( aout_instance_t *, aout_input_t *, aout_buffer_t * ) ); VLC_EXPORT( int, aout_DecPlay, ( aout_instance_t *, aout_input_t *, aout_buffer_t * ) );
/* From intf.c : */ /* From intf.c : */
VLC_EXPORT( int, aout_VolumeGet, ( aout_instance_t *, audio_volume_t * ) ); #define aout_VolumeGet(a, b) __aout_VolumeGet(VLC_OBJECT(a), b)
VLC_EXPORT( int, aout_VolumeSet, ( aout_instance_t *, audio_volume_t ) ); VLC_EXPORT( int, __aout_VolumeGet, ( vlc_object_t *, audio_volume_t * ) );
VLC_EXPORT( int, aout_VolumeInfos, ( aout_instance_t *, audio_volume_t * ) ); #define aout_VolumeSet(a, b) __aout_VolumeSet(VLC_OBJECT(a), b)
VLC_EXPORT( int, aout_VolumeUp, ( aout_instance_t *, int, audio_volume_t * ) ); VLC_EXPORT( int, __aout_VolumeSet, ( vlc_object_t *, audio_volume_t ) );
VLC_EXPORT( int, aout_VolumeDown, ( aout_instance_t *, int, audio_volume_t * ) ); #define aout_VolumeInfos(a, b) __aout_VolumeInfos(VLC_OBJECT(a), b)
VLC_EXPORT( int, aout_VolumeMute, ( aout_instance_t *, audio_volume_t * ) ); VLC_EXPORT( int, __aout_VolumeInfos, ( vlc_object_t *, audio_volume_t * ) );
#define aout_VolumeUp(a, b, c) __aout_VolumeUp(VLC_OBJECT(a), b, c)
VLC_EXPORT( int, __aout_VolumeUp, ( vlc_object_t *, int, audio_volume_t * ) );
#define aout_VolumeDown(a, b, c) __aout_VolumeDown(VLC_OBJECT(a), b, c)
VLC_EXPORT( int, __aout_VolumeDown, ( vlc_object_t *, int, audio_volume_t * ) );
#define aout_VolumeMute(a, b) __aout_VolumeMute(VLC_OBJECT(a), b)
VLC_EXPORT( int, __aout_VolumeMute, ( vlc_object_t *, audio_volume_t * ) );
VLC_EXPORT( int, aout_Restart, ( aout_instance_t * p_aout ) ); VLC_EXPORT( int, aout_Restart, ( aout_instance_t * p_aout ) );
VLC_EXPORT( void, aout_FindAndRestart, ( vlc_object_t * p_this ) ); VLC_EXPORT( void, aout_FindAndRestart, ( vlc_object_t * p_this ) );
VLC_EXPORT( int, aout_ChannelsRestart, ( vlc_object_t *, const char *, vlc_value_t, vlc_value_t, void * ) ); VLC_EXPORT( int, aout_ChannelsRestart, ( vlc_object_t *, const char *, vlc_value_t, vlc_value_t, void * ) );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* rc.c : remote control stdin/stdout plugin for vlc * rc.c : remote control stdin/stdout plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: rc.c,v 1.24 2003/02/06 23:59:40 sam Exp $ * $Id: rc.c,v 1.25 2003/02/09 01:13:43 massiot Exp $
* *
* Authors: Peter Surda <shurdeek@panorama.sth.ac.at> * Authors: Peter Surda <shurdeek@panorama.sth.ac.at>
* *
...@@ -681,10 +681,7 @@ static int Intf( vlc_object_t *p_this, char const *psz_cmd, ...@@ -681,10 +681,7 @@ static int Intf( vlc_object_t *p_this, char const *psz_cmd,
static int Volume( vlc_object_t *p_this, char const *psz_cmd, static int Volume( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data ) vlc_value_t oldval, vlc_value_t newval, void *p_data )
{ {
aout_instance_t * p_aout;
int i_error; int i_error;
p_aout = vlc_object_find( p_this, VLC_OBJECT_AOUT, FIND_ANYWHERE );
if ( p_aout == NULL ) return VLC_ENOOBJ;
if ( *newval.psz_string ) if ( *newval.psz_string )
{ {
...@@ -696,13 +693,13 @@ static int Volume( vlc_object_t *p_this, char const *psz_cmd, ...@@ -696,13 +693,13 @@ static int Volume( vlc_object_t *p_this, char const *psz_cmd,
AOUT_VOLUME_MAX ); AOUT_VOLUME_MAX );
i_error = VLC_EBADVAR; i_error = VLC_EBADVAR;
} }
else i_error = aout_VolumeSet( p_aout, i_volume ); else i_error = aout_VolumeSet( p_this, i_volume );
} }
else else
{ {
/* Get. */ /* Get. */
audio_volume_t i_volume; audio_volume_t i_volume;
if ( aout_VolumeGet( p_aout, &i_volume ) < 0 ) if ( aout_VolumeGet( p_this, &i_volume ) < 0 )
{ {
i_error = VLC_EGENERIC; i_error = VLC_EGENERIC;
} }
...@@ -712,7 +709,6 @@ static int Volume( vlc_object_t *p_this, char const *psz_cmd, ...@@ -712,7 +709,6 @@ static int Volume( vlc_object_t *p_this, char const *psz_cmd,
i_error = VLC_SUCCESS; i_error = VLC_SUCCESS;
} }
} }
vlc_object_release( (vlc_object_t *)p_aout );
return i_error; return i_error;
} }
...@@ -720,7 +716,6 @@ static int Volume( vlc_object_t *p_this, char const *psz_cmd, ...@@ -720,7 +716,6 @@ static int Volume( vlc_object_t *p_this, char const *psz_cmd,
static int VolumeMove( vlc_object_t *p_this, char const *psz_cmd, static int VolumeMove( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data ) vlc_value_t oldval, vlc_value_t newval, void *p_data )
{ {
aout_instance_t * p_aout;
audio_volume_t i_volume; audio_volume_t i_volume;
int i_nb_steps = atoi(newval.psz_string); int i_nb_steps = atoi(newval.psz_string);
int i_error = VLC_SUCCESS; int i_error = VLC_SUCCESS;
...@@ -730,20 +725,16 @@ static int VolumeMove( vlc_object_t *p_this, char const *psz_cmd, ...@@ -730,20 +725,16 @@ static int VolumeMove( vlc_object_t *p_this, char const *psz_cmd,
i_nb_steps = 1; i_nb_steps = 1;
} }
p_aout = vlc_object_find( p_this, VLC_OBJECT_AOUT, FIND_ANYWHERE );
if ( p_aout == NULL ) return VLC_ENOOBJ;
if ( !strcmp(psz_cmd, "volup") ) if ( !strcmp(psz_cmd, "volup") )
{ {
if ( aout_VolumeUp( p_aout, i_nb_steps, &i_volume ) < 0 ) if ( aout_VolumeUp( p_this, i_nb_steps, &i_volume ) < 0 )
i_error = VLC_EGENERIC; i_error = VLC_EGENERIC;
} }
else else
{ {
if ( aout_VolumeDown( p_aout, i_nb_steps, &i_volume ) < 0 ) if ( aout_VolumeDown( p_this, i_nb_steps, &i_volume ) < 0 )
i_error = VLC_EGENERIC; i_error = VLC_EGENERIC;
} }
vlc_object_release( (vlc_object_t *)p_aout );
if ( !i_error ) printf( "Volume is %d\n", i_volume ); if ( !i_error ) printf( "Volume is %d\n", i_volume );
return i_error; return i_error;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* controls.m: MacOS X interface plugin * controls.m: MacOS X interface plugin
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: controls.m,v 1.23 2003/02/08 19:10:21 massiot Exp $ * $Id: controls.m,v 1.24 2003/02/09 01:13:43 massiot Exp $
* *
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net> * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Christophe Massiot <massiot@via.ecp.fr> * Christophe Massiot <massiot@via.ecp.fr>
...@@ -279,19 +279,13 @@ ...@@ -279,19 +279,13 @@
{ {
intf_thread_t * p_intf = [NSApp getIntf]; intf_thread_t * p_intf = [NSApp getIntf];
aout_instance_t * p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT, aout_VolumeUp( p_intf, 1, NULL );
FIND_ANYWHERE );
if( p_aout != NULL )
{
if( p_intf->p_sys->b_mute ) if( p_intf->p_sys->b_mute )
{ {
[self mute: nil]; [self mute: nil];
} }
aout_VolumeUp( p_aout, 1, NULL );
vlc_object_release( (vlc_object_t *)p_aout );
}
[self updateVolumeSlider]; [self updateVolumeSlider];
} }
...@@ -299,38 +293,23 @@ ...@@ -299,38 +293,23 @@
{ {
intf_thread_t * p_intf = [NSApp getIntf]; intf_thread_t * p_intf = [NSApp getIntf];
aout_instance_t * p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT, aout_VolumeDown( p_intf, 1, NULL );
FIND_ANYWHERE );
if( p_aout != NULL )
{
if( p_intf->p_sys->b_mute ) if( p_intf->p_sys->b_mute )
{ {
[self mute: nil]; [self mute: nil];
} }
aout_VolumeDown( p_aout, 1, NULL );
vlc_object_release( (vlc_object_t *)p_aout );
}
[self updateVolumeSlider]; [self updateVolumeSlider];
} }
- (IBAction)mute:(id)sender - (IBAction)mute:(id)sender
{ {
intf_thread_t * p_intf = [NSApp getIntf]; intf_thread_t * p_intf = [NSApp getIntf];
aout_instance_t * p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT,
FIND_ANYWHERE );
if ( p_aout != NULL )
{
audio_volume_t i_volume; audio_volume_t i_volume;
aout_VolumeMute( p_aout, &i_volume ); aout_VolumeMute( p_intf, &i_volume );
vlc_object_release( (vlc_object_t *)p_aout );
p_intf->p_sys->b_mute = ( i_volume == 0 ); p_intf->p_sys->b_mute = ( i_volume == 0 );
}
[self updateVolumeSlider]; [self updateVolumeSlider];
} }
...@@ -338,36 +317,19 @@ ...@@ -338,36 +317,19 @@
- (IBAction)volumeSliderUpdated:(id)sender - (IBAction)volumeSliderUpdated:(id)sender
{ {
intf_thread_t * p_intf = [NSApp getIntf]; intf_thread_t * p_intf = [NSApp getIntf];
audio_volume_t i_volume = (audio_volume_t)[sender intValue];
aout_instance_t * p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT, aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_STEP );
FIND_ANYWHERE );
if( p_aout != NULL )
{
audio_volume_t i_volume;
i_volume = (audio_volume_t)[sender intValue];
aout_VolumeSet( p_aout, i_volume * AOUT_VOLUME_STEP );
vlc_object_release( (vlc_object_t *)p_aout );
}
} }
- (void)updateVolumeSlider - (void)updateVolumeSlider
{ {
intf_thread_t * p_intf = [NSApp getIntf]; intf_thread_t * p_intf = [NSApp getIntf];
aout_instance_t * p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT,
FIND_ANYWHERE );
if ( p_aout != NULL )
{
audio_volume_t i_volume; audio_volume_t i_volume;
aout_VolumeGet( p_aout, &i_volume ); aout_VolumeGet( p_intf, &i_volume );
vlc_object_release( (vlc_object_t *)p_aout );
[o_volumeslider setFloatValue: (float)(i_volume / AOUT_VOLUME_STEP)]; [o_volumeslider setFloatValue: (float)(i_volume / AOUT_VOLUME_STEP)];
}
} }
- (IBAction)halfWindow:(id)sender - (IBAction)halfWindow:(id)sender
...@@ -718,37 +680,8 @@ ...@@ -718,37 +680,8 @@
[o_mi setState: i_state]; [o_mi setState: i_state];
} }
else if( [[o_mi title] isEqualToString: _NS("Volume Up")] ||
[[o_mi title] isEqualToString: _NS("Volume Down")] )
{
aout_instance_t * p_aout;
p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT,
FIND_ANYWHERE );
if( p_aout != NULL )
{
vlc_object_release( (vlc_object_t *)p_aout );
}
else
{
bEnabled = FALSE;
}
}
else if( [[o_mi title] isEqualToString: _NS("Mute")] ) else if( [[o_mi title] isEqualToString: _NS("Mute")] )
{ {
aout_instance_t * p_aout;
p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT,
FIND_ANYWHERE );
if( p_aout != NULL )
{
vlc_object_release( (vlc_object_t *)p_aout );
}
else
{
bEnabled = FALSE;
}
[o_mi setState: p_intf->p_sys->b_mute ? NSOnState : NSOffState]; [o_mi setState: p_intf->p_sys->b_mute ? NSOnState : NSOffState];
} }
else if( [[o_mi title] isEqualToString: _NS("Fullscreen")] || else if( [[o_mi title] isEqualToString: _NS("Fullscreen")] ||
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* intf.m: MacOS X interface plugin * intf.m: MacOS X interface plugin
***************************************************************************** *****************************************************************************
* Copyright (C) 2002-2003 VideoLAN * Copyright (C) 2002-2003 VideoLAN
* $Id: intf.m,v 1.50 2003/02/08 20:32:44 massiot Exp $ * $Id: intf.m,v 1.51 2003/02/09 01:13:43 massiot Exp $
* *
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net> * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Christophe Massiot <massiot@via.ecp.fr> * Christophe Massiot <massiot@via.ecp.fr>
...@@ -459,6 +459,8 @@ int ExecuteOnMainThread( id target, SEL sel, void * p_arg ) ...@@ -459,6 +459,8 @@ int ExecuteOnMainThread( id target, SEL sel, void * p_arg )
if( !p_input->b_die ) if( !p_input->b_die )
{ {
audio_volume_t i_volume;
/* New input or stream map change */ /* New input or stream map change */
if( p_input->stream.b_changed ) if( p_input->stream.b_changed )
{ {
...@@ -479,7 +481,6 @@ int ExecuteOnMainThread( id target, SEL sel, void * p_arg ) ...@@ -479,7 +481,6 @@ int ExecuteOnMainThread( id target, SEL sel, void * p_arg )
if( p_aout != NULL ) if( p_aout != NULL )
{ {
vlc_value_t val; vlc_value_t val;
audio_volume_t i_volume;
if( var_Get( (vlc_object_t *)p_aout, "intf-change", &val ) if( var_Get( (vlc_object_t *)p_aout, "intf-change", &val )
>= 0 && val.b_bool ) >= 0 && val.b_bool )
...@@ -487,12 +488,10 @@ int ExecuteOnMainThread( id target, SEL sel, void * p_arg ) ...@@ -487,12 +488,10 @@ int ExecuteOnMainThread( id target, SEL sel, void * p_arg )
p_intf->p_sys->b_aout_update = 1; p_intf->p_sys->b_aout_update = 1;
b_need_menus = VLC_TRUE; b_need_menus = VLC_TRUE;
} }
aout_VolumeGet( p_aout, &i_volume );
vlc_object_release( (vlc_object_t *)p_aout ); vlc_object_release( (vlc_object_t *)p_aout );
p_intf->p_sys->b_mute = ( i_volume == 0 );
} }
aout_VolumeGet( p_intf, &i_volume );
p_intf->p_sys->b_mute = ( i_volume == 0 );
p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT, p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
FIND_ANYWHERE ); FIND_ANYWHERE );
...@@ -834,25 +833,12 @@ int ExecuteOnMainThread( id target, SEL sel, void * p_arg ) ...@@ -834,25 +833,12 @@ int ExecuteOnMainThread( id target, SEL sel, void * p_arg )
- (void)manageVolumeSlider - (void)manageVolumeSlider
{ {
audio_volume_t i_volume; audio_volume_t i_volume;
vlc_bool_t b_audio = VLC_FALSE;
intf_thread_t * p_intf = [NSApp getIntf]; intf_thread_t * p_intf = [NSApp getIntf];
aout_instance_t * p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT, aout_VolumeGet( p_intf, &i_volume );
FIND_ANYWHERE );
if( p_aout != NULL )
{
b_audio = VLC_TRUE;
aout_VolumeGet( p_aout, &i_volume );
vlc_object_release( (vlc_object_t *)p_aout );
}
else
{
i_volume = (audio_volume_t)config_GetInt( p_intf, "volume" );
}
[o_volumeslider setFloatValue: (float)i_volume / AOUT_VOLUME_STEP]; [o_volumeslider setFloatValue: (float)i_volume / AOUT_VOLUME_STEP];
[o_volumeslider setEnabled: b_audio]; [o_volumeslider setEnabled: 1];
p_intf->p_sys->b_mute = ( i_volume == 0 ); p_intf->p_sys->b_mute = ( i_volume == 0 );
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* intf.c : audio output API towards the interface modules * intf.c : audio output API towards the interface modules
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: intf.c,v 1.15 2003/01/21 10:29:12 massiot Exp $ * $Id: intf.c,v 1.16 2003/02/09 01:13:43 massiot Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -59,71 +59,64 @@ ...@@ -59,71 +59,64 @@
/***************************************************************************** /*****************************************************************************
* aout_VolumeGet : get the volume of the output device * aout_VolumeGet : get the volume of the output device
*****************************************************************************/ *****************************************************************************/
int aout_VolumeGet( aout_instance_t * p_aout, audio_volume_t * pi_volume ) int __aout_VolumeGet( vlc_object_t * p_object, audio_volume_t * pi_volume )
{ {
int i_result;
vlc_mutex_lock( &p_aout->mixer_lock );
if ( p_aout->mixer.b_error )
{
int i; int i;
/* The output module is destroyed. */
vlc_mutex_unlock( &p_aout->mixer_lock );
i = config_GetInt( p_aout, "volume" );
if (pi_volume != NULL ) *pi_volume = (audio_volume_t)i;
return 0;
}
i_result = p_aout->output.pf_volume_get( p_aout, pi_volume ); i = config_GetInt( p_object, "volume" );
if ( pi_volume != NULL ) *pi_volume = (audio_volume_t)i;
vlc_mutex_unlock( &p_aout->mixer_lock ); return 0;
return i_result;
} }
/***************************************************************************** /*****************************************************************************
* aout_VolumeSet : set the volume of the output device * aout_VolumeSet : set the volume of the output device
*****************************************************************************/ *****************************************************************************/
int aout_VolumeSet( aout_instance_t * p_aout, audio_volume_t i_volume ) int __aout_VolumeSet( vlc_object_t * p_object, audio_volume_t i_volume )
{ {
int i_result; aout_instance_t * p_aout = vlc_object_find( p_object, VLC_OBJECT_AOUT,
FIND_ANYWHERE );
int i_result = 0;
vlc_mutex_lock( &p_aout->mixer_lock ); config_PutInt( p_object, "volume", i_volume );
if ( p_aout->mixer.b_error ) if ( p_aout == NULL ) return 0;
{
/* The output module is destroyed. */
vlc_mutex_unlock( &p_aout->mixer_lock );
config_PutInt( p_aout, "volume", i_volume );
return 0;
}
vlc_mutex_lock( &p_aout->mixer_lock );
if ( !p_aout->mixer.b_error )
{
i_result = p_aout->output.pf_volume_set( p_aout, i_volume ); i_result = p_aout->output.pf_volume_set( p_aout, i_volume );
}
vlc_mutex_unlock( &p_aout->mixer_lock ); vlc_mutex_unlock( &p_aout->mixer_lock );
vlc_object_release( p_aout );
return i_result; return i_result;
} }
/***************************************************************************** /*****************************************************************************
* aout_VolumeInfos : get the boundary pi_soft * aout_VolumeInfos : get the boundary pi_soft
*****************************************************************************/ *****************************************************************************/
int aout_VolumeInfos( aout_instance_t * p_aout, audio_volume_t * pi_soft ) int __aout_VolumeInfos( vlc_object_t * p_object, audio_volume_t * pi_soft )
{ {
aout_instance_t * p_aout = vlc_object_find( p_object, VLC_OBJECT_AOUT,
FIND_ANYWHERE );
int i_result; int i_result;
vlc_mutex_lock( &p_aout->mixer_lock ); if ( p_aout == NULL ) return 0;
vlc_mutex_lock( &p_aout->mixer_lock );
if ( p_aout->mixer.b_error ) if ( p_aout->mixer.b_error )
{ {
/* The output module is destroyed. */ /* The output module is destroyed. */
vlc_mutex_unlock( &p_aout->mixer_lock ); i_result = -1;
msg_Err( p_aout, "VolumeInfos called without output module" );
return -1;
} }
else
{
i_result = p_aout->output.pf_volume_infos( p_aout, pi_soft ); i_result = p_aout->output.pf_volume_infos( p_aout, pi_soft );
}
vlc_mutex_unlock( &p_aout->mixer_lock ); vlc_mutex_unlock( &p_aout->mixer_lock );
vlc_object_release( p_aout );
return i_result; return i_result;
} }
...@@ -133,44 +126,32 @@ int aout_VolumeInfos( aout_instance_t * p_aout, audio_volume_t * pi_soft ) ...@@ -133,44 +126,32 @@ int aout_VolumeInfos( aout_instance_t * p_aout, audio_volume_t * pi_soft )
* If pi_volume != NULL, *pi_volume will contain the volume at the end of the * If pi_volume != NULL, *pi_volume will contain the volume at the end of the
* function. * function.
*****************************************************************************/ *****************************************************************************/
int aout_VolumeUp( aout_instance_t * p_aout, int i_nb_steps, int __aout_VolumeUp( vlc_object_t * p_object, int i_nb_steps,
audio_volume_t * pi_volume ) audio_volume_t * pi_volume )
{ {
int i_result; aout_instance_t * p_aout = vlc_object_find( p_object, VLC_OBJECT_AOUT,
audio_volume_t i_volume; FIND_ANYWHERE );
int i_result = 0, i;
vlc_mutex_lock( &p_aout->mixer_lock );
if ( p_aout->mixer.b_error ) i = config_GetInt( p_object, "volume" );
{
int i;
/* The output module is destroyed. */
vlc_mutex_unlock( &p_aout->mixer_lock );
i = config_GetInt( p_aout, "volume" );
i += AOUT_VOLUME_STEP * i_nb_steps; i += AOUT_VOLUME_STEP * i_nb_steps;
if ( i > AOUT_VOLUME_MAX ) if ( i > AOUT_VOLUME_MAX )
{ {
i = AOUT_VOLUME_MAX; i = AOUT_VOLUME_MAX;
} }
config_PutInt( p_aout, "volume", i ); config_PutInt( p_object, "volume", i );
if ( pi_volume != NULL ) *pi_volume = (audio_volume_t)i; if ( pi_volume != NULL ) *pi_volume = (audio_volume_t)i;
return 0;
}
if ( p_aout->output.pf_volume_get( p_aout, &i_volume ) ) if ( p_aout == NULL ) return 0;
vlc_mutex_lock( &p_aout->mixer_lock );
if ( !p_aout->mixer.b_error )
{ {
vlc_mutex_unlock( &p_aout->mixer_lock ); i_result = p_aout->output.pf_volume_set( p_aout, (audio_volume_t)i );
return -1;
} }
i_volume += AOUT_VOLUME_STEP * i_nb_steps;
if ( i_volume > AOUT_VOLUME_MAX ) i_volume = AOUT_VOLUME_MAX;
i_result = p_aout->output.pf_volume_set( p_aout, i_volume );
vlc_mutex_unlock( &p_aout->mixer_lock ); vlc_mutex_unlock( &p_aout->mixer_lock );
if ( pi_volume != NULL ) *pi_volume = i_volume; vlc_object_release( p_aout );
return i_result; return i_result;
} }
...@@ -180,46 +161,32 @@ int aout_VolumeUp( aout_instance_t * p_aout, int i_nb_steps, ...@@ -180,46 +161,32 @@ int aout_VolumeUp( aout_instance_t * p_aout, int i_nb_steps,
* If pi_volume != NULL, *pi_volume will contain the volume at the end of the * If pi_volume != NULL, *pi_volume will contain the volume at the end of the
* function. * function.
*****************************************************************************/ *****************************************************************************/
int aout_VolumeDown( aout_instance_t * p_aout, int i_nb_steps, int __aout_VolumeDown( vlc_object_t * p_object, int i_nb_steps,
audio_volume_t * pi_volume ) audio_volume_t * pi_volume )
{ {
int i_result; aout_instance_t * p_aout = vlc_object_find( p_object, VLC_OBJECT_AOUT,
audio_volume_t i_volume; FIND_ANYWHERE );
int i_result = 0, i;
vlc_mutex_lock( &p_aout->mixer_lock );
if ( p_aout->mixer.b_error ) i = config_GetInt( p_object, "volume" );
{
int i;
/* The output module is destroyed. */
vlc_mutex_unlock( &p_aout->mixer_lock );
i = config_GetInt( p_aout, "volume" );
i -= AOUT_VOLUME_STEP * i_nb_steps; i -= AOUT_VOLUME_STEP * i_nb_steps;
if ( i < 0 ) if ( i < AOUT_VOLUME_MIN )
{ {
i = AOUT_VOLUME_MAX; i = AOUT_VOLUME_MIN;
} }
config_PutInt( p_aout, "volume", i ); config_PutInt( p_object, "volume", i );
if ( pi_volume != NULL ) *pi_volume = (audio_volume_t)i; if ( pi_volume != NULL ) *pi_volume = (audio_volume_t)i;
return 0;
}
if ( p_aout->output.pf_volume_get( p_aout, &i_volume ) ) if ( p_aout == NULL ) return 0;
vlc_mutex_lock( &p_aout->mixer_lock );
if ( !p_aout->mixer.b_error )
{ {
vlc_mutex_unlock( &p_aout->mixer_lock ); i_result = p_aout->output.pf_volume_set( p_aout, (audio_volume_t)i );
return -1;
} }
if ( i_volume < AOUT_VOLUME_STEP * i_nb_steps )
i_volume = 0;
else
i_volume -= AOUT_VOLUME_STEP * i_nb_steps;
i_result = p_aout->output.pf_volume_set( p_aout, i_volume );
vlc_mutex_unlock( &p_aout->mixer_lock ); vlc_mutex_unlock( &p_aout->mixer_lock );
if ( pi_volume != NULL ) *pi_volume = i_volume; vlc_object_release( p_aout );
return i_result; return i_result;
} }
...@@ -229,43 +196,27 @@ int aout_VolumeDown( aout_instance_t * p_aout, int i_nb_steps, ...@@ -229,43 +196,27 @@ int aout_VolumeDown( aout_instance_t * p_aout, int i_nb_steps,
* If pi_volume != NULL, *pi_volume will contain the volume at the end of the * If pi_volume != NULL, *pi_volume will contain the volume at the end of the
* function (muted => 0). * function (muted => 0).
*****************************************************************************/ *****************************************************************************/
int aout_VolumeMute( aout_instance_t * p_aout, audio_volume_t * pi_volume ) int __aout_VolumeMute( vlc_object_t * p_object, audio_volume_t * pi_volume )
{ {
int i_result; int i_result;
audio_volume_t i_volume; audio_volume_t i_volume;
vlc_mutex_lock( &p_aout->mixer_lock ); i_volume = (audio_volume_t)config_GetInt( p_object, "volume" );
if ( i_volume != 0 )
if ( p_aout->mixer.b_error )
{
/* The output module is destroyed. */
vlc_mutex_unlock( &p_aout->mixer_lock );
config_PutInt( p_aout, "volume", 0 );
if ( pi_volume != NULL ) *pi_volume = 0;
return 0;
}
if ( p_aout->output.pf_volume_get( p_aout, &i_volume ) )
{
vlc_mutex_unlock( &p_aout->mixer_lock );
return -1;
}
if ( i_volume == 0 )
{ {
i_volume = p_aout->output.i_saved_volume; /* Mute */
i_result = aout_VolumeSet( p_object, AOUT_VOLUME_MIN );
config_PutInt( p_object, "saved-volume", (int)i_volume );
if ( pi_volume != NULL ) *pi_volume = AOUT_VOLUME_MIN;
} }
else else
{ {
p_aout->output.i_saved_volume = i_volume; /* Un-mute */
i_volume = 0; i_volume = (audio_volume_t)config_GetInt( p_object, "saved-volume" );
i_result = aout_VolumeSet( p_object, i_volume );
if ( pi_volume != NULL ) *pi_volume = i_volume;
} }
i_result = p_aout->output.pf_volume_set( p_aout, i_volume );
vlc_mutex_unlock( &p_aout->mixer_lock );
if ( pi_volume != NULL ) *pi_volume = i_volume;
return i_result; return i_result;
} }
...@@ -284,7 +235,7 @@ void aout_VolumeSoftInit( aout_instance_t * p_aout ) ...@@ -284,7 +235,7 @@ void aout_VolumeSoftInit( aout_instance_t * p_aout )
p_aout->output.pf_volume_set = aout_VolumeSoftSet; p_aout->output.pf_volume_set = aout_VolumeSoftSet;
i_volume = config_GetInt( p_aout, "volume" ); i_volume = config_GetInt( p_aout, "volume" );
if ( i_volume < 0 ) if ( i_volume < AOUT_VOLUME_MIN )
{ {
i_volume = AOUT_VOLUME_DEFAULT; i_volume = AOUT_VOLUME_DEFAULT;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* libvlc.h: main libvlc header * libvlc.h: main libvlc header
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2002 VideoLAN * Copyright (C) 1998-2002 VideoLAN
* $Id: libvlc.h,v 1.41 2003/02/08 19:10:22 massiot Exp $ * $Id: libvlc.h,v 1.42 2003/02/09 01:13:43 massiot Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -89,6 +89,10 @@ static char *ppsz_sout_vcodec[] = { "", "mpeg1", "mpeg2", "mpeg4", NULL }; ...@@ -89,6 +89,10 @@ static char *ppsz_sout_vcodec[] = { "", "mpeg1", "mpeg2", "mpeg4", NULL };
"You can set the default audio output volume here, in a range from 0 to " \ "You can set the default audio output volume here, in a range from 0 to " \
"1024.") "1024.")
#define VOLUME_SAVE_TEXT N_("audio output saved volume")
#define VOLUME_SAVE_LONGTEXT N_( \
"This saves the audio output volume when you select mute.")
#define AOUT_RATE_TEXT N_("audio output frequency (Hz)") #define AOUT_RATE_TEXT N_("audio output frequency (Hz)")
#define AOUT_RATE_LONGTEXT N_( \ #define AOUT_RATE_LONGTEXT N_( \
"You can force the audio output frequency here. Common values are " \ "You can force the audio output frequency here. Common values are " \
...@@ -438,7 +442,12 @@ vlc_module_begin(); ...@@ -438,7 +442,12 @@ vlc_module_begin();
add_module_with_short( "aout", 'A', "audio output", NULL, NULL, add_module_with_short( "aout", 'A', "audio output", NULL, NULL,
AOUT_TEXT, AOUT_LONGTEXT ); AOUT_TEXT, AOUT_LONGTEXT );
add_bool( "audio", 1, NULL, AUDIO_TEXT, AUDIO_LONGTEXT ); add_bool( "audio", 1, NULL, AUDIO_TEXT, AUDIO_LONGTEXT );
add_integer_with_range( "volume", 256, 0, 1024, NULL, VOLUME_TEXT, VOLUME_LONGTEXT ); add_integer_with_range( "volume", AOUT_VOLUME_DEFAULT, AOUT_VOLUME_MIN,
AOUT_VOLUME_MAX, NULL, VOLUME_TEXT,
VOLUME_LONGTEXT );
add_integer_with_range( "saved-volume", AOUT_VOLUME_DEFAULT,
AOUT_VOLUME_MIN, AOUT_VOLUME_MAX, NULL,
VOLUME_SAVE_TEXT, VOLUME_SAVE_LONGTEXT );
add_integer( "aout-rate", -1, NULL, AOUT_RATE_TEXT, AOUT_RATE_LONGTEXT ); add_integer( "aout-rate", -1, NULL, AOUT_RATE_TEXT, AOUT_RATE_LONGTEXT );
add_integer( "desync", 0, NULL, DESYNC_TEXT, DESYNC_LONGTEXT ); add_integer( "desync", 0, NULL, DESYNC_TEXT, DESYNC_LONGTEXT );
add_bool( "headphone", 0, NULL, HEADPHONE_TEXT, HEADPHONE_LONGTEXT ); add_bool( "headphone", 0, NULL, HEADPHONE_TEXT, HEADPHONE_LONGTEXT );
......
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