mirror of
https://github.com/larsimmisch/pyalsaaudio.git
synced 2026-04-17 00:25:29 +00:00
Import from divmod. Original log message:
r1316 | anthony | 2005-03-30 18:46:21 +0200 (Wed, 30 Mar 2005) | 1 line setchannels() no longer is insane for only-stereo devices git-svn-id: svn://svn.code.sf.net/p/pyalsaaudio/code/trunk@10 ec2f30ec-7544-0410-870e-f70ca00c83f0
This commit is contained in:
14
alsaaudio.c
14
alsaaudio.c
@@ -134,6 +134,7 @@ alsapcm_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
|
||||
|
||||
self->handle = 0;
|
||||
res = alsapcm_setup(self);
|
||||
|
||||
if (res < 0) {
|
||||
if (self->handle) {
|
||||
snd_pcm_close(self->handle);
|
||||
@@ -269,14 +270,23 @@ static PyObject *
|
||||
alsapcm_setchannels(alsapcm_t *self, PyObject *args) {
|
||||
int channels;
|
||||
int res;
|
||||
unsigned int val;
|
||||
snd_pcm_hw_params_t *hwparams;
|
||||
snd_pcm_hw_params_alloca(&hwparams);
|
||||
snd_pcm_hw_params_current(self->handle,hwparams);
|
||||
|
||||
if (!PyArg_ParseTuple(args,"i",&channels)) return NULL;
|
||||
self->channels = channels;
|
||||
res = alsapcm_setup(self);
|
||||
if (res < 0) {
|
||||
PyErr_SetString(ALSAAudioError, snd_strerror(res));
|
||||
return NULL;
|
||||
}
|
||||
return PyInt_FromLong(channels);
|
||||
|
||||
snd_pcm_hw_params_get_channels(hwparams, &val);
|
||||
|
||||
self->channels = val;
|
||||
|
||||
return PyInt_FromLong(val);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
||||
Reference in New Issue
Block a user