Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_stop_callback_duplex(backends, jackd_server):
stop_callback = mock.Mock()
duplex = miniaudio.DuplexStream(backends=backends)
gen = dummy_generator()
next(gen)
duplex.start(gen, stop_callback)
assert duplex.running is True
# Simulate an unexpected stop.
miniaudio.lib.ma_device_stop(duplex._device)
stop_callback.assert_called_once()
assert duplex.running is False
playbacks = devices.get_playbacks()
for d in enumerate(playbacks, 1):
print("{num} = {name}".format(num=d[0], name=d[1]['name']))
playback_choice = int(input("play on which device? "))
return captures[capture_choice-1], playbacks[playback_choice-1]
if __name__ == "__main__":
def pass_through():
data = yield b""
while True:
print(".", end="", flush=True)
data = yield data
capture_dev, playback_dev = choose_devices()
duplex = miniaudio.DuplexStream(sample_rate=48000, backends=backends,
playback_device_id=playback_dev["id"], capture_device_id=capture_dev["id"])
generator = pass_through()
next(generator)
print("Starting duplex stream. Press Ctrl + C to exit.")
duplex.start(generator)
running = True
while running:
try:
sleep(1)
except KeyboardInterrupt:
running = False
duplex.stop()