[vlc-commits] aout: implement changing of software gain while not playing

Rémi Denis-Courmont git at videolan.org
Wed Oct 31 19:33:11 CET 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Oct 31 20:32:28 2012 +0200| [0c3c36fd010c21305a49bd2d919877890f731429] | committer: Rémi Denis-Courmont

aout: implement changing of software gain while not playing

This concerns ALSA, AudioQueue, JACK and KAI.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0c3c36fd010c21305a49bd2d919877890f731429
---

 modules/audio_output/alsa.c       |    1 +
 modules/audio_output/audioqueue.c |    1 +
 modules/audio_output/jack.c       |    2 +-
 modules/audio_output/kai.c        |    4 ++--
 modules/audio_output/volume.h     |   17 +++++++++++------
 5 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c
index 0acd138..aa056a1 100644
--- a/modules/audio_output/alsa.c
+++ b/modules/audio_output/alsa.c
@@ -531,6 +531,7 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
     var_AddCallback (aout, "audio-device", DeviceChanged, NULL);
 
     free (device);
+    aout_SoftVolumeStart (aout);
     return 0;
 
 error:
diff --git a/modules/audio_output/audioqueue.c b/modules/audio_output/audioqueue.c
index b3eb68f..802d839 100644
--- a/modules/audio_output/audioqueue.c
+++ b/modules/audio_output/audioqueue.c
@@ -126,6 +126,7 @@ static int Start( audio_output_t *aout, audio_sample_format_t *restrict fmt )
     p_aout->play = aout_PacketPlay;
     p_aout->pause = aout_PacketPause;
     p_aout->flush = aout_PacketFlush;
+    aout_SoftVolumeStart(p_aout);
 
     msg_Dbg(p_aout, "Starting AudioQueue (status = %i)", status);
     status = AudioQueueStart(p_sys->audioQueue, NULL);
diff --git a/modules/audio_output/jack.c b/modules/audio_output/jack.c
index 4b641a1..b07536a 100644
--- a/modules/audio_output/jack.c
+++ b/modules/audio_output/jack.c
@@ -137,7 +137,7 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
     p_aout->flush = aout_PacketFlush;
     aout_PacketInit( p_aout, &p_sys->packet,
                      jack_get_buffer_size( p_sys->p_jack_client ), fmt );
-    aout_SoftVolumeInit( p_aout );
+    aout_SoftVolumeStart( p_aout );
 
     p_sys->i_channels = aout_FormatNbChannels( fmt );
 
diff --git a/modules/audio_output/kai.c b/modules/audio_output/kai.c
index 3cac90a1..935ffd3 100644
--- a/modules/audio_output/kai.c
+++ b/modules/audio_output/kai.c
@@ -204,10 +204,10 @@ static int Start ( audio_output_t *p_aout, audio_sample_format_t *fmt )
     p_aout->play  = Play;
     p_aout->pause = aout_PacketPause;
     p_aout->flush = aout_PacketFlush;
+    aout_SoftVolumeStart( p_aout );
 
     aout_PacketInit( p_aout, &p_sys->packet,
                      ks_obtained.ulBufferSize / i_bytes_per_frame );
-    aout_SoftVolumeInit( p_aout );
 
     if ( var_Type( p_aout, "audio-device" ) == 0 )
     {
@@ -343,8 +343,8 @@ static int Open (vlc_object_t *obj)
 {
     audio_output_t *aout = (audio_output_t *)obj;
 
-    /* FIXME: set volume/mute here */
     aout->start = Start;
     aout->stop = Stop;
+    aout_SoftVolumeInit( p_aout );
     return VLC_SUCCESS;
 }
diff --git a/modules/audio_output/volume.h b/modules/audio_output/volume.h
index 2c07a5e..94732dc 100644
--- a/modules/audio_output/volume.h
+++ b/modules/audio_output/volume.h
@@ -71,12 +71,6 @@ static void aout_SoftVolumeInit(audio_output_t *aout)
     float gain = var_InheritFloat(aout, MODULE_STRING"-gain");
     bool mute = var_InheritBool(aout, "mute");
 
-    if (aout_GainRequest(aout, mute ? 0.f : gain))
-    {
-        mute = false;
-        gain = 1.f;
-    }
-
     aout->volume_set = aout_SoftVolumeSet;
     aout->mute_set = aout_SoftMuteSet;
     sys->soft_gain = gain;
@@ -85,3 +79,14 @@ static void aout_SoftVolumeInit(audio_output_t *aout)
     aout_MuteReport(aout, mute);
     aout_VolumeReport(aout, cbrtf(gain));
 }
+
+static void aout_SoftVolumeStart (audio_output_t *aout)
+{
+    aout_sys_t *sys = aout->sys;
+
+    if (aout_GainRequest(aout, sys->soft_mute ? 0.f : sys->soft_gain))
+    {
+        aout_MuteReport(aout, false);
+        aout_VolumeReport(aout, 1.f);
+    }
+}



More information about the vlc-commits mailing list