[nas] [PATCH] mute button for aupanel

Erik Auerswald auerswal at unix-ag.uni-kl.de
Mon Nov 21 06:52:38 MST 2005


Hi,

> >I've made two small improvements to this patch:
> >
> 
> 	Thanks... but... the patches seem to be missing... :)

Oops...

2nd. try...

Erik
-------------- next part --------------
diff -Naur nas-1.7b/clients/audio/aupanel/Aupanel.ad nas-1.7b-new/clients/audio/aupanel/Aupanel.ad
--- nas-1.7b/clients/audio/aupanel/Aupanel.ad	1999-09-05 04:42:56.000000000 +0200
+++ nas-1.7b-new/clients/audio/aupanel/Aupanel.ad	2005-11-15 09:55:30.000000000 +0100
@@ -5,8 +5,11 @@
 
 Aupanel*query.label:		Query
 
+Aupanel*mute.lanel:		Mute
+Aupanel*mute.fromHoriz:		devices
+
 Aupanel*devices.label:		Devices
-Aupanel*devices.fromHoriz:	query
+Aupanel*devices.fromHoriz:	mute
 
 Aupanel*quit.label:		Quit
 Aupanel*quit.fromHoriz:		devices
diff -Naur nas-1.7b/clients/audio/aupanel/aupanel.c nas-1.7b-new/clients/audio/aupanel/aupanel.c
--- nas-1.7b/clients/audio/aupanel/aupanel.c	2005-04-07 21:08:14.000000000 +0200
+++ nas-1.7b-new/clients/audio/aupanel/aupanel.c	2005-11-15 09:41:24.000000000 +0100
@@ -83,6 +83,7 @@
                     form,
                     quit,
                     query,
+                    mute,
                     menu,
                     menuButton,
                     device,
@@ -96,7 +97,8 @@
                     outputModeLine;
     AuServer       *aud;
     int             numDevices,
-                    deviceNum;
+                    deviceNum,
+                   *restoreValues;
     AuDeviceAttributes *da;
 }               GlobalDataRec, *GlobalDataPtr;
 
@@ -105,10 +107,12 @@
     "*input:                          true",
     "*font:                           *courier-medium-r-normal*140*",
     "*query.label:                    Query",
+    "*mute.label:                     Mute",
+    "*mute.fromHoriz:                 devices",
     "*devices.label:                  Devices",
     "*devices.fromHoriz:              query",
     "*quit.label:                     Quit",
-    "*quit.fromHoriz:                 devices",
+    "*quit.fromHoriz:                 mute",
     "*deviceLabel.label:              Stereo Channel Output",
     "*deviceLabel.fromVert:           query",
     "*deviceLabel.font:               *courier-bold-r-normal*140*",
@@ -231,6 +235,12 @@
 	XtCallActionProc(g->outputModeLine, "reset", NULL, NULL, 0);
     }
 
+    if ((AuFixedPointRoundUp(AuDeviceGain(da)) == 0) &&
+        (g->restoreValues[g->deviceNum] > 0))
+        XtCallActionProc(g->mute, "set", NULL, NULL, 0);
+    else
+        XtCallActionProc(g->mute, "reset", NULL, NULL, 0);
+
 }
 
 static void
@@ -330,6 +340,36 @@
     AuDeviceGain(da) = AuFixedPointFromSum(value, 0);
     AuSetDeviceAttributes(g->aud, AuDeviceIdentifier(da),
 			  AuCompDeviceGainMask, da, NULL);
+
+    if ((AuFixedPointRoundUp(AuDeviceGain(da)) != 0) &&
+        (g->restoreValues[g->deviceNum] > 0)) {
+        g->restoreValues[g->deviceNum] = 0;
+        XtCallActionProc(g->mute, "reset", NULL, NULL, 0);
+    }
+}
+
+static void
+muteCB(w, gp, call_data)
+Widget          w;
+XtPointer       gp;
+XtPointer       call_data;
+{
+    GlobalDataPtr g = (GlobalDataPtr) gp;
+    AuDeviceAttributes *da;
+    int current;
+
+    queryCB(w, gp, call_data);
+    da = &g->da[g->deviceNum];
+    current = AuFixedPointRoundUp(AuDeviceGain(da));
+
+    if(current > 0) {
+        g->restoreValues[g->deviceNum] = current;
+        setGain(w, gp, (XtPointer)0);
+    } else if(g->restoreValues[g->deviceNum] > 0){
+        setGain(w, gp, (XtPointer)g->restoreValues[g->deviceNum]);
+        g->restoreValues[g->deviceNum] = 0;
+    }
+    showDevice((GlobalDataPtr)gp);
 }
 
 static void
