sound_file.cpp 457 Bytes
Newer Older
Georg Schaefer's avatar
Georg Schaefer committed
1
#include <audio/audio_helper.hpp>
Thomas Eppers's avatar
Thomas Eppers committed
2
#include <audio/sound_file.hpp>
Georg Schaefer's avatar
Georg Schaefer committed
3
4

namespace gdw {
Thomas Eppers's avatar
Thomas Eppers committed
5
	sound_file::sound_file(const char* mem, int size) {
Georg Schaefer's avatar
Georg Schaefer committed
6
7
8
9
10
11
12
		SDL_RWops* raw = SDL_RWFromConstMem((void*)mem, size);
		if (raw == nullptr) {
			audio_error("could not load music from memory");
		}
		impl_ = Mix_LoadWAV_RW(raw, 1);
	}

Thomas Eppers's avatar
Thomas Eppers committed
13
	sound_file::~sound_file() {
Georg Schaefer's avatar
Georg Schaefer committed
14
15
16
17
18
		if (impl_ != nullptr) {
			Mix_FreeChunk(impl_);
		}
	}

Thomas Eppers's avatar
Thomas Eppers committed
19
	Mix_Chunk*sound_file::get() const {
Georg Schaefer's avatar
Georg Schaefer committed
20
21
22
		return impl_;
	}
}