Re: alcCaptureSamples crashes on stereo capturing

Chris Robinson <[email protected]> Thu, 09 Aug 2012 20:20:44 -0700
Newsgroups gmane.comp.lib.openal
Message-ID <[email protected]>
On 08/09/2012 07:14 AM, Philipp Kraus wrote:
> Hello,
>
> I have got this code for capturing mono 8 bit data, the code works
> without any error:
>
> m_device = alcCaptureOpenDevice( p_device.c_str(),
> static_cast<ALCuint>(p_sampingfrequency),  AL_FORMAT_MONO8,
> static_cast<ALCsizei>(p_buffersize));
>
> ublas::vector<ALubyte> l_buffer(m_buffersize);
> alcCaptureStart(m_device);
> while(m_capturing)
> {
>         alcGetIntegerv(...)
>         l_samplesread = std::min(
> static_cast<std::size_t>(l_samplesread), l_buffer.size()-i);
>         alcCaptureSamples(m_device, (ALCvoid*)(&l_buffer[i]),
> l_samplesread);
> }
>
> If I switch the the AL_FORMAT_MONO8 to AL_FORMAT_STEREO8 and change the
> p_buffersize to 2*p_buffersize & m_buffersize to 2*m_buffersize the code
> crashes
> on the alcCaptureSamples line and the buffer is not filled.

It looks like you're not accounting for the count being in sample 
frames, so you're asking for n sample frames, but only have enough space 
for n/2 (since it needs two channels for each sample frame). 
l_buffer.size() is samples*channels, not the number of samples.

l_buffer.size()/2 is the number of samples to fill for stereo.
_______________________________________________
Openal mailing list
[email protected]
http://opensource.creative.com/mailman/listinfo/openal