@@ -360,6 +400,10 @@
 
     MakeWidget(g->menuButton, g->form, menuButtonWidgetClass, "devices");
 
+    MakeWidget(g->mute, g->form, toggleWidgetClass, "mute");
+    XtAddCallback(g->mute, XtNcallback, muteCB, g);
+    XtVaSetValues(g->mute, XtNsensitive, True, NULL);
+
     MakeCommandButton(g->quit, g->form, "quit", quitCB);
 
     MakeLabel(g->device, g->form, "deviceLabel");
@@ -432,6 +476,9 @@
     if (!(g->aud = AuOpenServer(audioServer, 0, NULL, 0, NULL, NULL)))
 	fatalError("Can't connect to audio server");
 
+    if(!(g->restoreValues = calloc(AuServerNumDevices(g->aud), sizeof(int))))
+        fatalError("Out of memory");
+
     createWidgets(g);
     XtRealizeWidget(g->top);
     alignWidgets(g);
@@ -442,5 +489,7 @@
     showDevice(g);
 
     XtAppMainLoop(appContext);
+
+    free(g->restoreValues);
     return 0;
 }
diff -Naur nas-1.7b/clients/audio/aupanel/aupanel.man nas-1.7b-new/clients/audio/aupanel/aupanel.man
--- nas-1.7b/clients/audio/aupanel/aupanel.man	1999-05-08 20:47:17.000000000 +0200
+++ nas-1.7b-new/clients/audio/aupanel/aupanel.man	2005-11-14 18:26:50.000000000 +0100
@@ -22,6 +22,8 @@
 these selections.
 .PP
 To query the current device attributes, click on the \fBQuery\fP button.
+.PP
+To mute (resp. unmute) the current device, click on the \fBMute\fP button.
 .SH ENVIRONMENT
 In addition to the standard toolkit environment variables, the
 following environment variables are used by \fIaupanel\fP:
-------------- next part --------------
diff -Naur nas-1.7b/clients/audio/aupanel/Aupanel.ad nas-1.7b-new/clients/audio/aupanel/Aupanel.ad
--- nas-1.7b/clients/audio/aupanel/Aupanel.ad	1999-09-05 04:42:56.000000000 +0200
+++ nas-1.7b-new/clients/audio/aupanel/Aupanel.ad	2005-11-15 09:55:30.000000000 +0100
@@ -5,8 +5,11 @@
 
 Aupanel*query.label:		Query
 
+Aupanel*mute.lanel:		Mute
+Aupanel*mute.fromHoriz:		devices
+
 Aupanel*devices.label:		Devices
-Aupanel*devices.fromHoriz:	query
+Aupanel*devices.fromHoriz:	mute
 
 Aupanel*quit.label:		Quit
 Aupanel*quit.fromHoriz:		devices
diff -Naur nas-1.7b/clients/audio/aupanel/aupanel.c nas-1.7b-new/clients/audio/aupanel/aupanel.c
--- nas-1.7b/clients/audio/aupanel/aupanel.c	2005-11-15 09:57:28.000000000 +0100
+++ nas-1.7b-new/clients/audio/aupanel/aupanel.c	2005-11-15 09:41:24.000000000 +0100
@@ -340,6 +340,12 @@
     AuDeviceGain(da) = AuFixedPointFromSum(value, 0);
     AuSetDeviceAttributes(g->aud, AuDeviceIdentifier(da),
 			  AuCompDeviceGainMask, da, NULL);
+
+    if ((AuFixedPointRoundUp(AuDeviceGain(da)) != 0) &&
+        (g->restoreValues[g->deviceNum] > 0)) {
+        g->restoreValues[g->deviceNum] = 0;
+        XtCallActionProc(g->mute, "reset", NULL, NULL, 0);
+    }
 }
 
 static void


More information about the Nas mailing list