forked from auracaster/pyalsaaudio
Applied slightly modified patch 3372909 by Erik Kulyk.
git-svn-id: svn://svn.code.sf.net/p/pyalsaaudio/code/trunk@40 ec2f30ec-7544-0410-870e-f70ca00c83f0
This commit is contained in:
5
CHANGES
5
CHANGES
@@ -1,8 +1,13 @@
|
|||||||
|
Version 0.7:
|
||||||
|
- fixed several memory leaks (patch 3372909), contributed by Erik Kulyk)
|
||||||
|
|
||||||
|
|
||||||
Version 0.6:
|
Version 0.6:
|
||||||
- mostly reverted patch 2594366: alsapcm_setup did not do complete error
|
- mostly reverted patch 2594366: alsapcm_setup did not do complete error
|
||||||
checking for good reasons; some ALSA functions in alsapcm_setup may fail without
|
checking for good reasons; some ALSA functions in alsapcm_setup may fail without
|
||||||
rendering the device unusable
|
rendering the device unusable
|
||||||
|
|
||||||
|
|
||||||
Version 0.5:
|
Version 0.5:
|
||||||
- applied patch 2777035: Fixed setrec method in alsaaudio.c
|
- applied patch 2777035: Fixed setrec method in alsaaudio.c
|
||||||
This included a mixertest with more features
|
This included a mixertest with more features
|
||||||
|
|||||||
130
alsaaudio.c
130
alsaaudio.c
@@ -131,7 +131,8 @@ alsacard_list(PyObject *self, PyObject *args)
|
|||||||
{
|
{
|
||||||
char name[32];
|
char name[32];
|
||||||
int err;
|
int err;
|
||||||
|
PyObject *item;
|
||||||
|
|
||||||
/* One would be tempted to think that snd_card_get_name returns a name
|
/* One would be tempted to think that snd_card_get_name returns a name
|
||||||
that is actually meaningful for any further operations.
|
that is actually meaningful for any further operations.
|
||||||
|
|
||||||
@@ -148,9 +149,10 @@ alsacard_list(PyObject *self, PyObject *args)
|
|||||||
Py_DECREF(result);
|
Py_DECREF(result);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyList_Append(result,
|
item = PyUnicode_FromString(snd_ctl_card_info_get_id(info));
|
||||||
PyUnicode_FromString(snd_ctl_card_info_get_id(info)));
|
PyList_Append(result, item);
|
||||||
|
Py_DECREF(item);
|
||||||
|
|
||||||
snd_ctl_close(handle);
|
snd_ctl_close(handle);
|
||||||
}
|
}
|
||||||
@@ -1205,6 +1207,8 @@ static PyObject *
|
|||||||
alsamixer_volumecap(alsamixer_t *self, PyObject *args)
|
alsamixer_volumecap(alsamixer_t *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *result;
|
PyObject *result;
|
||||||
|
PyObject *item;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args,":volumecap")) return NULL;
|
if (!PyArg_ParseTuple(args,":volumecap")) return NULL;
|
||||||
|
|
||||||
if (!self->handle)
|
if (!self->handle)
|
||||||
@@ -1215,18 +1219,42 @@ alsamixer_volumecap(alsamixer_t *self, PyObject *args)
|
|||||||
|
|
||||||
result = PyList_New(0);
|
result = PyList_New(0);
|
||||||
if (self->volume_cap&MIXER_CAP_VOLUME)
|
if (self->volume_cap&MIXER_CAP_VOLUME)
|
||||||
PyList_Append(result,PyUnicode_FromString("Volume"));
|
{
|
||||||
|
item = PyUnicode_FromString("Volume");
|
||||||
|
PyList_Append(result, item);
|
||||||
|
Py_DECREF(item);
|
||||||
|
}
|
||||||
if (self->volume_cap&MIXER_CAP_VOLUME_JOINED)
|
if (self->volume_cap&MIXER_CAP_VOLUME_JOINED)
|
||||||
PyList_Append(result,PyUnicode_FromString("Joined Volume"));
|
{
|
||||||
|
item = PyUnicode_FromString("Joined Volume");
|
||||||
|
PyList_Append(result, item);
|
||||||
|
Py_DECREF(item);
|
||||||
|
}
|
||||||
if (self->volume_cap&MIXER_CAP_PVOLUME)
|
if (self->volume_cap&MIXER_CAP_PVOLUME)
|
||||||
PyList_Append(result,PyUnicode_FromString("Playback Volume"));
|
{
|
||||||
|
item = PyUnicode_FromString("Playback Volume");
|
||||||
|
PyList_Append(result, item);
|
||||||
|
Py_DECREF(item);
|
||||||
|
}
|
||||||
if (self->volume_cap&MIXER_CAP_PVOLUME_JOINED)
|
if (self->volume_cap&MIXER_CAP_PVOLUME_JOINED)
|
||||||
PyList_Append(result,PyUnicode_FromString("Joined Playback Volume"));
|
{
|
||||||
|
item = PyUnicode_FromString("Joined Playback Volume");
|
||||||
|
PyList_Append(result, item);
|
||||||
|
Py_DECREF(item);
|
||||||
|
}
|
||||||
if (self->volume_cap&MIXER_CAP_CVOLUME)
|
if (self->volume_cap&MIXER_CAP_CVOLUME)
|
||||||
PyList_Append(result,PyUnicode_FromString("Capture Volume"));
|
{
|
||||||
|
item = PyUnicode_FromString("Capture Volume");
|
||||||
|
PyList_Append(result, item);
|
||||||
|
Py_DECREF(item);
|
||||||
|
}
|
||||||
if (self->volume_cap&MIXER_CAP_CVOLUME_JOINED)
|
if (self->volume_cap&MIXER_CAP_CVOLUME_JOINED)
|
||||||
PyList_Append(result,PyUnicode_FromString("Joined Capture Volume"));
|
{
|
||||||
|
item = PyUnicode_FromString("Joined Capture Volume");
|
||||||
|
PyList_Append(result, item);
|
||||||
|
Py_DECREF(item);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1247,6 +1275,8 @@ static PyObject *
|
|||||||
alsamixer_switchcap(alsamixer_t *self, PyObject *args)
|
alsamixer_switchcap(alsamixer_t *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *result;
|
PyObject *result;
|
||||||
|
PyObject *item;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args,":switchcap"))
|
if (!PyArg_ParseTuple(args,":switchcap"))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -1258,19 +1288,47 @@ alsamixer_switchcap(alsamixer_t *self, PyObject *args)
|
|||||||
|
|
||||||
result = PyList_New(0);
|
result = PyList_New(0);
|
||||||
if (self->volume_cap&MIXER_CAP_SWITCH)
|
if (self->volume_cap&MIXER_CAP_SWITCH)
|
||||||
PyList_Append(result,PyUnicode_FromString("Mute"));
|
{
|
||||||
|
item = PyUnicode_FromString("Mute");
|
||||||
|
PyList_Append(result, item);
|
||||||
|
Py_DECREF(item);
|
||||||
|
}
|
||||||
if (self->volume_cap&MIXER_CAP_SWITCH_JOINED)
|
if (self->volume_cap&MIXER_CAP_SWITCH_JOINED)
|
||||||
PyList_Append(result,PyUnicode_FromString("Joined Mute"));
|
{
|
||||||
|
item = PyUnicode_FromString("Joined Mute");
|
||||||
|
PyList_Append(result, item);
|
||||||
|
Py_DECREF(item);
|
||||||
|
}
|
||||||
if (self->volume_cap&MIXER_CAP_PSWITCH)
|
if (self->volume_cap&MIXER_CAP_PSWITCH)
|
||||||
PyList_Append(result,PyUnicode_FromString("Playback Mute"));
|
{
|
||||||
|
item = PyUnicode_FromString("Playback Mute");
|
||||||
|
PyList_Append(result, item);
|
||||||
|
Py_DECREF(item);
|
||||||
|
}
|
||||||
if (self->volume_cap&MIXER_CAP_PSWITCH_JOINED)
|
if (self->volume_cap&MIXER_CAP_PSWITCH_JOINED)
|
||||||
PyList_Append(result,PyUnicode_FromString("Joined Playback Mute"));
|
{
|
||||||
|
item = PyUnicode_FromString("Joined Playback Mute");
|
||||||
|
PyList_Append(result, item);
|
||||||
|
Py_DECREF(item);
|
||||||
|
}
|
||||||
if (self->volume_cap&MIXER_CAP_CSWITCH)
|
if (self->volume_cap&MIXER_CAP_CSWITCH)
|
||||||
PyList_Append(result,PyUnicode_FromString("Capture Mute"));
|
{
|
||||||
|
item = PyUnicode_FromString("Capture Mute");
|
||||||
|
PyList_Append(result, item);
|
||||||
|
Py_DECREF(item);
|
||||||
|
}
|
||||||
if (self->volume_cap&MIXER_CAP_CSWITCH_JOINED)
|
if (self->volume_cap&MIXER_CAP_CSWITCH_JOINED)
|
||||||
PyList_Append(result,PyUnicode_FromString("Joined Capture Mute"));
|
{
|
||||||
|
item = PyUnicode_FromString("Joined Capture Mute");
|
||||||
|
PyList_Append(result, item);
|
||||||
|
Py_DECREF(item);
|
||||||
|
}
|
||||||
if (self->volume_cap&MIXER_CAP_CSWITCH_EXCLUSIVE)
|
if (self->volume_cap&MIXER_CAP_CSWITCH_EXCLUSIVE)
|
||||||
PyList_Append(result,PyUnicode_FromString("Capture Exclusive"));
|
{
|
||||||
|
item = PyUnicode_FromString("Capture Exclusive");
|
||||||
|
PyList_Append(result, item);
|
||||||
|
Py_DECREF(item);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1326,6 +1384,7 @@ alsamixer_getvolume(alsamixer_t *self, PyObject *args)
|
|||||||
long ival;
|
long ival;
|
||||||
char *dirstr = 0;
|
char *dirstr = 0;
|
||||||
PyObject *result;
|
PyObject *result;
|
||||||
|
PyObject *item;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args,"|s:getvolume",&dirstr))
|
if (!PyArg_ParseTuple(args,"|s:getvolume",&dirstr))
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -1362,19 +1421,21 @@ alsamixer_getvolume(alsamixer_t *self, PyObject *args)
|
|||||||
snd_mixer_selem_has_playback_channel(elem, channel))
|
snd_mixer_selem_has_playback_channel(elem, channel))
|
||||||
{
|
{
|
||||||
snd_mixer_selem_get_playback_volume(elem, channel, &ival);
|
snd_mixer_selem_get_playback_volume(elem, channel, &ival);
|
||||||
PyList_Append(
|
item = PyLong_FromLong(alsamixer_getpercentage(self->pmin,
|
||||||
result, PyLong_FromLong(alsamixer_getpercentage(self->pmin,
|
self->pmax,
|
||||||
self->pmax,
|
ival));
|
||||||
ival)));
|
PyList_Append(result, item);
|
||||||
|
Py_DECREF(item);
|
||||||
}
|
}
|
||||||
else if (direction == 1
|
else if (direction == 1
|
||||||
&& snd_mixer_selem_has_capture_channel(elem, channel)
|
&& snd_mixer_selem_has_capture_channel(elem, channel)
|
||||||
&& 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(
|
item = PyLong_FromLong(alsamixer_getpercentage(self->cmin,
|
||||||
result, PyLong_FromLong(alsamixer_getpercentage(self->cmin,
|
self->cmax,
|
||||||
self->cmax,
|
ival));
|
||||||
ival)));
|
PyList_Append(result, item);
|
||||||
|
Py_DECREF(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1555,6 +1616,8 @@ alsamixer_getmute(alsamixer_t *self, PyObject *args)
|
|||||||
int i;
|
int i;
|
||||||
int ival;
|
int ival;
|
||||||
PyObject *result;
|
PyObject *result;
|
||||||
|
PyObject *item;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args,":getmute"))
|
if (!PyArg_ParseTuple(args,":getmute"))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -1570,13 +1633,18 @@ alsamixer_getmute(alsamixer_t *self, PyObject *args)
|
|||||||
PyErr_SetString(ALSAAudioError,"Mixer has no mute switch");
|
PyErr_SetString(ALSAAudioError,"Mixer has no mute switch");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = PyList_New(0);
|
result = PyList_New(0);
|
||||||
|
|
||||||
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,PyLong_FromLong(!ival));
|
|
||||||
|
item = PyLong_FromLong(!ival);
|
||||||
|
PyList_Append(result, item);
|
||||||
|
Py_DECREF(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -1598,6 +1666,8 @@ alsamixer_getrec(alsamixer_t *self, PyObject *args)
|
|||||||
int i;
|
int i;
|
||||||
int ival;
|
int ival;
|
||||||
PyObject *result;
|
PyObject *result;
|
||||||
|
PyObject *item;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args,":getrec"))
|
if (!PyArg_ParseTuple(args,":getrec"))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -1613,13 +1683,17 @@ alsamixer_getrec(alsamixer_t *self, PyObject *args)
|
|||||||
PyErr_SetString(ALSAAudioError,"Mixer has no record switch");
|
PyErr_SetString(ALSAAudioError,"Mixer has no record switch");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = PyList_New(0);
|
result = PyList_New(0);
|
||||||
|
|
||||||
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,PyLong_FromLong(ival));
|
item = PyLong_FromLong(ival);
|
||||||
|
PyList_Append(result, item);
|
||||||
|
Py_DECREF(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user