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
be65c7d5
Commit
be65c7d5
authored
Jan 02, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config/Block: add method GetPositiveValue()
Adds missing checks to several plugins.
parent
7c5306a8
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
37 additions
and
9 deletions
+37
-9
Block.cxx
src/config/Block.cxx
+25
-0
Block.hxx
src/config/Block.hxx
+3
-0
AdPlugDecoderPlugin.cxx
src/decoder/plugins/AdPlugDecoderPlugin.cxx
+1
-1
FluidsynthDecoderPlugin.cxx
src/decoder/plugins/FluidsynthDecoderPlugin.cxx
+1
-1
MikmodDecoderPlugin.cxx
src/decoder/plugins/MikmodDecoderPlugin.cxx
+1
-1
SidplayDecoderPlugin.cxx
src/decoder/plugins/SidplayDecoderPlugin.cxx
+1
-1
AlsaOutputPlugin.cxx
src/output/plugins/AlsaOutputPlugin.cxx
+2
-2
AoOutputPlugin.cxx
src/output/plugins/AoOutputPlugin.cxx
+1
-1
HaikuOutputPlugin.cxx
src/output/plugins/HaikuOutputPlugin.cxx
+1
-1
JackOutputPlugin.cxx
src/output/plugins/JackOutputPlugin.cxx
+1
-1
No files found.
src/config/Block.cxx
View file @
be65c7d5
...
@@ -52,6 +52,21 @@ BlockParam::GetUnsignedValue() const
...
@@ -52,6 +52,21 @@ BlockParam::GetUnsignedValue() const
return
(
unsigned
)
value2
;
return
(
unsigned
)
value2
;
}
}
unsigned
BlockParam
::
GetPositiveValue
()
const
{
const
char
*
const
s
=
value
.
c_str
();
char
*
endptr
;
unsigned
long
value2
=
strtoul
(
s
,
&
endptr
,
0
);
if
(
endptr
==
s
||
*
endptr
!=
0
)
FormatFatalError
(
"Not a valid number in line %i"
,
line
);
if
(
value2
<=
0
)
FormatFatalError
(
"Number in line %i must be positive"
,
line
);
return
(
unsigned
)
value2
;
}
bool
bool
BlockParam
::
GetBoolValue
()
const
BlockParam
::
GetBoolValue
()
const
{
{
...
@@ -131,6 +146,16 @@ ConfigBlock::GetBlockValue(const char *name, unsigned default_value) const
...
@@ -131,6 +146,16 @@ ConfigBlock::GetBlockValue(const char *name, unsigned default_value) const
return
bp
->
GetUnsignedValue
();
return
bp
->
GetUnsignedValue
();
}
}
unsigned
ConfigBlock
::
GetPositiveValue
(
const
char
*
name
,
unsigned
default_value
)
const
{
const
auto
*
param
=
GetBlockParam
(
name
);
if
(
param
==
nullptr
)
return
default_value
;
return
param
->
GetPositiveValue
();
}
bool
bool
ConfigBlock
::
GetBlockValue
(
const
char
*
name
,
bool
default_value
)
const
ConfigBlock
::
GetBlockValue
(
const
char
*
name
,
bool
default_value
)
const
{
{
...
...
src/config/Block.hxx
View file @
be65c7d5
...
@@ -47,6 +47,7 @@ struct BlockParam {
...
@@ -47,6 +47,7 @@ struct BlockParam {
int
GetIntValue
()
const
;
int
GetIntValue
()
const
;
unsigned
GetUnsignedValue
()
const
;
unsigned
GetUnsignedValue
()
const
;
unsigned
GetPositiveValue
()
const
;
bool
GetBoolValue
()
const
;
bool
GetBoolValue
()
const
;
};
};
...
@@ -117,6 +118,8 @@ struct ConfigBlock {
...
@@ -117,6 +118,8 @@ struct ConfigBlock {
unsigned
GetBlockValue
(
const
char
*
name
,
unsigned
default_value
)
const
;
unsigned
GetBlockValue
(
const
char
*
name
,
unsigned
default_value
)
const
;
unsigned
GetPositiveValue
(
const
char
*
name
,
unsigned
default_value
)
const
;
bool
GetBlockValue
(
const
char
*
name
,
bool
default_value
)
const
;
bool
GetBlockValue
(
const
char
*
name
,
bool
default_value
)
const
;
};
};
...
...
src/decoder/plugins/AdPlugDecoderPlugin.cxx
View file @
be65c7d5
...
@@ -42,7 +42,7 @@ adplug_init(const ConfigBlock &block)
...
@@ -42,7 +42,7 @@ adplug_init(const ConfigBlock &block)
FormatDebug
(
adplug_domain
,
"adplug %s"
,
FormatDebug
(
adplug_domain
,
"adplug %s"
,
CAdPlug
::
get_version
().
c_str
());
CAdPlug
::
get_version
().
c_str
());
sample_rate
=
block
.
Get
Block
Value
(
"sample_rate"
,
48000u
);
sample_rate
=
block
.
Get
Positive
Value
(
"sample_rate"
,
48000u
);
CheckSampleRate
(
sample_rate
);
CheckSampleRate
(
sample_rate
);
return
true
;
return
true
;
...
...
src/decoder/plugins/FluidsynthDecoderPlugin.cxx
View file @
be65c7d5
...
@@ -74,7 +74,7 @@ fluidsynth_mpd_log_function(int level, char *message, gcc_unused void *data)
...
@@ -74,7 +74,7 @@ fluidsynth_mpd_log_function(int level, char *message, gcc_unused void *data)
static
bool
static
bool
fluidsynth_init
(
const
ConfigBlock
&
block
)
fluidsynth_init
(
const
ConfigBlock
&
block
)
{
{
sample_rate
=
block
.
Get
Block
Value
(
"sample_rate"
,
48000u
);
sample_rate
=
block
.
Get
Positive
Value
(
"sample_rate"
,
48000u
);
CheckSampleRate
(
sample_rate
);
CheckSampleRate
(
sample_rate
);
soundfont_path
=
block
.
GetBlockValue
(
"soundfont"
,
soundfont_path
=
block
.
GetBlockValue
(
"soundfont"
,
...
...
src/decoder/plugins/MikmodDecoderPlugin.cxx
View file @
be65c7d5
...
@@ -114,7 +114,7 @@ mikmod_decoder_init(const ConfigBlock &block)
...
@@ -114,7 +114,7 @@ mikmod_decoder_init(const ConfigBlock &block)
static
char
params
[]
=
""
;
static
char
params
[]
=
""
;
mikmod_loop
=
block
.
GetBlockValue
(
"loop"
,
false
);
mikmod_loop
=
block
.
GetBlockValue
(
"loop"
,
false
);
mikmod_sample_rate
=
block
.
Get
Block
Value
(
"sample_rate"
,
44100u
);
mikmod_sample_rate
=
block
.
Get
Positive
Value
(
"sample_rate"
,
44100u
);
if
(
!
audio_valid_sample_rate
(
mikmod_sample_rate
))
if
(
!
audio_valid_sample_rate
(
mikmod_sample_rate
))
throw
FormatRuntimeError
(
"Invalid sample rate in line %d: %u"
,
throw
FormatRuntimeError
(
"Invalid sample rate in line %d: %u"
,
block
.
line
,
mikmod_sample_rate
);
block
.
line
,
mikmod_sample_rate
);
...
...
src/decoder/plugins/SidplayDecoderPlugin.cxx
View file @
be65c7d5
...
@@ -93,7 +93,7 @@ sidplay_init(const ConfigBlock &block)
...
@@ -93,7 +93,7 @@ sidplay_init(const ConfigBlock &block)
if
(
!
database_path
.
IsNull
())
if
(
!
database_path
.
IsNull
())
songlength_database
=
sidplay_load_songlength_db
(
database_path
);
songlength_database
=
sidplay_load_songlength_db
(
database_path
);
default_songlength
=
block
.
Get
Block
Value
(
"default_songlength"
,
0u
);
default_songlength
=
block
.
Get
Positive
Value
(
"default_songlength"
,
0u
);
all_files_are_containers
=
all_files_are_containers
=
block
.
GetBlockValue
(
"all_files_are_containers"
,
true
);
block
.
GetBlockValue
(
"all_files_are_containers"
,
true
);
...
...
src/output/plugins/AlsaOutputPlugin.cxx
View file @
be65c7d5
...
@@ -331,9 +331,9 @@ AlsaOutput::AlsaOutput(EventLoop &_loop, const ConfigBlock &block)
...
@@ -331,9 +331,9 @@ AlsaOutput::AlsaOutput(EventLoop &_loop, const ConfigBlock &block)
/* legacy name from MPD 0.18 and older: */
/* legacy name from MPD 0.18 and older: */
block
.
GetBlockValue
(
"dsd_usb"
,
false
)),
block
.
GetBlockValue
(
"dsd_usb"
,
false
)),
#endif
#endif
buffer_time
(
block
.
Get
Block
Value
(
"buffer_time"
,
buffer_time
(
block
.
Get
Positive
Value
(
"buffer_time"
,
MPD_ALSA_BUFFER_TIME_US
)),
MPD_ALSA_BUFFER_TIME_US
)),
period_time
(
block
.
Get
Block
Value
(
"period_time"
,
0u
))
period_time
(
block
.
Get
Positive
Value
(
"period_time"
,
0u
))
{
{
#ifdef SND_PCM_NO_AUTO_RESAMPLE
#ifdef SND_PCM_NO_AUTO_RESAMPLE
if
(
!
block
.
GetBlockValue
(
"auto_resample"
,
true
))
if
(
!
block
.
GetBlockValue
(
"auto_resample"
,
true
))
...
...
src/output/plugins/AoOutputPlugin.cxx
View file @
be65c7d5
...
@@ -101,7 +101,7 @@ MakeAoError()
...
@@ -101,7 +101,7 @@ MakeAoError()
AoOutput
::
AoOutput
(
const
ConfigBlock
&
block
)
AoOutput
::
AoOutput
(
const
ConfigBlock
&
block
)
:
AudioOutput
(
0
),
:
AudioOutput
(
0
),
write_size
(
block
.
Get
Block
Value
(
"write_size"
,
1024u
))
write_size
(
block
.
Get
Positive
Value
(
"write_size"
,
1024u
))
{
{
const
char
*
value
=
block
.
GetBlockValue
(
"driver"
,
"default"
);
const
char
*
value
=
block
.
GetBlockValue
(
"driver"
,
"default"
);
if
(
0
==
strcmp
(
value
,
"default"
))
if
(
0
==
strcmp
(
value
,
"default"
))
...
...
src/output/plugins/HaikuOutputPlugin.cxx
View file @
be65c7d5
...
@@ -64,7 +64,7 @@ public:
...
@@ -64,7 +64,7 @@ public:
HaikuOutput
(
const
ConfigBlock
&
block
)
HaikuOutput
(
const
ConfigBlock
&
block
)
:
AudioOutput
(
0
),
:
AudioOutput
(
0
),
/* XXX: by default we should let the MediaKit propose the buffer size */
/* XXX: by default we should let the MediaKit propose the buffer size */
write_size
(
block
.
Get
Block
Value
(
"write_size"
,
4096u
))
{}
write_size
(
block
.
Get
Positive
Value
(
"write_size"
,
4096u
))
{}
~
HaikuOutput
();
~
HaikuOutput
();
...
...
src/output/plugins/JackOutputPlugin.cxx
View file @
be65c7d5
...
@@ -210,7 +210,7 @@ JackOutput::JackOutput(const ConfigBlock &block)
...
@@ -210,7 +210,7 @@ JackOutput::JackOutput(const ConfigBlock &block)
num_source_ports
,
num_destination_ports
,
num_source_ports
,
num_destination_ports
,
block
.
line
);
block
.
line
);
ringbuffer_size
=
block
.
Get
Block
Value
(
"ringbuffer_size"
,
32768u
);
ringbuffer_size
=
block
.
Get
Positive
Value
(
"ringbuffer_size"
,
32768u
);
}
}
inline
jack_nframes_t
inline
jack_nframes_t
...
...
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