jackaudio.github.com icon indicating copy to clipboard operation
jackaudio.github.com copied to clipboard

`set_freewheel` documentation

Open 00sapo opened this issue 4 years ago • 0 comments

Hello, to my understanding, set_freewheel should be put after any call to Client.activate() and before any call to Client.deactivate().

I have prepared a little example to play with this. I think it should be added to the documentation...

import time
import jack
import threading

ttt = None

def trial():
    A = jack.Client("A")
    event = threading.Event()

    @A.set_process_callback
    def process(frames):
        global ttt
        tt = time.time()
        print(tt)
        if tt - ttt > 1:
            event.set()

    global ttt
    ttt = time.time()
    # A.set_freewheel(True) # this makes `activate` fail
    A.activate()
    A.set_freewheel(True)
    event.wait()
    A.set_freewheel(False)
    A.deactivate()
    # A.set_freewheel(False) # this makes errors on the next run
    A.close()
    del A

print("trial 1")
trial()
print("trial 2")
trial()

00sapo avatar Jul 22 '21 14:07 00sapo