OK, I’m gonna try to explain this as good as I can. So I basically created a playlist app on windows, what happens is that when the sound ends and switches to another sounds everything is OK, BUT when I force stop a sound and delete its memory values reset to null then recreate the new sound on OLD sound and channel pointers there is this slight memory issue where 300KB is newly allocated and never removed. This is issue will be a huge over LONG periods of usage. Can some1 point out what am I doing wrong?
My procedure in English statements:
-if current sound ends
-create new sound on old sound
-play new sound
no memory issue
-if skip sound
-force stop current sound, destroy sound
-create new sound on old sound
-play new sound
memory issues.
CODE:
main loop.
do
{
windowsUpdateCall(audioPlayer, dataPtr); // windows OS update call for input buffer, used instead of ACSII for special keys
myClear(false);
tick = (double)GetTickCount64();
audioPlayer->internalTick(tick); // FMOD audio system call to update sound information
if (!audioPlayer->isPlaying())
changeAudio(true, audioPlayer, dataPtr);
myShowFunc(audioPlayer, dataPtr);
sleepTick = sleepIntervalCalc(audioPlayer->isPlaying2());
if (myRunning)
Sleep(sleepTick);
} while(myRunning);
select new sound.
void changeAudio(const bool phase, class audioClass*& s, class std::vector<dataBatch>*& v)
{
UINT x;
x = s->getSoundID();
if (phase)
{
x++;
if (x == v->size())
x = 0;
}
else
{
x--;
if (x == -1)
x = (UINT)(v->size() - 1);
}
if (x >= 0 && x < v->size())
{
s->changeSoundPTR(v->at(x).lName, v->at(x).qPos);
}
}
change sound:
void audioClass::changeSound(const char * name, const unsigned int ID)
{
if (this->sound[this->currentSoundChannel] != nullptr)
{
this->soundCleanup(this->currentSoundChannel);
(this->*makeSoundFunc)(name, ID);
//this->playing = !this->playing;
this->playSound();
}
}
sound cleanup:
void audioClass::soundCleanup(unsigned int loc)
{
if (this->myParams[loc] != nullptr)
{
if (this->myParams[loc]->beatQueue->size() > 0)
this->myParams[loc]->beatQueue->empty();
delete this->myParams[loc]->beatQueue;
delete this->myParams[loc];
}
if (this->playing)
this->channel[loc]->setPaused(this->playing);
if (this->lowFreqDSP[loc] != nullptr && this->highFreqDSP[loc] != nullptr)
{
this->masterGroup->removeDSP(this->lowFreqDSP[loc]);
this->masterGroup->removeDSP(this->highFreqDSP[loc]);
this->highFreqDSP[loc]->release();
this->lowFreqDSP[loc]->release();
}
if (this->myDsp[loc] != nullptr)
this->myDsp[loc]->release();
if (this->myDsp2[loc] != nullptr)
this->myDsp2[loc]->release();
if (this->myNewDSP[loc] != nullptr)
delete this->myNewDSP[loc];
this->channel[loc]->stop();
if (this->sound[loc] != nullptr)
this->sound[loc]->release();
//delete channel[loc];
this->channel[loc] = 0;
this->sound[loc] = nullptr;
this->highFreqDSP[loc] = nullptr;
this->lowFreqDSP[loc] = nullptr;
this->myDsp[loc] = nullptr;
this->myDsp2[loc] = nullptr;
this->myNewDSP[loc] = nullptr;
this->myParams[loc] = nullptr;
}