From 218d9383d712809f42d62fde9e9de39b5e955d14 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 21 Sep 2018 16:57:54 +0200 Subject: [PATCH] decoder/Thread: move decoder_thread_start() into DecoderControl --- Makefile.am | 2 +- src/decoder/DecoderControl.hxx | 8 ++++++++ src/decoder/DecoderThread.cxx | 10 ---------- src/decoder/DecoderThread.hxx | 28 ---------------------------- src/player/Thread.cxx | 3 +-- 5 files changed, 10 insertions(+), 41 deletions(-) delete mode 100644 src/decoder/DecoderThread.hxx diff --git a/Makefile.am b/Makefile.am index c8fe5051b..3f531e2f7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -102,7 +102,7 @@ libmpd_a_SOURCES = \ src/Idle.cxx src/Idle.hxx \ src/IdleFlags.cxx src/IdleFlags.hxx \ src/decoder/DecoderError.cxx src/decoder/DecoderError.hxx \ - src/decoder/DecoderThread.cxx src/decoder/DecoderThread.hxx \ + src/decoder/DecoderThread.cxx \ src/decoder/DecoderCommand.hxx \ src/decoder/DecoderControl.cxx src/decoder/DecoderControl.hxx \ src/decoder/Client.hxx \ diff --git a/src/decoder/DecoderControl.hxx b/src/decoder/DecoderControl.hxx index 29e7fbfff..190b2ab22 100644 --- a/src/decoder/DecoderControl.hxx +++ b/src/decoder/DecoderControl.hxx @@ -178,6 +178,14 @@ struct DecoderControl final : InputStreamHandler { const ReplayGainConfig &_replay_gain_config) noexcept; ~DecoderControl() noexcept; + /** + * Throws on error. + */ + void StartThread() { + quit = false; + thread.Start(); + } + /** * Locks the object. */ diff --git a/src/decoder/DecoderThread.cxx b/src/decoder/DecoderThread.cxx index 0e4a34fab..cf1a7d679 100644 --- a/src/decoder/DecoderThread.cxx +++ b/src/decoder/DecoderThread.cxx @@ -18,7 +18,6 @@ */ #include "config.h" -#include "DecoderThread.hxx" #include "DecoderControl.hxx" #include "Bridge.hxx" #include "DecoderError.hxx" @@ -565,12 +564,3 @@ DecoderControl::RunThread() noexcept } } while (command != DecoderCommand::NONE || !quit); } - -void -decoder_thread_start(DecoderControl &dc) -{ - assert(!dc.thread.IsDefined()); - - dc.quit = false; - dc.thread.Start(); -} diff --git a/src/decoder/DecoderThread.hxx b/src/decoder/DecoderThread.hxx deleted file mode 100644 index cf1abf34b..000000000 --- a/src/decoder/DecoderThread.hxx +++ /dev/null @@ -1,28 +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_DECODER_THREAD_HXX -#define MPD_DECODER_THREAD_HXX - -struct DecoderControl; - -void -decoder_thread_start(DecoderControl &dc); - -#endif diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx index 8a91d0c57..6a7ccd024 100644 --- a/src/player/Thread.cxx +++ b/src/player/Thread.cxx @@ -21,7 +21,6 @@ #include "Thread.hxx" #include "Outputs.hxx" #include "Listener.hxx" -#include "decoder/DecoderThread.hxx" #include "decoder/DecoderControl.hxx" #include "MusicPipe.hxx" #include "MusicBuffer.hxx" @@ -1089,7 +1088,7 @@ PlayerControl::RunThread() noexcept DecoderControl dc(mutex, cond, configured_audio_format, replay_gain_config); - decoder_thread_start(dc); + dc.StartThread(); MusicBuffer buffer(buffer_chunks);