added avifile_initialized flag.
authorkramm <kramm>
Mon, 20 Sep 2004 16:15:59 +0000 (16:15 +0000)
committerkramm <kramm>
Mon, 20 Sep 2004 16:15:59 +0000 (16:15 +0000)
avi2swf/videoreader_vfw.cc

index 2c2f809..2da5acd 100644 (file)
@@ -223,13 +223,16 @@ void videoreader_vfw_close(videoreader_t* vr)
        AVIStreamRelease(i->as); i->vs = 0;
     }
     AVIFileRelease(i->avifile); i->avifile = 0;
        AVIStreamRelease(i->as); i->vs = 0;
     }
     AVIFileRelease(i->avifile); i->avifile = 0;
-    AVIFileExit();
+    
+    AVIFileExit(); avifile_initialized=0;
 
     free(vr->internal); vr->internal = 0;
 }
 
 void videoreader_vfw_setparameter(videoreader_t* vr, char*name, char*value) {}
 
 
     free(vr->internal); vr->internal = 0;
 }
 
 void videoreader_vfw_setparameter(videoreader_t* vr, char*name, char*value) {}
 
+static int avifile_initialized = 0;
+
 int videoreader_vfw_open(videoreader_t* vr, char* filename)
 {
     memset(vr, 0, sizeof(videoreader_t));
 int videoreader_vfw_open(videoreader_t* vr, char* filename)
 {
     memset(vr, 0, sizeof(videoreader_t));
@@ -248,7 +251,9 @@ int videoreader_vfw_open(videoreader_t* vr, char* filename)
     vr->close = videoreader_vfw_close;
     vr->setparameter = videoreader_vfw_setparameter;
 
     vr->close = videoreader_vfw_close;
     vr->setparameter = videoreader_vfw_setparameter;
 
-    AVIFileInit();
+    if(!avifile_initialized) {
+       AVIFileInit();
+    }
     if(AVIFileOpen(&i->avifile, filename, OF_SHARE_DENY_WRITE, 0)) {
         fprintf(stderr, "Couldn't open %s\n", filename);
         return -1;
     if(AVIFileOpen(&i->avifile, filename, OF_SHARE_DENY_WRITE, 0)) {
         fprintf(stderr, "Couldn't open %s\n", filename);
         return -1;