|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
Crashing when calling alDeleteBuffersI need help to pinpoint the crash culprit in my app, I'm using kubuntu
with openal 1.4.272. I'm streaming an ogg music to the openal and if I do an unload and load another music it works, but when I call the same unload method from window close event (before any openal deinit) it crashes inside openal alDeleteBuffers when trying to "free" the second buffer data (and I don't found if it is really related to closing window it is just the way I can reproduce). This is my Unload method: void Music::Unload() { if (!this->bLoaded) return; ALenum err = AL_NO_ERROR; if (this->iSource) { int queued = 0; alGetSourcei(iSource, AL_BUFFERS_QUEUED, &queued); err = alGetError(); while (queued--) { ALuint buffer; alSourceUnqueueBuffers(this->iSource, 1, &buffer); err = alGetError(); } alDeleteSources(1, &iSource); err = alGetError(); this->iSource = 0; } alDeleteBuffers(OPENAL_MUSIC_BUFFERS, iBuffers); // crash here err = alGetError(); memset(iBuffers, '\0', OPENAL_MUSIC_BUFFERS); ov_clear(&oggStream); stFile.Close(); this->bLoaded = FALSE; } I downloaded the source code from openal soft and debugged inside it (and tried the lastest release 1.8.466 too), both crashed at alBuffer.c line 189 but only for the second iteration (second buffer handle). As openal makes a copy of my pcm data I really don't think that it has anything to do with the ogg streaming. Last week I tested it on Windows and it was not crashing, but I will do some testing with MacOSX and Windows as soon as possible to be sure. Thank you -- Animal Liberation Front http://www.animal-liberation.com/ _______________________________________________ Openal mailing list Openal@... http://opensource.creative.com/mailman/listinfo/openal |
|
|
Re: Crashing when calling alDeleteBuffersOn Saturday 04 July 2009 7:37:38 pm fungos wrote:
> I'm streaming an ogg music to the openal and if I do an unload and > load another music it works, but when I call the same unload method > from window close event (before any openal deinit) it crashes inside > openal alDeleteBuffers when trying to "free" the second buffer data > (and I don't found if it is really related to closing window it is > just the way I can reproduce). How are the buffers declared and allocated? It may also help to see how the buffers are (re)filled. The only issue I see in the Unload method is: > memset(iBuffers, '\0', OPENAL_MUSIC_BUFFERS); memset takes the number of bytes to set to the given value, which should be sizeof(ALuint) times more. Eg: memset(iBuffers, '\0', OPENAL_MUSIC_BUFFERS*sizeof(iBuffers[0])); or even just: memset(iBuffers, '\0', sizeof(iBuffers)); if iBuffers is a static-sized array. > I downloaded the source code from openal soft and debugged inside it > (and tried the lastest release 1.8.466 too), both crashed at > alBuffer.c line 189 but only for the second iteration (second buffer > handle). As openal makes a copy of my pcm data I really don't think > that it has anything to do with the ogg streaming. > Last week I tested it on Windows and it was not crashing, but I will > do some testing with MacOSX and Windows as soon as possible to be > sure. The only thing I could guess at this point is some kind of memory corruption. The data pointer shouldn't be in use because of the lock on the context, and it should be valid (NULL or a pointer given by realloc). The buffer ID is also validated. If possible, try running with valgrind (with the debug-enabled openal lib). _______________________________________________ Openal mailing list Openal@... http://opensource.creative.com/mailman/listinfo/openal |
|
|
Re: Crashing when calling alDeleteBuffersOn Sun, Jul 5, 2009 at 7:41 AM, Chris Robinson <chris.kcat@...> wrote:
I have seen this happen when the buffers aren't allocated through alGenBuffers. I don't know if this is allowed by the specs but Creative's drivers seem to ignore this silently, while OpenAL Soft is more strict. _______________________________________________ Openal mailing list Openal@... http://opensource.creative.com/mailman/listinfo/openal |
|
|
Re: Crashing when calling alDeleteBuffersThank you for your help Chris and StApostol.
Fixed that memset too ;) I will try to run valgrind, If I find anything useful I will send another mail, for now there are more snippets from my code. *** This is the declaration in my class, where OPENAL_MUSIC_BUFFERS is 2: private: ALuint iBuffers[OPENAL_MUSIC_BUFFERS]; ALuint iSource; *** This is my Load method definition (just the part that deals with openal and ogg): void Music::Load(const char *filename, ResourceManager *res, IMemoryPool *pool) { ASSERT_NULL(filename); ASSERT_NULL(pool); ASSERT_NULL(res); /* ... cut ... */ /* prepare openal */ ALenum err = AL_NO_ERROR; alGenSources(1, &iSource); err = alGetError(); if (err != AL_NO_ERROR) { Log(TAG "Could not create OpenAL music source (0x%04x).", alGetError()); return; } alGenBuffers(OPENAL_MUSIC_BUFFERS, iBuffers); // create OpenAL buffers err = alGetError(); if (err != AL_NO_ERROR) { alDeleteSources(1, &iSource); memset(iBuffers, '\0', sizeof(iBuffers)); Log(TAG "Could not generate OpenAL music buffers (0x%04x).", alGetError()); } if (ov_fopen(const_cast<char *>(filename), &oggStream) < 0) { alDeleteSources(1, &iSource); alDeleteBuffers(OPENAL_MUSIC_BUFFERS, iBuffers); memset(iBuffers, '\0', sizeof(iBuffers)); Log(TAG "Could not open '%s' ogg stream (file does not exist or is not a valid ogg file).", filename); return; } vorbisInfo = ov_info(&oggStream, -1); vorbisComment = ov_comment(&oggStream, -1); if (vorbisInfo->channels > 1) eFormat = AL_FORMAT_STEREO16; alSource3f(iSource, AL_POSITION, 0.0f, 0.0f, 0.0f); alSource3f(iSource, AL_VELOCITY, 0.0f, 0.0f, 0.0f); alSource3f(iSource, AL_DIRECTION, 0.0f, 0.0f, 0.0f); alSourcef(iSource, AL_ROLLOFF_FACTOR, 0.0); alSourcei(iSource, AL_SOURCE_RELATIVE, AL_TRUE); this->Reset(); this->bLoaded = TRUE; } *** The Reset method will prepare/initialize the ogg streaming: void Music::Reset() { int queued = 0; alGetSourcei(iSource, AL_BUFFERS_QUEUED, &queued); while (queued--) { ALuint buffer; alSourceUnqueueBuffers(iSource, 1, &buffer); } ov_raw_seek(&oggStream, 0); for (u32 i = 0; i < OPENAL_MUSIC_BUFFERS; i++) ogg_update_stream(&oggStream, vorbisInfo->rate, eFormat, iBuffers[i], this->bLoop); alSourceQueueBuffers(iSource, OPENAL_MUSIC_BUFFERS, iBuffers); } *** And this is the ogg_update_stream function: bool ogg_update_stream(OggVorbis_File *oggStream, ogg_int64_t rate, ALenum format, ALuint buffer, bool loop) { char pcm[VORBIS_BUFFER_SIZE]; int size = 0; int section; int result; while (size < VORBIS_BUFFER_SIZE) { result = ov_read(oggStream, pcm + size, VORBIS_BUFFER_SIZE - size, 0, 2, 1, §ion); if (result > 0) size += result; else if (result < 0) return false; else // end of file { if (loop) ov_raw_seek(oggStream, 0); else break; } } if (size == 0) { ov_raw_seek(oggStream, 0); return false; } alBufferData(buffer, format, pcm, size, rate); // feed data to OpenAL return true; } *** This is my Update streaming method: BOOL Music::Update() { BOOL active = true; ALint processed = 0; alGetSourcei(iSource, AL_BUFFERS_PROCESSED, &processed); while (processed--) { ALuint buffer; alSourceUnqueueBuffers(iSource, 1, &buffer); active = ogg_update_stream(&oggStream, vorbisInfo->rate, eFormat, buffer, this->bLoop); if (active || bLoop) alSourceQueueBuffers(iSource, 1, &buffer); } if (!active) eState = MusicStopped; return active; } On Sun, Jul 5, 2009 at 7:34 AM, StApostol<stapostol@...> wrote: > On Sun, Jul 5, 2009 at 7:41 AM, Chris Robinson <chris.kcat@...> wrote: >> >> On Saturday 04 July 2009 7:37:38 pm fungos wrote: >> > I'm streaming an ogg music to the openal and if I do an unload and >> > load another music it works, but when I call the same unload method >> > from window close event (before any openal deinit) it crashes inside >> > openal alDeleteBuffers when trying to "free" the second buffer data >> > (and I don't found if it is really related to closing window it is >> > just the way I can reproduce). >> > I have seen this happen when the buffers aren't allocated through > alGenBuffers. I don't know if this is allowed by the specs but Creative's > drivers seem to ignore this silently, while OpenAL Soft is more strict. > > > _______________________________________________ > Openal mailing list > Openal@... > http://opensource.creative.com/mailman/listinfo/openal > > -- Animal Liberation Front http://www.animal-liberation.com/ _______________________________________________ Openal mailing list Openal@... http://opensource.creative.com/mailman/listinfo/openal |
|
|
Re: Crashing when calling alDeleteBuffersI think I found it, was a memory corruption in another module of the
application, when I fixed it everything worked perfectly and valgrind won't show any errors. Bye _______________________________________________ Openal mailing list Openal@... http://opensource.creative.com/mailman/listinfo/openal |
| Free embeddable forum powered by Nabble | Forum Help |