From fd80683ade480d6417d66d0fc882b598738002f8 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 18 Jul 2018 10:50:09 +0200 Subject: [PATCH] decoder/mad: make "gapless_mp3_playback" a block option Remove another dependency on the config/Global library. --- NEWS | 1 + doc/mpd.conf.5 | 8 ------- doc/mpdconf.example | 8 ------- doc/user.xml | 29 ++++++++++++++++++++++++ src/config/Migrate.cxx | 9 ++++++++ src/config/Templates.cxx | 2 +- src/decoder/plugins/MadDecoderPlugin.cxx | 8 +++---- 7 files changed, 44 insertions(+), 21 deletions(-) diff --git a/NEWS b/NEWS index 817824d2e..e586519e3 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,7 @@ ver 0.21 (not yet released) * decoder - gme: try loading m3u sidecar files - hybrid_dsd: new decoder plugin + - mad: move "gapless_mp3_playback" setting to "decoder" block - pcm: support audio/L24 (RFC 3190) * resampler - soxr: flush resampler at end of song diff --git a/doc/mpd.conf.5 b/doc/mpd.conf.5 index 787394774..74cfd5b48 100644 --- a/doc/mpd.conf.5 +++ b/doc/mpd.conf.5 @@ -127,14 +127,6 @@ This specifies the character set used for the filesystem. A list of supported character sets can be obtained by running "iconv \-l". The default is determined from the locale when the db was originally created. .TP -.B gapless_mp3_playback -This specifies whether to support gapless playback of MP3s which have the -necessary headers. Useful if your MP3s have headers with incorrect -information. If you have such MP3s, it is highly recommended that you fix them -using vbrfix (available from ) -instead of disabling gapless MP3 playback. The default is to support gapless -MP3 playback. -.TP .B save_absolute_paths_in_playlists This specifies whether relative or absolute paths for song filenames are used when saving playlists. The default is "no". diff --git a/doc/mpdconf.example b/doc/mpdconf.example index 504ecd825..4684c7c37 100644 --- a/doc/mpdconf.example +++ b/doc/mpdconf.example @@ -96,14 +96,6 @@ # #log_level "default" # -# If you have a problem with your MP3s ending abruptly it is recommended that -# you set this argument to "no" to attempt to fix the problem. If this solves -# the problem, it is highly recommended to fix the MP3 files with vbrfix -# (available from ), at which -# point gapless MP3 playback can be enabled. -# -#gapless_mp3_playback "yes" -# # Setting "restore_paused" to "yes" puts MPD into pause mode instead # of starting playback after startup. # diff --git a/doc/user.xml b/doc/user.xml index 57200c267..dad61f286 100644 --- a/doc/user.xml +++ b/doc/user.xml @@ -3068,6 +3068,35 @@ run playback path to a DSD-capable DAC; for everybody else, playing back the ALAC copy of the file is better. + + + + + + Setting + Description + + + + + + gapless + yes|no + + + This specifies whether to support gapless playback + of MP3s which have the necessary headers. Useful if + your MP3s have headers with incorrect information. + If you have such MP3s, it is highly recommended that + you fix them using vbrfix + instead of disabling gapless MP3 playback. The + default is to support gapless MP3 playback. + + + + +
diff --git a/src/config/Migrate.cxx b/src/config/Migrate.cxx index 9c1ebf7df..fa401dd2d 100644 --- a/src/config/Migrate.cxx +++ b/src/config/Migrate.cxx @@ -56,8 +56,17 @@ MigrateCurlProxyConfig(ConfigData &config) noexcept "proxy_password"); } +static void +MigrateMadConfig(ConfigData &config) noexcept +{ + MigrateParamToBlockParam(config, ConfigOption::GAPLESS_MP3_PLAYBACK, + ConfigBlockOption::DECODER, "plugin", "mad", + "gapless"); +} + void Migrate(ConfigData &config) noexcept { MigrateCurlProxyConfig(config); + MigrateMadConfig(config); } diff --git a/src/config/Templates.cxx b/src/config/Templates.cxx index f09321a74..3c2d78aae 100644 --- a/src/config/Templates.cxx +++ b/src/config/Templates.cxx @@ -68,7 +68,7 @@ const ConfigTemplate config_param_templates[] = { { "id3v1_encoding", false, true }, { "metadata_to_use" }, { "save_absolute_paths_in_playlists" }, - { "gapless_mp3_playback" }, + { "gapless_mp3_playback", false, true }, { "auto_update" }, { "auto_update_depth" }, { "despotify_user", false, true }, diff --git a/src/decoder/plugins/MadDecoderPlugin.cxx b/src/decoder/plugins/MadDecoderPlugin.cxx index 65c840424..4ad0efc0d 100644 --- a/src/decoder/plugins/MadDecoderPlugin.cxx +++ b/src/decoder/plugins/MadDecoderPlugin.cxx @@ -21,7 +21,7 @@ #include "MadDecoderPlugin.hxx" #include "../DecoderAPI.hxx" #include "input/InputStream.hxx" -#include "config/Global.hxx" +#include "config/Block.hxx" #include "tag/Id3Scan.hxx" #include "tag/Rva2.hxx" #include "tag/Handler.hxx" @@ -107,10 +107,10 @@ mad_fixed_to_24_buffer(int32_t *dest, const struct mad_synth *synth, } static bool -mp3_plugin_init(gcc_unused const ConfigBlock &block) +mp3_plugin_init(const ConfigBlock &block) { - gapless_playback = config_get_bool(ConfigOption::GAPLESS_MP3_PLAYBACK, - DEFAULT_GAPLESS_MP3_PLAYBACK); + gapless_playback = block.GetBlockValue("gapless", + DEFAULT_GAPLESS_MP3_PLAYBACK); return true; }