roc-streaming / roc-toolkit

Real-time audio streaming over the network.
https://roc-streaming.org
Mozilla Public License 2.0
1.09k stars 213 forks source link

Error "roc_sndio: sox sink: failed to write output buffer" streaming to blootooth #433

Open Richie765 opened 4 years ago

Richie765 commented 4 years ago

I've followed the step-by-step tutorial to stream from MPD on one machine to a Raspberry. I want to use the Pi to send over Bluetooth to one of my headsets or speakers. It all works very well, except when I turn-off the Bluetooth headset or switching to another BT headset / speaker. In that case the output gets flooded with errors (even after removing the -vv options):

Oct 29 15:34:52 pi1a roc-recv[3152]: 15:34:52.410 [err] roc_sndio: sox sink: failed to write output buffer
Oct 29 15:34:52 pi1a roc-recv[3152]: 15:34:52.411 [err] roc_sndio: sox sink: failed to write output buffer
Oct 29 15:34:52 pi1a roc-recv[3152]: 15:34:52.411 [err] roc_sndio: sox sink: failed to write output buffer
Oct 29 15:34:52 pi1a roc-recv[3152]: 15:34:52.412 [err] roc_sndio: sox sink: failed to write output buffer
Oct 29 15:34:52 pi1a roc-recv[3152]: 15:34:52.413 [err] roc_sndio: sox sink: failed to write output buffer
Oct 29 15:34:52 pi1a roc-recv[3152]: 15:34:52.414 [err] roc_sndio: sox sink: failed to write output buffer
Oct 29 15:34:52 pi1a roc-recv[3152]: 15:34:52.415 [err] roc_sndio: sox sink: failed to write output buffer
Oct 29 15:34:52 pi1a roc-recv[3152]: 15:34:52.416 [err] roc_sndio: sox sink: failed to write output buffer
Oct 29 15:34:52 pi1a roc-recv[3152]: 15:34:52.417 [err] roc_sndio: sox sink: failed to write output buffer
Oct 29 15:34:52 pi1a roc-recv[3152]: 15:34:52.418 [err] roc_sndio: sox sink: failed to write output buffer

When it happens I'll have to restart roc-recv to make it work again.

I was hoping to keep roc-recv running unattended and be able to use whatever output I like on the Pi.

Also, because of the excessive error output (>1000 per sec) the logfiles quickly axhausted my SD capacity more than a few times.

My setup is pretty much identical as described in the step-by-step tutorial.

Receiving end on the pi:

roc-recv -s rtp+rs8m::10001 -r rs8m::10002 -d alsa

Thanks!

gavv commented 3 years ago

Hi, thanks for report and sorry for late reply!

I agree, this is a problem. In pulseaudio sink, when write fails, we reopen stream. However in sox sink, used for alsa, we just continue logging errors every write and don't try to reopen sox stream.

We'll need to implement reopening in sndio::SoxSink and sndio::SoxSource. I'll look at it. For now, as an ugly workaround, you could wrap roc-recv into a bash script that restarts it if it notices failed to write output buffer in stderr.

When we'll implement #231, we'll also need to implement reopening in AlsaSink and AlsaSource.