cinap_lenrekadd hg and python4bb9e2215 years agoHistory
3226 lines · 79.7 KB · C
RawDownload
static PyObject *alc_setfloatmax(alcobject *self, PyObject *args){	double arg; 	if (!PyArg_ParseTuple(args, "d:SetFloatMax", &arg))		return 0;	if (ALsetfloatmax(self->config, arg) == -1)		return NULL;	Py_INCREF(Py_None);	return Py_None;}#endif /* AL_405 */	static struct PyMethodDef alc_methods[] = {#ifdef AL_NO_ELEM		/* IRIX 6 */	{"SetWidth",	(PyCFunction)alc_SetWidth,	METH_VARARGS,	alc_SetWidth__doc__},	{"GetWidth",	(PyCFunction)alc_GetWidth,	METH_VARARGS,	alc_GetWidth__doc__},	{"SetSampFmt",	(PyCFunction)alc_SetSampFmt,	METH_VARARGS,	alc_SetSampFmt__doc__},	{"GetSampFmt",	(PyCFunction)alc_GetSampFmt,	METH_VARARGS,	alc_GetSampFmt__doc__},	{"SetChannels",	(PyCFunction)alc_SetChannels,	METH_VARARGS,	alc_SetChannels__doc__},	{"GetChannels",	(PyCFunction)alc_GetChannels,	METH_VARARGS,	alc_GetChannels__doc__},	{"SetFloatMax",	(PyCFunction)alc_SetFloatMax,	METH_VARARGS,	alc_SetFloatMax__doc__},	{"GetFloatMax",	(PyCFunction)alc_GetFloatMax,	METH_VARARGS,	alc_GetFloatMax__doc__},	{"SetDevice",	(PyCFunction)alc_SetDevice,	METH_VARARGS,	alc_SetDevice__doc__},	{"GetDevice",	(PyCFunction)alc_GetDevice,	METH_VARARGS,	alc_GetDevice__doc__},	{"SetQueueSize",	(PyCFunction)alc_SetQueueSize,	METH_VARARGS,	alc_SetQueueSize__doc__},	{"GetQueueSize",	(PyCFunction)alc_GetQueueSize,	METH_VARARGS,	alc_GetQueueSize__doc__},#endif /* AL_NO_ELEM */	{"getqueuesize",	(PyCFunction)alc_getqueuesize,	METH_VARARGS},	{"setqueuesize",	(PyCFunction)alc_setqueuesize,	METH_VARARGS},	{"getwidth",		(PyCFunction)alc_getwidth,	METH_VARARGS},	{"setwidth",		(PyCFunction)alc_setwidth,	METH_VARARGS},	{"getchannels",		(PyCFunction)alc_getchannels,	METH_VARARGS},	{"setchannels",		(PyCFunction)alc_setchannels,	METH_VARARGS},#ifdef AL_405	{"getsampfmt",		(PyCFunction)alc_getsampfmt,	METH_VARARGS},	{"setsampfmt",		(PyCFunction)alc_setsampfmt,	METH_VARARGS},	{"getfloatmax",		(PyCFunction)alc_getfloatmax,	METH_VARARGS},	{"setfloatmax",		(PyCFunction)alc_setfloatmax,	METH_VARARGS},#endif /* AL_405 */ 	{NULL,		NULL}		/* sentinel */}; /* ---------- */  static PyObject *newalcobject(ALconfig config){	alcobject *self;		self = PyObject_New(alcobject, &Alctype);	if (self == NULL)		return NULL;	/* XXXX Add your own initializers here */	self->config = config;	return (PyObject *) self;}  static voidalc_dealloc(alcobject *self){	/* XXXX Add your own cleanup code here */#ifdef AL_NO_ELEM		/* IRIX 6 */	(void) alFreeConfig(self->config);	/* ignore errors */#else	(void) ALfreeconfig(self->config);	/* ignore errors */#endif	PyObject_Del(self);} static PyObject *alc_getattr(alcobject *self, char *name){	/* XXXX Add your own getattr code here */	return Py_FindMethod(alc_methods, (PyObject *)self, name);} PyDoc_STRVAR(Alctype__doc__, ""); static PyTypeObject Alctype = {	PyObject_HEAD_INIT(&PyType_Type)	0,				/*ob_size*/	"al.config",			/*tp_name*/	sizeof(alcobject),		/*tp_basicsize*/	0,				/*tp_itemsize*/	/* methods */	(destructor)alc_dealloc,	/*tp_dealloc*/	(printfunc)0,		/*tp_print*/	(getattrfunc)alc_getattr,	/*tp_getattr*/	(setattrfunc)0,	/*tp_setattr*/	(cmpfunc)0,		/*tp_compare*/	(reprfunc)0,		/*tp_repr*/	0,			/*tp_as_number*/	0,		/*tp_as_sequence*/	0,		/*tp_as_mapping*/	(hashfunc)0,		/*tp_hash*/	(ternaryfunc)0,		/*tp_call*/	(reprfunc)0,		/*tp_str*/ 	/* Space for future expansion */	0L,0L,0L,0L,	Alctype__doc__ /* Documentation string */}; /* End of code for config objects *//* ---------------------------------------------------------------- */ #ifdef AL_NO_ELEM		/* IRIX 6 */ PyDoc_STRVAR(alp_SetConfig__doc__,"alSetConfig: set the ALconfig of an audio ALport."); static PyObject *alp_SetConfig(alpobject *self, PyObject *args){	alcobject *config;	if (!PyArg_ParseTuple(args, "O!:SetConfig", &Alctype, &config))		return NULL;	if (alSetConfig(self->port, config->config) < 0)		return NULL;	Py_INCREF(Py_None);	return Py_None;}  PyDoc_STRVAR(alp_GetConfig__doc__,"alGetConfig: get the ALconfig of an audio ALport."); static PyObject *alp_GetConfig(alpobject *self, PyObject *args){	ALconfig config;	if (!PyArg_ParseTuple(args, ":GetConfig"))		return NULL;	if ((config = alGetConfig(self->port)) == NULL)		return NULL;	return newalcobject(config);}  PyDoc_STRVAR(alp_GetResource__doc__,"alGetResource: get the resource associated with an audio port."); static PyObject *alp_GetResource(alpobject *self, PyObject *args){	int resource; 	if (!PyArg_ParseTuple(args, ":GetResource"))		return NULL;	if ((resource = alGetResource(self->port)) == 0)		return NULL;	return PyInt_FromLong((long) resource);}  PyDoc_STRVAR(alp_GetFD__doc__,"alGetFD: get the file descriptor for an audio port."); static PyObject *alp_GetFD(alpobject *self, PyObject *args){	int fd; 	if (!PyArg_ParseTuple(args, ":GetFD"))		return NULL; 	if ((fd = alGetFD(self->port)) < 0)		return NULL; 	return PyInt_FromLong((long) fd);}  PyDoc_STRVAR(alp_GetFilled__doc__,"alGetFilled: return the number of filled sample frames in ""an audio port."); static PyObject *alp_GetFilled(alpobject *self, PyObject *args){	int filled; 	if (!PyArg_ParseTuple(args, ":GetFilled"))		return NULL;	if ((filled = alGetFilled(self->port)) < 0)		return NULL;	return PyInt_FromLong((long) filled);}  PyDoc_STRVAR(alp_GetFillable__doc__,"alGetFillable: report the number of unfilled sample frames ""in an audio port."); static PyObject *alp_GetFillable(alpobject *self, PyObject *args){	int fillable; 	if (!PyArg_ParseTuple(args, ":GetFillable"))		return NULL;	if ((fillable = alGetFillable(self->port)) < 0)		return NULL;	return PyInt_FromLong((long) fillable);}  PyDoc_STRVAR(alp_ReadFrames__doc__,"alReadFrames: read sample frames from an audio port."); static PyObject *alp_ReadFrames(alpobject *self, PyObject *args){	int framecount;	PyObject *v;	int size;	int ch;	ALconfig c; 	if (!PyArg_ParseTuple(args, "i:ReadFrames", &framecount))		return NULL;	if (framecount < 0) {		PyErr_SetString(ErrorObject, "negative framecount");		return NULL;	}	c = alGetConfig(self->port);	switch (alGetSampFmt(c)) {	case AL_SAMPFMT_TWOSCOMP:		switch (alGetWidth(c)) {		case AL_SAMPLE_8:			size = 1;			break;		case AL_SAMPLE_16:			size = 2;			break;		case AL_SAMPLE_24:			size = 4;			break;		default:			PyErr_SetString(ErrorObject, "can't determine width");			alFreeConfig(c);			return NULL;		}		break;	case AL_SAMPFMT_FLOAT:		size = 4;		break;	case AL_SAMPFMT_DOUBLE:		size = 8;		break;	default:		PyErr_SetString(ErrorObject, "can't determine format");		alFreeConfig(c);		return NULL;	}	ch = alGetChannels(c);	alFreeConfig(c);	if (ch < 0) {		PyErr_SetString(ErrorObject, "can't determine # of channels");		return NULL;	}	size *= ch;	v = PyString_FromStringAndSize((char *) NULL, size * framecount);	if (v == NULL)		return NULL; 	Py_BEGIN_ALLOW_THREADS	alReadFrames(self->port, (void *) PyString_AS_STRING(v), framecount);	Py_END_ALLOW_THREADS 	return v;}  PyDoc_STRVAR(alp_DiscardFrames__doc__,"alDiscardFrames: discard audio from an audio port."); static PyObject *alp_DiscardFrames(alpobject *self, PyObject *args){	int framecount; 	if (!PyArg_ParseTuple(args, "i:DiscardFrames", &framecount))		return NULL; 	Py_BEGIN_ALLOW_THREADS	framecount = alDiscardFrames(self->port, framecount);	Py_END_ALLOW_THREADS 	if (framecount < 0)		return NULL; 	return PyInt_FromLong((long) framecount);}  PyDoc_STRVAR(alp_ZeroFrames__doc__,"alZeroFrames: write zero-valued sample frames to an audio port."); static PyObject *alp_ZeroFrames(alpobject *self, PyObject *args){	int framecount; 	if (!PyArg_ParseTuple(args, "i:ZeroFrames", &framecount))		return NULL; 	if (framecount < 0) {		PyErr_SetString(ErrorObject, "negative framecount");		return NULL;	} 	Py_BEGIN_ALLOW_THREADS	alZeroFrames(self->port, framecount);	Py_END_ALLOW_THREADS 	Py_INCREF(Py_None);	return Py_None;}  PyDoc_STRVAR(alp_SetFillPoint__doc__,"alSetFillPoint: set low- or high-water mark for an audio port."); static PyObject *alp_SetFillPoint(alpobject *self, PyObject *args){	int fillpoint; 	if (!PyArg_ParseTuple(args, "i:SetFillPoint", &fillpoint))		return NULL; 	if (alSetFillPoint(self->port, fillpoint) < 0)		return NULL; 	Py_INCREF(Py_None);	return Py_None;}  PyDoc_STRVAR(alp_GetFillPoint__doc__,"alGetFillPoint: get low- or high-water mark for an audio port."); static PyObject *alp_GetFillPoint(alpobject *self, PyObject *args){	int fillpoint; 	if (!PyArg_ParseTuple(args, ":GetFillPoint"))		return NULL; 	if ((fillpoint = alGetFillPoint(self->port)) < 0)		return NULL; 	return PyInt_FromLong((long) fillpoint);}  PyDoc_STRVAR(alp_GetFrameNumber__doc__,"alGetFrameNumber: get the absolute sample frame number ""associated with a port."); static PyObject *alp_GetFrameNumber(alpobject *self, PyObject *args){	stamp_t fnum; 	if (!PyArg_ParseTuple(args, ":GetFrameNumber"))		return NULL; 	if (alGetFrameNumber(self->port, &fnum) < 0)		return NULL; 	return PyLong_FromLongLong((long long) fnum);}  PyDoc_STRVAR(alp_GetFrameTime__doc__,"alGetFrameTime: get the time at which a sample frame came ""in or will go out."); static PyObject *alp_GetFrameTime(alpobject *self, PyObject *args){	stamp_t fnum, time;	PyObject *ret, *v0, *v1; 	if (!PyArg_ParseTuple(args, ":GetFrameTime"))		return NULL;	if (alGetFrameTime(self->port, &fnum, &time) < 0)		return NULL;	v0 = PyLong_FromLongLong((long long) fnum);	v1 = PyLong_FromLongLong((long long) time);	if (PyErr_Occurred()) {		Py_XDECREF(v0);		Py_XDECREF(v1);		return NULL;	}	ret = PyTuple_Pack(2, v0, v1);	Py_DECREF(v0);	Py_DECREF(v1);	return ret;}  PyDoc_STRVAR(alp_WriteFrames__doc__,"alWriteFrames: write sample frames to an audio port."); static PyObject *alp_WriteFrames(alpobject *self, PyObject *args){	char *samples;	int length;	int size, ch;	ALconfig c; 	if (!PyArg_ParseTuple(args, "s#:WriteFrames", &samples, &length))		return NULL;	c = alGetConfig(self->port);	switch (alGetSampFmt(c)) {	case AL_SAMPFMT_TWOSCOMP:		switch (alGetWidth(c)) {		case AL_SAMPLE_8:			size = 1;			break;		case AL_SAMPLE_16:			size = 2;			break;		case AL_SAMPLE_24:			size = 4;			break;		default:			PyErr_SetString(ErrorObject, "can't determine width");			alFreeConfig(c);			return NULL;		}		break;	case AL_SAMPFMT_FLOAT:		size = 4;		break;	case AL_SAMPFMT_DOUBLE:		size = 8;		break;	default:		PyErr_SetString(ErrorObject, "can't determine format");		alFreeConfig(c);		return NULL;	}	ch = alGetChannels(c);	alFreeConfig(c);	if (ch < 0) {		PyErr_SetString(ErrorObject, "can't determine # of channels");		return NULL;	}	size *= ch;	if (length % size != 0) {		PyErr_SetString(ErrorObject,				"buffer length not whole number of frames");		return NULL;	} 	Py_BEGIN_ALLOW_THREADS	alWriteFrames(self->port, (void *) samples, length / size);	Py_END_ALLOW_THREADS 	Py_INCREF(Py_None);	return Py_None;}  PyDoc_STRVAR(alp_ClosePort__doc__, "alClosePort: close an audio port."); static PyObject *alp_ClosePort(alpobject *self, PyObject *args){	if (!PyArg_ParseTuple(args, ":ClosePort"))		return NULL;	if (alClosePort(self->port) < 0)		return NULL;	self->port = NULL;	Py_INCREF(Py_None);	return Py_None;} #endif /* AL_NO_ELEM */ #ifdef OLD_INTERFACEstatic PyObject *alp_closeport(alpobject *self, PyObject *args){	if (!PyArg_ParseTuple(args, ":ClosePort"))		return NULL;	if (ALcloseport(self->port) < 0)		return NULL;	self->port = NULL;

Lines 501–1000 of 3226. Previous lines