Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e8a3c28

Browse files
committed
Added new audio library functionality (getstatus, float sample fmts)
1 parent 38a22ba commit e8a3c28

3 files changed

Lines changed: 172 additions & 4 deletions

File tree

Lib/irix5/AL.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
RATE_11025 = 11025
77
RATE_8000 = 8000
88

9+
SAMPFMT_TWOSCOMP= 1
10+
SAMPFMT_FLOAT = 32
11+
SAMPFMT_DOUBLE = 64
12+
913
SAMPLE_8 = 1
1014
SAMPLE_16 = 2
1115
# SAMPLE_24 is the low 24 bits of a long, sign extended to 32 bits
@@ -18,8 +22,21 @@
1822
INPUT_MIC = 1
1923
INPUT_DIGITAL = 2
2024

21-
HOLD, RELEASE = 0, 1
22-
ATTAIL, ATHEAD, ATMARK, ATTIME = 0, 1, 2, 3
25+
MONITOR_OFF = 0
26+
MONITOR_ON = 1
27+
28+
ERROR_NUMBER = 0
29+
ERROR_TYPE = 1
30+
ERROR_LOCATION_LSP = 2
31+
ERROR_LOCATION_MSP = 3
32+
ERROR_LENGTH = 4
33+
34+
ERROR_INPUT_UNDERFLOW = 0
35+
ERROR_OUTPUT_OVERFLOW = 1
36+
37+
# These seem to be not supported anymore:
38+
##HOLD, RELEASE = 0, 1
39+
##ATTAIL, ATHEAD, ATMARK, ATTIME = 0, 1, 2, 3
2340

2441
DEFAULT_DEVICE = 1
2542

@@ -35,6 +52,9 @@
3552
UNUSED_COUNT = 9
3653
SYNC_INPUT_TO_AES = 10
3754
SYNC_OUTPUT_TO_AES = 11
55+
MONITOR_CTL = 12
56+
LEFT_MONITOR_ATTEN = 13
57+
RIGHT_MONITOR_ATTEN = 14
3858

3959
ENUM_VALUE = 0 # only certain values are valid
4060
RANGE_VALUE = 1 # any value in range is valid

Lib/plat-irix5/AL.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
RATE_11025 = 11025
77
RATE_8000 = 8000
88

9+
SAMPFMT_TWOSCOMP= 1
10+
SAMPFMT_FLOAT = 32
11+
SAMPFMT_DOUBLE = 64
12+
913
SAMPLE_8 = 1
1014
SAMPLE_16 = 2
1115
# SAMPLE_24 is the low 24 bits of a long, sign extended to 32 bits
@@ -18,8 +22,21 @@
1822
INPUT_MIC = 1
1923
INPUT_DIGITAL = 2
2024

21-
HOLD, RELEASE = 0, 1
22-
ATTAIL, ATHEAD, ATMARK, ATTIME = 0, 1, 2, 3
25+
MONITOR_OFF = 0
26+
MONITOR_ON = 1
27+
28+
ERROR_NUMBER = 0
29+
ERROR_TYPE = 1
30+
ERROR_LOCATION_LSP = 2
31+
ERROR_LOCATION_MSP = 3
32+
ERROR_LENGTH = 4
33+
34+
ERROR_INPUT_UNDERFLOW = 0
35+
ERROR_OUTPUT_OVERFLOW = 1
36+
37+
# These seem to be not supported anymore:
38+
##HOLD, RELEASE = 0, 1
39+
##ATTAIL, ATHEAD, ATMARK, ATTIME = 0, 1, 2, 3
2340

2441
DEFAULT_DEVICE = 1
2542

@@ -35,6 +52,9 @@
3552
UNUSED_COUNT = 9
3653
SYNC_INPUT_TO_AES = 10
3754
SYNC_OUTPUT_TO_AES = 11
55+
MONITOR_CTL = 12
56+
LEFT_MONITOR_ATTEN = 13
57+
RIGHT_MONITOR_ATTEN = 14
3858

3959
ENUM_VALUE = 0 # only certain values are valid
4060
RANGE_VALUE = 1 # any value in range is valid

Modules/almodule.c

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2626

2727
#include "audio.h"
2828

29+
/* Check which version audio library we have: */
30+
#ifdef AL_ERROR_NUMBER
31+
#define AL_405
32+
/* XXXX 4.0.5 libaudio also allows us to provide better error
33+
** handling (with ALseterrorhandler). We should implement that
34+
** sometime.
35+
*/
36+
37+
#endif
38+
2939
#include "allobjects.h"
3040
#include "import.h"
3141
#include "modsupport.h"
@@ -127,13 +137,65 @@ al_setchannels (self, args)
127137
return (setConfig (self, args, ALsetchannels));
128138
}
129139

