MusicPlayerDaemon / MPD

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

Output volume reset after disabling and enabling #1433

Closed Feanor1397 closed 2 years ago

Feanor1397 commented 2 years ago

Bug report

Describe the bug

When output set to hardware mixer, volume are reset to 100% after disabling and enabling output. Some times this happens even between songs. It worked fine for years with this config (except used pulse output) and this strange behavior started for no reasons. Nothing was updated, no configs was changed. Now it's 100% reproducible for me. Tried changing output from pulse to native pipewire - same bug.

System - Archlinux Sound server - Pipewire 0.3.45

Expected Behavior

Volume set to level it was before disabling

Actual Behavior

Volume always set to 100%

Config

music_directory             "/home/feanor1397/Музыка"
playlist_directory          "/home/feanor1397/.config/mpd/playlists"
sticker_file                "/home/feanor1397/.config/mpd/sticker.sql"
db_file                     "/home/feanor1397/.config/mpd/tag_cache"
pid_file                    "/home/feanor1397/.config/mpd/pid"
state_file                  "/home/feanor1397/.config/mpd/state"
log_file                    "syslog"

zeroconf_enabled            "yes"
auto_update                 "yes"
volume_normalization        "no"

metadata_to_use             "artist,album,title,track,name,genre,date,disc,albumartist,composer,musicbrainz_albumid,originaldate,albumartistsort,artistsort,albumsort"
audio_buffer_size           "8192"
filesystem_charset          "UTF-8"

audio_output {
    type            "httpd"
    name            "My HTTP Stream"
    encoder         "lame" # optional
    port            "8000"
    bitrate         "128"
    format          "44100:24:2"
    always_on       "yes"
    tags            "yes"
    mixer_type      "none"
}

audio_output {
    type            "pipewire"
    name            "Output"
    mixer_type      "hardware"
}

Version

Music Player Daemon 0.23.5 (0.23.5)
Copyright 2003-2007 Warren Dukes <warren.dukes@gmail.com>
Copyright 2008-2021 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 udisks nfs curl

Neighbor plugins:
 upnp udisks

