I am having an issue in which I receive the subject error. This is part of a large project. I have posted this question using code from the project here and on the GNU Radio list but have no solutions offered.
I decided to greatly simplify the basic code and still produce the error under the same basic conditions.This is the code I present here.
The first time through the loop there is no problem. The second time through the loop produces the error. The error text shows the command line call followed by the prompt to quit the first call. The second call then produces the error.
I expect to be able to loop through indefinitely repeatedly calling Test.
I cannot understand how the audio source is busy. Busy with what?? This has been incredibly frustrating.
The Test.py file was generated using GNU Radio. The audio source and sink use a sound card. I guess I could have just as well used a Null sink for this test.
Any help will be greatly appreciated.
error_test.py
import Test
def main():
for i in range(2):
Test.main()
input("nnPress Enter to Exit:nn")
quit()
if __name__ == "__main__":
main()
Test.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# SPDX-License-Identifier: GPL-3.0
#
# GNU Radio Python Flow Graph
# Title: Test
# GNU Radio version: 3.9.4.0
from gnuradio import audio
from gnuradio import gr
from gnuradio.filter import firdes
from gnuradio.fft import window
import sys
import signal
from argparse import ArgumentParser
from gnuradio.eng_arg import eng_float, intx
from gnuradio import eng_notation
class Test(gr.top_block):
def __init__(self):
gr.top_block.__init__(self, "Test", catch_exceptions=True)
##################################################
# Blocks
##################################################
self.audio_source_0 = audio.source(48000, 'hw:1,0', True)
self.audio_sink_0_1 = audio.sink(48000, 'hw:1,0', False)
##################################################
# Connections
##################################################
self.connect((self.audio_source_0, 0), (self.audio_sink_0_1, 0))
self.connect((self.audio_source_0, 1), (self.audio_sink_0_1, 1))
def main(top_block_cls=Test, options=None):
tb = top_block_cls()
def sig_handler(sig=None, frame=None):
tb.stop()
tb.wait()
sys.exit(0)
signal.signal(signal.SIGINT, sig_handler)
signal.signal(signal.SIGTERM, sig_handler)
tb.start()
try:
input('Press Enter to quit: ')
except EOFError:
pass
tb.stop()
tb.wait()
if __name__ == '__main__':
main()
error text
python3 test.py
Press Enter to quit:
gr::log :ERROR: audio_alsa_source1 - [hw:1,0]: Device or resource busy
Traceback (most recent call last):
File "/home/pi/gr-ft8_rxtx/python/test.py", line 13, in <module>
main()
File "/home/pi/gr-ft8_rxtx/python/test.py", line 6, in main
Test.main()
File "/home/pi/gr-ft8_rxtx/python/Test.py", line 47, in main
tb = top_block_cls()
File "/home/pi/gr-ft8_rxtx/python/Test.py", line 32, in __init__
self.audio_source_0 = audio.source(48000, 'hw:1,0', True)
RuntimeError: audio_alsa_source