From: Eloy D. <elo...@vo...> - 2004-04-26 12:34:53
|
Hi All, Another thing which keeps bugging me is a problem with the sound system of libiaxclient (or better portaudio). I am not sure what the real cause for it is. This is the problem: In the following function from audio_encode.c, I had to build in a protection to avoid a singularity issue when calling the log10() function: --- snip --- snip ---- static double vol_to_db(double vol) { // // protect the log10 function being called with vol=0 // if (vol<1e-99) vol=0.0001; return log10(vol) * 20; } --- snip --- snip ---- The original function just does a straight call to log10(vol) without check. When I traced the call, I got these references of vol_to_db(): lib\audio_encode.c(32): iaxc_do_levels_callback(vol_to_db(input_level), vol_to_db(output_level)); lib\audio_encode.c(90): volume = vol_to_db(input_level); In the end it turns out that the output_level=0 an awful lot of times, causing the log10() function to blow up. When I trace the setting of the output_level var, I get these references: lib\audio_encode.c(7): static double input_level = 0, output_level = 0; lib\audio_encode.c(103): calculate_level((short*)audio, len, &output_level); The calculate_level function is called to set both input_level and output_level, and is using the audio stream's data: --- snip --- snip --- static void calculate_level(short *audio, int len, double *level) { short now = 0; double nowd; int i; for(i=0;i<len;i++) if(abs(audio[i]) > now) now = abs(audio[i]); nowd = now/32767; // note: this seems useless to me *level += (((double)now/32767) - *level) / 5; } --- snip --- snip --- Which would suggest that the audio output can be zero, but the output_level is still being calculated. For some reason, the input_level does not seem to suffer from the same effect. When I enable the log10() safeguard, the softphone is fully functional, without the safeguard, you cannot run the program due to the runtime problem of doing a log10(0). Has anyone seen this problem before? Can it be avoided by certain actions or audio settings? Best regards, Eloy Domingos |