decoder/Thread: move decoder_thread_start() into DecoderControl

This commit is contained in:
Max Kellermann 2018-09-21 16:57:54 +02:00
parent af64bd5088
commit 218d9383d7
5 changed files with 10 additions and 41 deletions

View File

@ -102,7 +102,7 @@ libmpd_a_SOURCES = \
src/Idle.cxx src/Idle.hxx \ src/Idle.cxx src/Idle.hxx \
src/IdleFlags.cxx src/IdleFlags.hxx \ src/IdleFlags.cxx src/IdleFlags.hxx \
src/decoder/DecoderError.cxx src/decoder/DecoderError.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/DecoderCommand.hxx \
src/decoder/DecoderControl.cxx src/decoder/DecoderControl.hxx \ src/decoder/DecoderControl.cxx src/decoder/DecoderControl.hxx \
src/decoder/Client.hxx \ src/decoder/Client.hxx \

View File

@ -178,6 +178,14 @@ struct DecoderControl final : InputStreamHandler {
const ReplayGainConfig &_replay_gain_config) noexcept; const ReplayGainConfig &_replay_gain_config) noexcept;
~DecoderControl() noexcept; ~DecoderControl() noexcept;
/**
* Throws on error.
*/
void StartThread() {
quit = false;
thread.Start();
}
/** /**
* Locks the object. * Locks the object.
*/ */

View File

@ -18,7 +18,6 @@
*/ */
#include "config.h" #include "config.h"
#include "DecoderThread.hxx"
#include "DecoderControl.hxx" #include "DecoderControl.hxx"
#include "Bridge.hxx" #include "Bridge.hxx"
#include "DecoderError.hxx" #include "DecoderError.hxx"
@ -565,12 +564,3 @@ DecoderControl::RunThread() noexcept
} }
} while (command != DecoderCommand::NONE || !quit); } while (command != DecoderCommand::NONE || !quit);
} }
void
decoder_thread_start(DecoderControl &dc)
{
assert(!dc.thread.IsDefined());
dc.quit = false;
dc.thread.Start();
}

View File

@ -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

View File

@ -21,7 +21,6 @@
#include "Thread.hxx" #include "Thread.hxx"
#include "Outputs.hxx" #include "Outputs.hxx"
#include "Listener.hxx" #include "Listener.hxx"
#include "decoder/DecoderThread.hxx"
#include "decoder/DecoderControl.hxx" #include "decoder/DecoderControl.hxx"
#include "MusicPipe.hxx" #include "MusicPipe.hxx"
#include "MusicBuffer.hxx" #include "MusicBuffer.hxx"
@ -1089,7 +1088,7 @@ PlayerControl::RunThread() noexcept
DecoderControl dc(mutex, cond, DecoderControl dc(mutex, cond,
configured_audio_format, configured_audio_format,
replay_gain_config); replay_gain_config);
decoder_thread_start(dc); dc.StartThread();
MusicBuffer buffer(buffer_chunks); MusicBuffer buffer(buffer_chunks);