[PD-cvs] pd/src s_audio_sgi.c,1.1.4.1.4.2,1.1.4.1.4.3

Mathieu Bouchard matju at users.sourceforge.net
Tue Jul 31 00:48:23 CEST 2007


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

Modified Files:
      Tag: desiredata
	s_audio_sgi.c 
Log Message:
cleanup


Index: s_audio_sgi.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/s_audio_sgi.c,v
retrieving revision 1.1.4.1.4.2
retrieving revision 1.1.4.1.4.3
diff -C2 -d -r1.1.4.1.4.2 -r1.1.4.1.4.3
*** s_audio_sgi.c	30 Jul 2007 22:32:02 -0000	1.1.4.1.4.2
--- s_audio_sgi.c	30 Jul 2007 22:48:21 -0000	1.1.4.1.4.3
***************
*** 188,353 ****
      unsigned int outtransfersize = sys_dacblocksize;
      unsigned int intransfersize = sys_dacblocksize;
! 
!                 /* no audio channels open, return */
!     if (!inchannels && !outchannels)
!                 return (SENDDACS_NO); 
! 
      timelast = timenow;
      timenow = sys_getrealtime();
- 
  #ifdef DEBUG_SGI_XFER
      if (timenow - timelast > 0.050)
!         fprintf(stderr, "(%d)",
!             (int)(1000 * (timenow - timelast))), fflush(stderr);
  #endif
- 
      callno++;
! 
!     sgi_checkiosync();     /* check I/O are in sync and data not late */
! 
!                 /* check whether there is enough space in buffers */
!     if (sgi_nindevs)
!     {
!                 for (n = 0; n < sgi_nindevs; n++)
!                 {
!                         if (alGetFilled(sgi_iport[n]) < intransfersize)
!                         return SENDDACS_NO;
!                 }
      }
!     if (sgi_noutdevs)
!     {
!                 for(n = 0; n < sgi_noutdevs; n++)
!                 {
!                         if (alGetFillable(sgi_oport[n]) < outtransfersize)
!                         return SENDDACS_NO;
!                 }
      }
! 
!                 /* output audio data, if we use audio out */
!     if (sgi_noutdevs)
!     {
!                 fp2 = sys_soundout;             /* point to current output position in buffer */
!                 for(n = 0; n < sgi_noutdevs; n++)
!                 {
!                         outdevchannels = sgi_noutchans[n];      /* channels supported by this device */
! 
!                         for (channel = 0, fp1 = buf;
!                     channel < outdevchannels; channel++, fp1++, fp2 += sys_dacblocksize)
!                         {
!                             for (i = 0, fp3 = fp1, fp4 = fp2; i < sys_dacblocksize; 
!                                         i++, fp3 += outdevchannels, fp4++)
!                                 *fp3 = *fp4, *fp4 = 0;
!                         }
!                         alWriteFrames(sgi_oport[n], buf, sys_dacblocksize);
!                 }
      }
! 
!                 /* zero out the output buffer */
!         memset(sys_soundout, 0, sys_dacblocksize * sizeof(*sys_soundout) * sys_outchannels);
!         if (sys_getrealtime() - timenow > 0.002)
!         {
      #ifdef DEBUG_SGI_XFER
!             fprintf(stderr, "output %d took %d msec\n",
!                     callno, (int)(1000 * (timenow - timelast))), fflush(stderr);
      #endif
!             timenow = sys_getrealtime();
!             sys_log_error(ERR_DACSLEPT);
          }
- 
-                 /* get audio data from input, if we use audio in */
-         if (sgi_nindevs)
-     {
-                 fp2 = sys_soundin;              /* point to current input position in buffer */
-                 for (n = 0; n < sgi_nindevs; n++)
-                 {
-                         indevchannels = sgi_ninchans[n];        /* channels supported by this device */
- 
-                         if (alGetFilled(sgi_iport[n]) > sys_dacblocksize)
-                         {
-                             alReadFrames(sgi_iport[n], buf, sys_dacblocksize);
-                         }
-                         else    /* have to read but nothing's there... */
-                         {
-                             // if (sys_verbose) post("extra ADC buf");
-                                 /* set buffer to silence */
-                             memset(buf, 0, intransfersize * sizeof(*sys_soundout) * sgi_ninchans[n]);
-                         }
-                         for (channel = 0, fp1 = buf;
-                     channel < indevchannels; channel++, fp1++, fp2 += sys_dacblocksize)
-                         {
-                                 for (i = 0, fp3 = fp1, fp4 = fp2; i < sys_dacblocksize;
-                                         i++, fp3 += indevchannels, fp4++)
-                                     *fp4 = *fp3;
-                         }
-                 }
      }
