musicpd skips when I enable a fifo

Greg Fitzgerald

Member

Thanks: 2
Messages: 26

#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: 6,235
Messages: 27,227

#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.
 
OP
OP
Greg Fitzgerald

Greg Fitzgerald

Member

Thanks: 2
Messages: 26

#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: 6,235
Messages: 27,227

#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: 6,235
Messages: 27,227

#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,341
Messages: 1,909

#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: 26
Messages: 26

#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,341
Messages: 1,909

#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,341
Messages: 1,909

#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.
 

rsronin

Member

Thanks: 24
Messages: 36

#17
I have the same issue:


amw@n54l:/usr/home/amw$ uname -r
11.1-RELEASE-p9
amw@n54l:/usr/home/amw$ ncmpcpp -v
ncmpcpp 0.8.1

optional screens compiled-in:
- tag editor
- tiny tag editor
- outputs
- visualizer
- clock

encoding detection: enabled
built with support for: fftw ncurses taglib
amw@n54l:/usr/home/amw$


Music is on an ext4 partition which is mounted with DSBMC.
 

fdnull

New Member

Thanks: 1
Messages: 4

#21
man ncmpcpp:
visualizer_fifo_path = PATH
Path to mpd fifo output. This is needed to make music visualizer
work (note that output sound format of this fifo has to be
either 44100:16:1 or 44100:16:2, depending on whether you want
mono or stereo visualization)
 

rsronin

Member

Thanks: 24
Messages: 36

#22
I had/have this in my config file


amw@n54l:/mnt/bsd/home/amw/.ncmpcpp$ ls
config config.old error.log
amw@n54l:/mnt/bsd/home/amw/.ncmpcpp$ cat config
visualizer_fifo_path = "/tmp/mpd.fifo"
visualizer_output_name = "my_fifo"
visualizer_sync_interval = "30"
visualizer_in_stereo = "yes"
visualizer_type = "spectrum"
visualizer_look = "+

amw@n54l:/mnt/bsd/home/amw/.ncmpcpp$


so no difference yet, also in the ttyX when moving the mouse musicpd stutters like crazy.
 

fdnull

New Member

Thanks: 1
Messages: 4

#23
I had/have this in my config file


amw@n54l:/mnt/bsd/home/amw/.ncmpcpp$ ls
config config.old error.log
amw@n54l:/mnt/bsd/home/amw/.ncmpcpp$ cat config
visualizer_fifo_path = "/tmp/mpd.fifo"
visualizer_output_name = "my_fifo"
visualizer_sync_interval = "30"
visualizer_in_stereo = "yes"
visualizer_type = "spectrum"
visualizer_look = "+

amw@n54l:/mnt/bsd/home/amw/.ncmpcpp$


so no difference yet, also in the ttyX when moving the mouse musicpd stutters like crazy.
replace this /usr/local/etc/musicpd.conf:
audio_output {
type "fifo"
format "44100:16:2"
...
}
with
audio_output {
type "fifo"
format "44100:16:1"
...
}
 

rsronin

Member

Thanks: 24
Messages: 36

#24
replace this /usr/local/etc/musicpd.conf:

with
I did and also made changes to ~/.ncmpcpp/config to make sure using the same name:

visualizer_output_name = "my_fifo

as in /usr/local/etc/musicpd.conf:

name "my_fifo"


audio_output {
type "oss"
# name "My OSS Device"
# device "/dev/dsp0.0" # optional
# mixer_type "hardware" # optional
mixer_type "software"
# mixer_device "/dev/mixer" # optional
# mixer_control "PCM" # optional
}
#
# An example of a FIFO output:
#
audio_output {
type "fifo"
name "my_fifo"
path "/tmp/mpd.fifo"
format "44100:16:1"
"musicpd.conf" 406 lines, 12957 characters
amw@n54l:/usr/local/etc$ smpd.sh
Starting musicpd.
amw@n54l:/usr/local/etc$ ncmpcpp
Reading configuration from /home/amw/.ncmpcpp/config...
amw@n54l:/usr/local/etc$
 

fdnull

New Member

Thanks: 1
Messages: 4

#25
I did and also made changes to ~/.ncmpcpp/config to make sure using the same name:

visualizer_output_name = "my_fifo

as in /usr/local/etc/musicpd.conf:

name "my_fifo"


audio_output {
type "oss"
# name "My OSS Device"
# device "/dev/dsp0.0" # optional
# mixer_type "hardware" # optional
mixer_type "software"
# mixer_device "/dev/mixer" # optional
# mixer_control "PCM" # optional
}
#
# An example of a FIFO output:
#
audio_output {
type "fifo"
name "my_fifo"
path "/tmp/mpd.fifo"
format "44100:16:1"
"musicpd.conf" 406 lines, 12957 characters
amw@n54l:/usr/local/etc$ smpd.sh
Starting musicpd.
amw@n54l:/usr/local/etc$ ncmpcpp
Reading configuration from /home/amw/.ncmpcpp/config...
amw@n54l:/usr/local/etc$
cat /usr/local/etc/musicpd.conf|sed "/^#/d;/^ *$/d;"
music_directory "/mnt/media/music/"
playlist_directory "/var/mpd/.mpd/playlists"
db_file "/var/mpd/.mpd/database"
log_file "/var/mpd/.mpd/log"
pid_file "/var/mpd/.mpd/pid"
state_file "/var/mpd/.mpd/state"
sticker_file "/var/mpd/.mpd/sticker.sql"
user "mpd"
bind_to_address "/var/mpd/.mpd/socket"
input {
plugin "curl"
proxy "http://10.9.0.2:3128"
}
audio_output {
type "oss"
name "My OSS Device"
device "/dev/dsp0.0" # optional
mixer_type "hardware" # optional
mixer_device "/dev/mixer0" # optional
mixer_control "vol" # optional
}
audio_output {
type "fifo"
name "Visualizer feed"
path "/tmp/mpd.fifo"
format "44100:16:1"
}
cat .config/ncmpcpp/config
mpd_host=/var/mpd/.mpd/socket
mpd_music_dir=/mnt/media/music
visualizer_fifo_path=/tmp/mpd.fifo
No names, no buffers, no intervals. Try to remove unnecessary lines.
 
Top