Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9719
Modified Files: Tag: desiredata s_audio_alsa.c s_audio_portaudio.c Log Message: cleanup
Index: s_audio_alsa.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/s_audio_alsa.c,v retrieving revision 1.5.4.5.2.2.2.7 retrieving revision 1.5.4.5.2.2.2.8 diff -C2 -d -r1.5.4.5.2.2.2.7 -r1.5.4.5.2.2.2.8 *** s_audio_alsa.c 9 Jul 2007 17:41:02 -0000 1.5.4.5.2.2.2.7 --- s_audio_alsa.c 9 Jul 2007 18:16:13 -0000 1.5.4.5.2.2.2.8 *************** *** 36,41 **** #endif
! //static void alsa_close_audio(void); ! static void alsa_checkiosync(void); static void alsa_numbertoname(int iodev, char *devname, int nchar); static int alsa_jittermax; --- 36,41 ---- #endif
! //static void alsa_close_audio(); ! static void alsa_checkiosync(); static void alsa_numbertoname(int iodev, char *devname, int nchar); static int alsa_jittermax; *************** *** 300,304 **** }
! void alsa_close_audio(void) { int err, iodev; if (alsa_usemmap) { --- 300,304 ---- }
! void alsa_close_audio() { int err, iodev; if (alsa_usemmap) { *************** *** 317,321 **** }
! int alsa_send_dacs(void) { #ifdef DEBUG_ALSA_XFER static int xferno = 0; --- 317,321 ---- }
! int alsa_send_dacs() { #ifdef DEBUG_ALSA_XFER static int xferno = 0; *************** *** 480,484 **** }
! void alsa_printstate( void) { int result, iodev = 0; snd_pcm_sframes_t indelay, outdelay; --- 480,484 ---- }
! void alsa_printstate() { int result, iodev = 0; snd_pcm_sframes_t indelay, outdelay; *************** *** 505,509 ****
! void alsa_resync( void) { int i, result, iodev = 0; if (sys_audioapi != API_ALSA) { --- 505,509 ----
! void alsa_resync() { int i, result, iodev = 0; if (sys_audioapi != API_ALSA) { *************** *** 524,531 ****
void alsa_putzeros(int iodev, int n) { ! int i, result; ! memset(alsa_snd_buf, 0, ! alsa_outdev[iodev].a_sampwidth * sys_dacblocksize * alsa_outdev[iodev].a_channels); ! for (i = 0; i < n; i++) { result = snd_pcm_writei(alsa_outdev[iodev].a_handle, alsa_snd_buf, sys_dacblocksize); #if 0 --- 524,530 ----
void alsa_putzeros(int iodev, int n) { ! int result; ! memset(alsa_snd_buf, 0, alsa_outdev[iodev].a_sampwidth * sys_dacblocksize * alsa_outdev[iodev].a_channels); ! for (int i=0; i<n; i++) { result = snd_pcm_writei(alsa_outdev[iodev].a_handle, alsa_snd_buf, sys_dacblocksize); #if 0 *************** *** 550,554 ****
/* call this only if both input and output are open */ ! static void alsa_checkiosync( void) { int result, giveup = 1000, alreadylogged = 0, iodev = 0; snd_pcm_sframes_t minphase, maxphase, thisphase, outdelay; --- 549,553 ----
/* call this only if both input and output are open */ ! static void alsa_checkiosync() { int result, giveup = 1000, alreadylogged = 0, iodev = 0; snd_pcm_sframes_t minphase, maxphase, thisphase, outdelay;
Index: s_audio_portaudio.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/s_audio_portaudio.c,v retrieving revision 1.1.2.21.2.3 retrieving revision 1.1.2.21.2.4 diff -C2 -d -r1.1.2.21.2.3 -r1.1.2.21.2.4 *** s_audio_portaudio.c 9 Jul 2007 17:51:14 -0000 1.1.2.21.2.3 --- s_audio_portaudio.c 9 Jul 2007 18:16:13 -0000 1.1.2.21.2.4 *************** *** 47,61 **** int pa_initialized = 0;
! void pa_initialize(void) ! { // if (!pa_initialized) // { pa_status = Pa_Initialize(); ! if ( pa_status!= paNoError ) ! { ! fprintf( stderr, ! "Error number %d occured initializing portaudio\n", ! pa_status); ! fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( pa_status ) ); return; } --- 47,57 ---- int pa_initialized = 0;
! void pa_initialize() { // if (!pa_initialized) // { pa_status = Pa_Initialize(); ! if (pa_status!=paNoError) { ! fprintf(stderr, "Error number %d occured initializing portaudio\n", pa_status); ! fprintf(stderr, "Error message: %s\n", Pa_GetErrorText(pa_status)); return; } *************** *** 67,74 **** static float* pa_outbuffer[MAX_PA_CHANS]; static int pa_bufferpos; - static int pddev2padev(int pdindev,int isinput); static int padev2pddev(int padev,int isinput); - int process (const void *input, void *output, unsigned long frameCount, const PaStreamCallbackTimeInfo* timeInfo, --- 63,68 ---- *************** *** 87,117 ****
int pa_open_audio(int inchans, int outchans, int rate, int advance, ! int indeviceno, int outdeviceno, int schedmode) ! { PaError err; - int j; const PaDeviceInfo *pdi,*pdo; - schedmode = 1; /* we don't support blocking io */ - pa_initialize(); - sys_setscheduler(schedmode); - /* post("in %d out %d rate %d device %d", inchans, outchans, rate, deviceno); */ ! if (inchans > MAX_PA_CHANS) ! { post("input channels reduced to maximum %d", MAX_PA_CHANS); inchans = MAX_PA_CHANS; } ! if (outchans > MAX_PA_CHANS) ! { post("output channels reduced to maximum %d", MAX_PA_CHANS); outchans = MAX_PA_CHANS; } - pdi = NULL; ! if (inchans > 0) ! { pa_indev = pddev2padev(indeviceno,1); if(pa_indev >= 0) { --- 81,101 ----
int pa_open_audio(int inchans, int outchans, int rate, int advance, ! int indeviceno, int outdeviceno, int schedmode) { PaError err; const PaDeviceInfo *pdi,*pdo; schedmode = 1; /* we don't support blocking io */ pa_initialize(); sys_setscheduler(schedmode); /* post("in %d out %d rate %d device %d", inchans, outchans, rate, deviceno); */ ! if (inchans > MAX_PA_CHANS) { post("input channels reduced to maximum %d", MAX_PA_CHANS); inchans = MAX_PA_CHANS; } ! if (outchans > MAX_PA_CHANS) { post("output channels reduced to maximum %d", MAX_PA_CHANS); outchans = MAX_PA_CHANS; } pdi = NULL; ! if (inchans > 0) { pa_indev = pddev2padev(indeviceno,1); if(pa_indev >= 0) { *************** *** 121,128 **** } } - pdo = NULL; ! if (outchans > 0) ! { pa_outdev = pddev2padev(outdeviceno,0); if(pa_outdev >= 0) { --- 105,110 ---- } } pdo = NULL; ! if (outchans > 0) { pa_outdev = pddev2padev(outdeviceno,0); if(pa_outdev >= 0) { *************** *** 132,150 **** } } ! ! #ifndef DEBUG ! if (sys_verbose) ! #endif ! { post("input device %d, channels %d", pa_indev, inchans); post("output device %d, channels %d", pa_outdev, outchans); post("latency advance %d", advance); } ! ! if (inchans || outchans) ! { int blocksize; PaStreamParameters inputParameters, outputParameters; - /* initialize input */ inputParameters.device = pa_indev; --- 114,125 ---- } } ! if (sys_verbose) { post("input device %d, channels %d", pa_indev, inchans); post("output device %d, channels %d", pa_outdev, outchans); post("latency advance %d", advance); } ! if (inchans || outchans) { int blocksize; PaStreamParameters inputParameters, outputParameters; /* initialize input */ inputParameters.device = pa_indev; *************** *** 153,157 **** inputParameters.suggestedLatency = advance * 0.001; inputParameters.hostApiSpecificStreamInfo = NULL; - /* initialize output */ outputParameters.device = pa_outdev; --- 128,131 ---- *************** *** 160,171 **** outputParameters.suggestedLatency = advance * 0.001; outputParameters.hostApiSpecificStreamInfo = NULL; - /* set block size */ blocksize=64; while ((float)blocksize/(float)rate*1000*2 < advance && blocksize==1024) blocksize *= 2; pa_blocksize = blocksize; - /* initialize io buffer */ ! for (j=0; j != MAX_PA_CHANS;++j) { if (pa_inbuffer[j]) freealignedbytes(pa_inbuffer[j], 0); if (pa_outbuffer[j]) freealignedbytes(pa_outbuffer[j], 0); --- 134,143 ---- outputParameters.suggestedLatency = advance * 0.001; outputParameters.hostApiSpecificStreamInfo = NULL; /* set block size */ blocksize=64; while ((float)blocksize/(float)rate*1000*2 < advance && blocksize==1024) blocksize *= 2; pa_blocksize = blocksize; /* initialize io buffer */ ! for (int j=0; j != MAX_PA_CHANS;++j) { if (pa_inbuffer[j]) freealignedbytes(pa_inbuffer[j], 0); if (pa_outbuffer[j]) freealignedbytes(pa_outbuffer[j], 0); *************** *** 174,178 **** } pa_bufferpos = 0; - /* report to portaudio */ err = Pa_OpenStream(&pa_stream, --- 146,149 ---- *************** *** 191,195 **** t_symbol *selector1 = gensym("audiocurrentininfo"); t_symbol *selector2 = gensym("audiocurrentoutinfo"); - sys_schedadvance = int(1e-6 * streaminfo->outputLatency);
--- 162,165 ---- *************** *** 209,217 ****
if (err != paNoError) { ! post("Error number %d occured opening portaudio stream\n", ! err); ! post("Error message: %s\n", Pa_GetErrorText( err ) ); sys_inchannels = sys_outchannels = 0; ! pa_indev = int(pa_outdev = -1.f); pa_inchans = pa_outchans = 0; return 1; --- 179,186 ----
if (err != paNoError) { ! post("Error number %d occured opening portaudio stream\n", err); ! post("Error message: %s\n", Pa_GetErrorText(err)); sys_inchannels = sys_outchannels = 0; ! pa_indev = pa_outdev = -1; pa_inchans = pa_outchans = 0; return 1; *************** *** 222,287 **** /* we might have adapted the channel count */ sys_setchsr(inchans, outchans, rate, sys_dacblocksize); - err = Pa_StartStream(pa_stream); ! ! if ( err != paNoError ) ! { ! post("Error number %d occured starting portaudio stream\n", ! err); post("Error message: %s\n", Pa_GetErrorText(err)); sys_inchannels = sys_outchannels = 0; return 1; } - #ifndef DEBUG if(sys_verbose) #endif post("successfully started"); - return 0; }
! ! void sys_peakmeters(void); extern int sys_meters; /* true if we're metering */
#if 0 ! static int patestCallback(const void* inputBuffer, ! void* outputBuffer, ! unsigned long framesPerBuffer, ! const PaStreamCallbackTimeInfo* timeInfo, ! PaStreamCallbackFlags statusFlags, ! void* userData) ! { ! int frameIndex, i; float** outputs = (float**)outputBuffer; static float phase; ! ! for( frameIndex=0; frameIndex<(int)framesPerBuffer; frameIndex++ ) ! { /* Output sine wave on every channel. */ outputs[0][frameIndex] = (float) sin(phase); outputs[1][frameIndex] = (float) sin(phase); phase += 0.05; ! if( phase >= (2.0 * M_PI) ) phase -= (2.0 * M_PI); ! } ! for (i = 0; (unsigned)i != framesPerBuffer / sys_dacblocksize; ++i) ! { sched_tick(sys_time + sys_time_per_dsp_tick); } - return 0; } #endif
! void run_all_idle_callbacks(void); ! void sys_xrun_notification(void); /* in m_sched.c */ ! ! void sys_lock_timeout_notification(void);
int process (const void *input, void *output, unsigned long frameCount, const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void *userData) { - int i; int timeout = int((float)frameCount / (float) sys_dacsr * 1e6); if (statusFlags) sys_xrun_notification(); --- 191,238 ---- /* we might have adapted the channel count */ sys_setchsr(inchans, outchans, rate, sys_dacblocksize); err = Pa_StartStream(pa_stream); ! if (err!=paNoError) { ! post("Error number %d occured starting portaudio stream\n", err); post("Error message: %s\n", Pa_GetErrorText(err)); sys_inchannels = sys_outchannels = 0; return 1; } #ifndef DEBUG if(sys_verbose) #endif post("successfully started"); return 0; }
! void sys_peakmeters(); extern int sys_meters; /* true if we're metering */
#if 0 ! static int patestCallback( ! const void *inputBuffer, void *outputBuffer, ! unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo *timeInfo, ! PaStreamCallbackFlags statusFlags, void *userData) { float** outputs = (float**)outputBuffer; static float phase; ! for (int frameIndex=0; frameIndex<(int)framesPerBuffer; frameIndex++) { /* Output sine wave on every channel. */ outputs[0][frameIndex] = (float) sin(phase); outputs[1][frameIndex] = (float) sin(phase); phase += 0.05; ! if (phase >= 2*M_PI) phase -= 2*M_PI; } ! for (int i=0; (unsigned)i != framesPerBuffer / sys_dacblocksize; ++i) { sched_tick(sys_time + sys_time_per_dsp_tick); } return 0; } #endif
! void run_all_idle_callbacks(); ! void sys_xrun_notification(); /* in m_sched.c */ ! void sys_lock_timeout_notification();
int process (const void *input, void *output, unsigned long frameCount, const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void *userData) { int timeout = int((float)frameCount / (float) sys_dacsr * 1e6); if (statusFlags) sys_xrun_notification(); *************** *** 290,301 **** return 0; } ! for (i = 0; (unsigned)i < frameCount / sys_dacblocksize; ++i) { ! int j; ! for (j = 0; j < sys_inchannels; j++) { t_sample * in = ((t_sample**)input)[j] + i * sys_dacblocksize; copyvec(sys_soundin + j * sys_dacblocksize, 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; copyvec(out, sys_soundout + j * sys_dacblocksize, sys_dacblocksize); --- 241,251 ---- return 0; } ! for (int i=0; (unsigned)i < frameCount / sys_dacblocksize; ++i) { ! for (int j=0; j < sys_inchannels; j++) { t_sample * in = ((t_sample**)input)[j] + i * sys_dacblocksize; copyvec(sys_soundin + j * sys_dacblocksize, in, sys_dacblocksize); } sched_tick(sys_time + sys_time_per_dsp_tick); ! for (int j=0; j < sys_outchannels; j++) { t_sample * out = ((t_sample**)output)[j] + i * sys_dacblocksize; copyvec(out, sys_soundout + j * sys_dacblocksize, sys_dacblocksize); *************** *** 309,313 **** }
! void pa_close_audio(void) { #ifndef DEBUG if(sys_verbose) --- 259,263 ---- }
! void pa_close_audio() { #ifndef DEBUG if(sys_verbose) *************** *** 332,397 ****
/* for blocked IO */ ! int pa_send_dacs(void) { /* we don't support blocking i/o */ return SENDDACS_NO; }
! void pa_listdevs(void) /* lifted from pa_devs.c in portaudio */ ! { ! int i; ! int numDevices; ! PaError err; pa_initialize(); ! ! numDevices = Pa_GetDeviceCount(); ! if( numDevices < 0 ) ! { ! fprintf(stderr, "ERROR: Pa_GetDeviceCount returned %d\n", numDevices ); err = numDevices; goto error; } 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 ); ! if ( i == Pa_GetDefaultInputDevice() ) ! fprintf(stderr, " (Default Input)"); ! if ( i == Pa_GetDefaultOutputDevice() ) ! fprintf(stderr, " (Default Output)"); 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) ! { PaHostApiIndex api = pdi->hostApi; const PaHostApiInfo * info = Pa_GetHostApiInfo (api); --- 282,329 ----
/* for blocked IO */ ! int pa_send_dacs() { /* we don't support blocking i/o */ return SENDDACS_NO; }
! /* lifted from pa_devs.c in portaudio */ ! void pa_listdevs() { ! PaError err; pa_initialize(); ! int numDevices = Pa_GetDeviceCount(); ! if(numDevices < 0) { ! fprintf(stderr, "ERROR: Pa_GetDeviceCount returned %d\n", numDevices); err = numDevices; goto error; } fprintf(stderr, "Audio Devices:\n"); ! for(int 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); ! if (i == Pa_GetDefaultInputDevice()) fprintf(stderr, " (Default Input)"); ! if (i == Pa_GetDefaultOutputDevice()) fprintf(stderr, " (Default Output)"); 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 nin = 0, nout = 0, ndev; *canmulti = 1; /* one dev each for input and output */ pa_initialize(); ndev = Pa_GetDeviceCount(); ! for (int i=0; i<ndev; i++) { const PaDeviceInfo *pdi = Pa_GetDeviceInfo(i); ! if (pdi->maxInputChannels > 0 && nin < maxndev) { PaHostApiIndex api = pdi->hostApi; const PaHostApiInfo * info = Pa_GetHostApiInfo (api); *************** *** 403,408 **** nin++; } ! if (pdi->maxOutputChannels > 0 && nout < maxndev) ! { PaHostApiIndex api = pdi->hostApi; const PaHostApiInfo * info = Pa_GetHostApiInfo (api); --- 335,339 ---- nin++; } ! if (pdi->maxOutputChannels > 0 && nout < maxndev) { PaHostApiIndex api = pdi->hostApi; const PaHostApiInfo * info = Pa_GetHostApiInfo (api); *************** *** 410,414 **** unsigned int apiNameLen = strlen(apiName); strcpy(outdevlist + nout * devdescsize, apiName); - outdevlist[nout * devdescsize + apiNameLen] = '/'; strcpy(outdevlist + nout * devdescsize + apiNameLen + 1, pdi->name); --- 341,344 ---- *************** *** 420,435 **** }
! void pa_getaudioininfo(t_float f) ! { int i = pddev2padev((int)f,1); ! const PaDeviceInfo * pdi; ! pa_initialize(); ! pdi = Pa_GetDeviceInfo (i); ! ! if (pdi) ! { ! t_symbol * selector = gensym("audioininfo"); ! t_symbol * pd = gensym("pd"); t_atom argv[4]; SETFLOAT(argv, pdi->maxInputChannels); --- 350,361 ---- }
! void pa_getaudioininfo(t_float f) { int i = pddev2padev((int)f,1); ! const PaDeviceInfo *pdi; pa_initialize(); ! pdi = Pa_GetDeviceInfo(i); ! if (pdi) { ! t_symbol *selector = gensym("audioininfo"); ! t_symbol *pd = gensym("pd"); t_atom argv[4]; SETFLOAT(argv, pdi->maxInputChannels); *************** *** 441,456 **** }
! void pa_getaudiooutinfo(t_float f) ! { int i = pddev2padev((int)f,0); ! const PaDeviceInfo * pdi; ! pa_initialize(); ! pdi = Pa_GetDeviceInfo (i); ! ! if (pdi) ! { ! t_symbol * selector = gensym("audiooutinfo"); ! t_symbol * pd = gensym("pd"); t_atom argv[4]; SETFLOAT(argv, pdi->maxOutputChannels); --- 367,378 ---- }
! void pa_getaudiooutinfo(t_float f) { int i = pddev2padev((int)f,0); ! const PaDeviceInfo *pdi; pa_initialize(); ! pdi = Pa_GetDeviceInfo(i); ! if (pdi) { ! t_symbol *selector = gensym("audiooutinfo"); ! t_symbol *pd = gensym("pd"); t_atom argv[4]; SETFLOAT(argv, pdi->maxOutputChannels); *************** *** 462,468 **** }
! void pa_getcurrent_devices(void) { ! t_symbol * pd = gensym("pd"); ! t_symbol * selector = gensym("audiodevice"); t_atom argv[2]; SETFLOAT(argv, padev2pddev(pa_indev,1)); --- 384,390 ---- }
! void pa_getcurrent_devices() { ! t_symbol *pd = gensym("pd"); ! t_symbol *selector = gensym("audiodevice"); t_atom argv[2]; SETFLOAT(argv, padev2pddev(pa_indev,1)); *************** *** 487,491 **** int ret; PaStreamParameters inputParameters, outputParameters; - inputParameters.device = indev; inputParameters.channelCount = inchans; --- 409,412 ---- *************** *** 493,497 **** inputParameters.suggestedLatency = advance * 0.001; inputParameters.hostApiSpecificStreamInfo = NULL; - outputParameters.device = outdev; outputParameters.channelCount = outchans; --- 414,417 ---- *************** *** 499,505 **** outputParameters.suggestedLatency = advance * 0.001; outputParameters.hostApiSpecificStreamInfo = NULL; - ret = Pa_IsFormatSupported(&inputParameters, &outputParameters, samplerate); - SETFLOAT(argv, ret == paNoError?1:0); typedmess(pd->s_thing, selector, 1, argv); --- 419,423 ---- *************** *** 508,515 ****
static int pddev2padev(int pddev,int input) { - int j; - int devno; pa_initialize(); ! for (j = 0, devno = 0; j < Pa_GetDeviceCount(); j++) { const PaDeviceInfo *info = Pa_GetDeviceInfo(j); int maxchans = input?info->maxInputChannels:info->maxOutputChannels; --- 426,431 ----
static int pddev2padev(int pddev,int input) { pa_initialize(); ! for (int j=0, devno=0; j < Pa_GetDeviceCount(); j++) { const PaDeviceInfo *info = Pa_GetDeviceInfo(j); int maxchans = input?info->maxInputChannels:info->maxOutputChannels; *************** *** 522,535 **** }
! static int padev2pddev(int padev,int input) ! { ! int j,devno; int count = Pa_GetDeviceCount(); ! for (j = 0, devno = 0; j < count; j++) ! { const PaDeviceInfo *info = Pa_GetDeviceInfo(j); int chans = input?info->maxInputChannels:info->maxOutputChannels; ! if (chans > 0) ! { if(j == padev) return devno; devno++; --- 438,447 ---- }
! static int padev2pddev(int padev,int input) { int count = Pa_GetDeviceCount(); ! for (int j=0, devno=0; j < count; j++) { const PaDeviceInfo *info = Pa_GetDeviceInfo(j); int chans = input?info->maxInputChannels:info->maxOutputChannels; ! if (chans > 0) { if(j == padev) return devno; devno++; *************** *** 539,572 **** }
! void pa_get_asio_latencies(t_float f) ! { int index = pddev2padev((int)f,0); const PaDeviceInfo *pdi = Pa_GetDeviceInfo(index); const PaHostApiInfo *phi = Pa_GetHostApiInfo(pdi->hostApi); ! if (phi->type != 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 - }
--- 451,476 ---- }
! void pa_get_asio_latencies(t_float f) { int index = pddev2padev((int)f,0); const PaDeviceInfo *pdi = Pa_GetDeviceInfo(index); const PaHostApiInfo *phi = Pa_GetHostApiInfo(pdi->hostApi); ! if (phi->type != 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 }