The audio file is recorded with 44.1k sample rate, Mono, 16 bit, uLaw PCM.
Everything works fine if I play this file locally using the audio toolbox’s file service, or runs the RTSP server and using VLC to play the streamed audio is also no problem.
But if I do my audio streaming then things go bad:
I use the alBufferData API like the below one:
/* Specify the data to be copied into a buffer */
AL_API void AL_APIENTRY
alBufferData( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq );
The procedure of handling the audio data is:
1. RTSP data goes into ringbuffer,
2. OpenAL queries its ALbuffer and if the data been processed then dequeue that buffer and copy the data from ringbuffer to it, and then enqueue that buffer.
And I found that if ALsizei freq = 44.1k, then all I can hear is the noise, but if I change ALsizei freq = 22050 (half of the sample rate), the words in audio can be understandable but is comes up with noise, too.
Any useful guidance will be highly appreciated or anyone knows where should I look into VLC code?