- 
      xferno++;
! 
!     if (sys_getrealtime() - timenow > 0.002)
!     {
  #ifdef DEBUG_SGI_XFER
!         fprintf(stderr, "routine took %d msec\n",
!             (int)(1000 * (sys_getrealtime() - timenow)));
  #endif
          sys_log_error(ERR_ADCSLEPT);
      }
!     return (SENDDACS_YES);
  }
  
! void sgi_getdevs(char *indevlist, int *nindevs,
!     char *outdevlist, int *noutdevs, int *canmulti, 
!         int maxndev, int devdescsize)
! {
  #if 0
!         ALpv      pvs[1];
!         char      name[32];
      int i, ndev, err;
      *canmulti = 3;  /* supports multiple devices */
! 
!         /* get max. number of audio ports from system */
!         pvs[0].param = AL_DEVICES;
!         err = alGetParams(AL_SYSTEM, pvs, 1);
!         if (err < 0)
!         {
!                 sprintf("alGetParams failed: %s\n", alGetErrorString(oserror()));
!         }
      ndev = pvs[0].value.i;
! 
!     for (i = 0; i < ndev; i++)
!     {
!                 pvs[0].param = AL_NAME;  /* a string parameter */
!                 pvs[0].value.ptr = name; /* the string we've allocated */
!                 pvs[0].sizeIn = 32;      /* the array size, in characters,
!                                                                 including space for NULL */
!                 if (alGetParams(i, pvs, 1) < 0)
!                 {
!                         sprintf("alGetParams failed: %s\n", alGetErrorString(oserror()));
!                 }
          sprintf(indevlist + i * devdescsize, "%d: %s", i + 1, name);
          sprintf(outdevlist + i * devdescsize, "%d: %s", i + 1, name);
      }
      *nindevs = ndev;
!         *noutdevs = ndev;
  #else
!     sprintf(indevlist + 0 * devdescsize, "Default In");
      sprintf(outdevlist + 0 * devdescsize, "Default Out");
!     sprintf(indevlist + 1 * devdescsize, "Analog In");
      sprintf(outdevlist + 1 * devdescsize, "Analog Out");
!     sprintf(indevlist + 2 * devdescsize, "AES In");
      sprintf(outdevlist + 2 * devdescsize, "AES Out");
!     sprintf(indevlist + 3 * devdescsize, "ADAT In");
      sprintf(outdevlist + 3 * devdescsize, "ADAT Out");
- 
      *nindevs = 4;
!         *noutdevs = 4;
      *canmulti = 3;  /* supports multiple devices */
  #endif
  }
  
- 
  /* list devices: only reflect the most common setup (Octane) */
