Commit 28ef0fe1 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Pass mute flag to aout_output_t.pf_volume_set

This improves mute flag handling in the PulseAudio output:
We do not blindly reset the mute flag.
parent 475e356c
...@@ -198,7 +198,7 @@ typedef struct aout_output_t ...@@ -198,7 +198,7 @@ typedef struct aout_output_t
struct module_t * p_module; struct module_t * p_module;
struct aout_sys_t * p_sys; struct aout_sys_t * p_sys;
void (* pf_play)( aout_instance_t * ); void (* pf_play)( aout_instance_t * );
int (* pf_volume_set )( aout_instance_t *, audio_volume_t ); int (* pf_volume_set )( aout_instance_t *, audio_volume_t, bool );
int i_nb_samples; int i_nb_samples;
/* 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
......
...@@ -258,7 +258,7 @@ static void Play(aout_instance_t *aout) ...@@ -258,7 +258,7 @@ static void Play(aout_instance_t *aout)
pa_threaded_mainloop_unlock(sys->mainloop); pa_threaded_mainloop_unlock(sys->mainloop);
} }
static int VolumeSet(aout_instance_t *aout, audio_volume_t vol) static int VolumeSet(aout_instance_t *aout, audio_volume_t vol, bool mute)
{ {
aout_sys_t *sys = aout->output.p_sys; aout_sys_t *sys = aout->output.p_sys;
pa_threaded_mainloop *mainloop = sys->mainloop; pa_threaded_mainloop *mainloop = sys->mainloop;
...@@ -278,8 +278,7 @@ static int VolumeSet(aout_instance_t *aout, audio_volume_t vol) ...@@ -278,8 +278,7 @@ static int VolumeSet(aout_instance_t *aout, audio_volume_t vol)
op = pa_context_set_sink_input_volume(sys->context, idx, &cvolume, NULL, NULL); op = pa_context_set_sink_input_volume(sys->context, idx, &cvolume, NULL, NULL);
if (likely(op != NULL)) if (likely(op != NULL))
pa_operation_unref(op); pa_operation_unref(op);
op = pa_context_set_sink_input_mute(sys->context, idx, volume == PA_VOLUME_MUTED, op = pa_context_set_sink_input_mute(sys->context, idx, mute, NULL, NULL);
NULL, NULL);
if (likely(op != NULL)) if (likely(op != NULL))
pa_operation_unref(op); pa_operation_unref(op);
pa_threaded_mainloop_unlock(mainloop); pa_threaded_mainloop_unlock(mainloop);
......
...@@ -1019,8 +1019,12 @@ static void* WaveOutThread( vlc_object_t *p_this ) ...@@ -1019,8 +1019,12 @@ static void* WaveOutThread( vlc_object_t *p_this )
return NULL; return NULL;
} }
static int VolumeSet( aout_instance_t * p_aout, audio_volume_t i_volume ) static int VolumeSet( aout_instance_t * p_aout, audio_volume_t i_volume,
bool mute )
{ {
if( mute )
i_volume = AOUT_VOLUME_MIN;
unsigned long i_waveout_vol = i_volume * 0xFFFF * 2 / AOUT_VOLUME_MAX; unsigned long i_waveout_vol = i_volume * 0xFFFF * 2 / AOUT_VOLUME_MAX;
i_waveout_vol |= (i_waveout_vol << 16); i_waveout_vol |= (i_waveout_vol << 16);
...@@ -1029,8 +1033,6 @@ static int VolumeSet( aout_instance_t * p_aout, audio_volume_t i_volume ) ...@@ -1029,8 +1033,6 @@ static int VolumeSet( aout_instance_t * p_aout, audio_volume_t i_volume )
#else #else
waveOutSetVolume( p_aout->output.p_sys->h_waveout, i_waveout_vol ); waveOutSetVolume( p_aout->output.p_sys->h_waveout, i_waveout_vol );
#endif #endif
p_aout->output.i_volume = i_volume;
return 0; return 0;
} }
......
...@@ -140,10 +140,6 @@ void aout_FifoDestroy( aout_instance_t * p_aout, aout_fifo_t * p_fifo ); ...@@ -140,10 +140,6 @@ void aout_FifoDestroy( aout_instance_t * p_aout, aout_fifo_t * p_fifo );
void aout_FormatsPrint( aout_instance_t * p_aout, const char * psz_text, const audio_sample_format_t * p_format1, const audio_sample_format_t * p_format2 ); void aout_FormatsPrint( aout_instance_t * p_aout, const char * psz_text, const audio_sample_format_t * p_format1, const audio_sample_format_t * p_format2 );
bool aout_ChangeFilterString( vlc_object_t *, aout_instance_t *, const char *psz_variable, const char *psz_name, bool b_add ); bool aout_ChangeFilterString( vlc_object_t *, aout_instance_t *, const char *psz_variable, const char *psz_name, bool b_add );
/* From intf.c :*/
int aout_VolumeSoftSet( aout_instance_t *, audio_volume_t );
int aout_VolumeNoneSet( aout_instance_t *, audio_volume_t );
/* From dec.c */ /* From dec.c */
aout_input_t *aout_DecNew( aout_instance_t *, audio_sample_format_t *, aout_input_t *aout_DecNew( aout_instance_t *, audio_sample_format_t *,
const audio_replay_gain_t *, const aout_request_vout_t * ); const audio_replay_gain_t *, const aout_request_vout_t * );
......
...@@ -81,8 +81,6 @@ static int commitVolume (vlc_object_t *obj, aout_instance_t *aout, ...@@ -81,8 +81,6 @@ static int commitVolume (vlc_object_t *obj, aout_instance_t *aout,
int ret = 0; int ret = 0;
var_SetInteger (obj, "volume", volume); var_SetInteger (obj, "volume", volume);
if (mute)
volume = AOUT_VOLUME_MIN;
var_SetBool (obj, "mute", mute); var_SetBool (obj, "mute", mute);
if (aout != NULL) if (aout != NULL)
...@@ -90,7 +88,7 @@ static int commitVolume (vlc_object_t *obj, aout_instance_t *aout, ...@@ -90,7 +88,7 @@ static int commitVolume (vlc_object_t *obj, aout_instance_t *aout,
aout_lock_mixer (aout); aout_lock_mixer (aout);
aout_lock_input_fifos (aout); aout_lock_input_fifos (aout);
if (aout->p_mixer != NULL) if (aout->p_mixer != NULL)
ret = aout->output.pf_volume_set (aout, volume); ret = aout->output.pf_volume_set (aout, volume, mute);
aout_unlock_input_fifos (aout); aout_unlock_input_fifos (aout);
aout_unlock_mixer (aout); aout_unlock_mixer (aout);
...@@ -229,43 +227,41 @@ int aout_SetMute (vlc_object_t *obj, audio_volume_t *volp, bool mute) ...@@ -229,43 +227,41 @@ int aout_SetMute (vlc_object_t *obj, audio_volume_t *volp, bool mute)
return ret; return ret;
} }
/* /*
* The next functions are not supposed to be called by the interface, but * The next functions are not supposed to be called by the interface, but
* are placeholders for software-only scaling. * are placeholders for software-only scaling.
*/ */
static int aout_VolumeSoftSet (aout_instance_t *aout, audio_volume_t volume,
bool mute)
{
float f = mute ? 0. : (volume / (float)AOUT_VOLUME_DEFAULT);
aout_MixerMultiplierSet (aout, f);
aout->output.i_volume = volume;
return 0;
}
/* Meant to be called by the output plug-in's Open(). */ /* Meant to be called by the output plug-in's Open(). */
void aout_VolumeSoftInit( aout_instance_t * p_aout ) void aout_VolumeSoftInit (aout_instance_t *aout)
{ {
int i_volume; audio_volume_t volume = var_InheritInteger (aout, "volume");
bool mute = var_InheritBool (aout, "mute");
p_aout->output.pf_volume_set = aout_VolumeSoftSet;
i_volume = var_InheritInteger( p_aout, "volume" );
if ( i_volume < AOUT_VOLUME_MIN )
{
i_volume = AOUT_VOLUME_DEFAULT;
}
else if ( i_volume > AOUT_VOLUME_MAX )
{
i_volume = AOUT_VOLUME_MAX;
}
aout_VolumeSoftSet( p_aout, (audio_volume_t)i_volume ); aout->output.pf_volume_set = aout_VolumeSoftSet;
aout_VolumeSoftSet (aout, volume, mute);
} }
/* Placeholder for pf_volume_set(). */
int aout_VolumeSoftSet( aout_instance_t * p_aout, audio_volume_t i_volume )
{
aout_MixerMultiplierSet( p_aout, (float)i_volume / AOUT_VOLUME_DEFAULT );
p_aout->output.i_volume = i_volume;
return 0;
}
/* /*
* The next functions are not supposed to be called by the interface, but * The next functions are not supposed to be called by the interface, but
* are placeholders for unsupported scaling. * are placeholders for unsupported scaling.
*/ */
static int aout_VolumeNoneSet (aout_instance_t *aout, audio_volume_t volume,
bool mute)
{
(void)aout; (void)volume; (void)mute;
return -1;
}
/* Meant to be called by the output plug-in's Open(). */ /* Meant to be called by the output plug-in's Open(). */
void aout_VolumeNoneInit( aout_instance_t * p_aout ) void aout_VolumeNoneInit( aout_instance_t * p_aout )
...@@ -273,13 +269,6 @@ void aout_VolumeNoneInit( aout_instance_t * p_aout ) ...@@ -273,13 +269,6 @@ void aout_VolumeNoneInit( aout_instance_t * p_aout )
p_aout->output.pf_volume_set = aout_VolumeNoneSet; p_aout->output.pf_volume_set = aout_VolumeNoneSet;
} }
/* Placeholder for pf_volume_set(). */
int aout_VolumeNoneSet( aout_instance_t * p_aout, audio_volume_t i_volume )
{
(void)p_aout; (void)i_volume;
return -1;
}
/* /*
* Pipelines management * Pipelines management
......
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