[PD-cvs] pd/src s_audio_portaudio.c, 1.1.2.15, 1.1.2.16 m_glob.c, 1.4.4.2.2.13, 1.4.4.2.2.14

Tim Blechmann timblech at users.sourceforge.net
Fri Aug 4 13:55:54 CEST 2006


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

Modified Files:
      Tag: devel_0_39
	s_audio_portaudio.c m_glob.c 
Log Message:
improved feedback to pd receiver when opening portaudio devices

Index: s_audio_portaudio.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/s_audio_portaudio.c,v
retrieving revision 1.1.2.15
retrieving revision 1.1.2.16
diff -C2 -d -r1.1.2.15 -r1.1.2.16
*** s_audio_portaudio.c	4 Aug 2006 11:37:49 -0000	1.1.2.15
--- s_audio_portaudio.c	4 Aug 2006 11:55:51 -0000	1.1.2.16
***************
*** 44,48 ****
  static PaStream *pa_stream;
  /* Initialize PortAudio  */
! PaError pa_status = -1; 
  int pa_initialized = 0;
  
--- 44,48 ----
  static PaStream *pa_stream;
  /* Initialize PortAudio  */
! PaError pa_status = -1;
  int pa_initialized = 0;
  
***************
*** 71,76 ****
  static int pdoutdev2paoutdev(int pdoutdev);
  
! int process (const void *input, void *output, unsigned long frameCount, 
!     const PaStreamCallbackTimeInfo* timeInfo, 
      PaStreamCallbackFlags statusFlags, void *userData);
  
--- 71,76 ----
  static int pdoutdev2paoutdev(int pdoutdev);
  
! int process (const void *input, void *output, unsigned long frameCount,
!     const PaStreamCallbackTimeInfo* timeInfo,
      PaStreamCallbackFlags statusFlags, void *userData);
  
***************
*** 84,88 ****
  static int pa_indev = -1, pa_outdev = -1;
  
! int pa_open_audio(int inchans, int outchans, int rate, int advance, 
      int indeviceno, int outdeviceno, int schedmode)
  {
--- 84,88 ----
  static int pa_indev = -1, pa_outdev = -1;
  
! int pa_open_audio(int inchans, int outchans, int rate, int advance,
      int indeviceno, int outdeviceno, int schedmode)
  {
***************
*** 91,96 ****
  
      schedmode = 1; /* we don't support blocking io */
!     
!     pa_initialize();    
  
      sys_setscheduler(schedmode);
--- 91,96 ----
  
      schedmode = 1; /* we don't support blocking io */
! 
!     pa_initialize();
  
      sys_setscheduler(schedmode);
***************
*** 107,111 ****
          outchans = MAX_PA_CHANS;
      }
!     
      if (inchans > 0)
      {
--- 107,111 ----
          outchans = MAX_PA_CHANS;
      }
! 
      if (inchans > 0)
      {
***************
*** 127,131 ****
          }
      }
!   
      if (outchans > 0)
      {
--- 127,131 ----
          }
      }
! 
      if (outchans > 0)
      {
***************
*** 147,151 ****
          }
      }
!     
  
      if (1/* sys_verbose */)
--- 147,151 ----
          }
      }
! 
  
      if (1/* sys_verbose */)
***************
*** 159,166 ****
          int blocksize;
          PaStreamParameters inputParameters, outputParameters;
!         
          const PaDeviceInfo* pdi = Pa_GetDeviceInfo(pa_indev);
          const PaDeviceInfo* pdo = Pa_GetDeviceInfo(pa_outdev);
!         
          /* initialize input */
          inputParameters.device = pa_indev;
--- 159,166 ----
          int blocksize;
          PaStreamParameters inputParameters, outputParameters;
! 
          const PaDeviceInfo* pdi = Pa_GetDeviceInfo(pa_indev);
          const PaDeviceInfo* pdo = Pa_GetDeviceInfo(pa_outdev);
