Revert "Add destructor for SoundTrack/MusicTrack (and explicitly define move constructor to prevent double-free)"

This reverts commit 2f760af439.
This commit is contained in:
leo60228
2020-06-07 15:49:18 -04:00
committed by Ethan Lee
parent 098fb77611
commit d193caac98
3 changed files with 62 additions and 99 deletions

View File

@@ -24,15 +24,6 @@ MusicTrack::MusicTrack(SDL_RWops *rw)
}
}
MusicTrack::MusicTrack(MusicTrack&& moved) : m_music(move(moved.m_music)), m_isValid(move(moved.m_isValid)) {
moved.m_isValid = false;
}
MusicTrack::~MusicTrack() {
if (m_isValid) Mix_FreeMusic(m_music);
m_isValid = false;
}
SoundTrack::SoundTrack(const char* fileName)
{
sound = NULL;
@@ -47,22 +38,12 @@ SoundTrack::SoundTrack(const char* fileName)
FILESYSTEM_freeMemory(&mem);
}
if (sound == NULL) {
if (sound == NULL)
{
fprintf(stderr, "Unable to load WAV file: %s\n", Mix_GetError());
} else {
isValid = true;
}
}
SoundTrack::SoundTrack(SoundTrack&& moved) : sound(move(moved.sound)), isValid(move(moved.isValid)) {
moved.isValid = false;
}
SoundTrack::~SoundTrack() {
if (isValid) Mix_FreeChunk(sound);
isValid = false;
}
SoundSystem::SoundSystem()
{
int audio_rate = 44100;