decoder/Control: add attribute configured_audio_format
Obsoletes the same variable from AudioConfig.cxx.
This commit is contained in:
parent
3472208c05
commit
9fb7cc796b
@ -76,7 +76,6 @@ libmpd_a_SOURCES = \
|
|||||||
src/open.h \
|
src/open.h \
|
||||||
src/poison.h \
|
src/poison.h \
|
||||||
src/notify.cxx src/notify.hxx \
|
src/notify.cxx src/notify.hxx \
|
||||||
src/AudioConfig.cxx src/AudioConfig.hxx \
|
|
||||||
src/protocol/Ack.cxx src/protocol/Ack.hxx \
|
src/protocol/Ack.cxx src/protocol/Ack.hxx \
|
||||||
src/protocol/ArgParser.cxx src/protocol/ArgParser.hxx \
|
src/protocol/ArgParser.cxx src/protocol/ArgParser.hxx \
|
||||||
src/protocol/Result.cxx src/protocol/Result.hxx \
|
src/protocol/Result.cxx src/protocol/Result.hxx \
|
||||||
|
@ -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));
|
|
||||||
}
|
|
||||||
}
|
|
@ -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
|
|
16
src/Main.cxx
16
src/Main.cxx
@ -45,7 +45,7 @@
|
|||||||
#include "playlist/PlaylistRegistry.hxx"
|
#include "playlist/PlaylistRegistry.hxx"
|
||||||
#include "zeroconf/ZeroconfGlue.hxx"
|
#include "zeroconf/ZeroconfGlue.hxx"
|
||||||
#include "decoder/DecoderList.hxx"
|
#include "decoder/DecoderList.hxx"
|
||||||
#include "AudioConfig.hxx"
|
#include "AudioParser.hxx"
|
||||||
#include "pcm/PcmConvert.hxx"
|
#include "pcm/PcmConvert.hxx"
|
||||||
#include "unix/SignalHandlers.hxx"
|
#include "unix/SignalHandlers.hxx"
|
||||||
#include "system/FatalError.hxx"
|
#include "system/FatalError.hxx"
|
||||||
@ -327,10 +327,23 @@ initialize_decoder_and_player(void)
|
|||||||
config_get_positive(ConfigOption::MAX_PLAYLIST_LENGTH,
|
config_get_positive(ConfigOption::MAX_PLAYLIST_LENGTH,
|
||||||
DEFAULT_PLAYLIST_MAX_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,
|
instance->partition = new Partition(*instance,
|
||||||
max_length,
|
max_length,
|
||||||
buffered_chunks,
|
buffered_chunks,
|
||||||
buffered_before_play,
|
buffered_before_play,
|
||||||
|
configured_audio_format,
|
||||||
replay_gain_config);
|
replay_gain_config);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -489,7 +502,6 @@ try {
|
|||||||
glue_sticker_init();
|
glue_sticker_init();
|
||||||
|
|
||||||
command_init();
|
command_init();
|
||||||
initAudioConfig();
|
|
||||||
instance->partition->outputs.Configure(instance->event_loop,
|
instance->partition->outputs.Configure(instance->event_loop,
|
||||||
replay_gain_config,
|
replay_gain_config,
|
||||||
instance->partition->pc);
|
instance->partition->pc);
|
||||||
|
@ -28,13 +28,14 @@ Partition::Partition(Instance &_instance,
|
|||||||
unsigned max_length,
|
unsigned max_length,
|
||||||
unsigned buffer_chunks,
|
unsigned buffer_chunks,
|
||||||
unsigned buffered_before_play,
|
unsigned buffered_before_play,
|
||||||
|
AudioFormat configured_audio_format,
|
||||||
const ReplayGainConfig &replay_gain_config)
|
const ReplayGainConfig &replay_gain_config)
|
||||||
:instance(_instance),
|
:instance(_instance),
|
||||||
global_events(instance.event_loop, BIND_THIS_METHOD(OnGlobalEvent)),
|
global_events(instance.event_loop, BIND_THIS_METHOD(OnGlobalEvent)),
|
||||||
playlist(max_length, *this),
|
playlist(max_length, *this),
|
||||||
outputs(*this),
|
outputs(*this),
|
||||||
pc(*this, outputs, buffer_chunks, buffered_before_play,
|
pc(*this, outputs, buffer_chunks, buffered_before_play,
|
||||||
replay_gain_config)
|
configured_audio_format, replay_gain_config)
|
||||||
{
|
{
|
||||||
UpdateEffectiveReplayGainMode();
|
UpdateEffectiveReplayGainMode();
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ struct Partition final : QueueListener, PlayerListener, MixerListener {
|
|||||||
unsigned max_length,
|
unsigned max_length,
|
||||||
unsigned buffer_chunks,
|
unsigned buffer_chunks,
|
||||||
unsigned buffered_before_play,
|
unsigned buffered_before_play,
|
||||||
|
AudioFormat configured_audio_format,
|
||||||
const ReplayGainConfig &replay_gain_config);
|
const ReplayGainConfig &replay_gain_config);
|
||||||
|
|
||||||
void EmitGlobalEvent(unsigned mask) {
|
void EmitGlobalEvent(unsigned mask) {
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
#include "MusicChunk.hxx"
|
#include "MusicChunk.hxx"
|
||||||
#include "pcm/PcmConvert.hxx"
|
#include "pcm/PcmConvert.hxx"
|
||||||
#include "tag/Tag.hxx"
|
#include "tag/Tag.hxx"
|
||||||
#include "AudioConfig.hxx"
|
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
#include "input/InputStream.hxx"
|
#include "input/InputStream.hxx"
|
||||||
#include "util/ConstBuffer.hxx"
|
#include "util/ConstBuffer.hxx"
|
||||||
@ -260,7 +259,8 @@ DecoderBridge::Ready(const AudioFormat audio_format,
|
|||||||
assert(audio_format.IsValid());
|
assert(audio_format.IsValid());
|
||||||
|
|
||||||
dc.in_audio_format = audio_format;
|
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.seekable = seekable;
|
||||||
dc.total_time = duration;
|
dc.total_time = duration;
|
||||||
|
@ -28,8 +28,10 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
DecoderControl::DecoderControl(Mutex &_mutex, Cond &_client_cond,
|
DecoderControl::DecoderControl(Mutex &_mutex, Cond &_client_cond,
|
||||||
|
const AudioFormat _configured_audio_format,
|
||||||
const ReplayGainConfig &_replay_gain_config)
|
const ReplayGainConfig &_replay_gain_config)
|
||||||
:mutex(_mutex), client_cond(_client_cond),
|
:mutex(_mutex), client_cond(_client_cond),
|
||||||
|
configured_audio_format(_configured_audio_format),
|
||||||
replay_gain_config(_replay_gain_config) {}
|
replay_gain_config(_replay_gain_config) {}
|
||||||
|
|
||||||
DecoderControl::~DecoderControl()
|
DecoderControl::~DecoderControl()
|
||||||
|
@ -115,6 +115,11 @@ struct DecoderControl {
|
|||||||
bool seekable;
|
bool seekable;
|
||||||
SongTime seek_time;
|
SongTime seek_time;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The "audio_output_format" setting.
|
||||||
|
*/
|
||||||
|
const AudioFormat configured_audio_format;
|
||||||
|
|
||||||
/** the format of the song file */
|
/** the format of the song file */
|
||||||
AudioFormat in_audio_format;
|
AudioFormat in_audio_format;
|
||||||
|
|
||||||
@ -171,6 +176,7 @@ struct DecoderControl {
|
|||||||
* @param _client_cond see #client_cond
|
* @param _client_cond see #client_cond
|
||||||
*/
|
*/
|
||||||
DecoderControl(Mutex &_mutex, Cond &_client_cond,
|
DecoderControl(Mutex &_mutex, Cond &_client_cond,
|
||||||
|
const AudioFormat _configured_audio_format,
|
||||||
const ReplayGainConfig &_replay_gain_config);
|
const ReplayGainConfig &_replay_gain_config);
|
||||||
~DecoderControl();
|
~DecoderControl();
|
||||||
|
|
||||||
|
@ -30,10 +30,12 @@ PlayerControl::PlayerControl(PlayerListener &_listener,
|
|||||||
MultipleOutputs &_outputs,
|
MultipleOutputs &_outputs,
|
||||||
unsigned _buffer_chunks,
|
unsigned _buffer_chunks,
|
||||||
unsigned _buffered_before_play,
|
unsigned _buffered_before_play,
|
||||||
|
AudioFormat _configured_audio_format,
|
||||||
const ReplayGainConfig &_replay_gain_config)
|
const ReplayGainConfig &_replay_gain_config)
|
||||||
:listener(_listener), outputs(_outputs),
|
:listener(_listener), outputs(_outputs),
|
||||||
buffer_chunks(_buffer_chunks),
|
buffer_chunks(_buffer_chunks),
|
||||||
buffered_before_play(_buffered_before_play),
|
buffered_before_play(_buffered_before_play),
|
||||||
|
configured_audio_format(_configured_audio_format),
|
||||||
replay_gain_config(_replay_gain_config)
|
replay_gain_config(_replay_gain_config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -105,6 +105,11 @@ struct PlayerControl {
|
|||||||
|
|
||||||
const unsigned buffered_before_play;
|
const unsigned buffered_before_play;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The "audio_output_format" setting.
|
||||||
|
*/
|
||||||
|
const AudioFormat configured_audio_format;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The handle of the player thread.
|
* The handle of the player thread.
|
||||||
*/
|
*/
|
||||||
@ -187,6 +192,7 @@ struct PlayerControl {
|
|||||||
MultipleOutputs &_outputs,
|
MultipleOutputs &_outputs,
|
||||||
unsigned buffer_chunks,
|
unsigned buffer_chunks,
|
||||||
unsigned buffered_before_play,
|
unsigned buffered_before_play,
|
||||||
|
AudioFormat _configured_audio_format,
|
||||||
const ReplayGainConfig &_replay_gain_config);
|
const ReplayGainConfig &_replay_gain_config);
|
||||||
~PlayerControl();
|
~PlayerControl();
|
||||||
|
|
||||||
|
@ -1163,7 +1163,9 @@ player_task(void *arg)
|
|||||||
|
|
||||||
SetThreadName("player");
|
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);
|
decoder_thread_start(dc);
|
||||||
|
|
||||||
MusicBuffer buffer(pc.buffer_chunks);
|
MusicBuffer buffer(pc.buffer_chunks);
|
||||||
|
@ -54,10 +54,12 @@ PlayerControl::PlayerControl(PlayerListener &_listener,
|
|||||||
MultipleOutputs &_outputs,
|
MultipleOutputs &_outputs,
|
||||||
unsigned _buffer_chunks,
|
unsigned _buffer_chunks,
|
||||||
unsigned _buffered_before_play,
|
unsigned _buffered_before_play,
|
||||||
|
AudioFormat _configured_audio_format,
|
||||||
const ReplayGainConfig &_replay_gain_config)
|
const ReplayGainConfig &_replay_gain_config)
|
||||||
:listener(_listener), outputs(_outputs),
|
:listener(_listener), outputs(_outputs),
|
||||||
buffer_chunks(_buffer_chunks),
|
buffer_chunks(_buffer_chunks),
|
||||||
buffered_before_play(_buffered_before_play),
|
buffered_before_play(_buffered_before_play),
|
||||||
|
configured_audio_format(_configured_audio_format),
|
||||||
replay_gain_config(_replay_gain_config) {}
|
replay_gain_config(_replay_gain_config) {}
|
||||||
PlayerControl::~PlayerControl() {}
|
PlayerControl::~PlayerControl() {}
|
||||||
|
|
||||||
@ -73,6 +75,7 @@ load_audio_output(EventLoop &event_loop, const char *name)
|
|||||||
static struct PlayerControl dummy_player_control(*(PlayerListener *)nullptr,
|
static struct PlayerControl dummy_player_control(*(PlayerListener *)nullptr,
|
||||||
*(MultipleOutputs *)nullptr,
|
*(MultipleOutputs *)nullptr,
|
||||||
32, 4,
|
32, 4,
|
||||||
|
AudioFormat::Undefined(),
|
||||||
ReplayGainConfig());
|
ReplayGainConfig());
|
||||||
|
|
||||||
return audio_output_new(event_loop, ReplayGainConfig(), *param,
|
return audio_output_new(event_loop, ReplayGainConfig(), *param,
|
||||||
|
Loading…
Reference in New Issue
Block a user