[Asterisk-cvs] asterisk muted.c,1.10,1.11

twisted at lists.digium.com twisted at lists.digium.com
Mon Jul 18 11:43:39 CDT 2005


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv10074

Modified Files:
	muted.c 
Log Message:
fix smoothfade for osx.  


Index: muted.c
===================================================================
RCS file: /usr/cvsroot/asterisk/muted.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- muted.c	18 Jul 2005 04:30:33 -0000	1.10
+++ muted.c	18 Jul 2005 15:51:09 -0000	1.11
@@ -378,30 +378,46 @@
 static float mutevol = 0;
 #endif
 
+#ifndef __Darwin__
 static int mutedlevel(int orig, int mutelevel)
 {
 	int l = orig >> 8;
 	int r = orig & 0xff;
 	l = (float)(mutelevel) * (float)(l) / 100.0;
 	r = (float)(mutelevel) * (float)(r) / 100.0;
+
 	return (l << 8) | r;
+#else
+static float mutedlevel(float orig, float mutelevel)
+{
+	float master = orig;
+	master = mutelevel * master / 100.0;
+	return master;
+#endif
+	
 }
 
 static void mute(void)
 {
 #ifndef __Darwin__
 	int vol;
+	int start;
+	int x;
 #else
 	float vol;
+	float start = 1.0;
+	float x;
 #endif
-	int start;
-	int x;
 	vol = getvol();
 	oldvol = vol;
-	if (smoothfade) 
+	if (smoothfade)
+#ifdef __Darwin__ 
+		start = mutelevel;
+#else
 		start = 100;
 	else
 		start = mutelevel;
+#endif
 	for (x=start;x>=mutelevel;x-=stepsize) {
 		mutevol = mutedlevel(vol, x);
 		setvol(mutevol);
@@ -423,23 +439,31 @@
 {
 #ifdef __Darwin__
 	float vol;
+	float start;
+	float x;
 #else
 	int vol;
-#endif
 	int start;
 	int x;
+#endif
 	vol = getvol();
 	if (debug)
 #ifdef __Darwin__
 		printf("Unmute from '%f' (should be '%f') to '%f'!\n", vol, mutevol, oldvol);
+	mutevol = vol;
+	if (vol == mutevol) {
 #else
 		printf("Unmute from '%04x' (should be '%04x') to '%04x'!\n", vol, mutevol, oldvol);
-#endif
 	if ((int)vol == mutevol) {
+#endif
 		if (smoothfade)
 			start = mutelevel;
 		else
+#ifdef __Darwin__
+			start = 1.0;
+#else
 			start = 100;
+#endif
 		for (x=start;x<100;x+=stepsize) {
 			mutevol = mutedlevel(oldvol, x);
 			setvol(mutevol);




More information about the svn-commits mailing list