[xiph-cvs] cvs commit: snatch libsnatch.c x11.c

Monty xiphmont at xiph.org
Tue Nov 13 12:14:43 PST 2001



xiphmont    01/11/13 12:14:43

  Modified:    .        libsnatch.c x11.c
  Log:
  Output to capture file needs to be locked.

Revision  Changes    Path
1.28      +8 -6      snatch/libsnatch.c

Index: libsnatch.c
===================================================================
RCS file: /usr/local/cvsroot/snatch/libsnatch.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- libsnatch.c	2001/11/13 07:48:04	1.27
+++ libsnatch.c	2001/11/13 20:14:41	1.28
@@ -27,7 +27,7 @@
 #include <X11/Xlib.h>
 #include <X11/extensions/XShm.h>
 
-static pthread_mutex_t open_mutex=PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t output_mutex=PTHREAD_MUTEX_INITIALIZER;
 static pthread_cond_t event_cond=PTHREAD_COND_INITIALIZER;
 static pthread_mutex_t event_mutex=PTHREAD_MUTEX_INITIALIZER;
 static pthread_cond_t display_cond=PTHREAD_COND_INITIALIZER;
@@ -548,8 +548,10 @@
         len=sprintf(cbuf,"AUDIO %ld %ld %d %d %d %d:",a,b,audio_channels,
                     audio_rate,audio_format,count);
         
+	pthread_mutex_lock(&output_mutex);
         gwrite(outfile_fd,cbuf,len);
         gwrite(outfile_fd,(void *)buf,count);
+	pthread_mutex_unlock(&output_mutex);
         
       }
     }
@@ -609,7 +611,7 @@
 }
 
 static void OpenOutputFile(){
-  pthread_mutex_lock(&open_mutex);
+  pthread_mutex_lock(&output_mutex);
   if(outfile_fd!=-2){
     if(!strcmp(outpath,"-")){
       outfile_fd=STDOUT_FILENO;
@@ -665,7 +667,7 @@
                     (audio_channels==1?"mono":"stereo"),
                     audio_rate);
           }else{
-	    pthread_mutex_unlock(&open_mutex);
+	    pthread_mutex_unlock(&output_mutex);
             return;
           }
         }
@@ -719,11 +721,11 @@
       }
     }
   }
-  pthread_mutex_unlock(&open_mutex);
+  pthread_mutex_unlock(&output_mutex);
 }
 
 static void CloseOutputFile(){
-  pthread_mutex_lock(&open_mutex);
+  pthread_mutex_lock(&output_mutex);
   if(outfile_fd>=0){
     videocount=0;
     if(debug)fprintf(stderr,"    ...: Capture stopped.\n");
@@ -731,5 +733,5 @@
       close(outfile_fd);
     outfile_fd=-1;
   }
-  pthread_mutex_unlock(&open_mutex);
+  pthread_mutex_unlock(&output_mutex);
 }

1.20      +8 -2      snatch/x11.c

Index: x11.c
===================================================================
RCS file: /usr/local/cvsroot/snatch/x11.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- x11.c	2001/11/11 21:10:49	1.19
+++ x11.c	2001/11/13 20:14:41	1.20
@@ -532,7 +532,6 @@
         bigtime(&a,&b);
         len=sprintf(cbuf,"VIDEO %ld %ld %d %d %ld:",a,b,image->width,
                     image->height,n);
-	gwrite(outfile_fd,cbuf,len);
         
         if(worksize<n){
           if(worksize==0)
@@ -567,7 +566,10 @@
           }
         }
                     
+	pthread_mutex_lock(&output_mutex);
+	gwrite(outfile_fd,cbuf,len);
         gwrite(outfile_fd,workbuffer,n);
+	pthread_mutex_unlock(&output_mutex);
 
       }
     }else{
@@ -758,9 +760,9 @@
         int i,j,len;
         
         bigtime(&a,&b);
+
         len=sprintf(cbuf,"VIDEO %ld %ld %d %d %ld:",a,b,image->width,
                     image->height,n);
-	gwrite(outfile_fd,cbuf,len);
         
         if(worksize<n){
           if(worksize==0)
@@ -794,7 +796,11 @@
             ptr+=image->bytes_per_line;
           }
         }
+
+	pthread_mutex_lock(&output_mutex);
+	gwrite(outfile_fd,cbuf,len);
         gwrite(outfile_fd,workbuffer,n);
+	pthread_mutex_unlock(&output_mutex);
 
       }
     }else{

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list