From e8a3c28f8d962ca0dff6f6ad82f335706c90fa58 Mon Sep 17 00:00:00 2001 From: Jack Jansen Date: Wed, 10 Feb 1993 14:10:56 +0000 Subject: Added new audio library functionality (getstatus, float sample fmts) --- Lib/irix5/AL.py | 24 +++++++++- Lib/plat-irix5/AL.py | 24 +++++++++- Modules/almodule.c | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 172 insertions(+), 4 deletions(-) diff --git a/Lib/irix5/AL.py b/Lib/irix5/AL.py index e094f41..c4497ab 100755 --- a/Lib/irix5/AL.py +++ b/Lib/irix5/AL.py @@ -6,6 +6,10 @@ RATE_16000 = 16000 RATE_11025 = 11025 RATE_8000 = 8000 +SAMPFMT_TWOSCOMP= 1 +SAMPFMT_FLOAT = 32 +SAMPFMT_DOUBLE = 64 + SAMPLE_8 = 1 SAMPLE_16 = 2 # SAMPLE_24 is the low 24 bits of a long, sign extended to 32 bits @@ -18,8 +22,21 @@ INPUT_LINE = 0 INPUT_MIC = 1 INPUT_DIGITAL = 2 -HOLD, RELEASE = 0, 1 -ATTAIL, ATHEAD, ATMARK, ATTIME = 0, 1, 2, 3 +MONITOR_OFF = 0 +MONITOR_ON = 1 + +ERROR_NUMBER = 0 +ERROR_TYPE = 1 +ERROR_LOCATION_LSP = 2 +ERROR_LOCATION_MSP = 3 +ERROR_LENGTH = 4 + +ERROR_INPUT_UNDERFLOW = 0 +ERROR_OUTPUT_OVERFLOW = 1 + +# These seem to be not supported anymore: +##HOLD, RELEASE = 0, 1 +##ATTAIL, ATHEAD, ATMARK, ATTIME = 0, 1, 2, 3 DEFAULT_DEVICE = 1 @@ -35,6 +52,9 @@ OUTPUT_COUNT = 8 UNUSED_COUNT = 9 SYNC_INPUT_TO_AES = 10 SYNC_OUTPUT_TO_AES = 11 +MONITOR_CTL = 12 +LEFT_MONITOR_ATTEN = 13 +RIGHT_MONITOR_ATTEN = 14 ENUM_VALUE = 0 # only certain values are valid RANGE_VALUE = 1 # any value in range is valid diff --git a/Lib/plat-irix5/AL.py b/Lib/plat-irix5/AL.py index e094f41..c4497ab 100755 --- a/Lib/plat-irix5/AL.py +++ b/Lib/plat-irix5/AL.py @@ -6,6 +6,10 @@ RATE_16000 = 16000 RATE_11025 = 11025 RATE_8000 = 8000 +SAMPFMT_TWOSCOMP= 1 +SAMPFMT_FLOAT = 32 +SAMPFMT_DOUBLE = 64 + SAMPLE_8 = 1 SAMPLE_16 = 2 # SAMPLE_24 is the low 24 bits of a long, sign extended to 32 bits @@ -18,8 +22,21 @@ INPUT_LINE = 0 INPUT_MIC = 1 INPUT_DIGITAL = 2 -HOLD, RELEASE = 0, 1 -ATTAIL, ATHEAD, ATMARK, ATTIME = 0, 1, 2, 3 +MONITOR_OFF = 0 +MONITOR_ON = 1 + +ERROR_NUMBER = 0 +ERROR_TYPE = 1 +ERROR_LOCATION_LSP = 2 +ERROR_LOCATION_MSP = 3 +ERROR_LENGTH = 4 + +ERROR_INPUT_UNDERFLOW = 0 +ERROR_OUTPUT_OVERFLOW = 1 + +# These seem to be not supported anymore: +##HOLD, RELEASE = 0, 1 +##ATTAIL, ATHEAD, ATMARK, ATTIME = 0, 1, 2, 3 DEFAULT_DEVICE = 1 @@ -35,6 +52,9 @@ OUTPUT_COUNT = 8 UNUSED_COUNT = 9 SYNC_INPUT_TO_AES = 10 SYNC_OUTPUT_TO_AES = 11 +MONITOR_CTL = 12 +LEFT_MONITOR_ATTEN = 13 +RIGHT_MONITOR_ATTEN = 14 ENUM_VALUE = 0 # only certain values are valid RANGE_VALUE = 1 # any value in range is valid diff --git a/Modules/almodule.c b/Modules/almodule.c index 6b1dde3..aef2eee 100644 --- a/Modules/almodule.c +++ b/Modules/almodule.c @@ -26,6 +26,16 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "audio.h" +/* Check which version audio library we have: */ +#ifdef AL_ERROR_NUMBER +#define AL_405 +/* XXXX 4.0.5 libaudio also allows us to provide better error +** handling (with ALseterrorhandler). We should implement that +** sometime. +*/ + +#endif + #include "allobjects.h" #include "import.h" #include "modsupport.h" @@ -127,6 +137,52 @@ al_setchannels (self, args) return (setConfig (self, args, ALsetchannels)); } +#ifdef AL_405 + +static object * +al_getsampfmt (self, args) + configobject *self; + object *args; +{ + return (getConfig (self, args, ALgetsampfmt)); +} + +static object * +al_setsampfmt (self, args) + configobject *self; + object *args; +{ + return (setConfig (self, args, ALsetsampfmt)); +} + +static object * +al_getfloatmax(self, args) + configobject *self; + object *args; +{ + double arg; + + if ( !getnoarg(args) ) + return 0; + arg = ALgetfloatmax(self->ob_config); + return newfloatobject(arg); +} + +static object * +al_setfloatmax(self, args) + configobject *self; + object *args; +{ + double arg; + + if ( !getargs(args, "d", &arg) ) + return 0; + ALsetfloatmax(self->ob_config, arg); + INCREF(None); + return None; +} +#endif /* AL_405 */ + static struct methodlist config_methods[] = { {"getqueuesize", al_getqueuesize}, {"setqueuesize", al_setqueuesize}, @@ -134,6 +190,12 @@ static struct methodlist config_methods[] = { {"setwidth", al_setwidth}, {"getchannels", al_getchannels}, {"setchannels", al_setchannels}, +#ifdef AL_405 + {"getsampfmt", al_getsampfmt}, + {"setsampfmt", al_setsampfmt}, + {"getfloatmax", al_getfloatmax}, + {"setfloatmax", al_setfloatmax}, +#endif /* AL_405 */ {NULL, NULL} /* sentinel */ }; @@ -270,7 +332,17 @@ al_readsamps (self, args) } c = ALgetconfig(self->ob_port); +#ifdef AL_405 + width = ALgetsampfmt(c); + if ( width == AL_SAMPFMT_FLOAT ) + width = sizeof(float); + else if ( width == AL_SAMPFMT_DOUBLE ) + width = sizeof(double); + else + width = ALgetwidth(c); +#else width = ALgetwidth(c); +#endif /* AL_405 */ ALfreeconfig(c); v = newsizedstringobject ((char *)NULL, width * count); if (v == NULL) return NULL; @@ -295,7 +367,17 @@ al_writesamps (self, args) if (!getargs (args, "s#", &buf, &size)) return NULL; c = ALgetconfig(self->ob_port); +#ifdef AL_405 + width = ALgetsampfmt(c); + if ( width == AL_SAMPFMT_FLOAT ) + width = sizeof(float); + else if ( width == AL_SAMPFMT_DOUBLE ) + width = sizeof(double); + else + width = ALgetwidth(c); +#else width = ALgetwidth(c); +#endif /* AL_405 */ ALfreeconfig(c); BGN_SAVE ALwritesamps (self-> ob_port, (void *) buf, (long) size / width); @@ -363,6 +445,49 @@ al_getconfig (self, args) return newconfigobject (config); } +#ifdef AL_405 +static object * +al_getstatus (self, args) + portobject *self; + object *args; +{ + object *list, *v; + long *PVbuffer; + long length; + int i; + + if (!getargs(args, "O", &list)) + return NULL; + if (!is_listobject(list)) { + err_badarg(); + return NULL; + } + length = getlistsize(list); + PVbuffer = NEW(long, length); + if (PVbuffer == NULL) + return err_nomem(); + for (i = 0; i < length; i++) { + v = getlistitem(list, i); + if (!is_intobject(v)) { + DEL(PVbuffer); + err_badarg(); + return NULL; + } + PVbuffer[i] = getintvalue(v); + } + + ALgetstatus(self->ob_port, PVbuffer, length); + + for (i = 0; i < length; i++) + setlistitem(list, i, newintobject(PVbuffer[i])); + + DEL(PVbuffer); + + INCREF(None); + return None; +} +#endif /* AL_405 */ + static struct methodlist port_methods[] = { {"closeport", al_closeport}, {"getfd", al_getfd}, @@ -375,6 +500,9 @@ static struct methodlist port_methods[] = { {"getfillpoint", al_getfillpoint}, {"setconfig", al_setconfig}, {"getconfig", al_getconfig}, +#ifdef AL_405 + {"getstatus", al_getstatus}, +#endif /* AL_405 */ {NULL, NULL} /* sentinel */ }; -- cgit v0.12