0

My environment has two audio output: HDMI and Bluetooth speaker. Usually both of them work correctly. For example,

#this plays sound via bluetooth speaker
$ aplay -D default jingle.wav

#this plays sound via HDMI
$ aplay -D plughw:1,7 jingle.wav

However, mpc play doesn't play any sound. My /etc/mpd.conf is a default one except for the music directory. So

music_directory     "smb://xxx.xxx.xx.x/some_directory"
...
audio_output {
    type        "alsa"
    name        "My ALSA Device"
    #   device      "hw:0,0"    # optional
    #   mixer_type      "hardware"      # optional
    #   mixer_device    "default"   # optional
    #   mixer_control   "PCM"       # optional
    #   mixer_index "0"     # optional
}

I use a remote music directory (smb protocol) and the connection is ok. According to man mpd.conf, the default value of device field is "default". But mpc play plays no sound though I expect it plays via the bluetooth speaker as the aplay -D default command above. sudo mpd --no-daemon --stderr says

exception: OutputThread could not get realtime scheduling, continuing anyway: sched_setscheduler failed: Operation not permitted
avahi: Service 'Music Player' successfully established.
client: [0] opened from xxx.x.x.x:xxxxx
No protocol specified
xcb_connection_has_error() returned true
No protocol specified
No protocol specified
xcb_connection_has_error() returned true
exception: Failed to read mixer for 'My ALSA Device': no such mixer control: PCM

The last line may be the cause, so I set the mixer_type field as "none". But still no sound. mpc play successes and the current position (e.g. 00:56/3:20 (58%)) progresses but no sound.

How can I use my bluetooth speaker? If I set device to plughw:1,7, mpc play actually plays sound via HDMI as the aplay command above. However, I would like to use the bluetooth speaker.

Environment:

$ lsb_relase -d
Description:    Linux Mint 19 Tara

$ mpd --version
Music Player Daemon 0.20.18

I installed mpd via sudo apt install mpd.

2
  • Suggest you post your solution as an Answer tomorrow, so others may benefit from your hard work. Good job!
    – K7AAY
    May 8, 2019 at 20:51
  • @K7AAY Thank you for your advice. I posted an answer.
    – ynn
    May 9, 2019 at 3:08

1 Answer 1

5

The question is perfectly been solved by Music Player Daemon/Tips and tricks - PulseAudio. And MPD with pulseaudio is also helpful.

The website is actually sufficient but let me write what I did. In the first place, I did set the device field of /etc/mpd.conf to "alsa" but this is wrong. A bluetooth speaker is by default managed not by alsa but by pulseaudio (at least on Linux Mint and though you can use a bluetooth speaker via alsa using e.g. BlueALSA). So the value of the field should be "pulse". However, by default, pulseaudio is running in a user space while mpd runs system-wide. So mpd can't access the settings of the current user's pulseaudio session. To let mpd see the setting, you can turn on pulseaudio's remote functionality:

sudo cp /etc/pulse/default.pa /etc/pulse/default.pa.bak
sudo vi /etc/pulse/default.pa

and change the line of

#load-module module-native-protocol-tcp

to this (uncomment and add some words)

load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1

and restart pulseaudio to reflect this change.

#Note there is no `sudo` prefix.
#As written above, `pulseaudio` runs in a user session.
pulseaudio --kill
pulseaudio --start

Now you can access pulseaudio, using tcp protocol and via the ip address 127.0.0.1 (this is usually localhost). At last, mpd's setting should be changed:

sudo cp /etc/mpd.conf /etc/mpd.conf.bak
sudo vi /etc/mpd.conf

and set the value of audio_output field as below

audio_output {
    type        "pulse"
    name        "arbitrary_name_which_you_like"
    server      "localhost"
}

and restart mpd to reflect the change.

#Note there is `sudo` prefix.
sudo systemctl restart mpd

That's all.


Supplement:

By the way, the fact that aplay -D default jingle.wav succeeded but mpc play didn't comes from the difference of the running space, i.e. running system-wide or as a user session. So comparing the results is meaningless. I should have compared mpc play with sudo -u mpd aplay -D default jingle.wav. The latter command fails and this is an expected result.

1
  • This almost worked for me. I had to set the server value in audio_output to "127.0.0.1" instead of "localhost" but you got me real close, so thanks. Mar 27, 2021 at 5:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .