[MPlayer-dev-eng] [PATCH] real muting
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Sun Nov 20 11:17:30 CET 2005
Hi,
the attached patch implements real muting (i.e. the audio device gets
paused).
It currently disables the "set volume to 0" part, too, this probably
should be an option (suggestions for name + values?).
Please test it, I'm sure it will cause problems in some cases, e.g. with
-ao alsa the movie makes a short skip forward when muting.
Greetings,
Reimar Döffinger
-------------- next part --------------
Index: mixer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mixer.c,v
retrieving revision 1.19
diff -u -r1.19 mixer.c
--- mixer.c 14 Nov 2004 11:27:57 -0000 1.19
+++ mixer.c 20 Nov 2005 10:13:02 -0000
@@ -76,7 +76,8 @@
}
}
}
- mixer->muted=0;
+ if (mixer->muted)
+ mixer_mute(mixer);
}
void mixer_incvolume(mixer_t *mixer)
@@ -110,11 +111,18 @@
void mixer_mute(mixer_t *mixer)
{
- if (mixer->muted) mixer_setvolume(mixer, mixer->last_l, mixer->last_r);
+ if (mixer->muted)
+ {
+// mixer_setvolume(mixer, mixer->last_l, mixer->last_r);
+ if (mixer->audio_out)
+ mixer->audio_out->reset();
+ }
else
{
- mixer_getvolume(mixer, &mixer->last_l, &mixer->last_r);
- mixer_setvolume(mixer, 0, 0);
- mixer->muted=1;
+// mixer_getvolume(mixer, &mixer->last_l, &mixer->last_r);
+// mixer_setvolume(mixer, 0, 0);
+ if (mixer->audio_out)
+ mixer->audio_out->pause();
}
+ mixer->muted = !mixer->muted;
}
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.888
diff -u -r1.888 mplayer.c
--- mplayer.c 16 Nov 2005 16:51:48 -0000 1.888
+++ mplayer.c 20 Nov 2005 10:13:19 -0000
@@ -2542,13 +2573,24 @@
/*========================== PLAY AUDIO ============================*/
while(sh_audio){
+ static unsigned int last_play_time;
+ static unsigned int last_delay;
unsigned int t;
double tt;
int playsize;
+ int bps = (ao_data.bps && sh_audio->afilter) ? ao_data.bps : sh_audio->o_bps;
current_module="play_audio";
ao_data.pts=((sh_video?sh_video->timer:0)+sh_audio->delay)*90000.0;
+ if (mixer.muted) {
+ unsigned int diff = GetTimerMS() - last_play_time;
+ playsize = bps * diff / 1000;
+ if (playsize > sh_audio->a_out_buffer_size)
+ playsize = sh_audio->a_out_buffer_size;
+ playsize -= playsize % ao_data.outburst;
+ last_play_time += playsize * 1000 / bps;
+ } else
playsize=audio_out->get_space();
// handle audio-only case:
@@ -2580,13 +2622,15 @@
// play audio:
current_module="play_audio";
+ if (!mixer.muted) {
playsize=audio_out->play(sh_audio->a_out_buffer,playsize,0);
+ last_play_time = GetTimerMS();
+ }
if(playsize>0){
sh_audio->a_out_buffer_len-=playsize;
memmove(sh_audio->a_out_buffer,&sh_audio->a_out_buffer[playsize],sh_audio->a_out_buffer_len);
- sh_audio->delay+=playback_speed*playsize/((float)((ao_data.bps && sh_audio->afilter) ?
- ao_data.bps : sh_audio->o_bps));
+ sh_audio->delay+=playback_speed*playsize/((float)bps);
}
break;
More information about the MPlayer-dev-eng
mailing list