[MPlayer-cvslog] r37987 - in trunk: Changelog gui/interface.c gui/interface.h

ib subversion at mplayerhq.hu
Mon Oct 9 12:58:49 EEST 2017


Author: ib
Date: Mon Oct  9 12:58:49 2017
New Revision: 37987

Log:
Implement ReplayGain support.

If requested and if ReplayGain data is available for the audio stream,
save the current volume and adjust the playback volume accordingly.
When playback ends, restore the previously saved volume.

Additionally, add a changelog information.

Modified:
   trunk/Changelog
   trunk/gui/interface.c
   trunk/gui/interface.h

Modified: trunk/Changelog
==============================================================================
--- trunk/Changelog	Mon Oct  9 11:46:09 2017	(r37986)
+++ trunk/Changelog	Mon Oct  9 12:58:49 2017	(r37987)
@@ -30,6 +30,7 @@ MPlayer
     * No limitation on the number of entries in a font description file
     * Dramatic speedup of scanning font description files
     * Playback improvements for cue sheet playlists
+    * Implementation of audio playback utilizing ReplayGain data
 
 
   1.3.0: "worksforme" February 16, 2016

Modified: trunk/gui/interface.c
==============================================================================
--- trunk/gui/interface.c	Mon Oct  9 11:46:09 2017	(r37986)
+++ trunk/gui/interface.c	Mon Oct  9 12:58:49 2017	(r37987)
@@ -74,6 +74,7 @@ guiInterface_t guiInfo = {
     .StreamType   = STREAMTYPE_DUMMY,
     .Volume       = 50.0f,
     .Balance      = 50.0f,
+    .LastVolume   = -1.0f,
     .PlaylistNext = True
 };
 
@@ -410,7 +411,7 @@ int gui(int what, void *data)
 #ifdef CONFIG_DVDREAD
     dvd_priv_t *dvd;
 #endif
-    int idata = (intptr_t)data, msg, state;
+    int idata = (intptr_t)data, msg, state, replay_gain;
     stream_t *stream = NULL;
     sh_audio_t *sh_audio;
     mixer_t *mixer;
@@ -912,9 +913,17 @@ int gui(int what, void *data)
         if (guiInfo.AudioChannels < 2 || guiInfo.AudioPassthrough)
             btnSet(evSetBalance, btnDisabled);
 
-        if (last_balance < 0.0f) {
+        if (gtkReplayGainOn) {
+            if (demux_control(mpctx_get_demuxer(guiInfo.mpcontext), DEMUXER_CTRL_GET_REPLAY_GAIN, &replay_gain) == DEMUXER_CTRL_OK) {
+                guiInfo.LastVolume = guiInfo.Volume;
+                guiInfo.Volume     = constrain(100.0 + (replay_gain / 10.0 + gtkReplayGainAdjustment) / 0.5);
+            }
+        }
+
+        if (guiInfo.LastVolume >= 0.0f || last_balance < 0.0f)
             uiEvent(ivSetVolume, guiInfo.Volume);
 
+        if (last_balance < 0.0f) {
             if (guiInfo.AudioChannels == 2 && !guiInfo.AudioPassthrough)
                 uiEvent(ivSetBalance, guiInfo.Balance);
 
@@ -1002,6 +1011,11 @@ int gui(int what, void *data)
 
         guiInfo.sh_video = NULL;
 
+        if (guiInfo.LastVolume >= 0.0f) {
+            uiEvent(ivSetVolume, guiInfo.LastVolume);
+            guiInfo.LastVolume = -1.0f;
+        }
+
         btnSet(evSetVolume, btnReleased);
         btnSet(evSetBalance, btnReleased);
 

Modified: trunk/gui/interface.h
==============================================================================
--- trunk/gui/interface.h	Mon Oct  9 11:46:09 2017	(r37986)
+++ trunk/gui/interface.h	Mon Oct  9 12:58:49 2017	(r37987)
@@ -140,6 +140,7 @@ typedef struct {
     float Volume;
     float Balance;
 
+    float LastVolume;
     int MediumChanged;        // public, read access by MPlayer
     int PlaylistNext;
 


More information about the MPlayer-cvslog mailing list