diff --git a/amodem-cli b/amodem-cli index 56c81c2..9f38607 100755 --- a/amodem-cli +++ b/amodem-cli @@ -94,6 +94,15 @@ def get_volume_cmd(args): return c[args.command] +class _DummyInterface(object): + ''' Audio interface mock, to skip shared library loading. ''' + def __enter__(self): + pass + + def __exit__(self, *args): + pass + + def _main(): fmt = ('Audio OFDM MODEM: {0:.1f} kb/s ({1:d}-QAM x {2:d} carriers) ' 'Fs={3:.1f} kHz') @@ -194,7 +203,12 @@ def _main(): import pylab args.pylab = pylab - with interface.load(args.audio_library): + if args.audio_library == '-': + interface = _DummyInterface() + else: + interface.load(args.audio_library) + + with interface: args.src = args.input_type(args.input) args.dst = args.output_type(args.output) try: diff --git a/amodem/audio.py b/amodem/audio.py index eafc728..62a4069 100644 --- a/amodem/audio.py +++ b/amodem/audio.py @@ -17,7 +17,6 @@ class Interface(object): assert self._error_string(0) == b'Success' version = self.call('GetVersionText', restype=ctypes.c_char_p) log.info('%s loaded', version) - return self def _error_string(self, code): return self.call('GetErrorText', code, restype=ctypes.c_char_p) diff --git a/tests/test_audio.py b/tests/test_audio.py index 7a3b552..f4d1620 100644 --- a/tests/test_audio.py +++ b/tests/test_audio.py @@ -15,7 +15,8 @@ def test(): lib.Pa_OpenStream.return_value = 0 cdll.return_value = lib interface = audio.Interface(config=config.fastest(), debug=True) - with interface.load(name='portaudio'): + interface.load(name='portaudio') + with interface: s = interface.player() assert s.params.device == 1 s.stream = 1 # simulate non-zero output stream handle