diff options
author | Hoger Dehnhardt <holger@dehnhardt.org> | 2016-12-19 21:13:16 +0100 |
---|---|---|
committer | Hoger Dehnhardt <holger@dehnhardt.org> | 2016-12-19 21:13:16 +0100 |
commit | feef5ca5c10ffa9250cc3c51393efb859055cd37 (patch) | |
tree | 03fdd6b0a9bf2c935357f4d95810c8c37d16843d | |
parent | 4429cbe48e64bbe42c7ab2b1943560fcfc979f84 (diff) | |
download | jack2-feef5ca5c10ffa9250cc3c51393efb859055cd37.tar.gz |
added a toggle command to allow toggling between play and stop state
-rw-r--r-- | example-clients/transport.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/example-clients/transport.c b/example-clients/transport.c index c543b410..ff91e765 100644 --- a/example-clients/transport.c +++ b/example-clients/transport.c @@ -211,6 +211,29 @@ static void com_timeout(char *arg) jack_set_sync_timeout(client, (jack_time_t) (timeout*1000000)); } +/* Toggle between play and stop state */ +static void com_toggle(char *arg) +{ + jack_position_t current; + jack_transport_state_t transport_state; + + transport_state = jack_transport_query (client, ¤t); + + switch (transport_state) { + case JackTransportStopped: + com_play( arg ); + break; + case JackTransportRolling: + com_stop( arg ); + break; + case JackTransportStarting: + printf ("state: Starting - no transport toggling"); + break; + default: + printf ("state: Starting - no transport toggling"); + } +} + /* Command parsing based on GNU readline info examples. */ @@ -238,6 +261,7 @@ command_t commands[] = { {"stop", com_stop, "Stop transport"}, {"tempo", com_tempo, "Set beat tempo <beats_per_min>"}, {"timeout", com_timeout, "Set sync timeout in <seconds>"}, + {"toggle", com_toggle, "Toggle transport rolling"}, {"?", com_help, "Synonym for `help'" }, {(char *)NULL, (cmd_function_t *)NULL, (char *)NULL } }; |