]> git.sesse.net Git - vlc/commitdiff
Pass mute flag to aout_output_t.pf_volume_set
authorRémi Denis-Courmont <remi@remlab.net>
Thu, 7 Apr 2011 20:36:00 +0000 (23:36 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 7 Apr 2011 20:36:00 +0000 (23:36 +0300)
This improves mute flag handling in the PulseAudio output:
We do not blindly reset the mute flag.

include/vlc_aout.h
modules/audio_output/pulse.c
modules/audio_output/waveout.c
src/audio_output/aout_internal.h
src/audio_output/intf.c

index 20bc45586ce5ed2c51b27a8661d340e45c7ff097..3bb3265c16f1e30798fae207e9384435d0826d2f 100644 (file)
@@ -198,7 +198,7 @@ typedef struct aout_output_t
     struct module_t *       p_module;
     struct aout_sys_t *     p_sys;
     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;
 
     /* Current volume for the output - it's just a placeholder, the plug-in
index 809f0f626b6d838fba3766b3c2c5462c077e5a86..b212d95ee087071314f94803a1312b2f52a9e187 100644 (file)
@@ -258,7 +258,7 @@ static void Play(aout_instance_t *aout)
     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;
@@ -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);
     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);
index 36b8ae431b018326a7897e02907ea26a7272c409..a5f6e0411e4427f7495fd4784a549372153173af 100644 (file)
@@ -1019,8 +1019,12 @@ static void* WaveOutThread( vlc_object_t *p_this )
     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;
     i_waveout_vol |= (i_waveout_vol << 16);
 
@@ -1029,8 +1033,6 @@ static int VolumeSet( aout_instance_t * p_aout, audio_volume_t i_volume )
 #else
     waveOutSetVolume( p_aout->output.p_sys->h_waveout, i_waveout_vol );
 #endif
-
-    p_aout->output.i_volume = i_volume;
     return 0;
 }
 
index 8a648eb43cbc8cab3ae25956ad35f853517a65a4..004eed35c5af8659abcfbe18133a262a13ab675e 100644 (file)
@@ -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 );
 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 * );
index 8265d184bdfe80b9e4380e436f7181f0cab956a5..776e11ffb34a7d6c788ef205d8eccad30eaf2ab4 100644 (file)
@@ -81,8 +81,6 @@ static int commitVolume (vlc_object_t *obj, aout_instance_t *aout,
     int ret = 0;
 
     var_SetInteger (obj, "volume", volume);
-    if (mute)
-        volume = AOUT_VOLUME_MIN;
     var_SetBool (obj, "mute", mute);
 
     if (aout != NULL)
@@ -90,7 +88,7 @@ static int commitVolume (vlc_object_t *obj, aout_instance_t *aout,
         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);
 
@@ -229,43 +227,41 @@ int aout_SetMute (vlc_object_t *obj, audio_volume_t *volp, bool mute)
     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 )
@@ -273,13 +269,6 @@ 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