MusicPlayerDaemon / MPD

Music Player Daemon
https://www.musicpd.org/
GNU General Public License v2.0
2.15k stars 347 forks source link

Choppy or no audio output via Bluetooth on MacOS #961

Closed jottr closed 3 months ago

jottr commented 3 years ago

Bug report

Describe the bug

Audio stuttering when using Bluetooth Speaker as audio output device.

I'm currently using the JBL Charge 3 but the same issue occurs with other Bluetooth audio device.

# mpd.conf
...
audio_output {
  type                  "osx"
  name                  "CoreAudio"
  mixer_type            "software"
...
}

$ system_profiler SPAudioDataType

Audio:

    Devices:

        Built-in Microphone:

          Default Input Device: Yes
          Input Channels: 2
          Manufacturer: Apple Inc.
          Current SampleRate: 48000
          Transport: Built-in
          Input Source: Internal Microphone

        Built-in Output:

          Manufacturer: Apple Inc.
          Output Channels: 2
          Current SampleRate: 44100
          Transport: Built-in
          Output Source: Internal Speakers

        JBL Charge 3:

          Input Channels: 1
          Manufacturer: 57
          Current SampleRate: 8000
          Transport: Bluetooth
          Input Source: Default

        JBL Charge 3:

          Default Output Device: Yes
          Default System Output Device: Yes
          Manufacturer: 57
          Output Channels: 1
          Current SampleRate: 8000
          Transport: Bluetooth
          Output Source: Default

        Multi-Output Device:

          Manufacturer: Apple Inc.
          Output Channels: 2
          Current SampleRate: 44100
          Transport: Unknown
          Output Source: Default

MacOS Catalina

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.15.6
BuildVersion:   19G2021

Expected Behavior

Audio playback works on bluetooth audio.

Actual Behavior

  1. Select bluetooth audio device as audio output in menubar
  2. Start mpd.
  3. Playback stutters

OR

  1. Select internal audio as output device in menubar
  2. Start mpd
  3. Playback works without issues
  4. Select bluetooth audio device in menubar
  5. No audio output
  6. Switch back to internal audio device
  7. Audio output works again

Switching from CoreAudio to ao-audio as described in https://github.com/MusicPlayerDaemon/MPD/issues/72#issuecomment-339394839 didn't fix the issue for me.

Version

$ mpd --version
Music Player Daemon 0.21.25 (0.21.25)
Copyright 2003-2007 Warren Dukes <warren.dukes@gmail.com>
Copyright 2008-2018 Max Kellermann <max.kellermann@gmail.com>
This is free software; see the source for copying conditions.  There is NO
warranty; not even MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Database plugins:
 simple proxy upnp

Storage plugins:
 local nfs curl

Neighbor plugins:
 upnp

Decoders plugins:
 [vorbis] ogg oga
 [oggflac] ogg oga
 [flac] flac
 [opus] opus ogg oga
 [sndfile] wav aiff aif au snd paf iff svx sf voc w64 pvf xi htk caf sd2
 [dsdiff] dff
 [dsf] dsf
 [hybrid_dsd] m4a
 [faad] aac
 [fluidsynth] mid
 [ffmpeg] 16sv 3g2 3gp 4xm 8svx aa3 aac ac3 adx afc aif aifc aiff al alaw amr anim apc ape asf atrac au aud avi avm2 avs bap bfi c93 cak cin cmv cpk daud dct divx dts dv dvd dxa eac3 film flac flc fli fll flx flv g726 gsm gxf iss m1v m2v m2t m2ts m4a m4b m4v mad mj2 mjpeg mjpg mka mkv mlp mm mmf mov mp+ mp1 mp2 mp3 mp4 mpc mpeg mpg mpga mpp mpu mve mvi mxf nc nsv nut nuv oga ogm ogv ogx oma ogg omg opus psp pva qcp qt r3d ra ram rl2 rm rmvb roq rpl rvc shn smk snd sol son spx str swf tak tgi tgq tgv thp ts tsp tta xa xvid uv uv2 vb vid vob voc vp6 vmd wav webm wma wmv wsaud wsvga wv wve
 [pcm]

Filters:
 libsamplerate soxr

Tag plugins:
 id3tag

Output plugins:
 shout null fifo pipe ao openal osx httpd recorder

Encoder plugins:
 null vorbis opus lame wave flac

Archive plugins:
 [bz2] bz2

Input plugins:
 file archive curl ffmpeg nfs

Playlist plugins:
 extm3u m3u pls xspf asx rss flac cue embcue

Protocols:
 file:// http:// https:// gopher:// rtp:// rtsp:// rtmp:// rtmpt:// rtmps:// nfs://

Other features:
 icu ipv6 tcp un

Log

$ mpd --no-daemon -v
config_file: loading file /Users/jottr/.mpd/mpd.conf
Sep 26 18:31 : libsamplerate: libsamplerate converter 'Fastest Sinc Interpolator'
Sep 26 18:31 : vorbis: Xiph.Org libVorbis 1.3.7
Sep 26 18:31 : opus: libopus 1.3.1
Sep 26 18:31 : sndfile: libsndfile-1.0.29pre2
Sep 26 18:31 : hybrid_dsd: The Hybrid DSD decoder is disabled because it was not explicitly enabled
Sep 26 18:31 : simple_db: reading DB
Sep 26 18:31 : curl: version 7.64.1
Sep 26 18:31 : curl: with (SecureTransport) LibreSSL/2.8.3

Related bug reports:

MaxKellermann commented 3 years ago

@Wang-Yue can you have a look?

Wang-Yue commented 3 years ago

I don't have a bluetooth device to test so probably I cannot help much with this issue. I remember two years ago when I had a bluetooth capable DAC things were working fine for me.

The related bug reports are not very useful. one is missing log files. the other (#72) resolved when user disabled the fifo outputs (fifo speed on MacOS is slower and may cause hiccups in audio outputs even without bluetooth. so this is expected).

The potential cause may related to either the ring buffer length or the audio buffer size. It is likely that bluetooth device may need a lager buffer than USB as it's a network device (that's my understanding). On the internet there're a lot of users complaining about shuttering audio over bluetooth on MacOS in general (not mpd specific).

MaxKellermann commented 3 months ago

Due to lack of volunteers, the MPD project no longer supports macOS.