• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

musicpd skips when I enable a fifo

Greg Fitzgerald

Member

Thanks: 2
Messages: 23

#1
When I enable a output fifo in musicpd, wether something is reading from it or not musicpd skips every few seconds. This does not happen on my Linux box's. Its one of the things that always annoys me back to Linux as much as I want to stay on FreeBSD.

Soon as I disable the fifo output and restart musicpd it stops skipping. I have played with adding a %20 buffer to mpd config as well as adjusting the format to different levels. Nothing seems to resolve it.

I spoke to the MPD dev and he blamed the speed of FreeBSD fifo's. I don't know enough to argue the point.

Code:
music_directory "/mnt/storage/music"
playlist_directory "~/.mpd/playlists"
db_file "~/.mpd/mpd.db"
log_file "~/.mpd/mpd.log"
pid_file "~/.mpd/mpd.pid"
state_file "~/.mpd/state"
sticker_file "~/.mpd/sticker.sql"

# Needed for clerk --update
max_output_buffer_size "32000"

user "gregf"
group "gregf"

audio_output {
 type    "oss"
 name    "mpd"
}

audio_output {
  type "fifo"
  name "Visualizer feed"
  path "/tmp/mpd.fifo"
  format "16000:16:2"
}
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 5,508
Messages: 25,692

#2
What version of MPD and what version of FreeBSD?
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 5,508
Messages: 25,692

#5
What's attached to the FIFO? It might be blocking I/O because the application that reads from the FIFO isn't able to read quickly enough.
 

Greg Fitzgerald

Member

Thanks: 2
Messages: 23

#6
I don't know? Soon as I play a song with fifo enabled in my mpd config it starts skipping. I want it to have a visualizer in ncmpcpp or using cava, but it skips if those are open or not.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 5,508
Messages: 25,692

#7
It's a bit of a long shot, but try running something like cat /tmp/mpd.fifo > /dev/null in a separate shell. That should make sure the FIFO is continuously read and the output is sent to /dev/null.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 5,508
Messages: 25,692

#9
Then I'm out of ideas. I don't use any of this myself so I'm hoping someone else might have some suggestions.
 

tobik@

Daemon
Developer

Thanks: 1,185
Messages: 1,775

#11
I don't know? Soon as I play a song with fifo enabled in my mpd config it starts skipping. I want it to have a visualizer in ncmpcpp or using cava, but it skips if those are open or not.
Both audio/musicpd and audio/cava have an sndio backend which means that using a FIFO is not a necessity here. Build them with SNDIO=on and then enable sndiod via sysrc sndiod_enable=YES && service sndiod start. By default sndiod is configured to have a monitoring sub device which you can point cava to.

Musicpd can be configured to use it by using type "sndio" instead of type "oss" in the audio_output section. Point cava to the monitor device with env AUDIODEVICE=snd/0.monitor cava.

Of course a similar setup could probably also work when using their PulseAudio backends.
 

thebardian

Member

Thanks: 28
Messages: 25

#12
Both audio/musicpd and audio/cava have an sndio backend which means that using a FIFO is not a necessity here. Build them with SNDIO=on and then enable sndiod via sysrc sndiod_enable=YES && service sndiod start. By default sndiod is configured to have a monitoring sub device which you can point cava to.

Musicpd can be configured to use it by using type "sndio" instead of type "oss" in the audio_output section. Point cava to the monitor device with env AUDIODEVICE=snd/0.monitor cava.

Of course a similar setup could probably also work when using their PulseAudio backends.
I tried, sndio, and it did not work for me, cava couldn't seem to find the monitor device. I am fairly sure I had everything configured as you said, also. It led me on the right track, as I don't mind using pulseaudio, I recompiled again with musicpd pulseaudio support, enabled it within musicpd.conf and cava works without any issue.
 

tobik@

Daemon
Developer

Thanks: 1,185
Messages: 1,775

#13
I tried, sndio, and it did not work for me, cava couldn't seem to find the monitor device. I am fairly sure I had everything configured as you said, also. It led me on the right track, as I don't mind using pulseaudio, I recompiled again with musicpd pulseaudio support, enabled it within musicpd.conf and cava works without any issue.
There are a couple of things that could go wrong:
  1. If you're running musicpd and cava under different user accounts then you might have to share ~/.aucat_cookie between them, otherwise whoever gets the device first will block the other. See sndio(7):
    Code:
    AUTHENTICATION
         If a shared sndiod(8) server is running, for privacy reasons only one user
         may have connections to it at a given time (though the same user could have
         multiple connections to it).  Users are identified by their session cookie,
         which is automatically generated by audio or MIDI applications upon the
         first connection to the server.  The cookie is stored in
         $HOME/.aucat_cookie and contains 128 bits of raw random data.
    
         If a session needs to be shared between multiple users, they can connect to
         the server using the same cookie.
  2. Setting sndiod_flags (i.e. overwriting the defaults) in /etc/rc.conf but failing to create a monitor device
But good to hear it works fine for you with PulseAudio.
 

tobik@

Daemon
Developer

Thanks: 1,185
Messages: 1,775

#16
Sndio builds on top of OSS and they are tightly coupled on FreeBSD, so "sndio vs oss" is a false dichotomy.

Use sndio if you need networked audio/MIDI, need a monitor device to record what is played back, if your favorite application doesn't provide a working OSS or good alternative backend, or if you want something simpler to understand, configure, or hack than PulseAudio.