! 
          /* initialize input */
          inputParameters.device = pa_indev;
***************
*** 178,198 ****
  
          /* set block size */
! //        blocksize =  sys_advance_samples;
!         
! //        if (blocksize > 8192)
! //            blocksize = 8192;
! //        else if (blocksize < sys_dacblocksize)
! //            blocksize = sys_dacblocksize;
!         
! //        if (blocksize != (1 << ilog2(blocksize)))
! //        {
! //            blocksize = (1 << ilog2(blocksize));
! //        }
! 		blocksize=64;
  
- //        post("using blocksize %d", blocksize);
-         
          pa_blocksize = blocksize;
!     
          /* initialize io buffer */
          for (j=0; j != MAX_PA_CHANS;++j)
--- 178,185 ----
  
          /* set block size */
!         blocksize=64;
  
          pa_blocksize = blocksize;
! 
          /* initialize io buffer */
          for (j=0; j != MAX_PA_CHANS;++j)
***************
*** 200,204 ****
              if (pa_inbuffer[j])
                  freealignedbytes(pa_inbuffer[j], 0);
!             
              if (pa_outbuffer[j])
                  freealignedbytes(pa_outbuffer[j], 0);
--- 187,191 ----
              if (pa_inbuffer[j])
                  freealignedbytes(pa_inbuffer[j], 0);
! 
              if (pa_outbuffer[j])
                  freealignedbytes(pa_outbuffer[j], 0);
***************
*** 212,216 ****
          err = Pa_OpenStream(&pa_stream,
              ( (pa_indev  != -1) ? &inputParameters  : 0),
!             ( (pa_outdev != -1) ? &outputParameters : 0), 
              rate,
              pa_blocksize,
--- 199,203 ----
          err = Pa_OpenStream(&pa_stream,
              ( (pa_indev  != -1) ? &inputParameters  : 0),
!             ( (pa_outdev != -1) ? &outputParameters : 0),
              rate,
              pa_blocksize,
***************
*** 222,245 ****
          {
              const PaStreamInfo * streaminfo = Pa_GetStreamInfo (pa_stream);
!             t_atom atoms[2];
  
              t_symbol * pd = gensym("pd");
!             t_symbol * latency = gensym("latency");
!             t_symbol * selector1 = gensym("audioindev");
!             t_symbol * selector2 = gensym("audiooutdev");
  
              sys_schedadvance = 1e-6 * streaminfo->outputLatency;
!             SETSYMBOL(atoms, latency);
  
!             SETFLOAT(atoms+1, streaminfo->inputLatency);
!             typedmess(pd->s_thing, selector1, 2, atoms);
!             
!             SETFLOAT(atoms+1, streaminfo->outputLatency);
!             typedmess(pd->s_thing, selector2, 2, atoms);
          }
      }
      else
          err = 0;
!     
      if ( err != paNoError )
      {
--- 209,235 ----
          {
              const PaStreamInfo * streaminfo = Pa_GetStreamInfo (pa_stream);
!             t_atom atoms[4];
  
              t_symbol * pd = gensym("pd");
!             t_symbol * selector1 = gensym("audiocurrentininfo");
!             t_symbol * selector2 = gensym("audiocurrentoutinfo");
  
              sys_schedadvance = 1e-6 * streaminfo->outputLatency;
!             SETFLOAT(atoms, (float)pa_indev);
!             SETFLOAT(atoms+1, (float)inchans);
!             SETFLOAT(atoms+2, (float)rate);
!             SETFLOAT(atoms+3, (float)streaminfo->inputLatency * 1000);
!             typedmess(pd->s_thing, selector1, 4, atoms);
  
!             SETFLOAT(atoms, (float)pa_outdev);
!             SETFLOAT(atoms+1, (float)outchans);
!             SETFLOAT(atoms+2, (float)rate);
!             SETFLOAT(atoms+3, (float)streaminfo->outputLatency * 1000);
!             typedmess(pd->s_thing, selector2, 4, atoms);
          }
      }
      else
          err = 0;
! 
      if ( err != paNoError )
      {
***************
*** 256,265 ****
      pa_inchans = inchans;
      pa_outchans = outchans;
!     
      /* we might have adapted the channel count */
      sys_setchsr(inchans, outchans, rate, sys_dacblocksize);
!     
      err = Pa_StartStream(pa_stream);
!     
      if ( err != paNoError )
      {
--- 246,255 ----
      pa_inchans = inchans;
      pa_outchans = outchans;
! 
      /* we might have adapted the channel count */
      sys_setchsr(inchans, outchans, rate, sys_dacblocksize);
! 
      err = Pa_StartStream(pa_stream);
! 
      if ( err != paNoError )
      {
***************
*** 270,276 ****
          return (1);
      }
!     
      post("successfully started");
!     
      return (0);
  }
--- 260,266 ----
          return (1);
      }
! 
      post("successfully started");
! 
      return (0);
  }
