Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
3000b9dc
Commit
3000b9dc
authored
Nov 25, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filter/ReplayGain: add ReplayGainConfig copy
Remove dependency on ReplayGain global variables.
parent
3b867462
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
52 additions
and
47 deletions
+52
-47
Makefile.am
Makefile.am
+0
-2
Main.cxx
src/Main.cxx
+2
-1
ReplayGainFilterPlugin.cxx
src/filter/plugins/ReplayGainFilterPlugin.cxx
+15
-6
ReplayGainFilterPlugin.hxx
src/filter/plugins/ReplayGainFilterPlugin.hxx
+2
-1
Init.cxx
src/output/Init.cxx
+12
-5
Internal.hxx
src/output/Internal.hxx
+4
-1
MultipleOutputs.cxx
src/output/MultipleOutputs.cxx
+11
-5
MultipleOutputs.hxx
src/output/MultipleOutputs.hxx
+4
-1
FakeReplayGainGlobal.cxx
test/FakeReplayGainGlobal.cxx
+0
-24
run_output.cxx
test/run_output.cxx
+2
-1
No files found.
Makefile.am
View file @
3000b9dc
...
...
@@ -1979,7 +1979,6 @@ test_run_filter_LDADD = \
libsystem.a
\
libutil.a
test_run_filter_SOURCES
=
test
/run_filter.cxx
\
test
/FakeReplayGainGlobal.cxx
\
src/Log.cxx src/LogBackend.cxx
\
src/filter/FilterPlugin.cxx src/filter/FilterRegistry.cxx
...
...
@@ -2074,7 +2073,6 @@ test_run_output_LDADD = $(MPD_LIBS) \
libthread.a
\
libutil.a
test_run_output_SOURCES
=
test
/run_output.cxx
\
test
/FakeReplayGainGlobal.cxx
\
test
/ScopeIOThread.hxx
\
src/Log.cxx src/LogBackend.cxx
\
src/IOThread.cxx
\
...
...
src/Main.cxx
View file @
3000b9dc
...
...
@@ -477,10 +477,11 @@ try {
command_init
();
initAudioConfig
();
replay_gain_global_init
();
instance
->
partition
->
outputs
.
Configure
(
instance
->
event_loop
,
replay_gain_config
,
instance
->
partition
->
pc
);
client_manager_init
();
replay_gain_global_init
();
input_stream_global_init
();
playlist_list_global_init
();
...
...
src/filter/plugins/ReplayGainFilterPlugin.cxx
View file @
3000b9dc
...
...
@@ -22,7 +22,7 @@
#include "filter/FilterInternal.hxx"
#include "AudioFormat.hxx"
#include "ReplayGainInfo.hxx"
#include "ReplayGain
Global
.hxx"
#include "ReplayGain
Config
.hxx"
#include "mixer/MixerControl.hxx"
#include "pcm/Volume.hxx"
#include "util/ConstBuffer.hxx"
...
...
@@ -36,6 +36,8 @@
static
constexpr
Domain
replay_gain_domain
(
"replay_gain"
);
class
ReplayGainFilter
final
:
public
Filter
{
const
ReplayGainConfig
config
;
/**
* If set, then this hardware mixer is used for applying
* replay gain, instead of the software volume library.
...
...
@@ -67,9 +69,11 @@ class ReplayGainFilter final : public Filter {
PcmVolume
pv
;
public
:
ReplayGainFilter
(
const
AudioFormat
&
audio_format
,
ReplayGainFilter
(
const
ReplayGainConfig
&
_config
,
const
AudioFormat
&
audio_format
,
Mixer
*
_mixer
,
unsigned
_base
)
:
Filter
(
audio_format
),
config
(
_config
),
mixer
(
_mixer
),
base
(
_base
)
{
info
.
Clear
();
...
...
@@ -108,6 +112,8 @@ public:
};
class
PreparedReplayGainFilter
final
:
public
PreparedFilter
{
const
ReplayGainConfig
config
;
/**
* If set, then this hardware mixer is used for applying
* replay gain, instead of the software volume library.
...
...
@@ -121,6 +127,9 @@ class PreparedReplayGainFilter final : public PreparedFilter {
unsigned
base
;
public
:
explicit
PreparedReplayGainFilter
(
const
ReplayGainConfig
_config
)
:
config
(
_config
)
{}
void
SetMixer
(
Mixer
*
_mixer
,
unsigned
_base
)
{
assert
(
_mixer
==
nullptr
||
(
_base
>
0
&&
_base
<=
100
));
...
...
@@ -138,7 +147,7 @@ ReplayGainFilter::Update()
unsigned
volume
=
PCM_VOLUME_1
;
if
(
mode
!=
ReplayGainMode
::
OFF
)
{
const
auto
&
tuple
=
info
.
Get
(
mode
);
float
scale
=
tuple
.
CalculateScale
(
replay_gain_
config
);
float
scale
=
tuple
.
CalculateScale
(
config
);
FormatDebug
(
replay_gain_domain
,
"scale=%f
\n
"
,
(
double
)
scale
);
...
...
@@ -162,15 +171,15 @@ ReplayGainFilter::Update()
}
PreparedFilter
*
NewReplayGainFilter
()
NewReplayGainFilter
(
const
ReplayGainConfig
&
config
)
{
return
new
PreparedReplayGainFilter
();
return
new
PreparedReplayGainFilter
(
config
);
}
Filter
*
PreparedReplayGainFilter
::
Open
(
AudioFormat
&
af
)
{
return
new
ReplayGainFilter
(
af
,
mixer
,
base
);
return
new
ReplayGainFilter
(
config
,
af
,
mixer
,
base
);
}
ConstBuffer
<
void
>
...
...
src/filter/plugins/ReplayGainFilterPlugin.hxx
View file @
3000b9dc
...
...
@@ -25,10 +25,11 @@
class
Filter
;
class
PreparedFilter
;
class
Mixer
;
struct
ReplayGainConfig
;
struct
ReplayGainInfo
;
PreparedFilter
*
NewReplayGainFilter
();
NewReplayGainFilter
(
const
ReplayGainConfig
&
config
);
/**
* Enables or disables the hardware mixer for applying replay gain.
...
...
src/output/Init.cxx
View file @
3000b9dc
...
...
@@ -205,7 +205,9 @@ AudioOutput::Configure(const ConfigBlock &block)
}
static
void
audio_output_setup
(
EventLoop
&
event_loop
,
AudioOutput
&
ao
,
audio_output_setup
(
EventLoop
&
event_loop
,
const
ReplayGainConfig
&
replay_gain_config
,
AudioOutput
&
ao
,
MixerListener
&
mixer_listener
,
const
ConfigBlock
&
block
)
{
...
...
@@ -216,12 +218,14 @@ audio_output_setup(EventLoop &event_loop, AudioOutput &ao,
block
.
GetBlockValue
(
"replay_gain_handler"
,
"software"
);
if
(
strcmp
(
replay_gain_handler
,
"none"
)
!=
0
)
{
ao
.
prepared_replay_gain_filter
=
NewReplayGainFilter
();
ao
.
prepared_replay_gain_filter
=
NewReplayGainFilter
(
replay_gain_config
);
assert
(
ao
.
prepared_replay_gain_filter
!=
nullptr
);
ao
.
replay_gain_serial
=
0
;
ao
.
prepared_other_replay_gain_filter
=
NewReplayGainFilter
();
ao
.
prepared_other_replay_gain_filter
=
NewReplayGainFilter
(
replay_gain_config
);
assert
(
ao
.
prepared_other_replay_gain_filter
!=
nullptr
);
ao
.
other_replay_gain_serial
=
0
;
...
...
@@ -267,7 +271,9 @@ audio_output_setup(EventLoop &event_loop, AudioOutput &ao,
}
AudioOutput
*
audio_output_new
(
EventLoop
&
event_loop
,
const
ConfigBlock
&
block
,
audio_output_new
(
EventLoop
&
event_loop
,
const
ReplayGainConfig
&
replay_gain_config
,
const
ConfigBlock
&
block
,
MixerListener
&
mixer_listener
,
PlayerControl
&
pc
)
{
...
...
@@ -298,7 +304,8 @@ audio_output_new(EventLoop &event_loop, const ConfigBlock &block,
assert
(
ao
!=
nullptr
);
try
{
audio_output_setup
(
event_loop
,
*
ao
,
mixer_listener
,
block
);
audio_output_setup
(
event_loop
,
replay_gain_config
,
*
ao
,
mixer_listener
,
block
);
}
catch
(...)
{
ao_plugin_finish
(
ao
);
throw
;
...
...
src/output/Internal.hxx
View file @
3000b9dc
...
...
@@ -40,6 +40,7 @@ struct MusicChunk;
struct
ConfigBlock
;
struct
PlayerControl
;
struct
AudioOutputPlugin
;
struct
ReplayGainConfig
;
struct
AudioOutput
{
enum
class
Command
{
...
...
@@ -464,7 +465,9 @@ extern struct notify audio_output_client_notify;
* Throws #std::runtime_error on error.
*/
AudioOutput
*
audio_output_new
(
EventLoop
&
event_loop
,
const
ConfigBlock
&
block
,
audio_output_new
(
EventLoop
&
event_loop
,
const
ReplayGainConfig
&
replay_gain_config
,
const
ConfigBlock
&
block
,
MixerListener
&
mixer_listener
,
PlayerControl
&
pc
);
...
...
src/output/MultipleOutputs.cxx
View file @
3000b9dc
...
...
@@ -50,10 +50,12 @@ MultipleOutputs::~MultipleOutputs()
}
static
AudioOutput
*
LoadOutput
(
EventLoop
&
event_loop
,
MixerListener
&
mixer_listener
,
LoadOutput
(
EventLoop
&
event_loop
,
const
ReplayGainConfig
&
replay_gain_config
,
MixerListener
&
mixer_listener
,
PlayerControl
&
pc
,
const
ConfigBlock
&
block
)
try
{
return
audio_output_new
(
event_loop
,
block
,
return
audio_output_new
(
event_loop
,
replay_gain_config
,
block
,
mixer_listener
,
pc
);
}
catch
(
const
std
::
runtime_error
&
e
)
{
...
...
@@ -65,11 +67,14 @@ try {
}
void
MultipleOutputs
::
Configure
(
EventLoop
&
event_loop
,
PlayerControl
&
pc
)
MultipleOutputs
::
Configure
(
EventLoop
&
event_loop
,
const
ReplayGainConfig
&
replay_gain_config
,
PlayerControl
&
pc
)
{
for
(
const
auto
*
param
=
config_get_block
(
ConfigBlockOption
::
AUDIO_OUTPUT
);
param
!=
nullptr
;
param
=
param
->
next
)
{
auto
output
=
LoadOutput
(
event_loop
,
mixer_listener
,
auto
output
=
LoadOutput
(
event_loop
,
replay_gain_config
,
mixer_listener
,
pc
,
*
param
);
if
(
FindByName
(
output
->
name
)
!=
nullptr
)
throw
FormatRuntimeError
(
"output devices with identical "
...
...
@@ -81,7 +86,8 @@ MultipleOutputs::Configure(EventLoop &event_loop, PlayerControl &pc)
if
(
outputs
.
empty
())
{
/* auto-detect device */
const
ConfigBlock
empty
;
auto
output
=
LoadOutput
(
event_loop
,
mixer_listener
,
auto
output
=
LoadOutput
(
event_loop
,
replay_gain_config
,
mixer_listener
,
pc
,
empty
);
outputs
.
push_back
(
output
);
}
...
...
src/output/MultipleOutputs.hxx
View file @
3000b9dc
...
...
@@ -42,6 +42,7 @@ class MixerListener;
struct
MusicChunk
;
struct
PlayerControl
;
struct
AudioOutput
;
struct
ReplayGainConfig
;
class
MultipleOutputs
{
MixerListener
&
mixer_listener
;
...
...
@@ -75,7 +76,9 @@ public:
MultipleOutputs
(
MixerListener
&
_mixer_listener
);
~
MultipleOutputs
();
void
Configure
(
EventLoop
&
event_loop
,
PlayerControl
&
pc
);
void
Configure
(
EventLoop
&
event_loop
,
const
ReplayGainConfig
&
replay_gain_config
,
PlayerControl
&
pc
);
/**
* Returns the total number of audio output devices, including
...
...
test/FakeReplayGainGlobal.cxx
deleted
100644 → 0
View file @
3b867462
/*
* 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 "ReplayGainGlobal.hxx"
#include "ReplayGainConfig.hxx"
ReplayGainConfig
replay_gain_config
;
test/run_output.cxx
View file @
3000b9dc
...
...
@@ -29,6 +29,7 @@
#include "ScopeIOThread.hxx"
#include "fs/Path.hxx"
#include "AudioParser.hxx"
#include "ReplayGainConfig.hxx"
#include "pcm/PcmConvert.hxx"
#include "filter/FilterRegistry.hxx"
#include "player/Control.hxx"
...
...
@@ -71,7 +72,7 @@ load_audio_output(EventLoop &event_loop, const char *name)
*
(
MultipleOutputs
*
)
nullptr
,
32
,
4
);
return
audio_output_new
(
event_loop
,
*
param
,
return
audio_output_new
(
event_loop
,
ReplayGainConfig
(),
*
param
,
*
(
MixerListener
*
)
nullptr
,
dummy_player_control
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment