diff --git a/Makefile.am b/Makefile.am index 681e5461d..34b23bd4a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1786,8 +1786,6 @@ test_run_storage_LDADD = \ libutil.a test_run_storage_SOURCES = \ src/Log.cxx src/LogBackend.cxx \ - src/IOThread.cxx \ - test/ScopeIOThread.hxx \ test/run_storage.cxx if ENABLE_WEBDAV @@ -1808,16 +1806,13 @@ test_run_input_LDADD = \ libsystem.a \ libutil.a test_run_input_SOURCES = test/run_input.cxx \ - test/ScopeIOThread.hxx \ src/Log.cxx src/LogBackend.cxx \ - src/IOThread.cxx \ src/TagSave.cxx if ENABLE_NEIGHBOR_PLUGINS test_run_neighbor_explorer_SOURCES = \ src/Log.cxx src/LogBackend.cxx \ - src/IOThread.cxx \ test/run_neighbor_explorer.cxx test_run_neighbor_explorer_LDADD = $(AM_LDADD) \ $(NEIGHBOR_LIBS) \ @@ -1852,9 +1847,7 @@ test_visit_archive_LDADD = \ libsystem.a \ libutil.a test_visit_archive_SOURCES = test/visit_archive.cxx \ - test/ScopeIOThread.hxx \ src/Log.cxx src/LogBackend.cxx \ - src/IOThread.cxx \ src/input/Open.cxx endif @@ -1900,9 +1893,7 @@ test_dump_text_file_LDADD = \ libthread.a \ libutil.a test_dump_text_file_SOURCES = test/dump_text_file.cxx \ - test/ScopeIOThread.hxx \ - src/Log.cxx src/LogBackend.cxx \ - src/IOThread.cxx + src/Log.cxx src/LogBackend.cxx test_dump_playlist_LDADD = \ $(PLAYLIST_LIBS) \ @@ -1923,9 +1914,7 @@ test_dump_playlist_LDADD = \ libpcm.a test_dump_playlist_SOURCES = test/dump_playlist.cxx \ test/FakeDecoderAPI.cxx test/FakeDecoderAPI.hxx \ - test/ScopeIOThread.hxx \ src/Log.cxx src/LogBackend.cxx \ - src/IOThread.cxx \ src/TagSave.cxx \ src/TagFile.cxx \ src/DetachedSong.cxx @@ -1952,10 +1941,8 @@ test_run_decoder_LDADD = \ libutil.a test_run_decoder_SOURCES = test/run_decoder.cxx \ test/FakeDecoderAPI.cxx test/FakeDecoderAPI.hxx \ - test/ScopeIOThread.hxx \ src/DetachedSong.cxx \ src/Log.cxx src/LogBackend.cxx \ - src/IOThread.cxx \ src/ReplayGainInfo.cxx test_read_tags_LDADD = \ @@ -1974,10 +1961,8 @@ test_read_tags_LDADD = \ libutil.a test_read_tags_SOURCES = test/read_tags.cxx \ test/FakeDecoderAPI.cxx test/FakeDecoderAPI.hxx \ - test/ScopeIOThread.hxx \ src/DetachedSong.cxx \ src/Log.cxx src/LogBackend.cxx \ - src/IOThread.cxx \ src/ReplayGainInfo.cxx test_ReadApeTags_LDADD = \ @@ -2130,9 +2115,7 @@ test_run_output_LDADD = $(MPD_LIBS) \ libthread.a \ libutil.a test_run_output_SOURCES = test/run_output.cxx \ - test/ScopeIOThread.hxx \ src/Log.cxx src/LogBackend.cxx \ - src/IOThread.cxx \ src/output/Domain.cxx \ src/output/Init.cxx src/output/Finish.cxx src/output/Registry.cxx \ src/output/OutputPlugin.cxx \ diff --git a/test/ScopeIOThread.hxx b/test/ScopeIOThread.hxx deleted file mode 100644 index 782209d4f..000000000 --- a/test/ScopeIOThread.hxx +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2003-2017 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_SCOPE_IO_THREAD_HXX -#define MPD_SCOPE_IO_THREAD_HXX - -#include "IOThread.hxx" - -struct ScopeIOThread { - ScopeIOThread() { - io_thread_init(); - io_thread_start(); - } - - ~ScopeIOThread() { - io_thread_deinit(); - } -}; - -#endif diff --git a/test/dump_playlist.cxx b/test/dump_playlist.cxx index a33c392a2..3cb75a5c9 100644 --- a/test/dump_playlist.cxx +++ b/test/dump_playlist.cxx @@ -25,7 +25,7 @@ #include "config/ConfigGlobal.hxx" #include "decoder/DecoderList.hxx" #include "input/Init.hxx" -#include "ScopeIOThread.hxx" +#include "event/Thread.hxx" #include "playlist/PlaylistRegistry.hxx" #include "playlist/PlaylistPlugin.hxx" #include "fs/Path.hxx" @@ -64,9 +64,10 @@ try { ReadConfigFile(config_path); - const ScopeIOThread io_thread; + EventThread io_thread; + io_thread.Start(); - input_stream_global_init(io_thread_get()); + input_stream_global_init(io_thread.GetEventLoop()); playlist_list_global_init(); decoder_plugin_init_all(); diff --git a/test/dump_text_file.cxx b/test/dump_text_file.cxx index c88b04050..c72d60464 100644 --- a/test/dump_text_file.cxx +++ b/test/dump_text_file.cxx @@ -18,7 +18,7 @@ */ #include "config.h" -#include "ScopeIOThread.hxx" +#include "event/Thread.hxx" #include "input/Init.hxx" #include "input/InputStream.hxx" #include "input/TextInputStream.hxx" @@ -37,15 +37,16 @@ #include class GlobalInit { - const ScopeIOThread io_thread; + EventThread io_thread; public: GlobalInit() { + io_thread.Start(); config_global_init(); #ifdef ENABLE_ARCHIVE archive_plugin_init_all(); #endif - input_stream_global_init(io_thread_get()); + input_stream_global_init(io_thread.GetEventLoop()); } ~GlobalInit() { diff --git a/test/read_tags.cxx b/test/read_tags.cxx index 7534f661e..8bc33b804 100644 --- a/test/read_tags.cxx +++ b/test/read_tags.cxx @@ -18,7 +18,7 @@ */ #include "config.h" -#include "ScopeIOThread.hxx" +#include "event/Thread.hxx" #include "decoder/DecoderList.hxx" #include "decoder/DecoderPlugin.hxx" #include "input/Init.hxx" @@ -86,9 +86,10 @@ try { decoder_name = argv[1]; const Path path = Path::FromFS(argv[2]); - const ScopeIOThread io_thread; + EventThread io_thread; + io_thread.Start(); - input_stream_global_init(io_thread_get()); + input_stream_global_init(io_thread.GetEventLoop()); AtScopeExit() { input_stream_global_finish(); }; decoder_plugin_init_all(); diff --git a/test/run_decoder.cxx b/test/run_decoder.cxx index 7760d008c..5bc00199c 100644 --- a/test/run_decoder.cxx +++ b/test/run_decoder.cxx @@ -18,7 +18,7 @@ */ #include "config.h" -#include "ScopeIOThread.hxx" +#include "event/Thread.hxx" #include "decoder/DecoderList.hxx" #include "decoder/DecoderPlugin.hxx" #include "FakeDecoderAPI.hxx" @@ -46,9 +46,10 @@ try { const char *const decoder_name = argv[1]; const char *const uri = argv[2]; - const ScopeIOThread io_thread; + EventThread io_thread; + io_thread.Start(); - input_stream_global_init(io_thread_get()); + input_stream_global_init(io_thread.GetEventLoop()); decoder_plugin_init_all(); diff --git a/test/run_input.cxx b/test/run_input.cxx index 125e909c6..d7bf58824 100644 --- a/test/run_input.cxx +++ b/test/run_input.cxx @@ -23,7 +23,7 @@ #include "config/ConfigGlobal.hxx" #include "input/InputStream.hxx" #include "input/Init.hxx" -#include "ScopeIOThread.hxx" +#include "event/Thread.hxx" #include "thread/Cond.hxx" #include "Log.hxx" #include "fs/io/BufferedOutputStream.hxx" @@ -39,15 +39,16 @@ #include class GlobalInit { - const ScopeIOThread io_thread; + EventThread io_thread; public: GlobalInit() { + io_thread.Start(); config_global_init(); #ifdef ENABLE_ARCHIVE archive_plugin_init_all(); #endif - input_stream_global_init(io_thread_get()); + input_stream_global_init(io_thread.GetEventLoop()); } ~GlobalInit() { diff --git a/test/run_output.cxx b/test/run_output.cxx index 37954378b..a4a39b826 100644 --- a/test/run_output.cxx +++ b/test/run_output.cxx @@ -26,8 +26,7 @@ #include "config/ConfigOption.hxx" #include "Idle.hxx" #include "Main.hxx" -#include "event/Loop.hxx" -#include "ScopeIOThread.hxx" +#include "event/Thread.hxx" #include "fs/Path.hxx" #include "AudioParser.hxx" #include "ReplayGainConfig.hxx" @@ -136,14 +135,14 @@ try { config_global_init(); ReadConfigFile(config_path); - EventLoop event_loop; - - const ScopeIOThread io_thread; + EventThread io_thread; + io_thread.Start(); /* initialize the audio output */ DummyAudioOutputClient client; - AudioOutput *ao = load_audio_output(event_loop, client, argv[2]); + AudioOutput *ao = load_audio_output(io_thread.GetEventLoop(), client, + argv[2]); /* parse the audio format */ diff --git a/test/run_storage.cxx b/test/run_storage.cxx index 805211fe0..3d33772ea 100644 --- a/test/run_storage.cxx +++ b/test/run_storage.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "Log.hxx" -#include "ScopeIOThread.hxx" +#include "event/Thread.hxx" #include "storage/Registry.hxx" #include "storage/StorageInterface.hxx" #include "storage/FileInfo.hxx" @@ -34,9 +34,9 @@ #include static Storage * -MakeStorage(const char *uri) +MakeStorage(EventLoop &event_loop, const char *uri) { - Storage *storage = CreateStorageURI(io_thread_get(), uri); + Storage *storage = CreateStorageURI(event_loop, uri); if (storage == nullptr) throw std::runtime_error("Unrecognized storage URI"); @@ -95,7 +95,8 @@ try { const char *const command = argv[1]; const char *const storage_uri = argv[2]; - const ScopeIOThread io_thread; + EventThread io_thread; + io_thread.Start(); if (strcmp(command, "ls") == 0) { if (argc != 4) { @@ -105,7 +106,8 @@ try { const char *const path = argv[3]; - std::unique_ptr storage(MakeStorage(storage_uri)); + std::unique_ptr storage(MakeStorage(io_thread.GetEventLoop(), + storage_uri)); return Ls(*storage, path); } else { diff --git a/test/visit_archive.cxx b/test/visit_archive.cxx index c0668290a..c16d8e5e9 100644 --- a/test/visit_archive.cxx +++ b/test/visit_archive.cxx @@ -20,7 +20,7 @@ #include "config.h" #include "tag/Tag.hxx" #include "config/ConfigGlobal.hxx" -#include "ScopeIOThread.hxx" +#include "event/Thread.hxx" #include "input/Init.hxx" #include "archive/ArchiveList.hxx" #include "archive/ArchivePlugin.hxx" @@ -36,15 +36,16 @@ #include class GlobalInit { - const ScopeIOThread io_thread; + EventThread io_thread; public: GlobalInit() { + io_thread.Start(); config_global_init(); #ifdef ENABLE_ARCHIVE archive_plugin_init_all(); #endif - input_stream_global_init(io_thread_get()); + input_stream_global_init(io_thread.GetEventLoop()); } ~GlobalInit() {