From: <do...@us...> - 2007-10-01 05:23:08
|
Revision: 1162 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1162&view=rev Author: dohpaz Date: 2007-09-30 22:23:11 -0700 (Sun, 30 Sep 2007) Log Message: ----------- See any operating system documentation about shared libraries for Improved handling of aux device for ring in portable audio. + Don't assume that just because the output device uses virtual mono (stereo) that the ring output device will. + Start out trying to open the ring device as mono, then fall back to stereo + Don't specify an input device (pass in NULL as per PortAudio V19 docs). + Properly handle virtual mono in pa_aux_callback. Modified Paths: -------------- trunk/lib/audio_portaudio.c Modified: trunk/lib/audio_portaudio.c =================================================================== --- trunk/lib/audio_portaudio.c 2007-09-26 20:11:06 UTC (rev 1161) +++ trunk/lib/audio_portaudio.c 2007-10-01 05:23:11 UTC (rev 1162) @@ -131,6 +131,7 @@ static int auxStream; static int virtualMonoIn; static int virtualMonoOut; +static int virtualMonoRing; static int running; @@ -227,12 +228,12 @@ } } -static void mix_slin(short *dst, short *src, int samples) +static void mix_slin(short *dst, short *src, int samples, int virtualMono) { int i=0,val=0; for ( i=0; i < samples; i++ ) { - if ( virtualMonoOut ) + if ( virtualMono ) val = ((short *)dst)[2*i] + ((short *)src)[i]; else val = ((short *)dst)[i] + ((short *)src)[i]; @@ -245,7 +246,7 @@ val = -0x7fff+1; } - if ( virtualMonoOut ) + if ( virtualMono ) { dst[2*i] = val; dst[2*i+1] = val; @@ -257,7 +258,7 @@ } } -static int pa_mix_sounds (void *outputBuffer, unsigned long frames, int channel) +static int pa_mix_sounds (void *outputBuffer, unsigned long frames, int channel, int virtualMono) { struct iaxc_sound *s; struct iaxc_sound **sp; @@ -305,7 +306,7 @@ /* mix in the frames */ mix_slin((short *)outputBuffer + outpos, - s->data+s->pos, n); + s->data+s->pos, n, virtualMono); s->pos += n; outpos += n; @@ -497,10 +498,10 @@ /* zero underflowed space [ silence might be more golden * than garbage? ] */ - pa_mix_sounds(outputBuffer, samplesPerFrame, 0); + pa_mix_sounds(outputBuffer, samplesPerFrame, 0, virtualMonoOut); if(!auxStream) - pa_mix_sounds(outputBuffer, samplesPerFrame, 1); + pa_mix_sounds(outputBuffer, samplesPerFrame, 1, virtualMonoOut); } @@ -535,13 +536,12 @@ PaStreamCallbackFlags statusFlags, void *userData) { - int totBytes = samplesPerFrame * sizeof(SAMPLE); + int totBytes = samplesPerFrame * sizeof(SAMPLE) * (virtualMonoRing + 1); - /* XXX: need to handle virtualMonoOut case!!! */ if ( outputBuffer ) { memset((char *)outputBuffer, 0, totBytes); - pa_mix_sounds(outputBuffer, samplesPerFrame, 1); + pa_mix_sounds(outputBuffer, samplesPerFrame, 1, virtualMonoRing); } return 0; } @@ -680,36 +680,20 @@ { PaError err; - /* FEEDBACK - iaxclient seems to assume that the ring device is a - * mono device. I can't find any mono devices on the Mac and so - * ring device opening will fail. My code assumes the ring device - * is a stereo device - this might break stuff */ - struct PaStreamParameters ring_stream_params, no_device; + struct PaStreamParameters ring_stream_params; - struct PaStreamParameters in_stream_params; - in_stream_params.device = selectedInput; - in_stream_params.channelCount = virtualMonoOut + 1; - in_stream_params.sampleFormat = paInt16; - in_stream_params.suggestedLatency = - Pa_GetDeviceInfo(selectedInput)->defaultLowInputLatency; - in_stream_params.hostApiSpecificStreamInfo = NULL; - + // setup the ring parameters ring_stream_params.device = selectedRing; - ring_stream_params.channelCount = virtualMonoOut+1; ring_stream_params.sampleFormat = paInt16; ring_stream_params.suggestedLatency = Pa_GetDeviceInfo(selectedRing)->defaultLowOutputLatency; ring_stream_params.hostApiSpecificStreamInfo = NULL; - no_device.device = paNoDevice; - no_device.channelCount = 0; - no_device.sampleFormat = paInt16; - no_device.suggestedLatency = - Pa_GetDeviceInfo(selectedInput)->defaultLowInputLatency; //TODOC - no_device.hostApiSpecificStreamInfo = NULL; + // first we'll try mono + ring_stream_params.channelCount = 1; err = Pa_OpenStream ( &aStream, - &in_stream_params, + NULL, &ring_stream_params, sample_rate, paFramesPerBufferUnspecified, //FEEBACK - unsure if appropriate @@ -719,28 +703,33 @@ if ( err != paNoError ) { - /* FEEDBACK, we try one more time, maybe ring device is a mono - * output device */ - err = Pa_OpenStream ( &aStream, - &no_device, + // next we'll try virtual mono (stereo) + ring_stream_params.channelCount = 1; + + err = Pa_OpenStream ( &aStream, + NULL, &ring_stream_params, sample_rate, paFramesPerBufferUnspecified, //FEEBACK - unsure if appropriate - paNoFlag, /* flags */ + paNoFlag, (PaStreamCallback *)pa_aux_callback, NULL); + } // mmok, failure... if ( err != paNoError ) { - //fprintf(stderr, "Failure opening ring device with params: id: %d, output %d, default output %d\n", - //selectedRing, selectedOutput, Pa_GetDefaultOutputDevice()); + // fprintf(stderr, "Failure opening ring device with params: id: %d, output %d, default output %d\n", + // selectedRing, selectedOutput, Pa_GetDefaultOutputDevice()); handle_paerror(err, "opening separate ring stream"); return -1; } + // Determine whether virtual mono is being used + virtualMonoRing = ring_stream_params.channelCount - 1; + return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpg...@us...> - 2007-10-03 21:13:45
|
Revision: 1176 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1176&view=rev Author: jpgrayson Date: 2007-10-03 14:13:49 -0700 (Wed, 03 Oct 2007) Log Message: ----------- Whitespace. Modified Paths: -------------- trunk/lib/audio_portaudio.c Modified: trunk/lib/audio_portaudio.c =================================================================== --- trunk/lib/audio_portaudio.c 2007-10-03 19:26:45 UTC (rev 1175) +++ trunk/lib/audio_portaudio.c 2007-10-03 21:13:49 UTC (rev 1176) @@ -692,7 +692,7 @@ // first we'll try mono ring_stream_params.channelCount = 1; - err = Pa_OpenStream ( &aStream, + err = Pa_OpenStream(&aStream, NULL, &ring_stream_params, sample_rate, @@ -703,10 +703,10 @@ if ( err != paNoError ) { - // next we'll try virtual mono (stereo) - ring_stream_params.channelCount = 1; + // next we'll try virtual mono (stereo) + ring_stream_params.channelCount = 1; - err = Pa_OpenStream ( &aStream, + err = Pa_OpenStream(&aStream, NULL, &ring_stream_params, sample_rate, @@ -714,14 +714,13 @@ paNoFlag, (PaStreamCallback *)pa_aux_callback, NULL); - } // mmok, failure... if ( err != paNoError ) { - // fprintf(stderr, "Failure opening ring device with params: id: %d, output %d, default output %d\n", - // selectedRing, selectedOutput, Pa_GetDefaultOutputDevice()); + // fprintf(stderr, "Failure opening ring device with params: id: %d, output %d, default output %d\n", + // selectedRing, selectedOutput, Pa_GetDefaultOutputDevice()); handle_paerror(err, "opening separate ring stream"); return -1; @@ -756,7 +755,8 @@ if ( errcnt > 5 ) { iaxci_usermsg(IAXC_TEXT_TYPE_FATALERROR, - "iaxclient audio: Can't open Audio Device. Perhaps you do not have an input or output device?"); + "iaxclient audio: Can't open Audio Device. " + "Perhaps you do not have an input or output device?"); /* OK, we'll give the application the option to abort or * not here, but we will throw a fatal error anyway */ iaxc_millisleep(1000); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sb...@us...> - 2007-10-30 18:16:49
|
Revision: 1241 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1241&view=rev Author: sbalea Date: 2007-10-30 11:16:53 -0700 (Tue, 30 Oct 2007) Log Message: ----------- Fix memory leak in PortAudio destroy. PortMixer stuff needs cleaning too. Patch provided by Teri Schoech and enhanced by me. Modified Paths: -------------- trunk/lib/audio_portaudio.c Modified: trunk/lib/audio_portaudio.c =================================================================== --- trunk/lib/audio_portaudio.c 2007-10-30 17:54:55 UTC (rev 1240) +++ trunk/lib/audio_portaudio.c 2007-10-30 18:16:53 UTC (rev 1241) @@ -958,6 +958,24 @@ static int pa_destroy(struct iaxc_audio_driver *d) { + if( iMixer ) + { + Px_CloseMixer(iMixer); + iMixer = NULL; + } + if ( oMixer ) + { + Px_CloseMixer(oMixer); + oMixer = NULL; + } + if ( d ) + { + if ( d->devices ) + { + free(d->devices); + d->devices= NULL; + } + } return Pa_Terminate(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <do...@us...> - 2007-11-22 00:09:47
|
Revision: 1280 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1280&view=rev Author: dohpaz Date: 2007-11-21 16:09:52 -0800 (Wed, 21 Nov 2007) Log Message: ----------- Merge over fix from /branches/team/elbunce/iaxclient. Make sure to stop/start the audio devices in pa when selecting new devices and the audio isn't running. This fixes a bug where mixer level get/set would operate on the previously selected devices (usually system default at startup) instead of the devices people intend to set. Modified Paths: -------------- trunk/lib/audio_portaudio.c Modified: trunk/lib/audio_portaudio.c =================================================================== --- trunk/lib/audio_portaudio.c 2007-11-21 23:53:32 UTC (rev 1279) +++ trunk/lib/audio_portaudio.c 2007-11-22 00:09:52 UTC (rev 1280) @@ -941,9 +941,16 @@ selectedRing = ring; if ( running ) { + /* stop/start audio, in order to switch devices */ pa_stop(d); pa_start(d); } + else + { + /* start/stop audio, in order to initialize mixers and levels */ + pa_start(d); + pa_stop(d); + } return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bc...@us...> - 2008-01-24 20:15:53
|
Revision: 1333 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1333&view=rev Author: bcholew Date: 2008-01-24 12:15:59 -0800 (Thu, 24 Jan 2008) Log Message: ----------- Distinguish between speex-specific and echo-cancellation-generic code. Modified Paths: -------------- trunk/lib/audio_portaudio.c Modified: trunk/lib/audio_portaudio.c =================================================================== --- trunk/lib/audio_portaudio.c 2008-01-24 19:10:01 UTC (rev 1332) +++ trunk/lib/audio_portaudio.c 2008-01-24 20:15:59 UTC (rev 1333) @@ -38,16 +38,19 @@ #include "portmixer.h" #ifdef USE_MEC2 +#define DO_EC #include "mec3.h" static echo_can_state_t *ec; #endif #ifdef SPAN_EC +#define DO_EC #include "ec/echo.h" static echo_can_state_t *ec; #endif -#ifdef SPEEX_EC +#if defined(SPEEX_EC) && ! defined (WIN32) +#define DO_EC #define restrict __restrict #include "speex/speex_echo.h" static SpeexEchoState *ec; @@ -390,15 +393,16 @@ * it's turned back on. */ if ( !(iaxc_get_filters() & IAXC_FILTER_ECHO) ) { -#if defined(SPEEX_EC) +#if defined(DO_EC) if ( ec ) { #if defined(USE_MEC2) || defined(SPAN_EC) echo_can_free(ec); ec = NULL; -#endif +#elif defined(SPEEX_EC) speex_echo_state_destroy(ec); ec = NULL; +#endif } #endif @@ -407,14 +411,15 @@ /* we want echo cancellation */ -#if defined(SPEEX_EC) +#if defined(DO_EC) if ( !ec ) { rb_InitializeRingBuffer(&ecOutRing, EC_RING_SZ, &outRingBuf); #if defined(USE_MEC2) || defined(SPAN_EC) ec = echo_can_create(ECHO_TAIL, 0); +#elif defined(SPEEX_EC) + ec = speex_echo_state_init(SAMPLES_PER_FRAME, ECHO_TAIL); #endif - ec = speex_echo_state_init(SAMPLES_PER_FRAME, ECHO_TAIL); } #endif @@ -428,7 +433,7 @@ rb_ReadRingBuffer(&ecOutRing, delayedBuf, n * 2); -#if defined(SPEEX_EC) +#if defined(DO_EC) && defined(SPEEX_EC) { short cancelledBuffer[1024]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpg...@us...> - 2008-04-15 22:20:35
|
Revision: 1408 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1408&view=rev Author: jpgrayson Date: 2008-04-15 15:20:42 -0700 (Tue, 15 Apr 2008) Log Message: ----------- Print warning messages when portaudio reports audio under/overflow. Modified Paths: -------------- trunk/lib/audio_portaudio.c Modified: trunk/lib/audio_portaudio.c =================================================================== --- trunk/lib/audio_portaudio.c 2008-04-15 22:19:33 UTC (rev 1407) +++ trunk/lib/audio_portaudio.c 2008-04-15 22:20:42 UTC (rev 1408) @@ -212,7 +212,6 @@ static void mono2stereo(SAMPLE *out, SAMPLE *in, int nSamples) { int i; - //fprintf(stderr, "mono2stereo: %d samples\n", nSamples); for ( i=0; i < nSamples; i++ ) { *(out++) = *in; @@ -223,12 +222,11 @@ static void stereo2mono(SAMPLE *out, SAMPLE *in, int nSamples) { int i; - //fprintf(stderr, "stereo2mono: %d samples\n", nSamples); for ( i=0; i < nSamples; i++ ) { *(out) = *(in++); - out++; in++; - //*(out++) += *(in++); + out++; + in++; } } @@ -262,7 +260,8 @@ } } -static int pa_mix_sounds (void *outputBuffer, unsigned long frames, int channel, int virtualMono) +static int pa_mix_sounds (void *outputBuffer, unsigned long frames, + int channel, int virtualMono) { struct iaxc_sound *s; struct iaxc_sound **sp; @@ -470,30 +469,43 @@ exit(1); } #endif + if ( statusFlags & paOutputUnderflow ) + fprintf(stderr, "WARNING: Output Underflow detected\n"); + if ( statusFlags & paInputUnderflow ) + fprintf(stderr, "WARNING: Input Underflow detected\n"); + if ( statusFlags & paOutputOverflow ) + fprintf(stderr, "WARNING: Output Overflow detected\n"); + if ( statusFlags & paInputOverflow ) + fprintf(stderr, "WARNING: Input Overflow detected\n"); if ( outputBuffer ) { int bWritten; /* output underflow might happen here */ - if (virtualMonoOut) + if ( virtualMonoOut ) { bWritten = rb_ReadRingBuffer(&outRing, virtualOutBuffer, totBytes); - /* we zero "virtualOutBuffer", then convert the whole thing, - * yes, because we use virtualOutBuffer for ec below */ + + /* we zero "virtualOutBuffer", then convert the whole + * thing, yes, because we use virtualOutBuffer for ec + * below */ if ( bWritten < totBytes ) { - memset(((char *)virtualOutBuffer) + bWritten, - 0, totBytes - bWritten); + memset((char *)virtualOutBuffer + bWritten, 0, + totBytes - bWritten); //fprintf(stderr, "*U*"); } + mono2stereo((SAMPLE *)outputBuffer, virtualOutBuffer, samplesPerFrame); } else { - bWritten = rb_ReadRingBuffer(&outRing, outputBuffer, totBytes); - if ( bWritten < totBytes) + bWritten = rb_ReadRingBuffer(&outRing, outputBuffer, + totBytes); + + if ( bWritten < totBytes ) { memset((char *)outputBuffer + bWritten, 0, totBytes - bWritten); @@ -506,8 +518,9 @@ pa_mix_sounds(outputBuffer, samplesPerFrame, 0, virtualMonoOut); - if(!auxStream) - pa_mix_sounds(outputBuffer, samplesPerFrame, 1, virtualMonoOut); + if ( !auxStream ) + pa_mix_sounds(outputBuffer, samplesPerFrame, 1, + virtualMonoOut); } @@ -696,7 +709,7 @@ ring_stream_params.hostApiSpecificStreamInfo = NULL; // first we'll try mono - ring_stream_params.channelCount = 1; + ring_stream_params.channelCount = 1; err = Pa_OpenStream(&aStream, NULL, @@ -710,7 +723,7 @@ if ( err != paNoError ) { // next we'll try virtual mono (stereo) - ring_stream_params.channelCount = 1; + ring_stream_params.channelCount = 1; err = Pa_OpenStream(&aStream, NULL, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpg...@us...> - 2008-04-15 22:38:21
|
Revision: 1412 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1412&view=rev Author: jpgrayson Date: 2008-04-15 15:38:26 -0700 (Tue, 15 Apr 2008) Log Message: ----------- Add const qualifier to some functions. Modified Paths: -------------- trunk/lib/audio_portaudio.c Modified: trunk/lib/audio_portaudio.c =================================================================== --- trunk/lib/audio_portaudio.c 2008-04-15 22:33:37 UTC (rev 1411) +++ trunk/lib/audio_portaudio.c 2008-04-15 22:38:26 UTC (rev 1412) @@ -209,7 +209,7 @@ return 0; } -static void mono2stereo(SAMPLE *out, SAMPLE *in, int nSamples) +static void mono2stereo(SAMPLE *out, const SAMPLE *in, int nSamples) { int i; for ( i=0; i < nSamples; i++ ) @@ -219,7 +219,7 @@ } } -static void stereo2mono(SAMPLE *out, SAMPLE *in, int nSamples) +static void stereo2mono(SAMPLE *out, const SAMPLE *in, int nSamples) { int i; for ( i=0; i < nSamples; i++ ) @@ -451,7 +451,7 @@ #endif } -static int pa_callback(void *inputBuffer, void *outputBuffer, +static int pa_callback(const void *inputBuffer, void *outputBuffer, unsigned long samplesPerFrame, const PaStreamCallbackTimeInfo* outTime, PaStreamCallbackFlags statusFlags, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |