|
| 1 | +#!/usr/bin/env python |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | + |
| 4 | +import sys |
| 5 | + |
| 6 | +from ctypes import pointer |
| 7 | +import jacklib |
| 8 | +from jacklib.helpers import get_jack_status_error_string |
| 9 | + |
| 10 | + |
| 11 | +status = jacklib.jack_status_t() |
| 12 | +client = jacklib.client_open("transport-query", jacklib.JackNoStartServer, status) |
| 13 | + |
| 14 | +if status: |
| 15 | + err = get_jack_status_error_string(status) |
| 16 | + sys.exit("Error connecting to JACK server: %s" % err) |
| 17 | + |
| 18 | +position = jacklib.jack_position_t() |
| 19 | +transport_state = jacklib.transport_query(client, pointer(position)) |
| 20 | + |
| 21 | +for name, type_ in sorted(position._fields_): |
| 22 | + value = getattr(position, name) |
| 23 | + if name == 'padding': |
| 24 | + value = list(value) |
| 25 | + print("{}: {}".format(name, value), file=sys.stderr) |
| 26 | + |
| 27 | +if transport_state == jacklib.JackTransportStopped: |
| 28 | + print("JACK transport stopped, starting it now.") |
| 29 | + jacklib.transport_start(client) |
| 30 | +elif transport_state == jacklib.JackTransportRolling: |
| 31 | + print("JACK transport rolling, stopping it now.") |
| 32 | + jacklib.transport_stop(client) |
| 33 | +elif transport_state == jacklib.JackTransportStarting: |
| 34 | + print("JACK transport starting, nothing to do.") |
| 35 | +else: |
| 36 | + print("Unknown JACK transport state.") |
| 37 | + |
| 38 | +jacklib.client_close(client) |
0 commit comments