elifa=="--aplay":use_aplay=True# aplay and madplay, for older embedded devices, NOT tested together with --rpi-bluetooth-* above
elifa.startswith("--delegate="):# --delegate=IP address, will ping that IP and delegate all sound to it when it's up. E.g. if it has better amplification but it's not always switched on.
delegate_to_check=a.split('=')[1]
os.environ["PATH"]+=":/usr/local/bin"
try:use_aplay
except:use_aplay=False
try:delegate_to_check
except:delegate_to_check=None
delegate_known_down=0
s=socket.socket()
s.bind(('',8124))
s.listen(5)
iftype(b"")==type(""):S=lambdax:x# Python 2
else:S=lambdax:x.decode("latin1")# Python 3
whileTrue:
c,a=s.accept()
c,(a,port)=s.accept()
c.settimeout(10)
try:d=S(c.recv(4))
except:# e.g. timeout, or there was an error reading the file on the remote side and we got 0 bytes