[Openal] Buffer size problem
Jimmy Gervais
jimbo8086 at gmail.com
Fri Jul 3 23:26:04 PDT 2009
The call *needs *a ALvoid pointer, it is specified and otherwise returns an
error, hence to copy. But you are right about its location, it is not
initialized and then used to create an array, overwritting the memory
hazardously. So I did this instead:
ALvoid * PTampon1; // My Buffer void pointer
short * Tampon1; // My Buffer short pointer
Tampon1 = new short [B_SIZE]; // Initializing the short pointer with a
new array
PTampon1 = (ALvoid*)Tampon1; // Copy the short pointer into a void one
Now it doesn't crash, not even with 500MB, but I got *no sound at all*!!
loll
I put the warning option on as you suggested, but got none either ways.
Thanks for your help, I might be half way through now.
2009/7/3 Chris Robinson <chris.kcat at gmail.com>
> On Friday 03 July 2009 11:40:51 am Jimmy Gervais wrote:
> > ALvoid * PTampon1; // My Buffer
> > short * Tampon1;
> > Tampon1 = (short*)PTampon1;
> > Tampon1 = new short [taille];
> ...
> > std::cout << "Buffers ... " << std::endl;
> > alBufferData(MesTampons[0], AL_FORMAT_STEREO16, PTampon1, taille,
> > 44100); // Hangs here when size > ~ 250'000
>
> This doesn't look right. PTampon1 is left uninitialized, Tampon1 is set to
> the
> uninitialized value, then overwritten with a new buffer. PTampon1, still
> uninitialized, is passed to alBufferData. That it sometimes works is just a
> coincidence: if PTampon1 happens to be NULL, alBufferData will cause an
> error
> and return without crashing (though attaching it to a source an d trying to
> play the source will fail, too). If it's a non-NULL value, it will likely
> crash.
>
> Something like this should work:
>
> short * Tampon1; // My Buffer
> Tampon1 = new short [taille];
> ...
> std::cout << "Buffers ... " << std::endl;
> alBufferData(MesTampons[0], AL_FORMAT_STEREO16, Tampon1, taille,
> 44100);
>
> You don't need the extra PTampon1 pointer. It may also help to turn on
> compiler warnings (-Wall -Wextra in GCC), as that would have warned you
> about
> the uninitialized pointer.
> _______________________________________________
> Openal mailing list
> Openal at opensource.creative.com
> http://opensource.creative.com/mailman/listinfo/openal
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://opensource.creative.com/pipermail/openal/attachments/20090704/9c67aa08/attachment.html
More information about the Openal
mailing list