[MPlayer-dev-eng] [PATCH] Preserve Mixer Volume when switching Audio Streams

list at mofokom.biz list at mofokom.biz
Wed Jun 9 19:39:34 CEST 2010


FYI - I couldn't get &l to be set it was always set to 0 that is why I use v as well.
tested against software mixer also.

Index: command.c
===================================================================
--- command.c   (revision 31347)
+++ command.c   (working copy)
@@ -65,6 +65,7 @@
  #include "mp_core.h"
  #include "mp_fifo.h"
  #include "libavutil/avstring.h"
+#include "mixer.h"

  #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))

@@ -861,11 +862,18 @@
              tmp = *((int *) arg);
          else
              tmp = -1;
+        float l =0;
+        float r =0;
+        float v =0;
+        mixer_getvolume(&mpctx->mixer,&l,&r);
+        mixer_getbothvolume(&mpctx->mixer,&v);
          audio_id = demuxer_switch_audio(mpctx->demuxer, tmp);
          if (audio_id == -2
              || (audio_id > -1
                  && mpctx->demuxer->audio->id != current_id && current_id != -2))
              uninit_player(INITIALIZED_AO | INITIALIZED_ACODEC);
          if (audio_id > -1 && mpctx->demuxer->audio->id != current_id) {
              sh_audio_t *sh2;
              sh2 = mpctx->demuxer->a_streams[mpctx->demuxer->audio->id];
@@ -873,6 +881,8 @@
                  sh2->ds = mpctx->demuxer->audio;
                  mpctx->sh_audio = sh2;
                  reinit_audio_chain();
+                mixer_setbothvolume(&mpctx->mixer,v);
+                mixer_setvolume(&mpctx->mixer,l,r);

              }
          }
          mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_TRACK=%d\n", audio_id);



More information about the MPlayer-dev-eng mailing list