Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12281/src
Modified Files: Tag: devel_0_39 s_audio_portaudio.c Log Message: fixes for portaudio device indices
Index: s_audio_portaudio.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/s_audio_portaudio.c,v retrieving revision 1.1.2.17 retrieving revision 1.1.2.18 diff -C2 -d -r1.1.2.17 -r1.1.2.18 *** s_audio_portaudio.c 5 Aug 2006 19:03:59 -0000 1.1.2.17 --- s_audio_portaudio.c 7 Aug 2006 17:18:07 -0000 1.1.2.18 *************** *** 68,73 **** static int pa_bufferpos;
! static int pdindev2paindev(int pdindev); ! static int pdoutdev2paoutdev(int pdoutdev);
int process (const void *input, void *output, unsigned long frameCount, --- 68,73 ---- 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, *************** *** 89,92 **** --- 89,93 ---- PaError err; int j, devno; + const PaDeviceInfo *pdi,*pdo;
schedmode = 1; /* we don't support blocking io */ *************** *** 108,148 **** }
if (inchans > 0) { ! for (j = 0, devno = 0; j < Pa_GetDeviceCount(); j++) ! { ! const PaDeviceInfo *info = Pa_GetDeviceInfo(j); ! int maxchans = info->maxInputChannels; ! if (maxchans > 0) ! { ! if (devno == indeviceno) ! { ! if (maxchans < inchans) ! inchans = maxchans; ! pa_indev = j; ! break; ! } ! devno++; ! } } }
if (outchans > 0) { ! for (j = 0, devno = 0; j < Pa_GetDeviceCount(); j++) ! { ! const PaDeviceInfo *info = Pa_GetDeviceInfo(j); ! int maxchans = info->maxOutputChannels; ! if (maxchans > 0) ! { ! if (devno == outdeviceno) ! { ! if (maxchans < outchans) ! outchans = maxchans; ! pa_outdev = j; ! break; ! } ! devno++; ! } } } --- 109,131 ---- }
+ pdi = NULL; if (inchans > 0) { ! pa_indev = pddev2padev(indeviceno,1); ! if(pa_indev >= 0) { ! pdi = Pa_GetDeviceInfo(pa_indev); ! if(pdi->maxInputChannels < inchans) ! inchans = pdi->maxInputChannels; } }
+ pdo = NULL; if (outchans > 0) { ! pa_outdev = pddev2padev(outdeviceno,0); ! if(pa_outdev >= 0) { ! pdo = Pa_GetDeviceInfo(pa_outdev); ! if(pdo->maxOutputChannels < outchans) ! outchans = pdo->maxOutputChannels; } } *************** *** 160,166 **** PaStreamParameters inputParameters, outputParameters;
- const PaDeviceInfo* pdi = Pa_GetDeviceInfo(pa_indev); - const PaDeviceInfo* pdo = Pa_GetDeviceInfo(pa_outdev); - /* initialize input */ inputParameters.device = pa_indev; --- 143,146 ---- *************** *** 218,222 **** sys_schedadvance = 1e-6 * streaminfo->outputLatency;
! SETFLOAT(atoms, (float)pa_indev); SETFLOAT(atoms+1, (float)inchans); SETFLOAT(atoms+2, (float)rate); --- 198,202 ---- sys_schedadvance = 1e-6 * streaminfo->outputLatency;
! SETFLOAT(atoms, (float)indeviceno); SETFLOAT(atoms+1, (float)inchans); SETFLOAT(atoms+2, (float)rate); *************** *** 224,228 **** typedmess(pd->s_thing, selector1, 4, atoms);
! SETFLOAT(atoms, (float)pa_outdev); SETFLOAT(atoms+1, (float)outchans); SETFLOAT(atoms+2, (float)rate); --- 204,208 ---- typedmess(pd->s_thing, selector1, 4, atoms);
! SETFLOAT(atoms, (float)outdeviceno); SETFLOAT(atoms+1, (float)outchans); SETFLOAT(atoms+2, (float)rate); *************** *** 479,483 **** void pa_getaudioininfo(t_float f) { ! int i = pdindev2paindev((int)f); const PaDeviceInfo * pdi;
--- 459,463 ---- void pa_getaudioininfo(t_float f) { ! int i = pddev2padev((int)f,1); const PaDeviceInfo * pdi;
*************** *** 500,504 **** void pa_getaudiooutinfo(t_float f) { ! int i = pdoutdev2paoutdev((int)f); const PaDeviceInfo * pdi;
--- 480,484 ---- void pa_getaudiooutinfo(t_float f) { ! int i = pddev2padev((int)f,0); const PaDeviceInfo * pdi;
*************** *** 524,529 **** t_symbol * selector = gensym("audiodevice"); t_atom argv[2]; ! SETFLOAT(argv, pa_indev); ! SETFLOAT(argv+1, pa_outdev); typedmess(pd->s_thing, selector, 2, argv); } --- 504,509 ---- t_symbol * selector = gensym("audiodevice"); t_atom argv[2]; ! SETFLOAT(argv, padev2pddev(pa_indev,1)); ! SETFLOAT(argv+1, padev2pddev(pa_outdev,0)); typedmess(pd->s_thing, selector, 2, argv); } *************** *** 543,548 **** pa_initialize();
! indev = pdindev2paindev(indev); ! outdev = pdoutdev2paoutdev(outdev);
if ((pa_indev == -1) && (pa_outdev == -1)) --- 523,528 ---- pa_initialize();
! indev = pddev2padev(indev,1); ! outdev = pddev2padev(outdev,0);
if ((pa_indev == -1) && (pa_outdev == -1)) *************** *** 570,574 **** }
! static int pdindev2paindev(int pdindev) { int j; --- 550,554 ---- }
! static int pddev2padev(int pddev,int input) { int j; *************** *** 579,586 **** { const PaDeviceInfo *info = Pa_GetDeviceInfo(j); ! int maxchans = info->maxInputChannels; if (maxchans > 0) { ! if (devno == pdindev) { return j; --- 559,566 ---- { const PaDeviceInfo *info = Pa_GetDeviceInfo(j); ! int maxchans = input?info->maxInputChannels:info->maxOutputChannels; if (maxchans > 0) { ! if (devno == pddev) { return j; *************** *** 593,617 **** }
! static int pdoutdev2paoutdev(int pdoutdev) { ! int j; ! int devno; ! pa_initialize(); ! ! for (j = 0, devno = 0; j < Pa_GetDeviceCount(); j++) { const PaDeviceInfo *info = Pa_GetDeviceInfo(j); ! int maxchans = info->maxOutputChannels; ! if (maxchans > 0) { ! if (devno == pdoutdev) ! { ! return j; ! } devno++; } } ! ! return -1; }
--- 573,591 ---- }
! 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++; } } ! return -1; // no found }