diff --git a/src/cadence_aloop_daemon.py b/src/cadence_aloop_daemon.py index c759fb8..ae848b2 100755 --- a/src/cadence_aloop_daemon.py +++ b/src/cadence_aloop_daemon.py @@ -82,15 +82,9 @@ def sample_rate_callback(newSampleRate, arg): # listen to jack2 master switch def client_registration_callback(clientName, register, arg): - if clientName == b"system" and register: - print("NOTICE: Possible JACK2 master switch") - global bufferSize, sampleRate, doRunNow - bufferSize = jacklib.get_buffer_size(client) - sampleRate = jacklib.get_sample_rate(client) - doRunNow = True - - elif clientName in (b"alsa2jack", b"jack2alsa") and not register: - global doLoop, reactivateCounter, useZita + global doLoop, doRunNow, reactivateCounter, useZita + + if clientName in (b"alsa2jack", b"jack2alsa") and not register: if doRunNow or not doLoop: return @@ -102,6 +96,25 @@ def client_registration_callback(clientName, register, arg): doLoop = False print("NOTICE: %s has been stopped, quitting now..." % ("zita-a2j/j2a" if useZita else "alsa_in/out")) +# -------------------------------------------------- +# listen to jack freewheel + +def freewheel_callback(isFreewheel, arg): + global doRunNow, procIn, procOut + + if not isFreewheel: + # resume normal operation + doRunNow = True + return + + # stop daemon for freewheel access + if procIn.state() != QProcess.NotRunning: + procIn.terminate() + procIn.waitForFinished(1000) + if procOut.state() != QProcess.NotRunning: + procOut.terminate() + procOut.waitForFinished(1000) + # -------------------------------------------------- # listen to jack shutdown @@ -171,6 +184,7 @@ if __name__ == '__main__': jacklib.set_buffer_size_callback(client, buffer_size_callback, None) jacklib.set_sample_rate_callback(client, sample_rate_callback, None) + jacklib.set_freewheel_callback(client, freewheel_callback, None) jacklib.on_shutdown(client, shutdown_callback, None) jacklib.activate(client)