comparison mplayer.c @ 25635:25f6dca4df74

add support for per protocol and per extension playback profile loading
author ben
date Thu, 10 Jan 2008 18:45:08 +0000
parents 501847ab4460
children 3b0fed65048d
comparison
equal deleted inserted replaced
25634:4344e84f7a9f 25635:25f6dca4df74
832 if (m_config_parse_config_file(conf, conffile) < 0) 832 if (m_config_parse_config_file(conf, conffile) < 0)
833 exit_player(NULL); 833 exit_player(NULL);
834 free(conffile); 834 free(conffile);
835 } 835 }
836 } 836 }
837 }
838
839 #define PROFILE_CFG_PROTOCOL "protocol."
840
841 static void load_per_protocol_config (m_config_t* conf, const char *const file)
842 {
843 char *str;
844 char protocol[strlen (PROFILE_CFG_PROTOCOL) + strlen (file) + 1];
845 m_profile_t *p;
846
847 /* does filename actually uses a protocol ? */
848 str = strstr (file, "://");
849 if (!str)
850 return;
851
852 sprintf (protocol, "%s%s", PROFILE_CFG_PROTOCOL, file);
853 protocol[strlen (PROFILE_CFG_PROTOCOL)+strlen(file)-strlen(str)] = '\0';
854 p = m_config_get_profile (conf, protocol);
855 if (p)
856 {
857 mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LoadingProtocolProfile, protocol);
858 m_config_set_profile(conf,p);
859 }
860 }
861
862 #define PROFILE_CFG_EXTENSION "extension."
863
864 static void load_per_extension_config (m_config_t* conf, const char *const file)
865 {
866 char *str;
867 char extension[strlen (PROFILE_CFG_EXTENSION) + 8];
868 m_profile_t *p;
869
870 /* does filename actually have an extension ? */
871 str = strrchr (filename, '.');
872 if (!str)
873 return;
874
875 sprintf (extension, PROFILE_CFG_EXTENSION);
876 strncat (extension, ++str, 7);
877 p = m_config_get_profile (conf, extension);
878 if (p)
879 {
880 mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LoadingExtensionProfile, extension);
881 m_config_set_profile(conf,p);
882 }
837 } 883 }
838 884
839 static void load_per_file_config (m_config_t* conf, const char *const file) 885 static void load_per_file_config (m_config_t* conf, const char *const file)
840 { 886 {
841 char *confpath; 887 char *confpath;
2693 2739
2694 // init global sub numbers 2740 // init global sub numbers
2695 mpctx->global_sub_size = 0; 2741 mpctx->global_sub_size = 0;
2696 { int i; for (i = 0; i < SUB_SOURCES; i++) mpctx->global_sub_indices[i] = -1; } 2742 { int i; for (i = 0; i < SUB_SOURCES; i++) mpctx->global_sub_indices[i] = -1; }
2697 2743
2744 if (filename) load_per_protocol_config (mconfig, filename);
2745 if (filename) load_per_extension_config (mconfig, filename);
2698 if (filename) load_per_file_config (mconfig, filename); 2746 if (filename) load_per_file_config (mconfig, filename);
2699 2747
2700 // We must enable getch2 here to be able to interrupt network connection 2748 // We must enable getch2 here to be able to interrupt network connection
2701 // or cache filling 2749 // or cache filling
2702 if(!noconsolecontrols && !slave_mode){ 2750 if(!noconsolecontrols && !slave_mode){