Some preparations for porting to py3k.

git-svn-id: svn://svn.code.sf.net/p/pyalsaaudio/code/trunk@24 ec2f30ec-7544-0410-870e-f70ca00c83f0
This commit is contained in:
larsimmisch
2008-10-27 18:55:35 +00:00
parent df89c12581
commit 7fa6f1c85c
+15 -14
View File
@@ -14,6 +14,7 @@
*/ */
#include "Python.h" #include "Python.h"
#include "stringobject.h"
#include <alsa/asoundlib.h> #include <alsa/asoundlib.h>
#include <stdio.h> #include <stdio.h>
@@ -277,7 +278,7 @@ alsapcm_dumpinfo(alsapcm_t *self, PyObject *args) {
static PyObject * static PyObject *
alsapcm_pcmtype(alsapcm_t *self, PyObject *args) { alsapcm_pcmtype(alsapcm_t *self, PyObject *args) {
if (!PyArg_ParseTuple(args,":pcmtype")) return NULL; if (!PyArg_ParseTuple(args,":pcmtype")) return NULL;
return PyInt_FromLong(self->pcmtype); return PyLong_FromLong(self->pcmtype);
} }
PyDoc_STRVAR(pcmtype_doc, PyDoc_STRVAR(pcmtype_doc,
@@ -289,7 +290,7 @@ Returns either PCM_CAPTURE or PCM_PLAYBACK.");
static PyObject * static PyObject *
alsapcm_pcmmode(alsapcm_t *self, PyObject *args) { alsapcm_pcmmode(alsapcm_t *self, PyObject *args) {
if (!PyArg_ParseTuple(args,"pcmmode")) return NULL; if (!PyArg_ParseTuple(args,"pcmmode")) return NULL;
return PyInt_FromLong(self->pcmmode); return PyLong_FromLong(self->pcmmode);
} }
PyDoc_STRVAR(pcmmode_doc, PyDoc_STRVAR(pcmmode_doc,
@@ -324,7 +325,7 @@ alsapcm_setchannels(alsapcm_t *self, PyObject *args) {
PyErr_SetString(ALSAAudioError, snd_strerror(res)); PyErr_SetString(ALSAAudioError, snd_strerror(res));
return NULL; return NULL;
} }
return PyInt_FromLong(self->channels); return PyLong_FromLong(self->channels);
} }
PyDoc_STRVAR(setchannels_doc, PyDoc_STRVAR(setchannels_doc,
@@ -347,7 +348,7 @@ alsapcm_setrate(alsapcm_t *self, PyObject *args) {
PyErr_SetString(ALSAAudioError, snd_strerror(res)); PyErr_SetString(ALSAAudioError, snd_strerror(res));
return NULL; return NULL;
} }
return PyInt_FromLong(self->rate); return PyLong_FromLong(self->rate);
} }
PyDoc_STRVAR(setrate_doc, PyDoc_STRVAR(setrate_doc,
@@ -368,7 +369,7 @@ alsapcm_setformat(alsapcm_t *self, PyObject *args) {
PyErr_SetString(ALSAAudioError, snd_strerror(res)); PyErr_SetString(ALSAAudioError, snd_strerror(res));
return NULL; return NULL;
} }
return PyInt_FromLong(self->format); return PyLong_FromLong(self->format);
} }
PyDoc_STRVAR(setformat_doc, PyDoc_STRVAR(setformat_doc,
@@ -386,7 +387,7 @@ alsapcm_setperiodsize(alsapcm_t *self, PyObject *args) {
PyErr_SetString(ALSAAudioError, snd_strerror(res)); PyErr_SetString(ALSAAudioError, snd_strerror(res));
return NULL; return NULL;
} }
return PyInt_FromLong(self->periodsize); return PyLong_FromLong(self->periodsize);
} }
PyDoc_STRVAR(setperiodsize_doc, PyDoc_STRVAR(setperiodsize_doc,
@@ -471,14 +472,14 @@ static PyObject *alsapcm_write(alsapcm_t *self, PyObject *args) {
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
if (res == -EAGAIN) { if (res == -EAGAIN) {
return PyInt_FromLong(0); return PyLong_FromLong(0);
} }
else if (res < 0) { else if (res < 0) {
PyErr_SetString(ALSAAudioError,snd_strerror(res)); PyErr_SetString(ALSAAudioError,snd_strerror(res));
return NULL; return NULL;
} }
return PyInt_FromLong(res); return PyLong_FromLong(res);
} }
PyDoc_STRVAR(write_doc, PyDoc_STRVAR(write_doc,
@@ -510,7 +511,7 @@ static PyObject *alsapcm_pause(alsapcm_t *self, PyObject *args) {
PyErr_SetString(ALSAAudioError,snd_strerror(res)); PyErr_SetString(ALSAAudioError,snd_strerror(res));
return NULL; return NULL;
} }
return PyInt_FromLong(res); return PyLong_FromLong(res);
} }
PyDoc_STRVAR(pause_doc, PyDoc_STRVAR(pause_doc,
@@ -812,7 +813,7 @@ for example 'Master' or 'PCM'");
static PyObject * static PyObject *
alsamixer_mixerid(alsamixer_t *self, PyObject *args) { alsamixer_mixerid(alsamixer_t *self, PyObject *args) {
if (!PyArg_ParseTuple(args,":mixerid")) return NULL; if (!PyArg_ParseTuple(args,":mixerid")) return NULL;
return PyInt_FromLong(self->controlid); return PyLong_FromLong(self->controlid);
} }
PyDoc_STRVAR(mixerid_doc, PyDoc_STRVAR(mixerid_doc,
@@ -942,7 +943,7 @@ alsamixer_getvolume(alsamixer_t *self, PyObject *args) {
{ {
snd_mixer_selem_get_playback_volume(elem, channel, &ival); snd_mixer_selem_get_playback_volume(elem, channel, &ival);
PyList_Append( PyList_Append(
result, PyInt_FromLong(alsamixer_getpercentage(self->pmin, result, PyLong_FromLong(alsamixer_getpercentage(self->pmin,
self->pmax, ival))); self->pmax, ival)));
} }
else if (direction == 1 else if (direction == 1
@@ -950,7 +951,7 @@ alsamixer_getvolume(alsamixer_t *self, PyObject *args) {
&& snd_mixer_selem_has_capture_volume(elem)) { && snd_mixer_selem_has_capture_volume(elem)) {
snd_mixer_selem_get_capture_volume(elem, channel, &ival); snd_mixer_selem_get_capture_volume(elem, channel, &ival);
PyList_Append( PyList_Append(
result, PyInt_FromLong(alsamixer_getpercentage(self->cmin, result, PyLong_FromLong(alsamixer_getpercentage(self->cmin,
self->cmax, ival))); self->cmax, ival)));
} }
} }
@@ -1112,7 +1113,7 @@ alsamixer_getmute(alsamixer_t *self, PyObject *args) {
for (i = 0; i <= SND_MIXER_SCHN_LAST; i++) { for (i = 0; i <= SND_MIXER_SCHN_LAST; i++) {
if (snd_mixer_selem_has_playback_channel(elem, i)) { if (snd_mixer_selem_has_playback_channel(elem, i)) {
snd_mixer_selem_get_playback_switch(elem, i, &ival); snd_mixer_selem_get_playback_switch(elem, i, &ival);
PyList_Append(result,PyInt_FromLong(!ival)); PyList_Append(result,PyLong_FromLong(!ival));
} }
} }
return result; return result;
@@ -1144,7 +1145,7 @@ alsamixer_getrec(alsamixer_t *self, PyObject *args) {
for (i = 0; i <= SND_MIXER_SCHN_LAST; i++) { for (i = 0; i <= SND_MIXER_SCHN_LAST; i++) {
if (snd_mixer_selem_has_capture_channel(elem, i)) { if (snd_mixer_selem_has_capture_channel(elem, i)) {
snd_mixer_selem_get_capture_switch(elem, i, &ival); snd_mixer_selem_get_capture_switch(elem, i, &ival);
PyList_Append(result,PyInt_FromLong(!ival)); PyList_Append(result,PyLong_FromLong(!ival));
} }
} }
return result; return result;