예제 #1
0
bool mp_parse_cfgfiles(struct MPContext *mpctx)
{
    struct MPOpts *opts = mpctx->opts;
    if (!opts->load_config)
        return true;

    m_config_t *conf = mpctx->mconfig;
    void *tmp = talloc_new(NULL);
    bool r = true;
    char *conffile;

    // The #if is a stupid hack to avoid errors if libavfilter is not available.
#if HAVE_VF_LAVFI && HAVE_ENCODING
    conffile = mp_find_config_file(tmp, mpctx->global, "encoding-profiles.conf");
    if (conffile && mp_path_exists(conffile))
        m_config_parse_config_file(mpctx->mconfig, conffile, 0);
#endif

    conffile = mp_find_global_config_file(tmp, mpctx->global, "mpv.conf");
    if (conffile && m_config_parse_config_file(conf, conffile, 0) < 0) {
        r = false;
        goto done;
    }
    mp_mk_config_dir(mpctx->global, NULL);
    if (!(conffile = mp_find_user_config_file(tmp, mpctx->global, "config")))
        MP_ERR(mpctx, "mp_find_user_config_file(\"config\") problem\n");
    else if (m_config_parse_config_file(conf, conffile, 0) < 0) {
        r = false;
        goto done;
    }

done:
    talloc_free(tmp);
    return r;
}
예제 #2
0
파일: configfiles.c 프로젝트: asdlei00/mpv
bool mp_parse_cfgfiles(struct MPContext *mpctx)
{
    struct MPOpts *opts = mpctx->opts;
    if (!opts->load_config)
        return true;

    m_config_t *conf = mpctx->mconfig;
    void *tmp = talloc_new(NULL);
    bool r = true;
    char *conffile;
    char *section = NULL;
    bool encoding = opts->encode_output.file && *opts->encode_output.file;
    // In encoding mode, we don't want to apply normal config options.
    // So we "divert" normal options into a separate section, and the diverted
    // section is never used - unless maybe it's explicitly referenced from an
    // encoding profile.
    if (encoding)
        section = "playback-default";

    // The #if is a stupid hack to avoid errors if libavfilter is not available.
#if HAVE_LIBAVFILTER && HAVE_ENCODING
    conffile = mp_find_config_file(tmp, mpctx->global, "encoding-profiles.conf");
    if (conffile && mp_path_exists(conffile))
        m_config_parse_config_file(mpctx->mconfig, conffile, SECT_ENCODE, 0);
#endif

    conffile = mp_find_global_config_file(tmp, mpctx->global, "mpv.conf");
    if (conffile && m_config_parse_config_file(conf, conffile, section, 0) < 0) {
        r = false;
        goto done;
    }
    mp_mk_config_dir(mpctx->global, NULL);
    if (!(conffile = mp_find_user_config_file(tmp, mpctx->global, "config")))
        MP_ERR(mpctx, "mp_find_user_config_file(\"config\") problem\n");
    else if (m_config_parse_config_file(conf, conffile, section, 0) < 0) {
        r = false;
        goto done;
    }

    if (encoding)
        m_config_set_profile(conf, m_config_add_profile(conf, SECT_ENCODE), 0);

done:
    talloc_free(tmp);
    return r;
}
예제 #3
0
dvb_config_t *dvb_get_config(void)
{
	int i, fd, type, size;
	char filename[30], *conf_file, *name;
	dvb_channels_list *list;
	dvb_card_config_t *cards = NULL, *tmp;
	dvb_config_t *conf = NULL;


	conf = malloc(sizeof(dvb_config_t));
	if(conf == NULL)
		return NULL;

	conf->priv = NULL;
	conf->count = 0;
	conf->cards = NULL;
	for(i=0; i<MAX_CARDS; i++)
	{
		snprintf(filename, sizeof(filename), "/dev/dvb/adapter%d/frontend0", i);
		fd = open(filename, O_RDONLY|O_NONBLOCK);
		if(fd < 0)
		{
			mp_msg(MSGT_DEMUX, MSGL_V, "DVB_CONFIG, can't open device %s, skipping\n", filename);
			continue;
		}

		type = dvb_get_tuner_type(fd);
		close(fd);
		if(type != TUNER_SAT && type != TUNER_TER && type != TUNER_CBL && type != TUNER_ATSC)
		{
			mp_msg(MSGT_DEMUX, MSGL_V, "DVB_CONFIG, can't detect tuner type of card %d, skipping\n", i);
			continue;
		}

        void *talloc_ctx = talloc_new(NULL);
        conf_file = talloc_steal(talloc_ctx,
                mp_find_user_config_file("channels.conf"));
        switch(type) {
            case TUNER_TER:
                conf_file = talloc_steal(talloc_ctx,
                        mp_find_user_config_file("channels.conf.ter"));
                break;
            case TUNER_CBL:
                conf_file = talloc_steal(talloc_ctx,
                        mp_find_user_config_file("channels.conf.cbl"));
                break;
            case TUNER_SAT:
                conf_file = talloc_steal(talloc_ctx,
                        mp_find_user_config_file("channels.conf.sat"));
                break;
            case TUNER_ATSC:
                conf_file = talloc_steal(talloc_ctx,
                        mp_find_user_config_file("channels.conf.atsc"));
                break;
        }

        if(conf_file && (access(conf_file, F_OK | R_OK) != 0)) {
            conf_file = talloc_steal(talloc_ctx,
                    mp_find_user_config_file("channels.conf"));

            if(conf_file && (access(conf_file, F_OK | R_OK) != 0)) {
                conf_file = talloc_steal(talloc_ctx,
                        mp_find_global_config_file("channels.conf"));
            }
        }

        list = dvb_get_channels(conf_file, type);
        talloc_free(talloc_ctx);

		if(list == NULL)
			continue;

		size = sizeof(dvb_card_config_t) * (conf->count + 1);
		tmp = realloc(conf->cards, size);

		if(tmp == NULL)
		{
			fprintf(stderr, "DVB_CONFIG, can't realloc %d bytes, skipping\n", size);
			continue;
		}
		cards = tmp;

		name = malloc(20);
		if(name==NULL)
		{
			fprintf(stderr, "DVB_CONFIG, can't realloc 20 bytes, skipping\n");
			continue;
		}

		conf->cards = cards;
		conf->cards[conf->count].devno = i;
		conf->cards[conf->count].list = list;
		conf->cards[conf->count].type = type;
		snprintf(name, 20, "DVB-%c card n. %d", type==TUNER_TER ? 'T' : (type==TUNER_CBL ? 'C' : 'S'), conf->count+1);
		conf->cards[conf->count].name = name;
		conf->count++;
	}

	if(conf->count == 0)
	{
		free(conf);
		conf = NULL;
	}

	return conf;
}