test/ConfigGlue: merge duplicate code from various debug programs
This commit is contained in:
parent
848f6aa5ab
commit
b0739eca87
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2003-2019 The Music Player Daemon Project
|
||||||
|
* http://www.musicpd.org
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MPD_TEST_CONFIG_GLUE_HXX
|
||||||
|
#define MPD_TEST_CONFIG_GLUE_HXX
|
||||||
|
|
||||||
|
#include "config/File.hxx"
|
||||||
|
#include "config/Migrate.hxx"
|
||||||
|
#include "config/Data.hxx"
|
||||||
|
#include "fs/Path.hxx"
|
||||||
|
|
||||||
|
inline ConfigData
|
||||||
|
AutoLoadConfigFile(Path path)
|
||||||
|
{
|
||||||
|
ConfigData data;
|
||||||
|
|
||||||
|
if (!path.IsNull()) {
|
||||||
|
ReadConfigFile(data, path);
|
||||||
|
Migrate(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2003-2018 The Music Player Daemon Project
|
* Copyright 2003-2019 The Music Player Daemon Project
|
||||||
* http://www.musicpd.org
|
* http://www.musicpd.org
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -26,11 +26,7 @@
|
||||||
#include "db/LightDirectory.hxx"
|
#include "db/LightDirectory.hxx"
|
||||||
#include "song/LightSong.hxx"
|
#include "song/LightSong.hxx"
|
||||||
#include "db/PlaylistVector.hxx"
|
#include "db/PlaylistVector.hxx"
|
||||||
#include "config/File.hxx"
|
#include "ConfigGlue.hxx"
|
||||||
#include "config/Migrate.hxx"
|
|
||||||
#include "config/Data.hxx"
|
|
||||||
#include "config/Param.hxx"
|
|
||||||
#include "config/Block.hxx"
|
|
||||||
#include "tag/Config.hxx"
|
#include "tag/Config.hxx"
|
||||||
#include "fs/Path.hxx"
|
#include "fs/Path.hxx"
|
||||||
#include "event/Thread.hxx"
|
#include "event/Thread.hxx"
|
||||||
|
@ -124,9 +120,7 @@ try {
|
||||||
|
|
||||||
GlobalInit init;
|
GlobalInit init;
|
||||||
|
|
||||||
ConfigData config;
|
const auto config = AutoLoadConfigFile(config_path);
|
||||||
ReadConfigFile(config, config_path);
|
|
||||||
Migrate(config);
|
|
||||||
|
|
||||||
TagLoadConfig(config);
|
TagLoadConfig(config);
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,7 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config/File.hxx"
|
#include "ConfigGlue.hxx"
|
||||||
#include "config/Migrate.hxx"
|
|
||||||
#include "config/Data.hxx"
|
|
||||||
#include "tag/Chromaprint.hxx"
|
#include "tag/Chromaprint.hxx"
|
||||||
#include "pcm/PcmConvert.hxx"
|
#include "pcm/PcmConvert.hxx"
|
||||||
#include "event/Thread.hxx"
|
#include "event/Thread.hxx"
|
||||||
|
@ -90,18 +88,13 @@ ParseCommandLine(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
class GlobalInit {
|
class GlobalInit {
|
||||||
ConfigData config;
|
const ConfigData config;
|
||||||
EventThread io_thread;
|
EventThread io_thread;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GlobalInit(Path config_path, bool verbose) {
|
explicit GlobalInit(Path config_path)
|
||||||
SetLogThreshold(verbose ? LogLevel::DEBUG : LogLevel::INFO);
|
:config(AutoLoadConfigFile(config_path))
|
||||||
|
{
|
||||||
if (!config_path.IsNull()) {
|
|
||||||
ReadConfigFile(config, config_path);
|
|
||||||
Migrate(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
io_thread.Start();
|
io_thread.Start();
|
||||||
|
|
||||||
input_stream_global_init(config,
|
input_stream_global_init(config,
|
||||||
|
@ -245,7 +238,8 @@ int main(int argc, char **argv)
|
||||||
try {
|
try {
|
||||||
const auto c = ParseCommandLine(argc, argv);
|
const auto c = ParseCommandLine(argc, argv);
|
||||||
|
|
||||||
const GlobalInit init(c.config_path, c.verbose);
|
SetLogThreshold(c.verbose ? LogLevel::DEBUG : LogLevel::INFO);
|
||||||
|
const GlobalInit init(c.config_path);
|
||||||
|
|
||||||
const DecoderPlugin *plugin = decoder_plugin_from_name(c.decoder);
|
const DecoderPlugin *plugin = decoder_plugin_from_name(c.decoder);
|
||||||
if (plugin == nullptr) {
|
if (plugin == nullptr) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2003-2018 The Music Player Daemon Project
|
* Copyright 2003-2019 The Music Player Daemon Project
|
||||||
* http://www.musicpd.org
|
* http://www.musicpd.org
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -21,9 +21,7 @@
|
||||||
#include "song/DetachedSong.hxx"
|
#include "song/DetachedSong.hxx"
|
||||||
#include "playlist/SongEnumerator.hxx"
|
#include "playlist/SongEnumerator.hxx"
|
||||||
#include "input/InputStream.hxx"
|
#include "input/InputStream.hxx"
|
||||||
#include "config/File.hxx"
|
#include "ConfigGlue.hxx"
|
||||||
#include "config/Migrate.hxx"
|
|
||||||
#include "config/Data.hxx"
|
|
||||||
#include "decoder/DecoderList.hxx"
|
#include "decoder/DecoderList.hxx"
|
||||||
#include "input/Init.hxx"
|
#include "input/Init.hxx"
|
||||||
#include "event/Thread.hxx"
|
#include "event/Thread.hxx"
|
||||||
|
@ -61,9 +59,7 @@ try {
|
||||||
|
|
||||||
/* initialize MPD */
|
/* initialize MPD */
|
||||||
|
|
||||||
ConfigData config;
|
const auto config = AutoLoadConfigFile(config_path);
|
||||||
ReadConfigFile(config, config_path);
|
|
||||||
Migrate(config);
|
|
||||||
|
|
||||||
EventThread io_thread;
|
EventThread io_thread;
|
||||||
io_thread.Start();
|
io_thread.Start();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2003-2018 The Music Player Daemon Project
|
* Copyright 2003-2019 The Music Player Daemon Project
|
||||||
* http://www.musicpd.org
|
* http://www.musicpd.org
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -17,9 +17,7 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config/File.hxx"
|
#include "ConfigGlue.hxx"
|
||||||
#include "config/Migrate.hxx"
|
|
||||||
#include "config/Data.hxx"
|
|
||||||
#include "event/Thread.hxx"
|
#include "event/Thread.hxx"
|
||||||
#include "decoder/DecoderList.hxx"
|
#include "decoder/DecoderList.hxx"
|
||||||
#include "decoder/DecoderPlugin.hxx"
|
#include "decoder/DecoderPlugin.hxx"
|
||||||
|
@ -88,18 +86,13 @@ ParseCommandLine(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
class GlobalInit {
|
class GlobalInit {
|
||||||
ConfigData config;
|
const ConfigData config;
|
||||||
EventThread io_thread;
|
EventThread io_thread;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GlobalInit(Path config_path, bool verbose) {
|
explicit GlobalInit(Path config_path)
|
||||||
SetLogThreshold(verbose ? LogLevel::DEBUG : LogLevel::INFO);
|
:config(AutoLoadConfigFile(config_path))
|
||||||
|
{
|
||||||
if (!config_path.IsNull()) {
|
|
||||||
ReadConfigFile(config, config_path);
|
|
||||||
Migrate(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
io_thread.Start();
|
io_thread.Start();
|
||||||
|
|
||||||
input_stream_global_init(config,
|
input_stream_global_init(config,
|
||||||
|
@ -117,7 +110,8 @@ int main(int argc, char **argv)
|
||||||
try {
|
try {
|
||||||
const auto c = ParseCommandLine(argc, argv);
|
const auto c = ParseCommandLine(argc, argv);
|
||||||
|
|
||||||
const GlobalInit init(c.config_path, c.verbose);
|
SetLogThreshold(c.verbose ? LogLevel::DEBUG : LogLevel::INFO);
|
||||||
|
const GlobalInit init(c.config_path);
|
||||||
|
|
||||||
const DecoderPlugin *plugin = decoder_plugin_from_name(c.decoder);
|
const DecoderPlugin *plugin = decoder_plugin_from_name(c.decoder);
|
||||||
if (plugin == nullptr) {
|
if (plugin == nullptr) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2003-2018 The Music Player Daemon Project
|
* Copyright 2003-2019 The Music Player Daemon Project
|
||||||
* http://www.musicpd.org
|
* http://www.musicpd.org
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -17,10 +17,7 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config/Param.hxx"
|
#include "ConfigGlue.hxx"
|
||||||
#include "config/Data.hxx"
|
|
||||||
#include "config/File.hxx"
|
|
||||||
#include "config/Migrate.hxx"
|
|
||||||
#include "fs/Path.hxx"
|
#include "fs/Path.hxx"
|
||||||
#include "AudioParser.hxx"
|
#include "AudioParser.hxx"
|
||||||
#include "AudioFormat.hxx"
|
#include "AudioFormat.hxx"
|
||||||
|
@ -77,9 +74,7 @@ try {
|
||||||
|
|
||||||
/* read configuration file (mpd.conf) */
|
/* read configuration file (mpd.conf) */
|
||||||
|
|
||||||
ConfigData config;
|
const auto config = AutoLoadConfigFile(config_path);
|
||||||
ReadConfigFile(config, config_path);
|
|
||||||
Migrate(config);
|
|
||||||
|
|
||||||
/* parse the audio format */
|
/* parse the audio format */
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2003-2018 The Music Player Daemon Project
|
* Copyright 2003-2019 The Music Player Daemon Project
|
||||||
* http://www.musicpd.org
|
* http://www.musicpd.org
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -20,9 +20,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "TagSave.hxx"
|
#include "TagSave.hxx"
|
||||||
#include "tag/Tag.hxx"
|
#include "tag/Tag.hxx"
|
||||||
#include "config/File.hxx"
|
#include "ConfigGlue.hxx"
|
||||||
#include "config/Migrate.hxx"
|
|
||||||
#include "config/Data.hxx"
|
|
||||||
#include "input/InputStream.hxx"
|
#include "input/InputStream.hxx"
|
||||||
#include "input/Init.hxx"
|
#include "input/Init.hxx"
|
||||||
#include "input/Registry.hxx"
|
#include "input/Registry.hxx"
|
||||||
|
@ -103,7 +101,7 @@ ParseCommandLine(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
class GlobalInit {
|
class GlobalInit {
|
||||||
ConfigData config;
|
const ConfigData config;
|
||||||
EventThread io_thread;
|
EventThread io_thread;
|
||||||
|
|
||||||
#ifdef ENABLE_ARCHIVE
|
#ifdef ENABLE_ARCHIVE
|
||||||
|
@ -111,14 +109,9 @@ class GlobalInit {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GlobalInit(Path config_path, bool verbose) {
|
explicit GlobalInit(Path config_path)
|
||||||
SetLogThreshold(verbose ? LogLevel::DEBUG : LogLevel::INFO);
|
:config(AutoLoadConfigFile(config_path))
|
||||||
|
{
|
||||||
if (!config_path.IsNull()) {
|
|
||||||
ReadConfigFile(config, config_path);
|
|
||||||
Migrate(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
io_thread.Start();
|
io_thread.Start();
|
||||||
|
|
||||||
input_stream_global_init(config,
|
input_stream_global_init(config,
|
||||||
|
@ -234,7 +227,8 @@ try {
|
||||||
|
|
||||||
/* initialize MPD */
|
/* initialize MPD */
|
||||||
|
|
||||||
const GlobalInit init(c.config_path, c.verbose);
|
SetLogThreshold(c.verbose ? LogLevel::DEBUG : LogLevel::INFO);
|
||||||
|
const GlobalInit init(c.config_path);
|
||||||
|
|
||||||
if (c.scan)
|
if (c.scan)
|
||||||
return Scan(c.uri);
|
return Scan(c.uri);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2003-2018 The Music Player Daemon Project
|
* Copyright 2003-2019 The Music Player Daemon Project
|
||||||
* http://www.musicpd.org
|
* http://www.musicpd.org
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -17,9 +17,7 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config/File.hxx"
|
#include "ConfigGlue.hxx"
|
||||||
#include "config/Migrate.hxx"
|
|
||||||
#include "config/Data.hxx"
|
|
||||||
#include "neighbor/Listener.hxx"
|
#include "neighbor/Listener.hxx"
|
||||||
#include "neighbor/Info.hxx"
|
#include "neighbor/Info.hxx"
|
||||||
#include "neighbor/Glue.hxx"
|
#include "neighbor/Glue.hxx"
|
||||||
|
@ -57,14 +55,12 @@ try {
|
||||||
|
|
||||||
/* initialize the core */
|
/* initialize the core */
|
||||||
|
|
||||||
ConfigData config;
|
|
||||||
EventLoop loop;
|
EventLoop loop;
|
||||||
const ShutdownHandler shutdown_handler(loop);
|
const ShutdownHandler shutdown_handler(loop);
|
||||||
|
|
||||||
/* read configuration file (mpd.conf) */
|
/* read configuration file (mpd.conf) */
|
||||||
|
|
||||||
ReadConfigFile(config, config_path);
|
const auto config = AutoLoadConfigFile(config_path);
|
||||||
Migrate(config);
|
|
||||||
|
|
||||||
/* initialize neighbor plugins */
|
/* initialize neighbor plugins */
|
||||||
|
|
||||||
|
|
|
@ -20,12 +20,7 @@
|
||||||
#include "output/Interface.hxx"
|
#include "output/Interface.hxx"
|
||||||
#include "output/Registry.hxx"
|
#include "output/Registry.hxx"
|
||||||
#include "output/OutputPlugin.hxx"
|
#include "output/OutputPlugin.hxx"
|
||||||
#include "config/Param.hxx"
|
#include "ConfigGlue.hxx"
|
||||||
#include "config/Data.hxx"
|
|
||||||
#include "config/File.hxx"
|
|
||||||
#include "config/Migrate.hxx"
|
|
||||||
#include "config/Option.hxx"
|
|
||||||
#include "config/Block.hxx"
|
|
||||||
#include "event/Thread.hxx"
|
#include "event/Thread.hxx"
|
||||||
#include "fs/Path.hxx"
|
#include "fs/Path.hxx"
|
||||||
#include "AudioParser.hxx"
|
#include "AudioParser.hxx"
|
||||||
|
@ -122,9 +117,7 @@ try {
|
||||||
|
|
||||||
/* read configuration file (mpd.conf) */
|
/* read configuration file (mpd.conf) */
|
||||||
|
|
||||||
ConfigData config;
|
const auto config = AutoLoadConfigFile(config_path);
|
||||||
ReadConfigFile(config, config_path);
|
|
||||||
Migrate(config);
|
|
||||||
|
|
||||||
EventThread io_thread;
|
EventThread io_thread;
|
||||||
io_thread.Start();
|
io_thread.Start();
|
||||||
|
|
Loading…
Reference in New Issue