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

Monty xiphmont at xiph.org
Tue Nov 13 20:12:53 PST 2001



xiphmont    01/11/13 20:12:53

  Modified:    .        Snatch libsnatch.c x11.c
  Log:
  update version number, make locking marginally more safe

Revision  Changes    Path
1.2       +1 -1      snatch/Snatch

Index: Snatch
===================================================================
RCS file: /usr/local/cvsroot/snatch/Snatch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Snatch	2001/11/12 22:22:14	1.1
+++ Snatch	2001/11/14 04:12:52	1.2
@@ -15,7 +15,7 @@
     exit 1;
 }
 
-$version="Snatch 20011112";
+$version="Snatch 20011113";
 $configdir=$HOME."/.snatch";
 $configfile=$configdir."/config.txt";
 $historyfile=$configdir."/history.txt";

1.29      +13 -6     snatch/libsnatch.c

Index: libsnatch.c
===================================================================
RCS file: /usr/local/cvsroot/snatch/libsnatch.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- libsnatch.c	2001/11/13 20:14:41	1.28
+++ libsnatch.c	2001/11/14 04:12:52	1.29
@@ -511,12 +511,18 @@
 ssize_t write(int fd, const void *buf,size_t count){
 
   if(fd==audio_fd){
+
     /* track audio sync regardless of record activity or fake setting;
        we could have record suddenly activated */
     
     long a,b;
     double now=bigtime(NULL,NULL),fa;
     double stime=audio_samplepos/(double)audio_rate+audio_timezero;
+
+    /* do it first so we know how many bytes actually succeed */
+    if(!fake_audiop)
+      count=(*libc_write)(fd,buf,count);
+    if(count<=0)return(count);
     
     /* video and audio buffer differently; video is always 'just
        in time' and thus uses absolute time positioning.  Video
@@ -535,12 +541,16 @@
       audio_samplepos=(now-audio_timezero)*audio_rate;
       stime=audio_samplepos/(double)audio_rate+audio_timezero;
     }
-
+    
     b=modf(stime,&fa)*1000000.;
     a=fa;
     
     if(count>0 && snatch_active==1){
+      
+      pthread_mutex_lock(&output_mutex);
       if(outfile_fd<0)OpenOutputFile();
+      pthread_mutex_unlock(&output_mutex);
+      
       if(outfile_fd>=0){ /* always be careful */
         char cbuf[80];
         int len;
@@ -556,8 +566,8 @@
       }
     }
     audio_samplepos+=(count/(audio_channels*audio_fmt_bytesps[audio_format]));
-
-    if(fake_audiop)return(count);
+    
+    return(count);
   }
 
   if(esd_rw_hook_p(fd))return(esd_write_hook(fd,buf,count));
@@ -611,7 +621,6 @@
 }
 
 static void OpenOutputFile(){
-  pthread_mutex_lock(&output_mutex);
   if(outfile_fd!=-2){
     if(!strcmp(outpath,"-")){
       outfile_fd=STDOUT_FILENO;
@@ -667,7 +676,6 @@
                     (audio_channels==1?"mono":"stereo"),
                     audio_rate);
           }else{
-	    pthread_mutex_unlock(&output_mutex);
             return;
           }
         }
@@ -721,7 +729,6 @@
       }
     }
   }
-  pthread_mutex_unlock(&output_mutex);
 }
 
 static void CloseOutputFile(){

1.21      +6 -0      snatch/x11.c

Index: x11.c
===================================================================
RCS file: /usr/local/cvsroot/snatch/x11.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- x11.c	2001/11/13 20:14:41	1.20
+++ x11.c	2001/11/14 04:12:52	1.21
@@ -519,7 +519,10 @@
 
   if(snatch_active==1 && id==rpvideo_window){
     videocount++;
+
+    pthread_mutex_lock(&output_mutex);
     if(videocount>5 && outfile_fd<0)OpenOutputFile();
+    pthread_mutex_unlock(&output_mutex);
     /* only do 24 bit zPixmaps for now */
 
     if(image->format==2 && image->depth>16 && image->depth<=24){
@@ -749,7 +752,10 @@
 
   if(snatch_active==1 && id==rpvideo_window){
     videocount++;
+
+    pthread_mutex_lock(&output_mutex);
     if(videocount>5 && outfile_fd<0)OpenOutputFile();
+    pthread_mutex_unlock(&output_mutex);
 
     /* only do 24 bit zPixmaps for now */
     if(image->format==2 && image->depth>16 && image->depth<=24){

--- >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