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;
pa_threaded_mainloop *mainloop = sys->mainloop;
op = pa_context_set_sink_input_volume(sys->context, idx, &cvolume, NULL, NULL);
if (likely(op != NULL))
pa_operation_unref(op);
- op = pa_context_set_sink_input_mute(sys->context, idx, volume == PA_VOLUME_MUTED,
- NULL, NULL);
+ op = pa_context_set_sink_input_mute(sys->context, idx, mute, NULL, NULL);
if (likely(op != NULL))
pa_operation_unref(op);
pa_threaded_mainloop_unlock(mainloop);
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 );
-/* From intf.c :*/
-int aout_VolumeSoftSet( aout_instance_t *, audio_volume_t );
-int aout_VolumeNoneSet( aout_instance_t *, audio_volume_t );
-
/* From dec.c */
aout_input_t *aout_DecNew( aout_instance_t *, audio_sample_format_t *,
const audio_replay_gain_t *, const aout_request_vout_t * );
int ret = 0;
var_SetInteger (obj, "volume", volume);
- if (mute)
- volume = AOUT_VOLUME_MIN;
var_SetBool (obj, "mute", mute);
if (aout != NULL)
aout_lock_mixer (aout);
aout_lock_input_fifos (aout);
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_mixer (aout);
return ret;
}
+
/*
* The next functions are not supposed to be called by the interface, but
* 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(). */
-void aout_VolumeSoftInit( aout_instance_t * p_aout )
+void aout_VolumeSoftInit (aout_instance_t *aout)
{
- int i_volume;
-
- 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;
- }
+ audio_volume_t volume = var_InheritInteger (aout, "volume");
+ bool mute = var_InheritBool (aout, "mute");
- 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
* 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(). */
void aout_VolumeNoneInit( aout_instance_t * p_aout )
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