Verified Commit f91ff709 authored by RobLoach's avatar RobLoach
Browse files

Add OGG support

parent a74dbc62
......@@ -46,6 +46,10 @@ SOURCES_C += $(wildcard \
$(CORE_DIR)/vendor/libretro-common/lists/string_list.c \
)
# stb_vorbis
SOURCES_C += $(CORE_DIR)/vendor/stb/stb_vorbis.c
FLAGS += -DHAVE_STB_VORBIS
# zlib
SOURCES_C += \
$(CORE_DIR)/vendor/libretro-deps/libz/zutil.c \
......
......@@ -23,9 +23,16 @@ SoundData::SoundData(const std::string& filename) {
return;
}
// Load the file into the buffer.
// TODO(RobLoach): Check the audio file extensions of ".wav".
m_sound = audio_mixer_load_wav(buffer, size);
// Get the extension of the file.
std::string extension = app->filesystem.newFileData(filename).getExtension();
if (extension == "wav") {
m_sound = audio_mixer_load_wav(buffer, size);
} else if (extension == "ogg") {
m_sound = audio_mixer_load_ogg(buffer, size);
} else {
std::cout << "[ChaiLove] [SoundData] File " << filename << " extension of " << extension << " is currently not supported." << std::endl;
return;
}
free(buffer);
if (m_sound == NULL) {
std::cout << "[ChaiLove] [SoundData] Failed to load wav from buffer " << filename << std::endl;
......
......@@ -29,6 +29,8 @@ class audio {
* @param type ("static") The type of audio source to load ("static", "stream"). Optional.
*
* @return The new SoundData if it loaded correctly, NULL otherwise.
*
* @see love.sound.newSoundData
*/
SoundData* newSource(const std::string& filename, const std::string& type);
SoundData* newSource(const std::string& filename);
......
......@@ -22,6 +22,10 @@ class sound {
/**
* Creates a new SoundData.
*
* Supported file types include:
* - WAV
* - OGG
*
* @param filename The file name of the file to load.
*
* @return A new SoundData object, NULL if loading failed.
......
......@@ -9,7 +9,7 @@
global beat
def load() {
beat = love.audio.newSource("assets/startup.wav")
beat = love.audio.newSource("assets/unittests/assets/chailove.ogg")
}
def draw() {
......
......@@ -34,7 +34,7 @@ assert_not(love.filesystem.isSymlink("keyboard.chai"), "love.filesystem.isSymlin
// getDirectoryItems()
var getDirectoriesItems = love.filesystem.getDirectoryItems("assets").size()
assert_equal(getDirectoriesItems, 3, "love.filesystem.getDirectoryItems()")
assert_equal(getDirectoriesItems, 4, "love.filesystem.getDirectoryItems()")
// lines()
var theLines = love.filesystem.lines("filesystem.chai")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment