--- libwavesync-orig/cli.py	2020-09-04 02:54:37.107466220 +0200
+++ libwavesync/cli.py	2020-09-10 22:21:20.409116772 +0200
@@ -14,6 +14,7 @@
 
 import asyncio
 import socket
+import sys
 
 from . import (
     AudioConfig,
@@ -21,6 +22,7 @@
     ChunkPlayer,
     ChunkQueue,
     SampleReader,
+    time_machine,
     Receiver
 )
 
@@ -47,7 +49,8 @@
                              receiver=None,
                              tolerance_ms=args.tolerance_ms,
                              buffer_size=args.buffer_size,
-                             device_index=args.device_index)
+                             device_index=args.device_index,
+                             use_callback=args.callback)
         play = player.chunk_player()
         asyncio.ensure_future(play)
     else:
@@ -90,7 +93,8 @@
     player = ChunkPlayer(chunk_queue, receiver,
                          tolerance_ms=args.tolerance_ms,
                          buffer_size=args.buffer_size,
-                         device_index=args.device_index)
+                         device_index=args.device_index,
+                         use_callback=args.callback)
 
     play = player.chunk_player()
 
@@ -98,15 +102,60 @@
     loop.run_until_complete(tasks)
 
 
+def print_dev(p,d,verb):
+    print('Index:',d['index'])
+    if verb:
+      for k,v in d.items():
+        print('    ',k,'=',v)
+    else:
+      for i in ['name','hostApi','maxInputChannels','maxOutputChannels','defaultSampleRate']:
+        if i=='maxInputChannels' and d[i]==0:continue
+        if i=='maxOutputChannels' and d[i]==0:continue
+        if i=='hostApi':
+          desc=''
+          if d['index']==p.get_host_api_info_by_index(d[i])['defaultInputDevice']: desc=desc+' [defaultInput]'
+          if d['index']==p.get_host_api_info_by_index(d[i])['defaultOutputDevice']: desc=desc+' [defaultOutput]'
+          print('    ',i,'=',d[i],'('+p.get_host_api_info_by_index(d[i])['name']+')'+desc)
+        else:
+          print('    ',i,'=',d[i])
+      try:
+        ll=d['defaultLowOutputLatency']
+        lh=d['defaultHighOutputLatency']
+        if not ll==-1 and not lh==-1:
+          print('    ','output latency low/high: {:.1f} / {:.1f} ms'.format(ll*1000,lh*1000))
+      except:
+        pass
+
+
+def list_devs(verb):
+    import pyaudio
+    p=pyaudio.PyAudio()
+    print()
+    print(p.get_device_count(),'devices found:')
+    for i in range(p.get_device_count()):
+        d=p.get_device_info_by_index(i)
+        print()
+        print_dev(p,d,verb)
+
+
 def main():
     "Parse arguments and start the event loop"
     args = parse()
 
+    if args.list:
+        list_devs(False)
+        sys.exit()
+    elif args.listv:
+        list_devs(True)
+        sys.exit()
+
     loop = asyncio.get_event_loop()
 
     if args.debug:
         loop.set_debug(True)
 
+    if not args.ntp == '':
+        time_machine.ntp_init(args.ntp,args.ntpint,args.ntptol)
 
     try:
         if args.tx is not None:
@@ -115,3 +164,5 @@
             start_rx(args, loop)
     finally:
         loop.close()
+        if time_machine.ntptimer: time_machine.ntp_stoptimer()
+
