[PD-cvs] pd/src s_audio_pa.c,1.4.4.7.2.5.2.3,1.4.4.7.2.5.2.4

Mathieu Bouchard matju at users.sourceforge.net
Tue Jul 31 01:41:36 CEST 2007


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

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


Index: s_audio_pa.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_audio_pa.c,v
retrieving revision 1.4.4.7.2.5.2.3
retrieving revision 1.4.4.7.2.5.2.4
diff -C2 -d -r1.4.4.7.2.5.2.3 -r1.4.4.7.2.5.2.4
*** s_audio_pa.c	30 Jul 2007 23:36:20 -0000	1.4.4.7.2.5.2.3
--- s_audio_pa.c	30 Jul 2007 23:41:34 -0000	1.4.4.7.2.5.2.4
***************
*** 205,326 ****
  #ifdef PABLOCKING /* tb: blocking IO isn't really working for v19 yet */
      double timenow, timebefore;
!     if ((pa_inchans && Pa_GetStreamReadAvailable(pa_stream) < sys_dacblocksize*0.8) &&
! 		 (pa_outchans && Pa_GetStreamWriteAvailable(pa_stream) 
! 		  < sys_dacblocksize*0.8))
! 	{
! 		/* we can't transfer data ... wait in the scheduler */
! 		return SENDDACS_NO;
! 	}
! 	
! 	timebefore = sys_getrealtime();
! 
! 	if (pa_outchans)
! 		Pa_WriteStream(pa_stream, &sys_soundout, sys_dacblocksize);
! 	if (pa_inchans)
! 		Pa_ReadStream(pa_stream, &sys_soundin,  sys_dacblocksize);
  	zerovec(sys_soundout, pa_inchans * sys_dacblocksize);
! 
! 	while ( (pa_inchans && Pa_GetStreamReadAvailable(pa_stream) 
! 			 < sys_dacblocksize*0.8) &&
! 			(pa_outchans && Pa_GetStreamWriteAvailable(pa_stream) 
! 			 < sys_dacblocksize*0.8))
! 	{
! 		if (pa_outchans)
! 			Pa_WriteStream(pa_stream, &sys_soundout, sys_dacblocksize);
! 		if (pa_inchans)
! 			Pa_ReadStream(pa_stream, &sys_soundin,  sys_dacblocksize);
! 		zerovec(sys_soundout, pa_inchans * sys_dacblocksize);
! 
! 		sched_tick(sys_time + sys_time_per_dsp_tick);
! 	}
! 
!     if (sys_getrealtime() > timebefore + sys_sleepgrain * 1e-6)
! 	{
! 		return SENDDACS_SLEPT;
! 	}
! 	else
! 		return SENDDACS_YES;
! 
  #else /* for now we're using pablio */
- 	
      float *samples, *fp1, *fp2;
      int i, j;
      double timebefore;
!     
! 	samples=(float*)alloca(sizeof(float) * MAX_PA_CHANS * sys_dacblocksize);
! 
      timebefore = sys_getrealtime();
      if ((pa_inchans && PD_GetAudioStreamReadable(pablio_stream) < sys_dacblocksize) ||
!         (pa_outchans && PD_GetAudioStreamWriteable(pablio_stream) < sys_dacblocksize))
!     {
!         if (pa_inchans && pa_outchans)
!         {
              int synced = 0;
!             while (PD_GetAudioStreamWriteable(pablio_stream) > 2*sys_dacblocksize)
!             {
                  for (j = 0; j < pa_outchans; j++)
!                     for (i = 0, fp2 = samples + j; i < sys_dacblocksize; i++,
!                         fp2 += pa_outchans)
!                 {
!                     *fp2 = 0;
!                 }
                  synced = 1;
                  PD_WriteAudioStream(pablio_stream, samples, sys_dacblocksize);
              }
!             while (PD_GetAudioStreamReadable(pablio_stream) > 2*sys_dacblocksize)
!             {
                  synced = 1;
                  PD_ReadAudioStream(pablio_stream, samples, sys_dacblocksize);
              }
! /*             if (synced) */
! /*                 post("sync"); */
          }
!         return (SENDDACS_NO);
      }
!     if (pa_inchans)
!     {
          PD_ReadAudioStream(pablio_stream, samples, sys_dacblocksize);
          for (j = 0, fp1 = sys_soundin; j < pa_inchans; j++, fp1 += sys_dacblocksize)
!             for (i = 0, fp2 = samples + j; i < sys_dacblocksize; i++,
!                 fp2 += pa_inchans)
!         {
!             fp1[i] = *fp2;
!         }
      }
!     if (pa_outchans)
!     {
!         for (j = 0, fp1 = sys_soundout; j < pa_outchans; j++,
!             fp1 += sys_dacblocksize)
!                 for (i = 0, fp2 = samples + j; i < sys_dacblocksize; i++,
!                     fp2 += pa_outchans)
!         {
!             *fp2 = fp1[i];
!             fp1[i] = 0;
!         }
          PD_WriteAudioStream(pablio_stream, samples, sys_dacblocksize);
      }
