[xiph-commits] r18233 - trunk/spectrum

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Fri Apr 13 01:51:06 PDT 2012


Author: xiphmont
Date: 2012-04-13 01:51:06 -0700 (Fri, 13 Apr 2012)
New Revision: 18233

Modified:
   trunk/spectrum/io.c
   trunk/spectrum/io.h
   trunk/spectrum/version.h
   trunk/spectrum/wave_panel.c
   trunk/spectrum/wave_plot.c
Log:
Correct a hang bug from update race condiiton


Modified: trunk/spectrum/io.c
===================================================================
--- trunk/spectrum/io.c	2012-04-13 08:29:18 UTC (rev 18232)
+++ trunk/spectrum/io.c	2012-04-13 08:51:06 UTC (rev 18233)
@@ -23,6 +23,7 @@
 
 #include "io.h"
 
+pthread_mutex_t ioparam_mutex=PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
 int bits[MAX_FILES] = {-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1};
 int bigendian[MAX_FILES] = {-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1};
 int channels[MAX_FILES] = {-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1};
@@ -392,7 +393,7 @@
 
 /* Convert new data from readbuffer into the blockbuffers until the
    blockbuffer is full */
-static void LBEconvert(){
+static void LBEconvert(int *localslice){
   float scale=1./2147483648.;
   int ch=0,fi;
 
@@ -405,7 +406,7 @@
       channels[fi]/bytes*channels[fi]*bytes+readbufferptr[fi];
 
     int bfill = blockbufferfill[fi];
-    int tosize = blocksize + blockslice[fi];
+    int tosize = blocksize + localslice[fi];
     int rptr = readbufferptr[fi];
     unsigned char *rbuf = readbuffer[fi];
 
@@ -507,8 +508,13 @@
   int eof=1;
   int notdone=1;
   int rewound[total_ch];
+  int localslice[MAX_FILES];
   memset(rewound,0,sizeof(rewound));
 
+  pthread_mutex_lock(&ioparam_mutex);
+  memcpy(localslice,blockslice,sizeof(localslice));
+  pthread_mutex_unlock(&ioparam_mutex);
+
   if(blockbuffer==0){
     blockbuffer=malloc(total_ch*sizeof(*blockbuffer));
 
@@ -527,7 +533,7 @@
       if(partialok){
         blockbufferfill[fi]=blocksize;
       }else{
-        blockbufferfill[fi]=blockslice[fi];
+        blockbufferfill[fi]=localslice[fi];
       }
     }
   }
@@ -538,11 +544,11 @@
     notdone=0;
 
     /* if there's data left to be pulled out of a readbuffer, do that */
-    LBEconvert();
+    LBEconvert(localslice);
 
     ch=0;
     for(fi=0;fi<inputs;fi++){
-      if(blockbufferfill[fi]!=blocksize+blockslice[fi]){
+      if(blockbufferfill[fi]!=blocksize+localslice[fi]){
 
 	/* shift the read buffer before fill if there's a fractional
 	   frame in it */

Modified: trunk/spectrum/io.h
===================================================================
--- trunk/spectrum/io.h	2012-04-13 08:29:18 UTC (rev 18232)
+++ trunk/spectrum/io.h	2012-04-13 08:51:06 UTC (rev 18233)
@@ -46,6 +46,7 @@
 #define MAX_FILES 16
 #define readbuffersize 8192
 
+extern pthread_mutex_t ioparam_mutex;
 extern int input_load(void);
 extern int input_read(int loop_p, int partial_p);
 extern int rewind_files(void);

Modified: trunk/spectrum/version.h
===================================================================
--- trunk/spectrum/version.h	2012-04-13 08:29:18 UTC (rev 18232)
+++ trunk/spectrum/version.h	2012-04-13 08:51:06 UTC (rev 18233)
@@ -1,2 +1,2 @@
 #define VERSION "$Id$ "
-/* DO NOT EDIT: Automated versioning hack [Fri Apr 13 04:27:59 EDT 2012] */
+/* DO NOT EDIT: Automated versioning hack [Fri Apr 13 04:45:36 EDT 2012] */

Modified: trunk/spectrum/wave_panel.c
===================================================================
--- trunk/spectrum/wave_panel.c	2012-04-13 08:29:18 UTC (rev 18232)
+++ trunk/spectrum/wave_panel.c	2012-04-13 08:51:06 UTC (rev 18233)
@@ -69,6 +69,7 @@
   /* update interval limited to < 25fps */
   int temp = (interval < 50000 ? 50000:interval),fi;
 
+  pthread_mutex_lock(&ioparam_mutex);
   if(temp <= span){
     /* if the fps-limited update interval is shorter than or equal to
        the span, we simply frame limit */
@@ -85,6 +86,7 @@
       overslice[fi]=rint(rate[fi]/1000000.*interval);
     }
   }
+  pthread_mutex_unlock(&ioparam_mutex);
 }
 
 static void replot(struct panel *p){

Modified: trunk/spectrum/wave_plot.c
===================================================================
--- trunk/spectrum/wave_plot.c	2012-04-13 08:29:18 UTC (rev 18232)
+++ trunk/spectrum/wave_plot.c	2012-04-13 08:51:06 UTC (rev 18233)
@@ -362,7 +362,7 @@
             case 2: /* lollipop */
 
               {
-                if(spani<1.){
+                if(0){
                   int x0=-1;
                   float yH=NAN,yL=NAN;
                   int acc=0;



More information about the commits mailing list