From: <st...@us...> - 2003-06-20 23:38:28
|
Update of /cvsroot/iaxclient/iaxclient/lib In directory sc8-pr-cvs1:/tmp/cvs-serv23843 Modified Files: audio_portaudio.c Log Message: take 2. notes inside. Oh the pains of unix/oss :( Index: audio_portaudio.c =================================================================== RCS file: /cvsroot/iaxclient/iaxclient/lib/audio_portaudio.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- audio_portaudio.c 20 Jun 2003 23:09:04 -0000 1.10 +++ audio_portaudio.c 20 Jun 2003 23:38:25 -0000 1.11 @@ -74,13 +74,32 @@ } } + +/* some commentaty here: + * 1: MacOSX: MacOSX needs "virtual mono" and a single stream. That's + * really the only choice there, and it should always work (Famous last + * words). + * + * 2: Unix/OSS: most cards are OK with real mono, and a single stream. + * Except some. For those, a single open with real mono will succeed, + * but execution will fail. Maybe others will open OK with a single + * stream, and real mono, but fail later? + * + * The failure mode I saw with a volunteer was that reads/writes would + * return -enodev (down in the portaudio code). Bummer. + * + * Win32 works fine, in all cases, with a single stream and real mono, + * so far. + * */ + int pa_initialize_audio() { PaError err; -//#if 0 -#ifndef MACOSX /* Open simplified blocking I/O layer on top of PortAudio. */ + +#ifndef MACOSX /* first, try opening one stream for in/out, Mono */ + /* except for MacOSX, which needs virtual stereo */ err = OpenAudioStream( &iStream, SAMPLE_RATE, paInt16, (PABLIO_READ | PABLIO_WRITE | PABLIO_MONO) ); @@ -93,8 +112,9 @@ } #endif - /* Open simplified blocking I/O layer on top of PortAudio. */ - /* first, try opening one stream for in/out, Mono */ +#ifndef LINUX + /* then, we try a single stream, virtual stereo. Except on linux, + * see note above */ err = OpenAudioStream( &iStream, SAMPLE_RATE, paInt16, (PABLIO_READ | PABLIO_WRITE | PABLIO_STEREO) ); @@ -105,22 +125,25 @@ virtualMono = 1; return 0; } +#endif -#if TRY_TWO_OPENS + /* finally, we go to the worst case. Two opens, virtual mono */ oneStream = 0; + virtualMono = 1; err = OpenAudioStream( &iStream, SAMPLE_RATE, paInt16, - (PABLIO_READ | PABLIO_MONO) ); + (PABLIO_READ | PABLIO_STEREO) ); + if( err != paNoError ) { handle_paerror(err, "opening separate input stream"); return -1; } err = OpenAudioStream( &oStream, SAMPLE_RATE, paInt16, - (PABLIO_READ | PABLIO_MONO) ); + (PABLIO_WRITE | PABLIO_STEREO) ); + if( err != paNoError ) { handle_paerror(err, "opening separate output stream"); return -1; } -#endif return 0; } |