Mplayer 1.2 源码分析--main函数
2015-11-11 13:56
447 查看
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); } }
相关文章推荐
- golang中container/ring包用法
- Timus Online Judge 1651 Shortest Subchain
- No Brainer
- U3D 平行光阴影细节 Directional Shadow Details
- golang中container/heap包用法
- HDU 2389 ——Rain on your Parade——————【Hopcroft-Karp求最大匹配、sqrt(n)*e复杂度】
- main()函数常用的格式:main(int argc,char **argv)
- Active UNIX domain Sockets--------由netstat想到的
- Foxmail 绑定企业邮箱
- LeetCode -- Container With Most Water
- 简单几步,在heroku中部署你的rails项目
- sleep join yield | wait notify notifyAll
- 访百度糯米之 Caused by: libcore.io.ErrnoException: open failed: EACCES (P
- tail /grep/more
- 解决Visual Studio 2015创建工程时的“DNX SDK version 'dnx-clr-win-x86.1.0.0-beta5' failed to install.”错误
- 【已解决】Activity MainActivity has leaked window PhoneWindow$DecorView@ that was originally added here
- CC2541 AirSync(3)——特征值
- hdu 4770 Lights Against Dudely(暴力+状压)
- ERROR: transport error 202: bind failed: Address already in use
- AIDL实现应用进程间的通信。