]> git.sesse.net Git - vlc/commitdiff
AudioQueue: implement volume support just because we can
authorFelix Paul Kühne <fkuehne@videolan.org>
Sun, 16 Dec 2012 10:04:46 +0000 (11:04 +0100)
committerFelix Paul Kühne <fkuehne@videolan.org>
Sun, 16 Dec 2012 10:05:05 +0000 (11:05 +0100)
modules/audio_output/audioqueue.c

index 1fe71c4693d78723066b6caeaeedcdee42e5f347..b67baeb74cbce06caf143ad8f7712c12055a9d57 100644 (file)
@@ -47,6 +47,7 @@ struct aout_sys_t
 {
     AudioQueueRef audioQueue;
     bool          b_stopped;
+    float         f_volume;
 };
 
 /*****************************************************************************
@@ -207,6 +208,24 @@ static int TimeGet (audio_output_t *p_aout, mtime_t *restrict delay)
     return -1;
 }
 
+/*****************************************************************************
+ * Module management
+ *****************************************************************************/
+
+static int VolumeSet(audio_output_t * p_aout, float volume)
+{
+    struct aout_sys_t *p_sys = p_aout->sys;
+    OSStatus ostatus;
+
+    aout_VolumeReport(p_aout, volume);
+    p_sys->f_volume = volume;
+
+    /* Set volume for output unit */
+    ostatus = AudioQueueSetParameter(p_sys->audioQueue, kAudioQueueParam_Volume, volume * volume * volume);
+
+    return ostatus;
+}
+
 /*****************************************************************************
  * Module management
  *****************************************************************************/
@@ -222,6 +241,10 @@ static int Open(vlc_object_t *obj)
     aout->sys = sys;
     aout->start = Start;
     aout->stop = Stop;
+    aout->volume_set = VolumeSet;
+
+    /* reset volume */
+    aout_VolumeReport(aout, 1.0);
 
     return VLC_SUCCESS;
 }