***************
*** 300,304 ****
          phase += 0.05;
          if( phase >= (2.0 * M_PI) ) phase -= (2.0 * M_PI);
!         
      }
      for (i = 0; i != framesPerBuffer / sys_dacblocksize; ++i)
--- 290,294 ----
          phase += 0.05;
          if( phase >= (2.0 * M_PI) ) phase -= (2.0 * M_PI);
! 
      }
      for (i = 0; i != framesPerBuffer / sys_dacblocksize; ++i)
***************
*** 306,310 ****
          sched_tick(sys_time + sys_time_per_dsp_tick);
      }
!     
      return 0;
  }
--- 296,300 ----
          sched_tick(sys_time + sys_time_per_dsp_tick);
      }
! 
      return 0;
  }
***************
*** 315,320 ****
  void sys_lock_timeout_notification(void);
  
! int process (const void *input, void *output, unsigned long frameCount, 
!     const PaStreamCallbackTimeInfo* timeInfo, 
      PaStreamCallbackFlags statusFlags, void *userData)
  {
--- 305,310 ----
  void sys_lock_timeout_notification(void);
  
! int process (const void *input, void *output, unsigned long frameCount,
!     const PaStreamCallbackTimeInfo* timeInfo,
      PaStreamCallbackFlags statusFlags, void *userData)
  {
***************
*** 344,351 ****
                  in, sys_dacblocksize);
          }
!             
          sched_tick(sys_time + sys_time_per_dsp_tick);
!             
!         for (j = 0; j < sys_outchannels;  j++) 
          {
              t_sample * out = ((t_sample**)output)[j] + i * sys_dacblocksize;
--- 334,341 ----
                  in, sys_dacblocksize);
          }
! 
          sched_tick(sys_time + sys_time_per_dsp_tick);
! 
!         for (j = 0; j < sys_outchannels;  j++)
          {
              t_sample * out = ((t_sample**)output)[j] + i * sys_dacblocksize;
***************
*** 356,367 ****
          if (sys_meters)
              sys_peakmeters();
!             
          /* clear the output buffer */
          zerovec(sys_soundout, pa_outchans * sys_dacblocksize);
      }
!     
      run_all_idle_callbacks();
      sys_unlock();
!     
      return 0;
  }
--- 346,357 ----
          if (sys_meters)
              sys_peakmeters();
! 
          /* clear the output buffer */
          zerovec(sys_soundout, pa_outchans * sys_dacblocksize);
      }
! 
      run_all_idle_callbacks();
      sys_unlock();
! 
      return 0;
  }
***************
*** 407,411 ****
      const    PaDeviceInfo *pdi;
      PaError  err;
!     pa_initialize();    
  
      numDevices = Pa_GetDeviceCount();
--- 397,401 ----
      const    PaDeviceInfo *pdi;
      PaError  err;
