diff options
author | Max Kellermann <max@musicpd.org> | 2016-12-03 14:12:08 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2016-12-03 14:12:08 +0100 |
commit | 9fb7cc796b34f9faf8fa50354102a875e73fa476 (patch) | |
tree | 6e0bf5af8aa32fecfcc6b383bda35484e55d0e81 /src | |
parent | 3472208c054507e2fd6616268570121579b5fcdb (diff) |
decoder/Control: add attribute configured_audio_format
Obsoletes the same variable from AudioConfig.cxx.
Diffstat (limited to 'src')
-rw-r--r-- | src/AudioConfig.cxx | 52 | ||||
-rw-r--r-- | src/AudioConfig.hxx | 32 | ||||
-rw-r--r-- | src/Main.cxx | 16 | ||||
-rw-r--r-- | src/Partition.cxx | 3 | ||||
-rw-r--r-- | src/Partition.hxx | 1 | ||||
-rw-r--r-- | src/decoder/Bridge.cxx | 4 | ||||
-rw-r--r-- | src/decoder/DecoderControl.cxx | 2 | ||||
-rw-r--r-- | src/decoder/DecoderControl.hxx | 6 | ||||
-rw-r--r-- | src/player/Control.cxx | 2 | ||||
-rw-r--r-- | src/player/Control.hxx | 6 | ||||
-rw-r--r-- | src/player/Thread.cxx | 4 |
11 files changed, 38 insertions, 90 deletions
diff --git a/src/AudioConfig.cxx b/src/AudioConfig.cxx deleted file mode 100644 index 35b501cc7..000000000 --- a/src/AudioConfig.cxx +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2003-2016 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. - */ - -#include "config.h" -#include "AudioConfig.hxx" -#include "AudioFormat.hxx" -#include "AudioParser.hxx" -#include "config/Param.hxx" -#include "config/ConfigGlobal.hxx" -#include "config/ConfigOption.hxx" -#include "util/RuntimeError.hxx" - -static AudioFormat configured_audio_format; - -AudioFormat -getOutputAudioFormat(AudioFormat inAudioFormat) -{ - AudioFormat out_audio_format = inAudioFormat; - out_audio_format.ApplyMask(configured_audio_format); - return out_audio_format; -} - -void initAudioConfig(void) -{ - const auto *param = config_get_param(ConfigOption::AUDIO_OUTPUT_FORMAT); - - if (param == nullptr) - return; - - try { - configured_audio_format = ParseAudioFormat(param->value.c_str(), true); - } catch (const std::runtime_error &) { - std::throw_with_nested(FormatRuntimeError("error parsing line %i", - param->line)); - } -} diff --git a/src/AudioConfig.hxx b/src/AudioConfig.hxx deleted file mode 100644 index d84a259ad..000000000 --- a/src/AudioConfig.hxx +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2003-2016 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_AUDIO_CONFIG_HXX -#define MPD_AUDIO_CONFIG_HXX - -struct AudioFormat; - -AudioFormat -getOutputAudioFormat(AudioFormat inFormat); - -/* make sure initPlayerData is called before this function!! */ -void -initAudioConfig(); - -#endif diff --git a/src/Main.cxx b/src/Main.cxx index 8e576787b..381a10fc5 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -45,7 +45,7 @@ #include "playlist/PlaylistRegistry.hxx" #include "zeroconf/ZeroconfGlue.hxx" #include "decoder/DecoderList.hxx" -#include "AudioConfig.hxx" +#include "AudioParser.hxx" #include "pcm/PcmConvert.hxx" #include "unix/SignalHandlers.hxx" #include "system/FatalError.hxx" @@ -327,10 +327,23 @@ initialize_decoder_and_player(void) config_get_positive(ConfigOption::MAX_PLAYLIST_LENGTH, DEFAULT_PLAYLIST_MAX_LENGTH); + AudioFormat configured_audio_format = AudioFormat::Undefined(); + param = config_get_param(ConfigOption::AUDIO_OUTPUT_FORMAT); + if (param != nullptr) { + try { + configured_audio_format = ParseAudioFormat(param->value.c_str(), + true); + } catch (const std::runtime_error &) { + std::throw_with_nested(FormatRuntimeError("error parsing line %i", + param->line)); + } + } + instance->partition = new Partition(*instance, max_length, buffered_chunks, buffered_before_play, + configured_audio_format, replay_gain_config); try { @@ -489,7 +502,6 @@ try { glue_sticker_init(); command_init(); - initAudioConfig(); instance->partition->outputs.Configure(instance->event_loop, replay_gain_config, instance->partition->pc); diff --git a/src/Partition.cxx b/src/Partition.cxx index b3dc9b73d..824051d64 100644 --- a/src/Partition.cxx +++ b/src/Partition.cxx @@ -28,13 +28,14 @@ Partition::Partition(Instance &_instance, unsigned max_length, unsigned buffer_chunks, unsigned buffered_before_play, + AudioFormat configured_audio_format, const ReplayGainConfig &replay_gain_config) :instance(_instance), global_events(instance.event_loop, BIND_THIS_METHOD(OnGlobalEvent)), playlist(max_length, *this), outputs(*this), pc(*this, outputs, buffer_chunks, buffered_before_play, - replay_gain_config) + configured_audio_format, replay_gain_config) { UpdateEffectiveReplayGainMode(); } diff --git a/src/Partition.hxx b/src/Partition.hxx index c7fda3055..9637c5d30 100644 --- a/src/Partition.hxx +++ b/src/Partition.hxx @@ -59,6 +59,7 @@ struct Partition final : QueueListener, PlayerListener, MixerListener { unsigned max_length, unsigned buffer_chunks, unsigned buffered_before_play, + AudioFormat configured_audio_format, const ReplayGainConfig &replay_gain_config); void EmitGlobalEvent(unsigned mask) { diff --git a/src/decoder/Bridge.cxx b/src/decoder/Bridge.cxx index 8e9941192..db606b9d2 100644 --- a/src/decoder/Bridge.cxx +++ b/src/decoder/Bridge.cxx @@ -29,7 +29,6 @@ #include "MusicChunk.hxx" #include "pcm/PcmConvert.hxx" #include "tag/Tag.hxx" -#include "AudioConfig.hxx" #include "Log.hxx" #include "input/InputStream.hxx" #include "util/ConstBuffer.hxx" @@ -260,7 +259,8 @@ DecoderBridge::Ready(const AudioFormat audio_format, assert(audio_format.IsValid()); dc.in_audio_format = audio_format; - dc.out_audio_format = getOutputAudioFormat(audio_format); + dc.out_audio_format = audio_format; + dc.out_audio_format.ApplyMask(dc.configured_audio_format); dc.seekable = seekable; dc.total_time = duration; diff --git a/src/decoder/DecoderControl.cxx b/src/decoder/DecoderControl.cxx index f10968e2d..6bb80c7da 100644 --- a/src/decoder/DecoderControl.cxx +++ b/src/decoder/DecoderControl.cxx @@ -28,8 +28,10 @@ #include <assert.h> DecoderControl::DecoderControl(Mutex &_mutex, Cond &_client_cond, + const AudioFormat _configured_audio_format, const ReplayGainConfig &_replay_gain_config) :mutex(_mutex), client_cond(_client_cond), + configured_audio_format(_configured_audio_format), replay_gain_config(_replay_gain_config) {} DecoderControl::~DecoderControl() diff --git a/src/decoder/DecoderControl.hxx b/src/decoder/DecoderControl.hxx index c680f0365..9edaa44a7 100644 --- a/src/decoder/DecoderControl.hxx +++ b/src/decoder/DecoderControl.hxx @@ -115,6 +115,11 @@ struct DecoderControl { bool seekable; SongTime seek_time; + /** + * The "audio_output_format" setting. + */ + const AudioFormat configured_audio_format; + /** the format of the song file */ AudioFormat in_audio_format; @@ -171,6 +176,7 @@ struct DecoderControl { * @param _client_cond see #client_cond */ DecoderControl(Mutex &_mutex, Cond &_client_cond, + const AudioFormat _configured_audio_format, const ReplayGainConfig &_replay_gain_config); ~DecoderControl(); diff --git a/src/player/Control.cxx b/src/player/Control.cxx index cc56a19a3..db2537a33 100644 --- a/src/player/Control.cxx +++ b/src/player/Control.cxx @@ -30,10 +30,12 @@ PlayerControl::PlayerControl(PlayerListener &_listener, MultipleOutputs &_outputs, unsigned _buffer_chunks, unsigned _buffered_before_play, + AudioFormat _configured_audio_format, const ReplayGainConfig &_replay_gain_config) :listener(_listener), outputs(_outputs), buffer_chunks(_buffer_chunks), buffered_before_play(_buffered_before_play), + configured_audio_format(_configured_audio_format), replay_gain_config(_replay_gain_config) { } diff --git a/src/player/Control.hxx b/src/player/Control.hxx index 144bcade6..798aeacce 100644 --- a/src/player/Control.hxx +++ b/src/player/Control.hxx @@ -106,6 +106,11 @@ struct PlayerControl { const unsigned buffered_before_play; /** + * The "audio_output_format" setting. + */ + const AudioFormat configured_audio_format; + + /** * The handle of the player thread. */ Thread thread; @@ -187,6 +192,7 @@ struct PlayerControl { MultipleOutputs &_outputs, unsigned buffer_chunks, unsigned buffered_before_play, + AudioFormat _configured_audio_format, const ReplayGainConfig &_replay_gain_config); ~PlayerControl(); diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx index bf90a859d..320f12859 100644 --- a/src/player/Thread.cxx +++ b/src/player/Thread.cxx @@ -1163,7 +1163,9 @@ player_task(void *arg) SetThreadName("player"); - DecoderControl dc(pc.mutex, pc.cond, pc.replay_gain_config); + DecoderControl dc(pc.mutex, pc.cond, + pc.configured_audio_format, + pc.replay_gain_config); decoder_thread_start(dc); MusicBuffer buffer(pc.buffer_chunks); |