I'm developing an embedded device that acts as a music player. It has a development board (orange pi zero 2), three joystick buttons and an rfid reader. The joystick buttons are connected via gpio and send events to /dev/input/event0.
Now, I have programmed the musicplayer using python. Since I need to monitor evdev events, react on button presses and handle music playback, the python program has three threads:
- One worker thread listens to key events from /dev/input/event0
- One worker thread handles music playback using pygame.mixer.music
- The main thread checks for button presses, decides what to do when a button was pressed or when an rfid card is detected.
Everything seems to work just fine at program startup. However, when I start playing songs from a playlist, after a while I get messages like this:
ALSA lib conf.c:4617:(snd_config_update_r) cannot access file /usr/share/alsa/alsa.conf
Also, when the song ends and the next song has to be loaded, I get an Exception, that that file is not found, although, I'm absolutely sure that it is there:
Exception in thread Thread-4 (__do_play):
Traceback (most recent call last):
File "/usr/lib/python3.10/threading.py", line 1009, in _bootstrap_inner
File "/usr/lib/python3.10/threading.py", line 946, in run
File "/opt/tobibox/tobibox/tobibox/musicplayer.py", line 218, in __do_play
pygame.error: No such file or directory: '/opt/tobibox/files/83f729cb-81fc-4038-b2af-65a16f68636e.ogg'.
So it seem like the python program lost permissions to access the file system. However, I have no idea what might be the cause of this. The program is running as root, because it needs access to /dev/input/event0, so it also has all necessary file permissions.
I have already tried to limit the "framerate" of all threads (I've added time.sleep(0.5) to each thread at critical locations). That seemed to relax the situation at least a little bit, since at least now the second song starts playing, but shortly after that I still get the same error messages.
Does anyone know what might cause this behavior or where I should start searching for errors?
I'm running python 3.10.4 on a Linux xxx 5.19.4-sunxi64 #22.08.1 SMP Tue Aug 30 07:12:21 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux
I don't know what else might be relevant, so if I should provide any other info about the system, please ask!