Partition: pass configuration as struct

This commit is contained in:
Max Kellermann
2021-12-03 20:22:52 +01:00
parent 2384a240e0
commit 95a155b10d
15 changed files with 230 additions and 105 deletions

View File

@@ -28,15 +28,12 @@
PlayerControl::PlayerControl(PlayerListener &_listener,
PlayerOutputs &_outputs,
InputCacheManager *_input_cache,
unsigned _buffer_chunks,
AudioFormat _configured_audio_format,
const ReplayGainConfig &_replay_gain_config) noexcept
const PlayerConfig &_config) noexcept
:listener(_listener), outputs(_outputs),
input_cache(_input_cache),
buffer_chunks(_buffer_chunks),
configured_audio_format(_configured_audio_format),
thread(BIND_THIS_METHOD(RunThread)),
replay_gain_config(_replay_gain_config)
config(_config),
thread(BIND_THIS_METHOD(RunThread))
{
}

View File

@@ -21,13 +21,13 @@
#define MPD_PLAYER_CONTROL_HXX
#include "output/Client.hxx"
#include "config/PlayerConfig.hxx"
#include "pcm/AudioFormat.hxx"
#include "thread/Mutex.hxx"
#include "thread/Cond.hxx"
#include "thread/Thread.hxx"
#include "CrossFade.hxx"
#include "Chrono.hxx"
#include "ReplayGainConfig.hxx"
#include "ReplayGainMode.hxx"
#include "MusicChunkPtr.hxx"
@@ -36,6 +36,7 @@
#include <memory>
struct Tag;
struct PlayerConfig;
class PlayerListener;
class PlayerOutputs;
class InputCacheManager;
@@ -118,12 +119,7 @@ class PlayerControl final : public AudioOutputClient {
InputCacheManager *const input_cache;
const unsigned buffer_chunks;
/**
* The "audio_output_format" setting.
*/
const AudioFormat configured_audio_format;
const PlayerConfig config;
/**
* The handle of the player thread.
@@ -229,17 +225,13 @@ class PlayerControl final : public AudioOutputClient {
CrossFadeSettings cross_fade;
const ReplayGainConfig replay_gain_config;
FloatDuration total_play_time = FloatDuration::zero();
public:
PlayerControl(PlayerListener &_listener,
PlayerOutputs &_outputs,
InputCacheManager *_input_cache,
unsigned buffer_chunks,
AudioFormat _configured_audio_format,
const ReplayGainConfig &_replay_gain_config) noexcept;
const PlayerConfig &_config) noexcept;
~PlayerControl() noexcept;
void Kill() noexcept;

View File

@@ -1165,11 +1165,11 @@ try {
DecoderControl dc(mutex, cond,
input_cache,
configured_audio_format,
replay_gain_config);
config.audio_format,
config.replay_gain);
dc.StartThread();
MusicBuffer buffer(buffer_chunks);
MusicBuffer buffer{config.buffer_chunks};
std::unique_lock<Mutex> lock(mutex);