Skip to content

mpload: handle some settings being undef

Tomáš Janoušek requested to merge liskin/mpdtoys:undef-volume into master

After clearing (or loading) mpd (0.21.16) playlist, volume is undef, it only becomes defined after something is played. Storing such a state works fine, but restoring it via mpload crashes and fails to restore current song and position, which is very annoying, and saving again then leads to loss of information.

To be on the safe side, only restore settings which aren't undef.

Reproduction, first variant:

$ mpc clear
$ mpc add http://duramecho.com/Misc/SilentCd/Silence32s.mp3
$ mpstore | mpload
Use of uninitialized value $volume in pattern match (m//) at /usr/share/perl5/Audio/MPD.pm line 284, <GEN0> line 6316.
Use of uninitialized value $volume in concatenation (.) or string at /usr/share/perl5/Audio/MPD.pm line 288, <GEN0> line 6316.
[2@0] {setvol} wrong number of arguments for "setvol" at /usr/share/perl5/Audio/MPD.pm line 156, <GEN0> line 6317.

Reproduction, second (meaningful) variant:

$ mpc clear
$ mpc add http://duramecho.com/Misc/SilentCd/Silence32s.mp3
$ mpc play; sleep 1; mpc pause
$ mpstore | mpload
$ mpstore | mpload
Use of uninitialized value $volume in pattern match (m//) at /usr/share/perl5/Audio/MPD.pm line 284, <GEN0> line 6316.
Use of uninitialized value $volume in concatenation (.) or string at /usr/share/perl5/Audio/MPD.pm line 288, <GEN0> line 6316.
[2@0] {setvol} wrong number of arguments for "setvol" at /usr/share/perl5/Audio/MPD.pm line 156, <GEN0> line 6317.

Merge request reports

Loading