I'm trying to use my Raspberry Pi as a white noise generator using SOX and my bluetooth speaker (BOSE mini soundlink II). Everything works great at first, however after a certain period of time (as early as 20 min, as long as 6 hours) the sound stops and I get this error on the command line:
ALSA lib bluealsa-pcm.c:200:(io_thread) PCM FIFO write error: Broken pipe play WARN alsa: under-run play FAIL sox: `default' No such device: Operation not permitted
After this error I am unable to play any audio (the little speaker icon in the task bar is grey with a red line through it). The only way I have been able to fix it is to reboot the Pi. After reboot everything works great again until the audio plays for a while (the time varies) and then the same error occurs and I need to reboot again.
I would like to play the white noise overnight while sleeping (ideally indefinitely) however I usually only get about 30 - 60 min before the error occurs. I can play white noise using an app on my phone with the same bluetooth speaker and this works fine (indefinitely). I have tried physically plugging in the speaker using the aux cable connection and the same error occurs. I am using raspbian stretch with desktop (Pi model 3 B). I have also tried several fresh raspbian installs, also on raspbian stretch lite (this is the one that lasted for 6 hours... but still gave an error eventually). The same error happens when I play any audio file/collection of audio files after a similar period of time (20 - 30 min on average).
I am very much an amateur so perhaps I am missing something obvious but I cannot seem to find any solution to this problem anywhere online and nothing I have tried works. I am using SOX because it is a very useful way of playing white noise from the Pi - I would just like it to play indefinitely without error.
Any ideas on what the problem might be? Thank you!