[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nas] [RFC][PATCH] let aupanel query device settings regularly
Hi,
the attached patch implements an automatic querying of the NAS device
settings by aupanel.
As long as aupanel runs the existing query functionality is invoked in
regular intervals. Whenever a manual query is used, the interval timer
is reset to it's starting value.
Via a command line option the interval length can be specified, using a
value of 0 disables the functionality.
The default interval time used in my patch is 10 seconds. This is just a
starting point for discussion. Using a default of 0 would mean to keep
the current behaviour (by disabling automatic querying), using some
positive value shorter than 10s would make the feature more noticable.
Using an even larger value would reduce network load a little bit. ;)
The automatic querying functionality is helpful whenever several mixer
clients are used concurrently, possibly by different users (this is the
case in the Unix-AG at the TU Kaiserslautern ;).
I did not commit this patch to svn because IMHO it needs some discussion
first. If everybody agrees that the new functionality is desirable, I'll
happily commit the patch. ;)
Erik
Index: clients/audio/aupanel/aupanel.man
===================================================================
--- clients/audio/aupanel/aupanel.man (revision 255)
+++ clients/audio/aupanel/aupanel.man (working copy)
@@ -21,6 +21,11 @@
it is used as the resource identifier of the desired device. Otherwise,
\fIid\fP should be the exact device name (e.g. Stereo Channel Output).
You can use \fIauinfo\fP to query an audioserver for this information.
+.TP 8
+.BI "\-interval " seconds
+\fIaupanel\fP queries the device attributes in regular intervals with a default
+length of \fB10\fP seconds. With this option a different interval length can be
+specified. Using an interval length of \fB0\fP disables the automatic querying.
.PP
Additionally, options from the Athena Widget Set can be used.
.SH AUPANEL AND THE ATHENA WIDGET SET
Index: clients/audio/aupanel/aupanel.c
===================================================================
--- clients/audio/aupanel/aupanel.c (revision 255)
+++ clients/audio/aupanel/aupanel.c (working copy)
@@ -55,8 +55,10 @@
#define APP_CLASS "Aupanel"
+#define DEFAULT_QUERY_INTERVAL 10000UL
+
#define USAGE "\
-usage: aupanel [-a audioserver] [-dev id]\
+usage: aupanel [-a audioserver] [-dev id] [-in seconds]\
"
#define MakeCommandButton(w, parent, label, callback) \
@@ -100,6 +102,8 @@
deviceNum,
*restoreValues;
AuDeviceAttributes *da;
+ unsigned long queryInterval;
+ XtIntervalId queryTimerID;
} GlobalDataRec, *GlobalDataPtr;
static String defaultResources[] =
@@ -237,17 +241,34 @@
}
+static void timedQueryCB(XtPointer, XtIntervalId *);
+
static void
queryCB(Widget w, XtPointer gp, XtPointer call_data)
{
GlobalDataPtr g = (GlobalDataPtr) gp;
+ if(g->queryInterval)
+ XtRemoveTimeOut(g->queryTimerID);
+
AuFreeDeviceAttributes(g->aud, g->numDevices, g->da);
g->da = AuListDevices(g->aud, 0, NULL, &g->numDevices, NULL);
showDevice(g);
+
+ if(g->queryInterval)
+ g->queryTimerID = XtAppAddTimeOut(XtWidgetToApplicationContext(g->top),
+ g->queryInterval, timedQueryCB, gp);
}
static void
+timedQueryCB(XtPointer gp, XtIntervalId *queryIntervalID)
+{
+ GlobalDataPtr g = (GlobalDataPtr) gp;
+
+ queryCB(g->top, gp, NULL);
+}
+
+static void
inputModeCB(Widget w, XtPointer gp, XtPointer call_data)
{
GlobalDataPtr g = (GlobalDataPtr) gp;
@@ -491,12 +512,19 @@
g->top = XtVaAppInitialize(&appContext, APP_CLASS, NULL, ZERO,
&argc, argv, defaultResources, NULL, 0);
+ g->queryInterval = DEFAULT_QUERY_INTERVAL;
+
for (i = 1; i < argc; i++) {
if (!strncmp(argv[i], "-a", 2)) {
audioServer = argv[++i];
} else if (!strncmp(argv[i], "-dev", 4)) {
initialDeviceName = argv[++i];
initialDevice = parse_device_id(initialDeviceName);
+ } else if (!strncmp(argv[i], "-in", 3)) {
+ int tmp = atoi(argv[++i]);
+ if (tmp >= 0) {
+ g->queryInterval = tmp * 1000;
+ }
} else {
fatalError(USAGE, NULL);
}
@@ -534,6 +562,9 @@
showDevice(g);
+ g->queryTimerID = XtAppAddTimeOut(appContext, g->queryInterval,
+ timedQueryCB , g);
+
XtAppMainLoop(appContext);
free(g->restoreValues);