From: Frédéric Péters Date: Fri, 11 Dec 2009 14:36:06 +0000 (+0100) Subject: Add methods to know if a channel has been muted/soloed X-Git-Tag: release-7~23 X-Git-Url: https://git.0d.be/?p=jack_mixer.git;a=commitdiff_plain;h=05b07d34037da55b39cab4ec3451b35d578cecd9 Add methods to know if a channel has been muted/soloed --- diff --git a/jack_mixer.c b/jack_mixer.c index 2ae8e93..92da87c 100644 --- a/jack_mixer.c +++ b/jack_mixer.c @@ -1313,3 +1313,28 @@ output_channel_set_muted( output_channel_ptr->muted_channels = g_slist_remove(output_channel_ptr->muted_channels, channel); } } + +bool +output_channel_is_muted( + jack_mixer_output_channel_t output_channel, + jack_mixer_channel_t channel) +{ + struct output_channel *output_channel_ptr = output_channel; + + if (g_slist_find(output_channel_ptr->muted_channels, channel) != NULL) + return true; + return false; +} + +bool +output_channel_is_solo( + jack_mixer_output_channel_t output_channel, + jack_mixer_channel_t channel) +{ + struct output_channel *output_channel_ptr = output_channel; + + if (g_slist_find(output_channel_ptr->soloed_channels, channel) != NULL) + return true; + return false; +} + diff --git a/jack_mixer.h b/jack_mixer.h index bc4c007..7d85d87 100644 --- a/jack_mixer.h +++ b/jack_mixer.h @@ -231,4 +231,14 @@ output_channel_set_muted( jack_mixer_channel_t channel, bool muted_value); +bool +output_channel_is_muted( + jack_mixer_output_channel_t output_channel, + jack_mixer_channel_t channel); + +bool +output_channel_is_solo( + jack_mixer_output_channel_t output_channel, + jack_mixer_channel_t channel); + #endif /* #ifndef JACK_MIXER_H__DAEB51D8_5861_40F2_92E4_24CA495A384D__INCLUDED */ diff --git a/jack_mixer_c.c b/jack_mixer_c.c index a1c2e1b..c1ba4b8 100644 --- a/jack_mixer_c.c +++ b/jack_mixer_c.c @@ -576,7 +576,7 @@ static PyObject* OutputChannel_set_solo(OutputChannelObject *self, PyObject *args) { PyObject *channel; - int solo; + unsigned char solo; if (! PyArg_ParseTuple(args, "Ob", &channel, &solo)) return NULL; @@ -592,7 +592,7 @@ static PyObject* OutputChannel_set_muted(OutputChannelObject *self, PyObject *args) { PyObject *channel; - int muted; + unsigned char muted; if (! PyArg_ParseTuple(args, "Ob", &channel, &muted)) return NULL; @@ -604,12 +604,50 @@ OutputChannel_set_muted(OutputChannelObject *self, PyObject *args) return Py_None; } +static PyObject* +OutputChannel_is_solo(OutputChannelObject *self, PyObject *args) +{ + PyObject *channel; + PyObject *result; + + if (! PyArg_ParseTuple(args, "O", &channel)) return NULL; + + if (output_channel_is_solo(self->output_channel, + ((ChannelObject*)channel)->channel)) { + result = Py_True; + } else { + result = Py_False; + } + + Py_INCREF(result); + return result; +} +static PyObject* +OutputChannel_is_muted(OutputChannelObject *self, PyObject *args) +{ + PyObject *channel; + PyObject *result; + + if (! PyArg_ParseTuple(args, "O", &channel)) return NULL; + + if (output_channel_is_muted(self->output_channel, + ((ChannelObject*)channel)->channel)) { + result = Py_True; + } else { + result = Py_False; + } + + Py_INCREF(result); + return result; +} static PyMethodDef output_channel_methods[] = { {"remove", (PyCFunction)OutputChannel_remove, METH_VARARGS, "Remove"}, {"set_solo", (PyCFunction)OutputChannel_set_solo, METH_VARARGS, "Set a channel as solo"}, {"set_muted", (PyCFunction)OutputChannel_set_muted, METH_VARARGS, "Set a channel as muted"}, + {"is_solo", (PyCFunction)OutputChannel_is_solo, METH_VARARGS, "Is a channel set as solo"}, + {"is_muted", (PyCFunction)OutputChannel_is_muted, METH_VARARGS, "Is a channel set as muted"}, {NULL} };