!     pa_initialize();
  
      numDevices = Pa_GetDeviceCount();
***************
*** 451,455 ****
      *canmulti = 1;  /* one dev each for input and output */
  
!     pa_initialize();    
  
      ndev = Pa_GetDeviceCount();
--- 441,445 ----
      *canmulti = 1;  /* one dev each for input and output */
  
!     pa_initialize();
  
      ndev = Pa_GetDeviceCount();
***************
*** 475,479 ****
              unsigned int apiNameLen = strlen(apiName);
              strcpy(outdevlist + nout * devdescsize, apiName);
!             
              outdevlist[nout * devdescsize + apiNameLen] = '/';
              strcpy(outdevlist + nout * devdescsize + apiNameLen + 1, pdi->name);
--- 465,469 ----
              unsigned int apiNameLen = strlen(apiName);
              strcpy(outdevlist + nout * devdescsize, apiName);
! 
              outdevlist[nout * devdescsize + apiNameLen] = '/';
              strcpy(outdevlist + nout * devdescsize + apiNameLen + 1, pdi->name);
***************
*** 489,494 ****
      int i = pdindev2paindev((int)f);
      const PaDeviceInfo * pdi;
!    
!     pa_initialize();    
      pdi = Pa_GetDeviceInfo (i);
  
--- 479,484 ----
      int i = pdindev2paindev((int)f);
      const PaDeviceInfo * pdi;
! 
!     pa_initialize();
      pdi = Pa_GetDeviceInfo (i);
  
***************
*** 510,515 ****
      int i = pdoutdev2paoutdev((int)f);
      const PaDeviceInfo * pdi;
!    
!     pa_initialize();    
      pdi = Pa_GetDeviceInfo (i);
  
--- 500,505 ----
      int i = pdoutdev2paoutdev((int)f);
      const PaDeviceInfo * pdi;
! 
!     pa_initialize();
      pdi = Pa_GetDeviceInfo (i);
  
***************
*** 549,563 ****
      t_symbol * selector = gensym("testaudiosettingresult");
      t_atom argv[1];
!     
! 	pa_initialize();
!             
      indev = pdindev2paindev(indev);
      outdev = pdoutdev2paoutdev(outdev);
