Skip to content

Instantly share code, notes, and snippets.

@SpotlightKid
Last active April 11, 2024 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SpotlightKid/420b975c296b08bfc5ecdcbe82cedba7 to your computer and use it in GitHub Desktop.
Save SpotlightKid/420b975c296b08bfc5ecdcbe82cedba7 to your computer and use it in GitHub Desktop.
Check whether JACK transport is rolling and toggle state
import sys
# See https://github.com/SpotlightKid/jack-matchmaker/blob/master/jackmatchmaker/jacklib.py
import jacklib
result = jacklib.jack_status_t()
client = jacklib.client_open("transport-query", jacklib.JackNoStartServer, result)
if result:
sys.exit("Error connecting to JACK server.")
transport_state = jacklib.transport_query(client, None)
if transport_state == jacklib.JackTransportStopped:
print("JACK transport stopped, starting it now.")
jacklib.transport_start(client)
elif transport_state == jacklib.JackTransportRolling:
print("JACK transport rolling, stopping it now.")
jacklib.transport_stop(client)
elif transport_state == jacklib.JackTransportStarting:
print("JACK transport starting, nothing to do.")
else:
print("Unknown JACK transport state.")
jacklib.client_close(client)
@SpotlightKid
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment