[MPlayer-dev-eng] [PATCH] Mac OS X native audio output
Wojtek Kaniewski
wojtekka at bydg.pdi.net
Thu May 22 12:09:39 CEST 2003
On Thu, 22 May 2003, D Richard Felker III wrote:
> pl_* are obsolete and should be removed, but no one's written the code
> to allow interactive volume control with af_volume... :(
maybe this patch would help? it modifies MP_CMD_VOLUME a bit. if
af_volume is loaded, it uses its control interface instead of the
mixer_*() functions.
regards,
wojtek
-------------- next part --------------
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.694
diff -u -r1.694 mplayer.c
--- mplayer.c 17 May 2003 09:20:58 -0000 1.694
+++ mplayer.c 22 May 2003 10:08:20 -0000
@@ -2504,7 +2504,12 @@
} break;
case MP_CMD_VOLUME : {
int v = cmd->args[0].v.i;
+ af_stream_t *afs = sh_audio->afilter;
+ af_instance_t *afi;
+ if (!(afi = af_get(afs, "volume"))) {
+ // use pcm mixer if af_volume isn't loaded
+
// start change for absolute volume value
int abs = (cmd->nargs > 1) ? cmd->args[1].v.i : 0;
@@ -2512,20 +2517,56 @@
{
mixer_setvolume( (float)v, (float)v );
} else {
- if(v > 0)
- mixer_incvolume();
- else
- mixer_decvolume();
+ if(v > 0)
+ mixer_incvolume();
+ else
+ mixer_decvolume();
}
-
+
#ifdef USE_OSD
- if(osd_level && sh_video){
- osd_visible=sh_video->fps; // 1 sec
- vo_osd_progbar_type=OSD_VOLUME;
- vo_osd_progbar_value=(mixer_getbothvolume()*256.0)/100.0;
- vo_osd_changed(OSDTYPE_PROGBAR);
- }
+ if(osd_level && sh_video){
+ osd_visible=sh_video->fps; // 1 sec
+ vo_osd_progbar_type=OSD_VOLUME;
+ vo_osd_progbar_value=(mixer_getbothvolume()*256.0)/100.0;
+ vo_osd_changed(OSDTYPE_PROGBAR);
+ }
+#endif
+ } else {
+ float vol[AF_NCH], voldB[AF_NCH];
+ int i, abs = (cmd->nargs > 1) ? cmd->args[1].v.i : 0;
+
+ if (abs) {
+ for (i = 0; i < AF_NCH; i++)
+ vol[i] = (float) abs / 50.0;
+
+ af_to_dB(AF_NCH, vol, voldB, 20.0);
+
+ afi->control(afi, AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_SET, voldB);
+ } else {
+ afi->control(afi, AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_GET, voldB);
+
+ for (i = 0; i < AF_NCH; i++) {
+ voldB[i] += (v > 0) ? 5 : -5;
+ if (voldB[i] <= -200.0)
+ voldB[i] = -200.0;
+ if (voldB[i] >= 60.0)
+ voldB[i] = 60.0;
+ }
+
+ afi->control(afi, AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_SET, voldB);
+ }
+
+ afi->control(afi, AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_GET, voldB);
+
+#ifdef USE_OSD
+ if (osd_level && sh_video) {
+ osd_visible = sh_video->fps;
+ vo_osd_progbar_type = OSD_VOLUME;
+ vo_osd_progbar_value = (voldB[0] + voldB[1]) / 2.0 + 200.0 / 260.0 * 256.0;
+ vo_osd_changed(OSDTYPE_PROGBAR);
+ }
#endif
+ }
} break;
case MP_CMD_MUTE:
mixer_mute();
More information about the MPlayer-dev-eng
mailing list