[PD-cvs] pd/src d_soundfile.c,1.4.4.11.2.10.2.2,1.4.4.11.2.10.2.3

Mathieu Bouchard matju at users.sourceforge.net
Wed Dec 20 07:55:09 CET 2006


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16749

Modified Files:
      Tag: desiredata
	d_soundfile.c 
Log Message:
removed debugging messages


Index: d_soundfile.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/d_soundfile.c,v
retrieving revision 1.4.4.11.2.10.2.2
retrieving revision 1.4.4.11.2.10.2.3
diff -C2 -d -r1.4.4.11.2.10.2.2 -r1.4.4.11.2.10.2.3
*** d_soundfile.c	19 Dec 2006 18:32:36 -0000	1.4.4.11.2.10.2.2
--- d_soundfile.c	20 Dec 2006 06:55:07 -0000	1.4.4.11.2.10.2.3
***************
*** 204,208 ****
      long skipframes)
  {
!     int format, nchannels, bigendian, bytespersamp, swap, sysrtn;
      long bytelimit = 0x7fffffff;
      errno = 0;
--- 204,208 ----
      long skipframes)
  {
!     int nchannels, bigendian, bytespersamp, swap, sysrtn;
      long bytelimit = 0x7fffffff;
      errno = 0;
***************
*** 242,246 ****
          if (format == FORMAT_NEXT)   /* nextstep header */
          {
-             uint32 param;
              if (bytesread < (int)sizeof(t_nextstep))
                  goto badheader;
--- 242,245 ----
***************
*** 1150,1172 ****
  }
  
! static void soundfiler_t_write(t_soundfiler *x, t_symbol *s,
! 							   int argc, t_atom *argv);
! 
! static void soundfiler_t_write_addq(t_soundfiler *x, t_symbol *s,
! 									int argc, t_atom *argv)
! {
      soundfiler_queue_add(soundfiler_t_write,(void *)x,argc, argv);
  }
! 
! static void soundfiler_t_read(t_soundfiler *x, t_symbol *s,
! 							  int argc, t_atom *argv);
! 
! static void soundfiler_t_read_addq(t_soundfiler *x, t_symbol *s,
! 								   int argc, t_atom *argv)
! {
      soundfiler_queue_add(soundfiler_t_read,(void *)x,argc, argv);
  }
  
- 
      /* soundfiler_read ...
      
--- 1149,1161 ----
  }
  
! static void soundfiler_t_write(     t_soundfiler *x, t_symbol *s, int argc, t_atom *argv);
! static void soundfiler_t_write_addq(t_soundfiler *x, t_symbol *s, int argc, t_atom *argv) {
      soundfiler_queue_add(soundfiler_t_write,(void *)x,argc, argv);
  }
! static void soundfiler_t_read(     t_soundfiler *x, t_symbol *s, int argc, t_atom *argv);
! static void soundfiler_t_read_addq(t_soundfiler *x, t_symbol *s, int argc, t_atom *argv) {
      soundfiler_queue_add(soundfiler_t_read,(void *)x,argc, argv);
  }
  
      /* soundfiler_read ...
      
***************
*** 2320,2331 ****
  /************** the child thread which performs file I/O ***********/
  
- #if 0
- static void pute(char *s)   /* debug routine */
- {
-     write(2, s, strlen(s));
- }
- #define DEBUG_SOUNDFILE
- #endif
- 
  #if 1
  #define sfread_cond_wait pthread_cond_wait
--- 2309,2312 ----
***************
*** 2348,2383 ****
  #endif
  
! static void *readsf_child_main(void *zz)
! {
      t_readsf *x = (t_readsf *)zz;
- #ifdef DEBUG_SOUNDFILE
-     pute("1\n");
- #endif
      pthread_mutex_lock(&x->x_mutex);
!     while (1)
!     {
          int fd, fifohead;
          char *buf;
! #ifdef DEBUG_SOUNDFILE
!         pute("0\n");
! #endif
!         if (x->x_requestcode == REQUEST_NOTHING)
!         {
! #ifdef DEBUG_SOUNDFILE
!             pute("wait 2\n");
! #endif
              sfread_cond_signal(&x->x_answercondition);
              sfread_cond_wait(&x->x_requestcondition, &x->x_mutex);
! #ifdef DEBUG_SOUNDFILE
!             pute("3\n");
! #endif
!         }
!         else if (x->x_requestcode == REQUEST_OPEN)
!         {
              char boo[80];
              int sysrtn, wantbytes;
!             
!                 /* copy file stuff out of the data structure so we can
!                 relinquish the mutex while we're in open_soundfile(). */
              long onsetframes = x->x_onsetframes;
              long bytelimit = 0x7fffffff;
--- 2329,2346 ----
  #endif
  
! static void *readsf_child_main(void *zz) {
      t_readsf *x = (t_readsf *)zz;
      pthread_mutex_lock(&x->x_mutex);
!     while (1) {
          int fd, fifohead;
          char *buf;
!         if (x->x_requestcode == REQUEST_NOTHING) {
              sfread_cond_signal(&x->x_answercondition);
              sfread_cond_wait(&x->x_requestcondition, &x->x_mutex);
!         } else if (x->x_requestcode == REQUEST_OPEN) {
              char boo[80];
              int sysrtn, wantbytes;
!             /* copy file stuff out of the data structure so we can
!                relinquish the mutex while we're in open_soundfile(). */
              long onsetframes = x->x_onsetframes;
              long bytelimit = 0x7fffffff;
***************
*** 2388,2400 ****
              char *filename = x->x_filename;
              char *dirname = canvas_getdir(x->x_canvas)->s_name;
!                 /* alter the request code so that an ensuing "open" will get
!                 noticed. */
! #ifdef DEBUG_SOUNDFILE
!             pute("4\n");
! #endif
              x->x_requestcode = REQUEST_BUSY;
              x->x_fileerror = 0;
! 
!                 /* if there's already a file open, close it */
              if (x->x_fd >= 0)
              {
--- 2351,2358 ----
              char *filename = x->x_filename;
              char *dirname = canvas_getdir(x->x_canvas)->s_name;
!             /* alter the request code so that an ensuing "open" will get noticed. */
              x->x_requestcode = REQUEST_BUSY;
              x->x_fileerror = 0;
!             /* if there's already a file open, close it */
              if (x->x_fd >= 0)
              {
***************
*** 2407,2411 ****
                      goto lost;
              }
!                 /* open the soundfile with the mutex unlocked */
              pthread_mutex_unlock(&x->x_mutex);
              fd = open_soundfile(dirname, filename,
--- 2365,2369 ----
                      goto lost;
              }
!             /* open the soundfile with the mutex unlocked */
              pthread_mutex_unlock(&x->x_mutex);
              fd = open_soundfile(dirname, filename,
***************
*** 2414,2421 ****
              pthread_mutex_lock(&x->x_mutex);
  
! #ifdef DEBUG_SOUNDFILE
!             pute("5\n");
! #endif
!                 /* copy back into the instance structure. */
              x->x_bytespersample = bytespersample;
              x->x_sfchannels = sfchannels;
--- 2372,2376 ----
              pthread_mutex_lock(&x->x_mutex);
  
!             /* copy back into the instance structure. */
              x->x_bytespersample = bytespersample;
              x->x_sfchannels = sfchannels;
***************
*** 2427,2435 ****
                  x->x_fileerror = errno;
                  x->x_eof = 1;
- #ifdef DEBUG_SOUNDFILE
-                 pute("open failed\n");
-                 pute(filename);
-                 pute(dirname);
- #endif
                  goto lost;
              }
--- 2382,2385 ----
***************
*** 2437,2443 ****
              if (x->x_requestcode != REQUEST_BUSY)
                  goto lost;
- #ifdef DEBUG_SOUNDFILE
-             pute("6\n");
- #endif
              x->x_fifohead = 0;
                      /* set fifosize from bufsize.  fifosize must be a
--- 2387,2390 ----
***************
*** 2451,2459 ****
                      /* arrange for the "request" condition to be signalled 16
                      times per buffer */
- #ifdef DEBUG_SOUNDFILE
-             sprintf(boo, "fifosize %d\n", 
-                 x->x_fifosize);
-             pute(boo);
- #endif
              x->x_sigcountdown = x->x_sigperiod =
                  (x->x_fifosize /
--- 2398,2401 ----
***************
*** 2465,2471 ****
              {
                  int fifosize = x->x_fifosize;
- #ifdef DEBUG_SOUNDFILE
-                 pute("77\n");
- #endif
                  if (x->x_eof)
                      break;
--- 2407,2410 ----
***************
*** 2485,2508 ****
                          if (wantbytes > x->x_bytelimit)
                              wantbytes = x->x_bytelimit;
- #ifdef DEBUG_SOUNDFILE
-                         sprintf(boo, "head %d, tail %d, size %d\n", 
-                             x->x_fifohead, x->x_fifotail, wantbytes);
-                         pute(boo);
- #endif
                      }
                      else
                      {
- #ifdef DEBUG_SOUNDFILE
-                         pute("wait 7a ...\n");
- #endif
                          sfread_cond_signal(&x->x_answercondition);
- #ifdef DEBUG_SOUNDFILE
-                         pute("signalled\n");
- #endif
                          sfread_cond_wait(&x->x_requestcondition,
                              &x->x_mutex);
- #ifdef DEBUG_SOUNDFILE
-                         pute("7a done\n");
- #endif
                          continue;
                      }
--- 2424,2433 ----
***************
*** 2515,2527 ****
                      if (wantbytes < READSIZE)
                      {
- #ifdef DEBUG_SOUNDFILE
-                         pute("wait 7...\n");
- #endif
                          sfread_cond_signal(&x->x_answercondition);
                          sfread_cond_wait(&x->x_requestcondition,
                              &x->x_mutex);
- #ifdef DEBUG_SOUNDFILE
-                         pute("7 done\n");
- #endif
                          continue;
                      }
--- 2440,2446 ----
***************
*** 2530,2536 ****
                          wantbytes = x->x_bytelimit;
                  }
- #ifdef DEBUG_SOUNDFILE
-                 pute("8\n");
- #endif
                  fd = x->x_fd;
                  buf = x->x_buf;
--- 2449,2452 ----
***************
*** 2543,2549 ****
                  if (sysrtn < 0)
                  {
- #ifdef DEBUG_SOUNDFILE
-                     pute("fileerror\n");
- #endif
                      x->x_fileerror = errno;
                      break;
--- 2459,2462 ----
***************
*** 2566,2574 ****
                          x->x_fifohead = 0;
                  }
- #ifdef DEBUG_SOUNDFILE
-                 sprintf(boo, "after: head %d, tail %d\n", 
-                     x->x_fifohead, x->x_fifotail);
-                 pute(boo);
- #endif
                      /* signal parent in case it's waiting for data */
                  sfread_cond_signal(&x->x_answercondition);
--- 2479,2482 ----
***************
*** 2621,2632 ****
          else
          {
- #ifdef DEBUG_SOUNDFILE
-             pute("13\n");
- #endif
          }
      }
- #ifdef DEBUG_SOUNDFILE
-     pute("thread exit\n");
- #endif
      pthread_mutex_unlock(&x->x_mutex);
      return (0);
--- 2529,2534 ----
***************
*** 2699,2710 ****
                  x->x_fifohead < x->x_fifotail + wantbytes-1)
          {
- #ifdef DEBUG_SOUNDFILE
-             pute("wait...\n");
- #endif
              sfread_cond_signal(&x->x_requestcondition);
              sfread_cond_wait(&x->x_answercondition, &x->x_mutex);
- #ifdef DEBUG_SOUNDFILE
-             pute("done\n");
- #endif
          }
          if (x->x_eof && x->x_fifohead >= x->x_fifotail &&
--- 2601,2606 ----
***************
*** 2902,2924 ****
  {
      t_writesf *x = (t_writesf*)zz;
- #ifdef DEBUG_SOUNDFILE
-     pute("1\n");
- #endif
      pthread_mutex_lock(&x->x_mutex);
      while (1)
      {
- #ifdef DEBUG_SOUNDFILE
-         pute("0\n");
- #endif
          if (x->x_requestcode == REQUEST_NOTHING)
          {
- #ifdef DEBUG_SOUNDFILE
-             pute("wait 2\n");
- #endif
              sfread_cond_signal(&x->x_answercondition);
              sfread_cond_wait(&x->x_requestcondition, &x->x_mutex);
- #ifdef DEBUG_SOUNDFILE
-             pute("3\n");
- #endif
          }
          else if (x->x_requestcode == REQUEST_OPEN)
--- 2798,2808 ----
***************
*** 2942,2948 ****
                  /* alter the request code so that an ensuing "open" will get
                  noticed. */
- #ifdef DEBUG_SOUNDFILE
-             pute("4\n");
- #endif
              x->x_requestcode = REQUEST_BUSY;
              x->x_fileerror = 0;
--- 2826,2829 ----
***************
*** 2969,2979 ****
                  pthread_mutex_lock(&x->x_mutex);
                  x->x_fd = -1;
- #ifdef DEBUG_SOUNDFILE
-                 {
-                     char s[1000];
-                     sprintf(s, "bug??? ditched %d\n", itemswritten);
-                     pute(s);
-                 }
- #endif  
                  if (x->x_requestcode != REQUEST_BUSY)
                      continue;
--- 2850,2853 ----
***************
*** 2985,2992 ****
                          garray_ambigendian() != bigendian, samplerate);
              pthread_mutex_lock(&x->x_mutex);
- #ifdef DEBUG_SOUNDFILE
-             pute("5\n");
- #endif
- 
              if (fd < 0)
              {
--- 2859,2862 ----
***************
*** 2994,3001 ****
                  x->x_eof = 1;
                  x->x_fileerror = errno;
- #ifdef DEBUG_SOUNDFILE
-                 pute("open failed\n");
-                 pute(filename);
- #endif
                  x->x_requestcode = REQUEST_NOTHING;
                  continue;
--- 2864,2867 ----
***************
*** 3004,3010 ****
              if (x->x_requestcode != REQUEST_BUSY)
                  continue;
- #ifdef DEBUG_SOUNDFILE
-             pute("6\n");
- #endif
              x->x_fd = fd;
              x->x_fifotail = 0;
--- 2870,2873 ----
***************
*** 3019,3030 ****
                  int fifosize = x->x_fifosize, fifotail;
                  char *buf = x->x_buf;
! #ifdef DEBUG_SOUNDFILE
!                 pute("77\n");
! #endif
! 
!                     /* if the head is < the tail, we can immediately write
!                     from tail to end of fifo to disk; otherwise we hold off
!                     writing until there are at least WRITESIZE bytes in the
!                     buffer */
                  if (x->x_fifohead < x->x_fifotail ||
                      x->x_fifohead >= x->x_fifotail + WRITESIZE
--- 2882,2889 ----
                  int fifosize = x->x_fifosize, fifotail;
                  char *buf = x->x_buf;
!                 /* if the head is < the tail, we can immediately write
!                    from tail to end of fifo to disk; otherwise we hold off
!                    writing until there are at least WRITESIZE bytes in the
!                    buffer */
                  if (x->x_fifohead < x->x_fifotail ||
                      x->x_fifohead >= x->x_fifotail + WRITESIZE
***************
*** 3039,3059 ****
                  else
                  {
- #ifdef DEBUG_SOUNDFILE
-                     pute("wait 7a ...\n");
- #endif
                      sfread_cond_signal(&x->x_answercondition);
- #ifdef DEBUG_SOUNDFILE
-                     pute("signalled\n");
- #endif
                      sfread_cond_wait(&x->x_requestcondition,
                          &x->x_mutex);
- #ifdef DEBUG_SOUNDFILE
-                     pute("7a done\n");
- #endif
                      continue;
                  }
- #ifdef DEBUG_SOUNDFILE
-                 pute("8\n");
- #endif
                  fifotail = x->x_fifotail;
                  fd = x->x_fd;
--- 2898,2906 ----
***************
*** 3066,3072 ****
                  if (sysrtn < writebytes)
                  {
- #ifdef DEBUG_SOUNDFILE
-                     pute("fileerror\n");
- #endif
                      x->x_fileerror = errno;
                      break;
--- 2913,2916 ----
***************
*** 3080,3088 ****
                  x->x_itemswritten +=
                      sysrtn / (x->x_bytespersample * x->x_sfchannels);
- #ifdef DEBUG_SOUNDFILE
-                 sprintf(boo, "after: head %d, tail %d written %d\n", 
-                     x->x_fifohead, x->x_fifotail, x->x_itemswritten);
-                 pute(boo);
- #endif
                      /* signal parent in case it's waiting for data */
                  sfread_cond_signal(&x->x_answercondition);
--- 2924,2927 ----
***************
*** 3117,3130 ****
                  break;
          }
-         else
-         {
- #ifdef DEBUG_SOUNDFILE
-             pute("13\n");
- #endif
-         }
      }
- #ifdef DEBUG_SOUNDFILE
-     pute("thread exit\n");
- #endif
      pthread_mutex_unlock(&x->x_mutex);
      return (0);
--- 2956,2960 ----
***************
*** 3192,3198 ****
              x->x_fifotail < x->x_fifohead + wantbytes + 1)
          {
- #ifdef DEBUG_SOUNDFILE
-             pute("wait...\n");
- #endif
              sfread_cond_signal(&x->x_requestcondition);
              sfread_cond_wait(&x->x_answercondition, &x->x_mutex);
--- 3022,3025 ----
***************
*** 3203,3211 ****
  			wantbytes = sfchannels * vecsize * bytespersample;
  			bigendian = x->x_bigendian;
- #ifdef DEBUG_SOUNDFILE
-             pute("done\n");
- #endif
          }
- 
          soundfile_xferout(sfchannels, x->x_outvec,
              (unsigned char *)(x->x_buf + x->x_fifohead), vecsize, 0,
--- 3030,3034 ----
***************
*** 3217,3223 ****
          if ((--x->x_sigcountdown) <= 0)
          {
- #ifdef DEBUG_SOUNDFILE
-             pute("signal 1\n");
- #endif
              sfread_cond_signal(&x->x_requestcondition);
              x->x_sigcountdown = x->x_sigperiod;
--- 3040,3043 ----
***************
*** 3244,3250 ****
      x->x_state = STATE_IDLE;
      x->x_requestcode = REQUEST_CLOSE;
- #ifdef DEBUG_SOUNDFILE
-     pute("signal 2\n");
- #endif
      sfread_cond_signal(&x->x_requestcondition);
      pthread_mutex_unlock(&x->x_mutex);
--- 3064,3067 ----





More information about the Pd-cvs mailing list