[Openal] Blocking Audio Capture

Stefan Kögel stefan-wieland.koegel at stud.tu-ilmenau.de
Tue May 5 02:17:05 PDT 2009


Hello Fellows,

i am using OpenAL to capture Audio from the microphone. This works quite
well, the only thing that bothers me, is that I have to poll the number
of available samples.
This is so cpu intensive. There must be some other way. Isnt there a
blocking call, which returns a previous specified number of samples in a
buffer. Or some kind of callback construction.
So far I have not found something like inside the OpenAL source.

Does anyone know if there exists such a thing? Or has anyone done this
before and can tell me what approach I can use?

Here is what I do:

while (tNumSamplesAvail < tCaptureSamples-1)
        {
            //Get number of captured samples
            alcGetIntegerv(mCaptureDevice, ALC_CAPTURE_SAMPLES,
sizeof(tNumSamplesAvail), &tNumSamplesAvail);
            if (tNumSamplesAvail < tCaptureSamples-1)
                usleep(10);
        }
        alcCaptureSamples(mCaptureDevice, (ALCvoid *)pBuffer,
tNumSamplesAvail);

I hate to use "usleep". Actively waiting is not very sophisticated.

Thanks in advance.

Kind regards,
Stefan


More information about the Openal mailing list