changeset 31871:c3775dbb8509

Simplify code: allow file_format argument to open_stream to be NULL.
author reimar
date Tue, 10 Aug 2010 13:23:04 +0000
parents e061d5d981ba
children 66b846665274
files libass/ass_mp.c mencoder.c stream/open.c subreader.c
diffstat 4 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libass/ass_mp.c	Tue Aug 10 00:36:53 2010 +0000
+++ b/libass/ass_mp.c	Tue Aug 10 13:23:04 2010 +0000
@@ -219,14 +219,13 @@
 }
 
 ASS_Track* ass_read_stream(ASS_Library* library, const char *fname, char *charset) {
-	int i;
 	char *buf = NULL;
 	ASS_Track *track;
 	size_t sz = 0;
 	size_t buf_alloc = 0;
 	stream_t *fd;
 
-	fd = open_stream(fname, NULL, &i);
+	fd = open_stream(fname, NULL, NULL);
 	if (!fd) {
 		mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FopenFailed, fname);
 		return NULL;
@@ -235,6 +234,7 @@
 		/* read entire file if size is known */
 		buf_alloc = fd->end_pos;
 	for (;;) {
+		int i;
 		if (buf_alloc >= 100*1024*1024) {
 			mp_msg(MSGT_ASS, MSGL_INFO, MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan100M, fname);
 			sz = 0;
--- a/mencoder.c	Tue Aug 10 00:36:53 2010 +0000
+++ b/mencoder.c	Tue Aug 10 13:23:04 2010 +0000
@@ -643,7 +643,7 @@
 
 
 if (frameno_filename) {
-  stream2=open_stream(frameno_filename,0,&i);
+  stream2=open_stream(frameno_filename, NULL, NULL);
   if(stream2){
     demuxer2=demux_open(stream2,DEMUXER_TYPE_AVI,-1,-1,-2,NULL);
     if(demuxer2) mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_UsingPass3ControlFile, frameno_filename);
--- a/stream/open.c	Tue Aug 10 00:36:53 2010 +0000
+++ b/stream/open.c	Tue Aug 10 13:23:04 2010 +0000
@@ -48,6 +48,8 @@
 // Open a new stream  (stdin/file/vcd/url)
 
 stream_t* open_stream(const char* filename,char** options, int* file_format){
+  int dummy = DEMUXER_TYPE_UNKNOWN;
+  if (!file_format) file_format = &dummy;
   // Check if playlist or unknown
   if (*file_format != DEMUXER_TYPE_PLAYLIST){
     *file_format=DEMUXER_TYPE_UNKNOWN;
--- a/subreader.c	Tue Aug 10 00:36:53 2010 +0000
+++ b/subreader.c	Tue Aug 10 13:23:04 2010 +0000
@@ -1449,8 +1449,7 @@
     const struct subreader *srp;
 
     if(filename==NULL) return NULL; //qnx segfault
-    i = 0;
-    fd=open_stream (filename, NULL, &i); if (!fd) return NULL;
+    fd=open_stream (filename, NULL, NULL); if (!fd) return NULL;
 
     sub_format = SUB_INVALID;
     for (utf16 = 0; sub_format == SUB_INVALID && utf16 < 3; utf16++) {