Closed afritz1 closed 8 years ago
It looks like it could potentially just be the wrong variable being used there. Let me explain. According to the OpenALStream constructor, the mSource value will be set to 0: https://github.com/afritz1/OpenTESArena/blob/master/OpenTESArena/src/Media/AudioManager.cpp#L406
Cool, but the reason I say there might be wrong values in use here is the init itself using mSource: https://github.com/afritz1/OpenTESArena/blob/master/OpenTESArena/src/Media/AudioManager.cpp#L477
Why? It appears maybe it wants to assert(source != 0) because we're initializing mSource with the source value input to ::init: https://github.com/afritz1/OpenTESArena/blob/master/OpenTESArena/src/Media/AudioManager.cpp#L510
Which makes sense as to why mSource might not be initialized (well, why it might be 0).
I have a feeling it should say assert(source != 0)
. @kcat?
@Ragora, I think you should use the link of the actual commit instead of using master. It would go out of date if master was updated, right?
Also ::reset will pretty much just reinitialize the unique_ptr with a new pointer value, destroying the old one if there is a non-NULL value stored: http://en.cppreference.com/w/cpp/memory/unique_ptr/reset
I have a feeling it should say assert(source != 0).
Actually that should've been assert(mSource == 0);
to ensure the init
method isn't being called again. The source
parameter is valid, there's no way it can be called with 0 (if it is, there's more serious issues to worry about). I'll get a fix for that shortly.
Really annoying that cmake's RelWithDebInfo build type disables assertions, even though debug info is supposed to remain. I would've caught it earlier.
assert(mSource != 0)
inOpenALStream::init()
fails whenGameState::tick()
is called the first time.The
mSongStream.reset(new OpenALStream(this, mCurrentSong.get()))
function right beforeif (mSongStream->init(mFreeSources.front(), mMusicVolume))
inAudioManagerImpl::playMusic()
seems to be the problem. It causesmSource
to always be set to 0 in theOpenALStream()
initialization list.Could it just be that the
mSongStream.reset()
unintentionally setsmSource
to 0?