Mplayer 1.2 源码分析--main函数

int main(int argc, char *argv[]) {

   
int opt_exit = 0; //标示 MPlayer 在没有播放视频时是否应该退出


int profile_config_loaded; //配置文件加载标示
profile_config_loaded = load_profile_config(mconfig, filename);
static int load_profile_config(m_config_t *conf, const char *const file) {
   if (file) {
       load_per_protocol_config(conf, file);
       
load_per_extension_config(conf, file);
       
load_per_file_config(conf, file);
   
}
   return file != NULL;
}


static void load_per_protocol_config(m_config_t *conf, const char *const file) {
   char *str;
   
char protocol[strlen(PROFILE_CFG_PROTOCOL) + strlen(file) + 1];
   
m_profile_t *p;

   
/* does filename actually uses a protocol ? */
   
str = strstr(file, "://");
   
if (!str)
       return;

   
sprintf(protocol, "%s%s", PROFILE_CFG_PROTOCOL, file);
   
protocol[strlen(PROFILE_CFG_PROTOCOL) + strlen(file) - strlen(str)] = '\0';
   
p = m_config_get_profile(conf, protocol);
   
if (p) {
       mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_LoadingProtocolProfile, protocol);
       
m_config_set_profile(conf, p);
   
}
}
static void load_per_extension_config(m_config_t *conf, const char *const file) {
   char *str;
   
char extension[strlen(PROFILE_CFG_EXTENSION) + 8];
   
m_profile_t *p;

   
/* does filename actually have an extension ? */
   
str = strrchr(filename, '.');
   
if (!str)
       return;

   
sprintf(extension, PROFILE_CFG_EXTENSION);
   
strncat(extension, ++str, 7);
   
p = m_config_get_profile(conf, extension);
   
if (p) {
       mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_LoadingExtensionProfile, extension);
       
m_config_set_profile(conf, p);
   
}
}
static void load_per_file_config(m_config_t *conf, const char *const file) {
   char *confpath;
   
char cfg[PATH_MAX];
   
const char *name;

   
if (strlen(file) > PATH_MAX - 14) {
       mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_FilenameTooLong);
       
return;
   
}
   sprintf(cfg, "%s.conf", file);

   
name = mp_basename(cfg);
   
if (use_filedir_conf) {
       char dircfg[PATH_MAX];
       
strcpy(dircfg, cfg);
       
strcpy(dircfg + (name - cfg), "mplayer.conf");
       
try_load_config(conf, dircfg);

       
if (try_load_config(conf, cfg))
           return;
   
}

   if ((confpath = get_path(name)) != NULL) {
       try_load_config(conf, confpath);

       
free(confpath);
   
}
}


转载于:https://my.oschina.net/fonddream/blog/528872

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值