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
2fc0a738
Commit
2fc0a738
authored
Jul 17, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Main: use struct ConfigData
parent
86c531b3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
24 deletions
+28
-24
Main.cxx
src/Main.cxx
+28
-24
No files found.
src/Main.cxx
View file @
2fc0a738
...
...
@@ -144,11 +144,12 @@ LoadConfig(const ConfigData &config)
#ifdef ENABLE_DAEMON
static
void
glue_daemonize_init
(
const
struct
options
*
options
)
glue_daemonize_init
(
const
struct
options
*
options
,
const
ConfigData
&
config
)
{
daemonize_init
(
config
_get_string
(
ConfigOption
::
USER
,
nullptr
),
config
_get_string
(
ConfigOption
::
GROUP
,
nullptr
),
config
_get_p
ath
(
ConfigOption
::
PID_FILE
));
daemonize_init
(
config
.
GetString
(
ConfigOption
::
USER
),
config
.
GetString
(
ConfigOption
::
GROUP
),
config
.
GetP
ath
(
ConfigOption
::
PID_FILE
));
if
(
options
->
kill
)
daemonize_kill
();
...
...
@@ -157,9 +158,9 @@ glue_daemonize_init(const struct options *options)
#endif
static
void
glue_mapper_init
()
glue_mapper_init
(
const
ConfigData
&
config
)
{
mapper_init
(
config
_get_p
ath
(
ConfigOption
::
PLAYLIST_DIR
));
mapper_init
(
config
.
GetP
ath
(
ConfigOption
::
PLAYLIST_DIR
));
}
#ifdef ENABLE_DATABASE
...
...
@@ -241,21 +242,23 @@ InitDatabaseAndStorage(const ConfigData &config)
* Configure and initialize the sticker subsystem.
*/
static
void
glue_sticker_init
()
glue_sticker_init
(
const
ConfigData
&
config
)
{
#ifdef ENABLE_SQLITE
auto
sticker_file
=
config
_get_p
ath
(
ConfigOption
::
STICKER_FILE
);
auto
sticker_file
=
config
.
GetP
ath
(
ConfigOption
::
STICKER_FILE
);
if
(
sticker_file
.
IsNull
())
return
;
sticker_global_init
(
std
::
move
(
sticker_file
));
#else
(
void
)
config
;
#endif
}
static
void
glue_state_file_init
(
const
ConfigData
&
config
)
{
auto
path_fs
=
config
_get_p
ath
(
ConfigOption
::
STATE_FILE
);
auto
path_fs
=
config
.
GetP
ath
(
ConfigOption
::
STATE_FILE
);
if
(
path_fs
.
IsNull
())
{
#ifdef ANDROID
const
auto
cache_dir
=
GetUserCacheDir
();
...
...
@@ -282,12 +285,13 @@ glue_state_file_init(const ConfigData &config)
* Initialize the decoder and player core, including the music pipe.
*/
static
void
initialize_decoder_and_player
(
const
ReplayGainConfig
&
replay_gain_config
)
initialize_decoder_and_player
(
const
ConfigData
&
config
,
const
ReplayGainConfig
&
replay_gain_config
)
{
const
ConfigParam
*
param
;
size_t
buffer_size
;
param
=
config
_get_p
aram
(
ConfigOption
::
AUDIO_BUFFER_SIZE
);
param
=
config
.
GetP
aram
(
ConfigOption
::
AUDIO_BUFFER_SIZE
);
if
(
param
!=
nullptr
)
{
char
*
test
;
long
tmp
=
strtol
(
param
->
value
.
c_str
(),
&
test
,
10
);
...
...
@@ -313,7 +317,7 @@ initialize_decoder_and_player(const ReplayGainConfig &replay_gain_config)
(
unsigned
long
)
buffer_size
);
float
perc
;
param
=
config
_get_p
aram
(
ConfigOption
::
BUFFER_BEFORE_PLAY
);
param
=
config
.
GetP
aram
(
ConfigOption
::
BUFFER_BEFORE_PLAY
);
if
(
param
!=
nullptr
)
{
char
*
test
;
perc
=
strtod
(
param
->
value
.
c_str
(),
&
test
);
...
...
@@ -344,11 +348,11 @@ initialize_decoder_and_player(const ReplayGainConfig &replay_gain_config)
buffered_before_play
=
buffered_chunks
;
const
unsigned
max_length
=
config
_get_p
ositive
(
ConfigOption
::
MAX_PLAYLIST_LENGTH
,
DEFAULT_PLAYLIST_MAX_LENGTH
);
config
.
GetP
ositive
(
ConfigOption
::
MAX_PLAYLIST_LENGTH
,
DEFAULT_PLAYLIST_MAX_LENGTH
);
AudioFormat
configured_audio_format
=
AudioFormat
::
Undefined
();
param
=
config
_get_p
aram
(
ConfigOption
::
AUDIO_OUTPUT_FORMAT
);
param
=
config
.
GetP
aram
(
ConfigOption
::
AUDIO_OUTPUT_FORMAT
);
if
(
param
!=
nullptr
)
{
try
{
configured_audio_format
=
ParseAudioFormat
(
param
->
value
.
c_str
(),
...
...
@@ -369,7 +373,7 @@ initialize_decoder_and_player(const ReplayGainConfig &replay_gain_config)
auto
&
partition
=
instance
->
partitions
.
back
();
try
{
param
=
config
_get_p
aram
(
ConfigOption
::
REPLAYGAIN
);
param
=
config
.
GetP
aram
(
ConfigOption
::
REPLAYGAIN
);
if
(
param
!=
nullptr
)
partition
.
replay_gain_mode
=
FromString
(
param
->
value
.
c_str
());
...
...
@@ -500,7 +504,7 @@ try {
const
auto
config
=
LoadConfig
(
raw_config
);
#ifdef ENABLE_DAEMON
glue_daemonize_init
(
&
options
);
glue_daemonize_init
(
&
options
,
raw_config
);
#endif
TagLoadConfig
(
raw_config
);
...
...
@@ -521,10 +525,10 @@ try {
#endif
const
unsigned
max_clients
=
config_get_p
ositive
(
ConfigOption
::
MAX_CONN
,
10
);
raw_config
.
GetP
ositive
(
ConfigOption
::
MAX_CONN
,
10
);
instance
->
client_list
=
new
ClientList
(
max_clients
);
initialize_decoder_and_player
(
config
.
replay_gain
);
initialize_decoder_and_player
(
raw_config
,
config
.
replay_gain
);
listen_global_init
(
*
instance
->
partitions
.
front
().
listener
);
...
...
@@ -545,7 +549,7 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config)
try
{
ConfigureFS
();
glue_mapper_init
();
glue_mapper_init
(
raw_config
);
initPermissions
();
spl_global_init
(
raw_config
);
...
...
@@ -561,7 +565,7 @@ try {
const
bool
create_db
=
InitDatabaseAndStorage
(
raw_config
);
#endif
glue_sticker_init
();
glue_sticker_init
(
raw_config
);
command_init
();
...
...
@@ -613,15 +617,15 @@ try {
glue_state_file_init
(
raw_config
);
#ifdef ENABLE_DATABASE
if
(
config_get_b
ool
(
ConfigOption
::
AUTO_UPDATE
,
false
))
{
if
(
raw_config
.
GetB
ool
(
ConfigOption
::
AUTO_UPDATE
,
false
))
{
#ifdef ENABLE_INOTIFY
if
(
instance
->
storage
!=
nullptr
&&
instance
->
update
!=
nullptr
)
mpd_inotify_init
(
instance
->
event_loop
,
*
instance
->
storage
,
*
instance
->
update
,
config_get_u
nsigned
(
ConfigOption
::
AUTO_UPDATE_DEPTH
,
INT_MAX
));
raw_config
.
GetU
nsigned
(
ConfigOption
::
AUTO_UPDATE_DEPTH
,
INT_MAX
));
#else
FormatWarning
(
config_domain
,
"inotify: auto_update was disabled. enable during compilation phase"
);
...
...
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