!     
      if ((pa_indev == -1) && (pa_outdev == -1))
      {
! 	    int ret;
! 		PaStreamParameters inputParameters, outputParameters;
!         
          inputParameters.device = indev;
          inputParameters.channelCount = inchans;
--- 539,553 ----
      t_symbol * selector = gensym("testaudiosettingresult");
      t_atom argv[1];
! 
!     pa_initialize();
! 
      indev = pdindev2paindev(indev);
      outdev = pdoutdev2paoutdev(outdev);
! 
      if ((pa_indev == -1) && (pa_outdev == -1))
      {
!         int ret;
!         PaStreamParameters inputParameters, outputParameters;
! 
          inputParameters.device = indev;
          inputParameters.channelCount = inchans;
***************
*** 565,569 ****
          inputParameters.suggestedLatency = advance * 0.001;
          inputParameters.hostApiSpecificStreamInfo = NULL;
!         
          outputParameters.device = outdev;
          outputParameters.channelCount = outchans;
--- 555,559 ----
          inputParameters.suggestedLatency = advance * 0.001;
          inputParameters.hostApiSpecificStreamInfo = NULL;
! 
          outputParameters.device = outdev;
          outputParameters.channelCount = outchans;
***************
*** 571,577 ****
          outputParameters.suggestedLatency = advance * 0.001;
          outputParameters.hostApiSpecificStreamInfo = NULL;
!         
          ret = Pa_IsFormatSupported(&inputParameters, &outputParameters, samplerate);
!     
          SETFLOAT(argv, ret);
          typedmess(pd->s_thing, selector, 1, argv);
--- 561,567 ----
          outputParameters.suggestedLatency = advance * 0.001;
          outputParameters.hostApiSpecificStreamInfo = NULL;
! 
          ret = Pa_IsFormatSupported(&inputParameters, &outputParameters, samplerate);
! 
          SETFLOAT(argv, ret);
          typedmess(pd->s_thing, selector, 1, argv);
***************
*** 583,587 ****
      int j;
      int devno;
!     pa_initialize();    
  
      for (j = 0, devno = 0; j < Pa_GetDeviceCount(); j++)
--- 573,577 ----
      int j;
      int devno;
!     pa_initialize();
  
      for (j = 0, devno = 0; j < Pa_GetDeviceCount(); j++)
***************
*** 606,610 ****
      int j;
      int devno;
!     pa_initialize();    
  
      for (j = 0, devno = 0; j < Pa_GetDeviceCount(); j++)
--- 596,600 ----
      int j;
      int devno;
!     pa_initialize();
  
      for (j = 0, devno = 0; j < Pa_GetDeviceCount(); j++)
***************
*** 627,655 ****
  void pa_get_asio_latencies(t_float f)
  {
! 	int index = (int)f;
! 	const PaDeviceInfo *pdi = Pa_GetDeviceInfo(index);
! 	if (pdi->hostApi != paASIO)
! 	{
! 		post("device not an asio device");
! 		return;
! 	}
  #ifdef WIN32
! 	else
! 	{
! 		long minlat, maxlat, preflat, gran;
! 		t_atom argv[4];
  
! 	    t_symbol * selector = gensym("asiolatency");
! 		t_symbol * pd = gensym("pd");
  
! 		PaAsio_GetAvailableLatencyValues(index, &minlat, &maxlat, &preflat, &gran);
  
! 		SETFLOAT(argv, (float) minlat);
! 		SETFLOAT(argv + 1, (float) maxlat);
! 		SETFLOAT(argv + 2, (float) preflat);
! 		SETFLOAT(argv + 3, (float) gran);
! 		
! 		typedmess(pd->s_thing, selector, 4, argv);
! 	}
  #endif
  
--- 617,645 ----
  void pa_get_asio_latencies(t_float f)
  {
!     int index = (int)f;
!     const PaDeviceInfo *pdi = Pa_GetDeviceInfo(index);
!     if (pdi->hostApi != paASIO)
!     {
!         post("device not an asio device");
!         return;
!     }
  #ifdef WIN32
!     else
!     {
!         long minlat, maxlat, preflat, gran;
!         t_atom argv[4];
  
!         t_symbol * selector = gensym("asiolatency");
!         t_symbol * pd = gensym("pd");
  
!         PaAsio_GetAvailableLatencyValues(index, &minlat, &maxlat, &preflat, &gran);
  
!         SETFLOAT(argv, (float) minlat);
!         SETFLOAT(argv + 1, (float) maxlat);
!         SETFLOAT(argv + 2, (float) preflat);
!         SETFLOAT(argv + 3, (float) gran);
! 
!         typedmess(pd->s_thing, selector, 4, argv);
!     }
  #endif
  

Index: m_glob.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/m_glob.c,v
retrieving revision 1.4.4.2.2.13
retrieving revision 1.4.4.2.2.14
diff -C2 -d -r1.4.4.2.2.13 -r1.4.4.2.2.14
*** m_glob.c	4 Aug 2006 09:48:06 -0000	1.4.4.2.2.13
--- m_glob.c	4 Aug 2006 11:55:52 -0000	1.4.4.2.2.14
***************
*** 101,104 ****
--- 101,108 ----
      if (s == gensym("midicurrentoutdev"))
          return;
+     if (s == gensym("audiocurrentininfo"))
+         return;
+     if (s == gensym("audiocurrentoutinfo"))
+         return;
  
      startpost("%s: unknown message %s ", class_getname(pd_class(x)),





More information about the Pd-cvs mailing list