diff options
author | cbdev <cb@cbcdn.com> | 2020-08-08 15:38:48 +0200 |
---|---|---|
committer | cbdev <cb@cbcdn.com> | 2020-08-08 15:38:48 +0200 |
commit | 7a00b8fda337ad38cfba4689dd5fc07686783158 (patch) | |
tree | a342cac88c9b3b1158c044be295e19e4e51b6ced /backends/python.c | |
parent | b6ea5bbddf9db836ba206127b6eb77ca21cb8fa4 (diff) | |
download | midimonster-7a00b8fda337ad38cfba4689dd5fc07686783158.tar.gz midimonster-7a00b8fda337ad38cfba4689dd5fc07686783158.tar.bz2 midimonster-7a00b8fda337ad38cfba4689dd5fc07686783158.zip |
Python channel introspection (#68)
Diffstat (limited to 'backends/python.c')
-rw-r--r-- | backends/python.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/backends/python.c b/backends/python.c index bd73a20..b9b6518 100644 --- a/backends/python.c +++ b/backends/python.c @@ -112,6 +112,24 @@ static int python_prepend_str(PyObject* list, char* str){ return 0; } +static PyObject* mmpy_channels(PyObject* self, PyObject* args){ + size_t u = 0; + PyObject* list = NULL; + instance* inst = *((instance**) PyModule_GetState(self)); + python_instance_data* data = (python_instance_data*) inst->impl; + + if(!last_timestamp){ + LOG("The channels() API will not return usable results before the configuration has been read completely"); + } + + list = PyList_New(data->channels); + for(u = 0; u < data->channels; u++){ + PyList_SET_ITEM(list, u, PyUnicode_FromString(data->channel[u].name)); + } + + return list; +} + static PyObject* mmpy_output(PyObject* self, PyObject* args){ instance* inst = *((instance**) PyModule_GetState(self)); python_instance_data* data = (python_instance_data*) inst->impl; @@ -432,6 +450,7 @@ static PyObject* mmpy_init(){ {"timestamp", mmpy_timestamp, METH_VARARGS, "Get the core timestamp (in milliseconds)"}, {"manage", mmpy_manage_fd, METH_VARARGS, "(Un-)register a socket or file descriptor for notifications"}, {"interval", mmpy_interval, METH_VARARGS, "Register or update an interval handler"}, + {"channels", mmpy_channels, METH_VARARGS, "List currently registered instance channels"}, {"cleanup_handler", mmpy_cleanup_handler, METH_VARARGS, "Register or update the instances cleanup handler"}, {0} }; |