/* -*-c-*-
*
- * $Id: rxglue.c,v 1.3 2002/02/02 19:17:41 mdw Exp $
+ * $Id: rxglue.c,v 1.4 2002/02/02 22:43:50 mdw Exp $
*
* REXX glue for C core functionality
*
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-/*----- Revision history --------------------------------------------------*
- *
- * $Log: rxglue.c,v $
- * Revision 1.3 2002/02/02 19:17:41 mdw
- * New audio subsystem.
- *
- * Revision 1.2 2002/01/30 09:22:48 mdw
- * Use memory-allocation functions provided by the REXX interpreter.
- * Now that configuration can be applied after initialization, allow
- * @txconf@ to set parameters. Make @txsend@ add a newline to its output,
- * unless forbidden.
- *
- * Revision 1.1 2002/01/25 19:34:45 mdw
- * Initial revision
- *
- */
-
/*----- Header files ------------------------------------------------------*/
#ifdef HAVE_CONFIG_H
return (0);
}
+/* --- @AUCACHE([FLAG], [VALUE, ...]@ --- *
+ *
+ * Arguments: @FLAG@ = operation to perform
+ *
+ * Returns: Dependent on operation.
+ *
+ * Use: If @FLAG@ is omitted or `Info', returns audio cache usage
+ * information as words in the following order:
+ *
+ * sz_max Maximum allowed cache size
+ * sz_total Total size used by samples
+ * sz_spare Size used by `spare' samples
+ * sz_queue Size used by queued samples
+ * n_total Total number of cached samples
+ * n_spare Number of `spare' samples
+ * n_queue Number of queued samples
+ * hits Number of cache hits
+ * misses Number of cache misses
+ *
+ * If @FLAG@ is `Max', sets the maximum cache size to the first
+ * @VALUE@ (if set), and returns the old maximum on its own.
+ *
+ * If @FLAG@ is `Usage', returns the `sz_*' items, as a list of
+ * words.
+ *
+ * If @FLAGS@ is `Numbers', returns the `n_*' items, as a list
+ * of words.
+ *
+ * If @FLAGS@ is `Hits', returns `hits' and `misses' as a pair
+ * of words.
+ */
+
+static APIRET APIENTRY rxfn_aucache(const char *fn, ULONG ac, RXSTRING *av,
+ const char *sn, RXSTRING *r)
+{
+ int i = 1;
+ au_cacheinfo c;
+
+ au_getcacheinfo(&c);
+ if (ac < 1 || !av[0].strlength)
+ goto info;
+ switch (av[0].strptr[0]) {
+ case 'i': case 'I': info:
+ rxs_putf(r, "%lu %lu %lu %lu %u %u %u %lu %lu",
+ (unsigned long)c.sz_max, (unsigned long)c.sz_total,
+ (unsigned long)c.sz_spare, (unsigned long)c.sz_queue,
+ c.n_total, c.n_spare, c.n_total, c.hits, c.misses);
+ break;
+ case 'm': case 'M':
+ if (ac > i) {
+ long max;
+ if (rxs_tol(&av[i], &max))
+ return (-1);
+ au_setcachelimit(max);
+ i++;
+ }
+ rxs_putf(r, "%lu", (unsigned long)c.sz_max);
+ break;
+ case 'u': case 'U':
+ rxs_putf(r, "%lu %lu %lu %lu",
+ (unsigned long)c.sz_max, (unsigned long)c.sz_total,
+ (unsigned long)c.sz_spare, (unsigned long)c.sz_queue);
+ break;
+ case 'n': case 'N':
+ rxs_putf(r, "%u %u %u", c.n_total, c.n_spare, c.n_total);
+ break;
+ case 'h': case 'H':
+ rxs_putf(r, "%lu %lu", c.hits, c.misses);
+ break;
+ default:
+ return (-1);
+ }
+ if (i > ac)
+ return (-1);
+ return (0);
+}
+
/* --- @MILLIWAIT(MILLIS)@ --- *
*
* Arguments: @MILLIS@ = how long (in milliseconds) to wait
{ "txready", rxfn_txready },
{ "auplay", rxfn_auplay },
{ "aufetch", rxfn_aufetch },
+ { "aucache", rxfn_aucache },
{ "aunum", rxfn_aunum },
{ "milliwait", rxfn_milliwait },
{ 0, 0 }