140+
#ifdef AL_405
141+
142+
static object *
143+
al_getsampfmt (self, args)
144+
configobject *self;
145+
object *args;
146+
{
147+
return (getConfig (self, args, ALgetsampfmt));
148+
}
149+
150+
static object *
151+
al_setsampfmt (self, args)
152+
configobject *self;
153+
object *args;
154+
{
155+
return (setConfig (self, args, ALsetsampfmt));
156+
}
157+
158+
static object *
159+
al_getfloatmax(self, args)
160+
configobject *self;
161+
object *args;
162+
{
163+
double arg;
164+
165+
if ( !getnoarg(args) )
166+
return 0;
167+
arg = ALgetfloatmax(self->ob_config);
168+
return newfloatobject(arg);
169+
}
170+
171+
static object *
172+
al_setfloatmax(self, args)
173+
configobject *self;
174+
object *args;
175+
{
176+
double arg;
177+
178+
if ( !getargs(args, "d", &arg) )
179+
return 0;
180+
ALsetfloatmax(self->ob_config, arg);
181+
INCREF(None);
182+
return None;
183+
}
184+
#endif /* AL_405 */
185+
130186
static struct methodlist config_methods[] = {
131187
{"getqueuesize", al_getqueuesize},
132188
{"setqueuesize", al_setqueuesize},
133189
{"getwidth", al_getwidth},
134190
{"setwidth", al_setwidth},
135191
{"getchannels", al_getchannels},
136192
{"setchannels", al_setchannels},
193+
#ifdef AL_405
194+
{"getsampfmt", al_getsampfmt},
195+
{"setsampfmt", al_setsampfmt},
196+
{"getfloatmax", al_getfloatmax},
197+
{"setfloatmax", al_setfloatmax},
198+
#endif /* AL_405 */
137199
{NULL, NULL} /* sentinel */
138200
};
139201

@@ -270,7 +332,17 @@ al_readsamps (self, args)
270332
}
271333

272334
c = ALgetconfig(self->ob_port);
335+
#ifdef AL_405
336+
width = ALgetsampfmt(c);
337+
if ( width == AL_SAMPFMT_FLOAT )
338+
width = sizeof(float);
339+
else if ( width == AL_SAMPFMT_DOUBLE )
340+
width = sizeof(double);
341+
else
342+
width = ALgetwidth(c);
343+
#else
273344
width = ALgetwidth(c);
345+
#endif /* AL_405 */
274346
ALfreeconfig(c);
275347
v = newsizedstringobject ((char *)NULL, width * count);
276348
if (v == NULL) return NULL;
@@ -295,7 +367,17 @@ al_writesamps (self, args)
295367
if (!getargs (args, "s#", &buf, &size)) return NULL;
296368

297369
c = ALgetconfig(self->ob_port);
370+
#ifdef AL_405
371+
width = ALgetsampfmt(c);
372+
if ( width == AL_SAMPFMT_FLOAT )
373+
width = sizeof(float);
374+
else if ( width == AL_SAMPFMT_DOUBLE )
375+
width = sizeof(double);
376+
else
377+
width = ALgetwidth(c);
378+
#else
298379
width = ALgetwidth(c);
380+
#endif /* AL_405 */
299381
ALfreeconfig(c);
300382
BGN_SAVE
301383
ALwritesamps (self-> ob_port, (void *) buf, (long) size / width);
@@ -363,6 +445,49 @@ al_getconfig (self, args)
363445
return newconfigobject (config);
364446
}
365447

448+
#ifdef AL_405
449+
static object *
450+
al_getstatus (self, args)
451+
portobject *self;
452+
object *args;
453+
{
454+
object *list, *v;
455+
long *PVbuffer;
456+
long length;
457+
int i;
458+
459+
if (!getargs(args, "O", &list))
460+
return NULL;
461+
if (!is_listobject(list)) {
462+
err_badarg();
463+
return NULL;
464+
}
465+
length = getlistsize(list);
466+
PVbuffer = NEW(long, length);
467+
if (PVbuffer == NULL)
468+
return err_nomem();
469+
for (i = 0; i < length; i++) {
470+
v = getlistitem(list, i);
471+
if (!is_intobject(v)) {
472+
DEL(PVbuffer);
473+
err_badarg();
474+
return NULL;
475+
}
476+
PVbuffer[i] = getintvalue(v);
477+
}
478+
479+
ALgetstatus(self->ob_port, PVbuffer, length);
480+
481+
for (i = 0; i < length; i++)
482+
setlistitem(list, i, newintobject(PVbuffer[i]));
483+
484+
DEL(PVbuffer);
485+
486+
INCREF(None);
487+
return None;
488+
}
489+
#endif /* AL_405 */
490+
366491
static struct methodlist port_methods[] = {
367492
{"closeport", al_closeport},
368493
{"getfd", al_getfd},
@@ -375,6 +500,9 @@ static struct methodlist port_methods[] = {
375500
{"getfillpoint", al_getfillpoint},
376501
{"setconfig", al_setconfig},
377502
{"getconfig", al_getconfig},
503+
#ifdef AL_405
504+
{"getstatus", al_getstatus},
505+
#endif /* AL_405 */
378506
{NULL, NULL} /* sentinel */
379507
};
380508

0 commit comments

Comments
 (0)