Decoders plugins:
 [mad] mp3 mp2
 [mpg123] mp3
 [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
 [audiofile] wav au aiff aif
 [dsdiff] dff
 [dsf] dsf
 [hybrid_dsd] m4a
 [faad] aac
 [mpcdec] mpc
 [wavpack] wv
 [openmpt] mptm mod s3m xm it 669 amf ams c67 dbm digi dmf dsm dtm far imf ice j2b m15 mdl med mms mt2 mtm nst okt plm psm pt36 ptm sfx sfx2 st26 stk stm stp ult wow gdm mo3 oxm umx xpk ppm mmcmp
 [modplug] 669 amf ams dbm dfm dsm far it med mdl mod mtm mt2 okt s3m stm ult umx xm
 [mikmod] amf dsm far gdm imf it med mod mtm s3m stm stx ult uni xm
 [sidplay] sid mus str prg P00
 [wildmidi] mid
 [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 rtp:// rtsp:// rtsps://
 [gme] ay gbs gym hes kss nsf nsfe rsn sap spc vgm vgz
 [pcm]

Filters:
 libsamplerate soxr

Tag plugins:
 id3tag

Output plugins:
 shout null fifo pipe alsa ao oss openal solaris pipewire pulse jack httpd snapcast recorder

Encoder plugins:
 null vorbis opus lame twolame wave flac

Archive plugins:
 [bz2] bz2
 [zzip] zip
 [iso] iso

Input plugins:
 file io_uring archive alsa qobuz curl ffmpeg nfs mms cdio_paranoia

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

Protocols:
 file:// alsa:// cdda:// ftp:// ftps:// gopher:// hls+http:// hls+https:// http:// https:// mms:// mmsh:// mmst:// mmsu:// nfs:// qobuz:// rtmp:// rtmpe:// rtmps:// rtmpt:// rtmpte:// rtmpts:// rtp:// rtsp:// rtsps:// scp:// sftp:// smb:// srtp://

Other features:
 avahi dbus udisks epoll icu inotify ipv6 systemd tcp un

Log

config_file: loading file /home/feanor1397/.config/mpd/mpd.conf
server_socket: bind to '0.0.0.0:6600' failed (continuing anyway, because binding to '[::]:6600' succeeded): Failed to bind socket: Адрес уже используется
path: SetFSCharset: fs charset is
libsamplerate: libsamplerate converter 'Fastest Sinc Interpolator'
vorbis: Xiph.Org libVorbis 1.3.7
opus: libopus 1.3.1
sndfile: libsndfile-1.0.31
hybrid_dsd: The Hybrid DSD decoder is disabled because it was not explicitly enabled
simple_db: reading DB
input: Input plugin 'qobuz' is not configured: No Qobuz app_id configured
curl: version 7.81.0
curl: with OpenSSL/1.1.1m
state_file: Loading state file /home/feanor1397/.config/mpd/state
playlist: queue song 11:"GHOST DATA/096 - Thigh Highs (feat. Jovani Occomy).mp3"
inotify: initializing inotify
decoder_thread: probing plugin mad
mad: detected LAME version 3.100 ("LAME3.100")
mad: LAME peak found: 0
mad: LAME track gain found: -8.2
mad: encoder delay is 576, encoder padding is 872
decoder: audio_format=48000:24:2, seekable=true
server_socket: bind to '0.0.0.0:8000' failed (continuing anyway, because binding to '[::]:8000' succeeded): Failed to bind socket: Адрес уже используется
output: opened "My HTTP Stream" (httpd) audio_format=44100:16:2
libsamplerate: setting samplerate conversion ratio to 0.92
output: converting in=48000:24:2 -> f=48000:24:2 -> out=44100:16:2
output: opened "Output" (pipewire) audio_format=48000:24:2
inotify: watching music directory
client: [0] opened from [::1]:40102
client: [0] process command "status"
client: [0] command returned 0
client: [0] process command "setvol "50""
client: [0] command returned 0
client: [0] process command list
client: process command "status"
client: command returned 0
client: process command "currentsong"
client: command returned 0
client: [0] process command list returned 0
client: [0] closed
client: [1] opened from [::1]:40112
client: [1] process command "outputs"
client: [1] command returned 0
client: [1] process command list
client: process command "toggleoutput "1""
output: closed "Output" (pipewire)
client: command returned 0
client: [1] process command list returned 0
client: [1] process command "outputs"
client: [1] command returned 0
client: [1] closed
client: [2] opened from [::1]:40114
client: [2] process command "outputs"
client: [2] command returned 0
client: [2] process command list
client: process command "toggleoutput "1""
client: command returned 0
client: [2] process command list returned 0
client: [2] process command "outputs"
client: [2] command returned 0
client: [2] closed
output: opened "Output" (pipewire) audio_format=48000:24:2
state_file: Saving state file /home/feanor1397/.config/mpd/state
player: played "Monstercat: Instinct/Rootkit - Taking Me Higher [Monstercat Release]-UKT5_l324wg.mp3"
output: closed "My HTTP Stream" (httpd)
output: closed "Output" (pipewire)
JeppeX commented 2 years ago

Can attest. This weird behavior started about a week ago or so. I was meddling with internet radios so I thought that was the cause...

JeppeX commented 2 years ago
[2022-02-03T22:59:43+0200] [ALPM] upgraded pipewire (1:0.3.44-1 -> 1:0.3.45-1)
[2022-02-03T22:59:43+0200] [ALPM] upgraded pipewire-pulse (1:0.3.44-1 -> 1:0.3.45-1)

Did some digging and it seems that the pipewire update (on arch repos at least) matches with the date when these errors started occurring. Since MPD wasn't updated during this time I think this is a bug or very retarded feature from pipewire to reset application volume.

A relevant discussion about this can be found on pipewire's issues page. The basic gist is that volume is restored by a session manager, which is by default pipewire-media-session. However, it seems to be broken currently so you can either:

  1. Replace your session manager with another e.g. wireplumber
  2. Downgrade your software using:
    sudo pacman -U /var/cache/pacman/pkg/pipewire-pulse-1\:0.3.43-5-x86_64.pkg.tar.zst
    sudo pacman -U /var/cache/pacman/pkg/pipewire-1\:0.3.43-1-x86_64.pkg.tar.zst

This issue should be closed because it is not related to MPD.

Feanor1397 commented 2 years ago

Yeah, just looked in .config/pipewire/media-session.d/restore-session

There was line "restore.stream.Output/Audio.application.name:mpv": { "volume": 1.000000, "mute": false, "volumes": [ 1.000000, 1.000000 ], "channels": [ "FL", "FR" ], "target-node": "alsa_output.pci-0000_09_00.6.analog-stereo" },

Deleted it, now everything works fine.