X-Git-Url: https://git.distorted.org.uk/~mdw/jog/blobdiff_plain/b41f38f059a9e191c97c03259649b27393475f2f..af666e6f949ddb4f2cdfc4d3564fbe82e8b8d81b:/rxglue.c diff --git a/rxglue.c b/rxglue.c index d57d798..75e0f96 100644 --- a/rxglue.c +++ b/rxglue.c @@ -1,6 +1,6 @@ /* -*-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 * @@ -29,6 +29,10 @@ /*----- Revision history --------------------------------------------------* * * $Log: rxglue.c,v $ + * Revision 1.4 2002/02/02 22:43:50 mdw + * Provide a decent interface for finding out about the audio cache and + * configuring its capacity. + * * Revision 1.3 2002/02/02 19:17:41 mdw * New audio subsystem. * @@ -575,6 +579,83 @@ static APIRET APIENTRY rxfn_aunum(const char *fn, ULONG ac, RXSTRING *av, 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 @@ -616,6 +697,7 @@ static const struct rxfntab rxfntab[] = { { "txready", rxfn_txready }, { "auplay", rxfn_auplay }, { "aufetch", rxfn_aufetch }, + { "aucache", rxfn_aucache }, { "aunum", rxfn_aunum }, { "milliwait", rxfn_milliwait }, { 0, 0 }