[MPlayer-dev-eng] codecs.conf versioning

Joey Parrish joey at yunamusic.com
Tue May 21 00:37:17 CEST 2002


On Mon, May 20, 2002 at 10:05:34PM +0200, Arpi wrote:
> Hi,
> 
> imho, there should be a #define in codec-cfg.h, containing the minimum
> required version. for 'big' changes, codec-cfg is also changed, so imho
> it's the best place to define it.
> 
> the check for the value should be done when teh codecs.conf is parsed,
> so if it's too old, the file should be ignored (same as for syntax errors)
> if no new&correct codecs.conf found (nor in home, nor in common global dir)
> then it should stop with error. 

Attached below is a patch to add release checking code to codec-cfg.c,
add documentation for it to DOCS/tech/codecs.conf.txt, and fix a bug in
codecs.conf parsing which shows up with the newly revised codecs.conf format.

When discarding the copy in ~/.mplayer/codecs.conf due to parse errors, 
the global version was not always read properly.  MPlayer reported the same
parse error in /usr/local/share/mplayer/codecs.conf as in the local user's 
copy, even if the error did not exist in both.  I moved static int read_nextline
from get_token to make it global, so that it could be properly reset when
opening a new file.  I also added a line to reset line_num to 0.  Otherwise
MPlayer will say "error on line 13" for one file and "error on line 19" for
the other, when the second file should complain about line 6.
(If you need to see these bugs reproduced, comment out lines 469 & 674 in
codec-cfg.c after applying this patch.  Then just add garbage to your local
codecs.conf and leave the global copy valid.  Or I can send in a proper report.)

--Joey

-- 

"Yes." -- John F. Kennedy
-------------- next part --------------
--- DOCS/tech/codecs.conf.txt.orig	Fri Apr 12 21:09:18 2002
+++ DOCS/tech/codecs.conf.txt	Mon May 20 16:30:05 2002
@@ -33,6 +33,18 @@
 human readers. For example, all of the open source decoders that MPlayer
 implements natively are grouped in one section.
 
+Release Number
+--------------
+Your codecs.conf now requires a release number to avoid codec release
+incompatibilities. The format is simple: (YYYYMMDD)
+
+release 20020520
+
+Whenever changes are made to the codecs that *require* an updated
+codecs.conf, then MPlayer will no longer accept outdated versions.
+It is not recommended to change this line unless you know exactly
+what you are doing.
+
 Video Codecs
 ------------
 Let's jump right in with an example. Here is an example video codec block:
--- codec-cfg.c.orig	Thu May 16 16:50:38 2002
+++ codec-cfg.c	Mon May 20 16:54:05 2002
@@ -368,10 +368,10 @@
 static int line_num = 0;
 static char *line;
 static char *token[MAX_NR_TOKEN];
+static int read_nextline = 1;
 
 static int get_token(int min, int max)
 {
-	static int read_nextline = 1;
 	static int line_pos;
 	int i;
 	char c;
@@ -466,15 +466,33 @@
 		mp_msg(MSGT_CODECCFG,MSGL_FATAL,"can't get memory for 'line': %s\n", strerror(errno));
 		return 0;
 	}
+	read_nextline = 1;
 
 	/*
-	 * check if the cfgfile starts with 'audiocodec' or
-	 * with 'videocodec'
+	 * this only catches release lines at the start of 
+	 * codecs.conf, before audiocodecs and videocodecs.
 	 */
 	while ((tmp = get_token(1, 1)) == RET_EOL)
 		/* NOTHING */;
 	if (tmp == RET_EOF)
 		goto out;
+	if (!strcmp(token[0], "release")) {
+		if (get_token(1, 2) < 0)
+			goto err_out_parse_error;
+		tmp = atoi(token[0]);
+		if (tmp < CODEC_CFG_MIN)
+			goto err_out_release_num;
+		while ((tmp = get_token(1, 1)) == RET_EOL)
+			/* NOTHING */;
+		if (tmp == RET_EOF)
+			goto out;
+	} else
+		goto err_out_release_num;
+
+	/*
+	 * check if the next block starts with 'audiocodec' or
+	 * with 'videocodec'
+	 */
 	if (!strcmp(token[0], "audiocodec") || !strcmp(token[0], "videocodec"))
 		goto loop_enter;
 	goto err_out_parse_error;
@@ -652,10 +670,14 @@
 
 	free(line);
 	line=NULL;
+	line_num = 0;
 	fclose(fp);
 	return 0;
 err_out_not_valid:
 	mp_msg(MSGT_CODECCFG,MSGL_ERR,"codec is not defined correctly");
+	goto err_out_print_linenum;
+err_out_release_num:
+	mp_msg(MSGT_CODECCFG,MSGL_ERR,"release incompatibility");
 	goto err_out_print_linenum;
 }
 
--- codec-cfg.h.orig	Thu May 16 16:50:38 2002
+++ codec-cfg.h	Mon May 20 16:09:07 2002
@@ -1,6 +1,8 @@
 #ifndef __CODEC_CFG_H
 #define __CODEC_CFG_H
 
+#define CODEC_CFG_MIN	20020520
+
 #define CODECS_MAX_FOURCC	32
 #define CODECS_MAX_OUTFMT	16
 #define CODECS_MAX_INFMT	16
--- etc/codecs.conf.orig	Thu May 16 18:23:16 2002
+++ etc/codecs.conf	Mon May 20 16:09:07 2002
@@ -3,6 +3,8 @@
 ;  Before editing this file, please read DOCS/tech/codecs.conf.txt !
 ;=============================================================================
 
+release 20020520
+
 ;=============================================================================
 ;                   VIDEO CODECS
 ;=============================================================================


More information about the MPlayer-dev-eng mailing list