summaryrefslogtreecommitdiffstats
path: root/player/configfiles.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-06-26 17:56:47 +0200
committerwm4 <wm4@nowhere>2014-06-26 19:37:26 +0200
commitc63378d41cdb004bac8e400bef8f3e73c5123de7 (patch)
tree08e396fe81823943bb5f25f4ddfbec0250e46045 /player/configfiles.c
parentcb250d490c14872f03bb0320179e48d05fe2539d (diff)
downloadmpv-c63378d41cdb004bac8e400bef8f3e73c5123de7.tar.bz2
mpv-c63378d41cdb004bac8e400bef8f3e73c5123de7.tar.xz
player: remove some minor code duplication in config loader code
It's better to keep the logic in one place. Also drop that a broken config file aborts loading of the player. I don't see much reason for this, and it inflates the code slightly.
Diffstat (limited to 'player/configfiles.c')
-rw-r--r--player/configfiles.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/player/configfiles.c b/player/configfiles.c
index a295d7d9f2..a44bc93437 100644
--- a/player/configfiles.c
+++ b/player/configfiles.c
@@ -46,17 +46,26 @@
#include "core.h"
#include "command.h"
+static void load_all_cfgfiles(struct MPContext *mpctx, char *section,
+ char *filename)
+{
+ void *tmp = talloc_new(NULL);
+ char **cf = mp_find_all_config_files(tmp, mpctx->global, filename);
+ for (int i = 0; cf && cf[i]; i++)
+ m_config_parse_config_file(mpctx->mconfig, cf[i], section, 0);
+ talloc_free(tmp);
+}
+
#define SECT_ENCODE "encoding"
-bool mp_parse_cfgfiles(struct MPContext *mpctx)
+void mp_parse_cfgfiles(struct MPContext *mpctx)
{
struct MPOpts *opts = mpctx->opts;
if (!opts->load_config)
- return true;
+ return;
m_config_t *conf = mpctx->mconfig;
void *tmp = talloc_new(NULL);
- bool r = true;
char *conffile;
char *section = NULL;
bool encoding = opts->encode_opts &&
@@ -75,26 +84,13 @@ bool mp_parse_cfgfiles(struct MPContext *mpctx)
m_config_parse_config_file(mpctx->mconfig, conffile, SECT_ENCODE, 0);
#endif
- // Maintain compatibility with /config
- for (char** cf = mp_find_all_config_files(tmp, mpctx->global, "config"); *cf; cf++) {
- if (m_config_parse_config_file(conf, *cf, section, 0) < 0) {
- r = false;
- goto done;
- }
- }
- for (char** cf = mp_find_all_config_files(tmp, mpctx->global, "mpv.conf"); *cf; cf++) {
- if (m_config_parse_config_file(conf, *cf, section, 0) < 0) {
- r = false;
- goto done;
- }
- }
+ load_all_cfgfiles(mpctx, section, "config");
+ load_all_cfgfiles(mpctx, section, "mpv.conf");
if (encoding)
m_config_set_profile(conf, m_config_add_profile(conf, SECT_ENCODE), 0);
-done:
talloc_free(tmp);
- return r;
}
static int try_load_config(struct MPContext *mpctx, const char *file, int flags)