[vlc-commits] aout: add option to initialize hardware volume
Rémi Denis-Courmont
git at videolan.org
Sun May 6 15:34:29 CEST 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun May 6 16:27:51 2012 +0300| [1387f38f99d1c48b6355780c156fa0544b4a45b4] | committer: Rémi Denis-Courmont
aout: add option to initialize hardware volume
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1387f38f99d1c48b6355780c156fa0544b4a45b4
---
include/vlc_aout.h | 2 +-
modules/audio_output/auhal.c | 7 +------
modules/audio_output/pulse.c | 2 +-
modules/audio_output/waveout.c | 2 +-
src/audio_output/output.c | 11 ++++++++++-
5 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/include/vlc_aout.h b/include/vlc_aout.h
index 9545fec..e2ef668 100644
--- a/include/vlc_aout.h
+++ b/include/vlc_aout.h
@@ -221,7 +221,7 @@ VLC_API const char * aout_FormatPrintChannels( const audio_sample_format_t * ) V
VLC_API void aout_VolumeNoneInit( audio_output_t * );
VLC_API void aout_VolumeSoftInit( audio_output_t * );
-VLC_API void aout_VolumeHardInit( audio_output_t *, aout_volume_cb );
+VLC_API void aout_VolumeHardInit( audio_output_t *, aout_volume_cb, bool );
VLC_API void aout_VolumeHardSet( audio_output_t *, float, bool );
VLC_API void aout_TimeReport(audio_output_t *, mtime_t);
diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c
index f308aad..292995d 100644
--- a/modules/audio_output/auhal.c
+++ b/modules/audio_output/auhal.c
@@ -560,12 +560,7 @@ static int OpenAnalog( audio_output_t *p_aout )
/* Do the last VLC aout setups */
aout_FormatPrepare( &p_aout->format );
aout_PacketInit( p_aout, &p_sys->packet, FRAMESIZE );
- aout_VolumeHardInit( p_aout, VolumeSet );
-
- /* Initialize starting volume */
- audio_volume_t volume = var_InheritInteger (p_aout, "volume");
- bool mute = var_InheritBool (p_aout, "mute");
- VolumeSet(p_aout, volume / (float)AOUT_VOLUME_DEFAULT, mute);
+ aout_VolumeHardInit( p_aout, VolumeSet, true );
/* set the IOproc callback */
input.inputProc = (AURenderCallback) RenderCallbackAnalog;
diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index 4d12ae9..26183b4 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -947,7 +947,7 @@ static int Open(vlc_object_t *obj)
aout->pf_play = Play;
aout->pf_pause = Pause;
aout->pf_flush = Flush;
- aout_VolumeHardInit (aout, VolumeSet);
+ aout_VolumeHardInit (aout, VolumeSet, false);
return VLC_SUCCESS;
fail:
diff --git a/modules/audio_output/waveout.c b/modules/audio_output/waveout.c
index f15e656..4bb6831 100644
--- a/modules/audio_output/waveout.c
+++ b/modules/audio_output/waveout.c
@@ -296,7 +296,7 @@ static int Open( vlc_object_t *p_this )
if( waveOutGetDevCaps( (UINT_PTR)p_aout->sys->h_waveout,
&wocaps, sizeof(wocaps) ) == MMSYSERR_NOERROR
&& (wocaps.dwSupport & WAVECAPS_VOLUME) )
- aout_VolumeHardInit( p_aout, VolumeSet );
+ aout_VolumeHardInit( p_aout, VolumeSet, false /* ?? */ );
else
aout_VolumeSoftInit( p_aout );
}
diff --git a/src/audio_output/output.c b/src/audio_output/output.c
index 979c3b6..28a9c32 100644
--- a/src/audio_output/output.c
+++ b/src/audio_output/output.c
@@ -334,13 +334,22 @@ void aout_VolumeSoftInit (audio_output_t *aout)
* Configures a custom volume setter. This is used by audio outputs that can
* control the hardware volume directly and/or emulate it internally.
* @param setter volume setter callback
+ * @param restore apply volume from VLC configuration immediately
*/
-void aout_VolumeHardInit (audio_output_t *aout, aout_volume_cb setter)
+void aout_VolumeHardInit (audio_output_t *aout, aout_volume_cb setter,
+ bool restore)
{
aout_assert_locked (aout);
aout->pf_volume_set = setter;
var_Create (aout, "volume", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT);
var_Create (aout, "mute", VLC_VAR_BOOL|VLC_VAR_DOINHERIT);
+
+ if (restore)
+ {
+ float vol = var_InheritInteger (aout, "volume")
+ / (float)AOUT_VOLUME_DEFAULT;
+ setter (aout, vol, var_InheritBool (aout, "mute"));
+ }
}
/**
More information about the vlc-commits
mailing list