From: <jpg...@us...> - 2008-04-24 17:52:45
|
Revision: 1425 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1425&view=rev Author: jpgrayson Date: 2008-04-24 10:52:51 -0700 (Thu, 24 Apr 2008) Log Message: ----------- Merge some cleanups from the echo cancellation branch into trunk. Modified Paths: -------------- trunk/lib/audio_encode.c trunk/lib/audio_encode.h trunk/lib/audio_portaudio.c trunk/lib/iaxclient_lib.c Modified: trunk/lib/audio_encode.c =================================================================== --- trunk/lib/audio_encode.c 2008-04-24 17:15:57 UTC (rev 1424) +++ trunk/lib/audio_encode.c 2008-04-24 17:52:51 UTC (rev 1425) @@ -34,6 +34,8 @@ static float input_level = 0.0f; static float output_level = 0.0f; +int iaxci_sample_rate = 8000; + static SpeexPreprocessState *st = NULL; static int speex_state_size = 0; static int speex_state_rate = 0; @@ -408,3 +410,12 @@ set_speex_filters(); } +int audio_initialize() +{ + return 0; +} + +int audio_destroy() +{ + return 0; +} Modified: trunk/lib/audio_encode.h =================================================================== --- trunk/lib/audio_encode.h 2008-04-24 17:15:57 UTC (rev 1424) +++ trunk/lib/audio_encode.h 2008-04-24 17:52:51 UTC (rev 1425) @@ -15,6 +15,8 @@ #ifndef _AUDIO_ENCODE_H #define _AUDIO_ENCODE_H +extern int iaxci_sample_rate; + /* Minimum dB possible in the iaxclient world. This level * is intended to represent silence. */ @@ -33,6 +35,9 @@ struct iaxc_call; struct iax_event; +int audio_initialize(); +int audio_destroy(); + int audio_send_encoded_audio(struct iaxc_call * most_recent_answer, int callNo, void * data, int iEncodeType, int samples); Modified: trunk/lib/audio_portaudio.c =================================================================== --- trunk/lib/audio_portaudio.c 2008-04-24 17:15:57 UTC (rev 1424) +++ trunk/lib/audio_portaudio.c 2008-04-24 17:52:51 UTC (rev 1425) @@ -33,6 +33,7 @@ #endif #include "audio_portaudio.h" +#include "audio_encode.h" #include "iaxclient_lib.h" #include "ringbuffer.h" #include "portmixer.h" @@ -58,7 +59,6 @@ #define EC_RING_SZ 8192 /* must be pow(2) */ - typedef short SAMPLE; static PaStream *iStream, *oStream, *aStream; @@ -66,15 +66,13 @@ static int selectedInput, selectedOutput, selectedRing; -static int sample_rate = 8000; static int mixers_initialized; - #define MAX_SAMPLE_RATE 48000 #ifndef MS_PER_FRAME -# define MS_PER_FRAME 40 +# define MS_PER_FRAME 20 #endif -#define SAMPLES_PER_FRAME (MS_PER_FRAME * sample_rate / 1000) +#define SAMPLES_PER_FRAME (MS_PER_FRAME * iaxci_sample_rate / 1000) /* static frame buffer allocation */ #define MAX_SAMPLES_PER_FRAME (MS_PER_FRAME * MAX_SAMPLE_RATE / 1000) @@ -124,11 +122,12 @@ #endif /* size in bytes of ringbuffer target */ -#define RBOUTTARGET_BYTES (RBOUTTARGET * (sample_rate / 1000) * sizeof(SAMPLE)) +#define RBOUTTARGET_BYTES (RBOUTTARGET * (iaxci_sample_rate / 1000) * sizeof(SAMPLE)) static char inRingBuf[INRBSZ], outRingBuf[OUTRBSZ]; static rb_RingBuffer inRing, outRing; +/* TODO: This is used without explicit initialization */ static int outRingLenAvg; static int oneStream; @@ -457,11 +456,10 @@ PaStreamCallbackFlags statusFlags, void *userData) { + short virtualInBuffer[MAX_SAMPLES_PER_FRAME]; + short virtualOutBuffer[MAX_SAMPLES_PER_FRAME]; int totBytes = samplesPerFrame * sizeof(SAMPLE); - short virtualInBuffer[MAX_SAMPLES_PER_FRAME * 2]; - short virtualOutBuffer[MAX_SAMPLES_PER_FRAME * 2]; - #if 0 /* I think this can't happen */ if(virtualMono && samplesPerFrame > SAMPLES_PER_FRAME) { @@ -600,7 +598,7 @@ err = Pa_OpenStream(&iStream, &in_stream_params, &out_stream_params, - sample_rate, + iaxci_sample_rate, paFramesPerBufferUnspecified, //FEEBACK - unsure if appropriate paNoFlag, (PaStreamCallback *)pa_callback, @@ -613,7 +611,7 @@ err = Pa_OpenStream(&iStream, &in_stream_params, &no_device, - sample_rate, + iaxci_sample_rate, paFramesPerBufferUnspecified, //FEEBACK - unsure if appropriate paNoFlag, (PaStreamCallback *)pa_callback, @@ -623,7 +621,7 @@ err = Pa_OpenStream(&oStream, &no_device, &out_stream_params, - sample_rate, + iaxci_sample_rate, paFramesPerBufferUnspecified, //FEEBACK - unsure if appropriate paNoFlag, (PaStreamCallback *)pa_callback, @@ -714,7 +712,7 @@ err = Pa_OpenStream(&aStream, NULL, &ring_stream_params, - sample_rate, + iaxci_sample_rate, paFramesPerBufferUnspecified, //FEEBACK - unsure if appropriate paNoFlag, (PaStreamCallback *)pa_aux_callback, @@ -728,7 +726,7 @@ err = Pa_OpenStream(&aStream, NULL, &ring_stream_params, - sample_rate, + iaxci_sample_rate, paFramesPerBufferUnspecified, //FEEBACK - unsure if appropriate paNoFlag, (PaStreamCallback *)pa_aux_callback, @@ -1092,7 +1090,7 @@ { PaError err; - sample_rate = sr; + iaxci_sample_rate = sr; /* initialize portaudio */ if ( paNoError != (err = Pa_Initialize()) ) Modified: trunk/lib/iaxclient_lib.c =================================================================== --- trunk/lib/iaxclient_lib.c 2008-04-24 17:15:57 UTC (rev 1424) +++ trunk/lib/iaxclient_lib.c 2008-04-24 17:52:51 UTC (rev 1425) @@ -626,6 +626,7 @@ if ( !test_mode ) { + audio_initialize(); #ifndef AUDIO_ALSA if ( pa_initialize(&audio_driver, 8000) ) { @@ -672,6 +673,7 @@ if ( !test_mode ) { audio_driver.destroy(&audio_driver); + audio_destroy(); #ifdef USE_VIDEO video_destroy(); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |