mirror of
https://github.com/romanz/amodem.git
synced 2026-05-09 21:13:04 +08:00
recv: use finally for exit code
This commit is contained in:
@@ -217,7 +217,6 @@ def main(config, src, dst, dump_audio=None, pylab=None):
|
|||||||
pylab = pylab or common.Dummy()
|
pylab = pylab or common.Dummy()
|
||||||
detector = detect.Detector(config=config, pylab=pylab)
|
detector = detect.Detector(config=config, pylab=pylab)
|
||||||
receiver = Receiver(config=config, pylab=pylab)
|
receiver = Receiver(config=config, pylab=pylab)
|
||||||
success = False
|
|
||||||
try:
|
try:
|
||||||
log.info('Waiting for carrier tone: %.1f kHz', config.Fc / 1e3)
|
log.info('Waiting for carrier tone: %.1f kHz', config.Fc / 1e3)
|
||||||
signal, amplitude, freq_error = detector.run(signal)
|
signal, amplitude, freq_error = detector.run(signal)
|
||||||
@@ -230,10 +229,10 @@ def main(config, src, dst, dump_audio=None, pylab=None):
|
|||||||
|
|
||||||
sampler = sampling.Sampler(signal, sampling.Interpolator(), freq=freq)
|
sampler = sampling.Sampler(signal, sampling.Interpolator(), freq=freq)
|
||||||
receiver.run(sampler, gain=1.0/amplitude, output=dst)
|
receiver.run(sampler, gain=1.0/amplitude, output=dst)
|
||||||
success = True
|
return True
|
||||||
except Exception:
|
except Exception:
|
||||||
log.exception('Decoding failed')
|
log.exception('Decoding failed')
|
||||||
|
return False
|
||||||
|
finally:
|
||||||
dst.flush()
|
dst.flush()
|
||||||
receiver.report()
|
receiver.report()
|
||||||
return success
|
|
||||||
|
|||||||
Reference in New Issue
Block a user