Browse Source

implemented Port.set_short_name()

Fabian Peter Hammerle 9 năm trước cách đây
mục cha
commit
30c2defe29
3 tập tin đã thay đổi với 23 bổ sung1 xóa
  1. 1 1
      examples/ports-list.py
  2. 0 0
      examples/registration-callback.py
  3. 22 0
      jack.c

+ 1 - 1
tests/ports-list.py → examples/ports-list.py

@@ -9,7 +9,7 @@ import argparse
 
 def run():
 
-    client = jack.Client("registration callback test");
+    client = jack.Client("ports list example");
 
     for port in client.get_ports():
         print port.get_name()

+ 0 - 0
tests/registration-callback.py → examples/registration-callback.py


+ 22 - 0
jack.c

@@ -180,6 +180,22 @@ static PyObject* port_get_short_name(Port* self)
     return (PyObject*)PyString_FromString(jack_port_short_name(self->port));
 }
 
+static PyObject* port_set_short_name(Port* self, PyObject* args)
+{
+    const char* name;
+    if(!PyArg_ParseTuple(args, "s", &name)) {
+        return NULL;
+    }
+
+    // 0 on success, otherwise a non-zero error code.
+    if(jack_port_set_name(self->port, name)) {
+        return NULL;
+    }
+
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+
 static PyObject* port_get_aliases(Port* self)
 {
     PyObject* aliases_list = PyList_New(0);
@@ -226,6 +242,12 @@ static PyMethodDef port_methods[] = {
         METH_NOARGS,
         "Return port's name without the preceding name of the asssociated client.",
         },
+    {
+        "set_short_name",
+        (PyCFunction)port_set_short_name,
+        METH_VARARGS,
+        "Modify a port's short name. May be called at any time.",
+        },
     {
         "get_aliases",
         (PyCFunction)port_get_aliases,