! 
!     if (sys_getrealtime() > timebefore + sys_sleepgrain * 1e-6)
!     {
! /*         post("slept"); */
!         return (SENDDACS_SLEPT);
!     }
!     else return (SENDDACS_YES);
! 
  #endif
  }
  
! 
! 
! void pa_listdevs(void)     /* lifted from pa_devs.c in portaudio */
! {
!     int      i,j;
!     int      numDevices;
!     const    PaDeviceInfo *pdi;
!     PaError  err;
      Pa_Initialize();
      numDevices = Pa_GetDeviceCount();
!     if( numDevices < 0 )
!     {
          fprintf(stderr, "ERROR: Pa_GetDeviceCount returned %d\n", numDevices );
          err = numDevices;
--- 205,281 ----
  #ifdef PABLOCKING /* tb: blocking IO isn't really working for v19 yet */
      double timenow, timebefore;
!     if (( pa_inchans &&  Pa_GetStreamReadAvailable(pa_stream) < sys_dacblocksize*0.8) &&
! 	(pa_outchans && Pa_GetStreamWriteAvailable(pa_stream) < sys_dacblocksize*0.8)) {
! 	/* we can't transfer data ... wait in the scheduler */
! 	return SENDDACS_NO;
!     }
!     timebefore = sys_getrealtime();
!     if (pa_outchans) Pa_WriteStream(pa_stream, &sys_soundout, sys_dacblocksize);
!     if ( pa_inchans)  Pa_ReadStream(pa_stream, &sys_soundin,  sys_dacblocksize);
!     zerovec(sys_soundout, pa_inchans * sys_dacblocksize);
!     while (( pa_inchans &&  Pa_GetStreamReadAvailable(pa_stream) < sys_dacblocksize*0.8) &&
! 	   (pa_outchans && Pa_GetStreamWriteAvailable(pa_stream) < sys_dacblocksize*0.8)) {
! 	if (pa_outchans) Pa_WriteStream(pa_stream, &sys_soundout, sys_dacblocksize);
! 	if ( pa_inchans)  Pa_ReadStream(pa_stream, &sys_soundin,  sys_dacblocksize);
  	zerovec(sys_soundout, pa_inchans * sys_dacblocksize);
! 	sched_tick(sys_time + sys_time_per_dsp_tick);
!     }
!     if (sys_getrealtime() > timebefore + sys_sleepgrain * 1e-6) {
! 	return SENDDACS_SLEPT;
!     } else return SENDDACS_YES;
  #else /* for now we're using pablio */
      float *samples, *fp1, *fp2;
      int i, j;
      double timebefore;
!     samples=(float*)alloca(sizeof(float) * MAX_PA_CHANS * sys_dacblocksize);
      timebefore = sys_getrealtime();
      if ((pa_inchans && PD_GetAudioStreamReadable(pablio_stream) < sys_dacblocksize) ||
!         (pa_outchans && PD_GetAudioStreamWriteable(pablio_stream) < sys_dacblocksize)) {
!         if (pa_inchans && pa_outchans) {
              int synced = 0;
!             while (PD_GetAudioStreamWriteable(pablio_stream) > 2*sys_dacblocksize) {
                  for (j = 0; j < pa_outchans; j++)
!                     for (i = 0, fp2 = samples + j; i < sys_dacblocksize; i++, fp2 += pa_outchans)
!                         *fp2 = 0;
                  synced = 1;
                  PD_WriteAudioStream(pablio_stream, samples, sys_dacblocksize);
              }
!             while (PD_GetAudioStreamReadable(pablio_stream) > 2*sys_dacblocksize) {
                  synced = 1;
                  PD_ReadAudioStream(pablio_stream, samples, sys_dacblocksize);
              }
! /*          if (synced) post("sync"); */
          }
!         return SENDDACS_NO;
      }
!     if (pa_inchans) {
          PD_ReadAudioStream(pablio_stream, samples, sys_dacblocksize);
          for (j = 0, fp1 = sys_soundin; j < pa_inchans; j++, fp1 += sys_dacblocksize)
!             for (i = 0, fp2 = samples + j; i < sys_dacblocksize; i++, fp2 += pa_inchans)
!                 fp1[i] = *fp2;
      }
!     if (pa_outchans) {
!         for (j = 0, fp1 = sys_soundout; j < pa_outchans; j++, fp1 += sys_dacblocksize)
!             for (i = 0, fp2 = samples + j; i < sys_dacblocksize; i++, fp2 += pa_outchans) {
!                 *fp2 = fp1[i];
!                 fp1[i] = 0;
!             }
          PD_WriteAudioStream(pablio_stream, samples, sys_dacblocksize);
      }
!     if (sys_getrealtime() > timebefore + sys_sleepgrain * 1e-6) {
!         /* post("slept"); */
!         return SENDDACS_SLEPT;
!     } else return SENDDACS_YES;
  #endif
  }
  
! void pa_listdevs() /* lifted from pa_devs.c in portaudio */ {
!     int     i,j;
!     int     numDevices;
!     const   PaDeviceInfo *pdi;
!     PaError err;
      Pa_Initialize();
      numDevices = Pa_GetDeviceCount();
!     if (numDevices<0) {
          fprintf(stderr, "ERROR: Pa_GetDeviceCount returned %d\n", numDevices );
          err = numDevices;
***************
*** 328,388 ****
      }
      fprintf(stderr, "Audio Devices:\n");
!     for( i=0; i<numDevices; i++ )
!     {
! 		const PaDeviceInfo *pdi = Pa_GetDeviceInfo( i );
!         post ("device %s", pdi->name);
! 		fprintf(stderr, "device %d:", i+1 );
!         fprintf(stderr, " %s;", pdi->name );
!         fprintf(stderr, "%d inputs, ", pdi->maxInputChannels  );
!         fprintf(stderr, "%d outputs", pdi->maxOutputChannels  );
  #ifdef PA19
!         if ( i == Pa_GetDefaultInputDevice() )
!             fprintf(stderr, " (Default Input)");
!         if ( i == Pa_GetDefaultOutputDevice() )
!             fprintf(stderr, " (Default Output)");
  #else
!         if ( i == Pa_GetDefaultInputDeviceID() )
!             fprintf(stderr, " (Default Input)");
!         if ( i == Pa_GetDefaultOutputDeviceID() )
!             fprintf(stderr, " (Default Output)");
  #endif
          fprintf(stderr, "\n");
      }
- 
      fprintf(stderr, "\n");
      return;
- 
  error:
!     fprintf( stderr, "An error occured while using the portaudio stream\n" );
!     fprintf( stderr, "Error number: %d\n", err );
!     fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
  
  }
- 
- 
  /* scanning for devices */
! void pa_getdevs(char *indevlist, int *nindevs,
!     char *outdevlist, int *noutdevs, int *canmulti, 
!         int maxndev, int devdescsize)
! {
      int i, nin = 0, nout = 0, ndev;
      *canmulti = 1;  /* one dev each for input and output */
- 
      Pa_Initialize();
      ndev = Pa_GetDeviceCount();
!     for (i = 0; i < ndev; i++)
!     {
          const PaDeviceInfo *pdi = Pa_GetDeviceInfo(i);
!         if (pdi->maxInputChannels > 0 && nin < maxndev)
!         {
!             sprintf(indevlist + nin * devdescsize, "(%d)%s",
!                 pdi->hostApi,pdi->name);
              /* strcpy(indevlist + nin * devdescsize, pdi->name); */
              nin++;
          }
!         if (pdi->maxOutputChannels > 0 && nout < maxndev)
!         {
!             sprintf(outdevlist + nout * devdescsize, "(%d)%s",
!                 pdi->hostApi,pdi->name);
              /* strcpy(outdevlist + nout * devdescsize, pdi->name); */
              nout++;
--- 283,325 ----
      }
      fprintf(stderr, "Audio Devices:\n");
!     for (i=0; i<numDevices; i++) {
! 	const PaDeviceInfo *pdi = Pa_GetDeviceInfo(i);
!         post("device %s", pdi->name);
! 	fprintf(stderr, "device %d:", i+1);
!         fprintf(stderr, " %s;", pdi->name);
!         fprintf(stderr, "%d inputs, ", pdi->maxInputChannels);
!         fprintf(stderr, "%d outputs", pdi->maxOutputChannels);
  #ifdef PA19
!         if (i == Pa_GetDefaultInputDevice ())   fprintf(stderr, " (Default Input)");
!         if (i == Pa_GetDefaultOutputDevice())   fprintf(stderr, " (Default Output)");
  #else
!         if (i == Pa_GetDefaultInputDeviceID ()) fprintf(stderr, " (Default Input)");
!         if (i == Pa_GetDefaultOutputDeviceID()) fprintf(stderr, " (Default Output)");
  #endif
          fprintf(stderr, "\n");
      }
      fprintf(stderr, "\n");
      return;
  error:
!     fprintf(stderr, "An error occured while using the portaudio stream\n");
!     fprintf(stderr, "Error number: %d\n",err);
!     fprintf(stderr, "Error message: %s\n",Pa_GetErrorText(err));
  
  }
  /* scanning for devices */
! void pa_getdevs(char *indevlist, int *nindevs, char *outdevlist, int *noutdevs, int *canmulti, int maxndev, int devdescsize) {
      int i, nin = 0, nout = 0, ndev;
      *canmulti = 1;  /* one dev each for input and output */
      Pa_Initialize();
      ndev = Pa_GetDeviceCount();
!     for (i = 0; i < ndev; i++) {
          const PaDeviceInfo *pdi = Pa_GetDeviceInfo(i);
!         if (pdi->maxInputChannels > 0 && nin < maxndev) {
!             sprintf(indevlist + nin * devdescsize, "(%d)%s", pdi->hostApi,pdi->name);
              /* strcpy(indevlist + nin * devdescsize, pdi->name); */
              nin++;
          }
!         if (pdi->maxOutputChannels > 0 && nout < maxndev) {
!             sprintf(outdevlist + nout * devdescsize, "(%d)%s", pdi->hostApi,pdi->name);
              /* strcpy(outdevlist + nout * devdescsize, pdi->name); */
              nout++;





More information about the Pd-cvs mailing list