! void sgi_listaudiodevs(void)
! {
      post("common devices on SGI machines:");
      post("#-1 - Default In/Out selected in Audio Panel");
--- 188,303 ----
      unsigned int outtransfersize = sys_dacblocksize;
      unsigned int intransfersize = sys_dacblocksize;
!     /* no audio channels open, return */
!     if (!inchannels && !outchannels) return SENDDACS_NO;
      timelast = timenow;
      timenow = sys_getrealtime();
  #ifdef DEBUG_SGI_XFER
      if (timenow - timelast > 0.050)
!         fprintf(stderr, "(%d)", (int)(1000 * (timenow - timelast))), fflush(stderr);
  #endif
      callno++;
!     sgi_checkiosync(); /* check I/O are in sync and data not late */
!     /* check whether there is enough space in buffers */
!     if (sgi_nindevs) {
!         for (n = 0; n < sgi_nindevs; n++) {
!             if (alGetFilled(sgi_iport[n]) < intransfersize)
!             return SENDDACS_NO;
!         }
      }
!     if (sgi_noutdevs) {
!         for(n = 0; n < sgi_noutdevs; n++) {
!             if (alGetFillable(sgi_oport[n]) < outtransfersize)
!             return SENDDACS_NO;
!         }
      }
!     /* output audio data, if we use audio out */
!     if (sgi_noutdevs) {
!         fp2 = sys_soundout;             /* point to current output position in buffer */
!         for(n = 0; n < sgi_noutdevs; n++) {
!             outdevchannels = sgi_noutchans[n];      /* channels supported by this device */
!             for (channel = 0, fp1 = buf; channel < outdevchannels; channel++, fp1++, fp2 += sys_dacblocksize) {
!                 for (i = 0, fp3 = fp1, fp4 = fp2; i < sys_dacblocksize; i++, fp3 += outdevchannels, fp4++) *fp3 = *fp4, *fp4 = 0;
!             }
!             alWriteFrames(sgi_oport[n], buf, sys_dacblocksize);
!         }
      }
!     /* zero out the output buffer */
!     memset(sys_soundout, 0, sys_dacblocksize * sizeof(*sys_soundout) * sys_outchannels);
!     if (sys_getrealtime() - timenow > 0.002) {
      #ifdef DEBUG_SGI_XFER
!         fprintf(stderr, "output %d took %d msec\n", callno, (int)(1000 * (timenow - timelast))), fflush(stderr);
      #endif
!         timenow = sys_getrealtime();
!         sys_log_error(ERR_DACSLEPT);
!     }
!     /* get audio data from input, if we use audio in */
!     if (sgi_nindevs) {
!         fp2 = sys_soundin;              /* point to current input position in buffer */
!         for (n = 0; n < sgi_nindevs; n++) {
!             indevchannels = sgi_ninchans[n];        /* channels supported by this device */
!             if (alGetFilled(sgi_iport[n]) > sys_dacblocksize) {
!                 alReadFrames(sgi_iport[n], buf, sys_dacblocksize);
!             } else /* have to read but nothing's there... */ {
!                 // if (sys_verbose) post("extra ADC buf");
!                 /* set buffer to silence */
!                 memset(buf, 0, intransfersize * sizeof(*sys_soundout) * sgi_ninchans[n]);
!             }
!             for (channel = 0, fp1 = buf; channel < indevchannels; channel++, fp1++, fp2 += sys_dacblocksize) {
!                 for (i = 0, fp3 = fp1, fp4 = fp2; i < sys_dacblocksize; i++, fp3 += indevchannels, fp4++) *fp4 = *fp3;
!             }
          }
      }
      xferno++;
!     if (sys_getrealtime() - timenow > 0.002) {
  #ifdef DEBUG_SGI_XFER
!         fprintf(stderr, "routine took %d msec\n", (int)(1000 * (sys_getrealtime() - timenow)));
  #endif
          sys_log_error(ERR_ADCSLEPT);
      }
!     return SENDDACS_YES;
  }
  
! void sgi_getdevs(char *indevlist, int *nindevs, char *outdevlist, int *noutdevs, int *canmulti, int maxndev, int devdescsize) {
  #if 0
!     ALpv pvs[1];
!     char name[32];
      int i, ndev, err;
      *canmulti = 3;  /* supports multiple devices */
!     /* get max. number of audio ports from system */
!     pvs[0].param = AL_DEVICES;
!     err = alGetParams(AL_SYSTEM, pvs, 1);
!     if (err < 0) {
!         sprintf("alGetParams failed: %s\n", alGetErrorString(oserror()));
!     }
      ndev = pvs[0].value.i;
!     for (i = 0; i < ndev; i++) {
!         pvs[0].param = AL_NAME;  /* a string parameter */
!         pvs[0].value.ptr = name; /* the string we've allocated */
!         pvs[0].sizeIn = 32;      /* the array size, in characters, including space for NULL */
!         if (alGetParams(i, pvs, 1) < 0) {
!             sprintf("alGetParams failed: %s\n", alGetErrorString(oserror()));
!         }
          sprintf(indevlist + i * devdescsize, "%d: %s", i + 1, name);
          sprintf(outdevlist + i * devdescsize, "%d: %s", i + 1, name);
      }
      *nindevs = ndev;
!     *noutdevs = ndev;
  #else
!     sprintf( indevlist + 0 * devdescsize, "Default In");
      sprintf(outdevlist + 0 * devdescsize, "Default Out");
!     sprintf( indevlist + 1 * devdescsize, "Analog In");
      sprintf(outdevlist + 1 * devdescsize, "Analog Out");
!     sprintf( indevlist + 2 * devdescsize, "AES In");
      sprintf(outdevlist + 2 * devdescsize, "AES Out");
!     sprintf( indevlist + 3 * devdescsize, "ADAT In");
      sprintf(outdevlist + 3 * devdescsize, "ADAT Out");
      *nindevs = 4;
!     *noutdevs = 4;
      *canmulti = 3;  /* supports multiple devices */
  #endif
  }
  
  /* list devices: only reflect the most common setup (Octane) */
! void sgi_listaudiodevs() {
      post("common devices on SGI machines:");
      post("#-1 - Default In/Out selected in Audio Panel");





More information about the Pd-cvs mailing list