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
dc5984d0
Commit
dc5984d0
authored
Nov 24, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ReplayGainConfig: move code to ParsePreamp()
parent
7afbd480
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
39 deletions
+31
-39
ReplayGainConfig.cxx
src/ReplayGainConfig.cxx
+31
-39
No files found.
src/ReplayGainConfig.cxx
View file @
dc5984d0
...
...
@@ -21,7 +21,6 @@
#include "ReplayGainConfig.hxx"
#include "config/Param.hxx"
#include "config/ConfigGlobal.hxx"
#include "system/FatalError.hxx"
#include "util/RuntimeError.hxx"
#include <assert.h>
...
...
@@ -36,6 +35,33 @@ float replay_gain_preamp = 1.0;
float
replay_gain_missing_preamp
=
1.0
;
bool
replay_gain_limit
=
DEFAULT_REPLAYGAIN_LIMIT
;
static
float
ParsePreamp
(
const
char
*
s
)
{
assert
(
s
!=
nullptr
);
char
*
endptr
;
float
f
=
strtod
(
s
,
&
endptr
);
if
(
endptr
==
s
||
*
endptr
!=
'\0'
)
throw
std
::
invalid_argument
(
"Not a numeric value"
);
if
(
f
<
-
15
||
f
>
15
)
throw
std
::
invalid_argument
(
"Number must be between -15 and 15"
);
return
pow
(
10
,
f
/
20.0
);
}
static
float
ParsePreamp
(
const
ConfigParam
&
p
)
{
try
{
return
ParsePreamp
(
p
.
value
.
c_str
());
}
catch
(...)
{
std
::
throw_with_nested
(
FormatRuntimeError
(
"Failed to parse line %i"
,
p
.
line
));
}
}
void
replay_gain_global_init
(
void
)
{
const
auto
*
param
=
config_get_param
(
ConfigOption
::
REPLAYGAIN
);
...
...
@@ -49,46 +75,12 @@ void replay_gain_global_init(void)
}
param
=
config_get_param
(
ConfigOption
::
REPLAYGAIN_PREAMP
);
if
(
param
)
{
char
*
test
;
float
f
=
strtod
(
param
->
value
.
c_str
(),
&
test
);
if
(
*
test
!=
'\0'
)
{
FormatFatalError
(
"Replaygain preamp
\"
%s
\"
is not a number at "
"line %i
\n
"
,
param
->
value
.
c_str
(),
param
->
line
);
}
if
(
f
<
-
15
||
f
>
15
)
{
FormatFatalError
(
"Replaygain preamp
\"
%s
\"
is not between -15 and"
"15 at line %i
\n
"
,
param
->
value
.
c_str
(),
param
->
line
);
}
replay_gain_preamp
=
pow
(
10
,
f
/
20.0
);
}
if
(
param
)
replay_gain_preamp
=
ParsePreamp
(
*
param
);
param
=
config_get_param
(
ConfigOption
::
REPLAYGAIN_MISSING_PREAMP
);
if
(
param
)
{
char
*
test
;
float
f
=
strtod
(
param
->
value
.
c_str
(),
&
test
);
if
(
*
test
!=
'\0'
)
{
FormatFatalError
(
"Replaygain missing preamp
\"
%s
\"
is not a number at "
"line %i
\n
"
,
param
->
value
.
c_str
(),
param
->
line
);
}
if
(
f
<
-
15
||
f
>
15
)
{
FormatFatalError
(
"Replaygain missing preamp
\"
%s
\"
is not between -15 and"
"15 at line %i
\n
"
,
param
->
value
.
c_str
(),
param
->
line
);
}
replay_gain_missing_preamp
=
pow
(
10
,
f
/
20.0
);
}
if
(
param
)
replay_gain_missing_preamp
=
ParsePreamp
(
*
param
);
replay_gain_limit
=
config_get_bool
(
ConfigOption
::
REPLAYGAIN_LIMIT
,
DEFAULT_REPLAYGAIN_LIMIT
);
...
...
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