[Mplayer-cvslog] CVS: main mplayer.c,1.634,1.635

Arpi of Ize arpi at mplayerhq.hu
Sat Dec 28 15:29:44 CET 2002


Update of /cvsroot/mplayer/main
In directory mail:/var/tmp.root/cvs-serv436

Modified Files:
	mplayer.c 
Log Message:
The patch adds support for a per-file config, which is loaded before
playing the file.  The config file is looked for in the same directory
as the input file, and in the ~/.mplayer dir.
Magne Oestlyngen <ml at skybert.org>


Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.634
retrieving revision 1.635
diff -u -r1.634 -r1.635
--- mplayer.c	28 Dec 2002 14:17:38 -0000	1.634
+++ mplayer.c	28 Dec 2002 14:29:41 -0000	1.635
@@ -521,6 +521,39 @@
 }
 }
 
+void load_per_file_config (m_config_t* conf, const char *const file)
+{
+    char *confpath;
+    char cfg[PATH_MAX];
+    struct stat st;
+    char *name;
+
+    sprintf (cfg, "%s.conf", file);
+    
+    if (!stat (cfg, &st))
+    {
+	mp_msg(MSGT_CPLAYER,MSGL_INFO,"Loading config '%s'\n", cfg);
+	m_config_parse_config_file (conf, cfg);
+	return;
+    }
+
+    if ((name = strrchr (cfg, '/')) == NULL)
+	name = cfg;
+    else
+	name++;
+
+    if ((confpath = get_path (name)) != NULL)
+    {
+	if (!stat (confpath, &st))
+	{
+	    mp_msg(MSGT_CPLAYER,MSGL_INFO,"Loading config '%s'\n", confpath);
+	    m_config_parse_config_file (conf, confpath);
+	}
+
+	free (confpath);
+    }
+}
+
 // When libmpdemux perform a blocking operation (network connection or cache filling)
 // if the operation fail we use this function to check if it was interrupted by the user.
 // The function return a new value for eof.
@@ -970,6 +1003,8 @@
 // ******************* Now, let's see the per-file stuff ********************
 
 play_next_file:
+
+  if (filename) load_per_file_config (mconfig, filename);
 
 // We must enable getch2 here to be able to interrupt network connection
 // or cache filling




More information about the MPlayer-cvslog mailing list