From e40a79435d9e3d2f099165b8b336db83a243bcaa Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Thu, 19 May 2011 17:14:00 -0400 Subject: [PATCH] update AV to remove FileLoader --- src/AV.cc | 34 ++++++++++++---------------------- src/AV.h | 5 +---- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/src/AV.cc b/src/AV.cc index 8e4ef3b..128db20 100644 --- a/src/AV.cc +++ b/src/AV.cc @@ -238,8 +238,7 @@ void AV::playCallback(Uint8 * stream, int len) /******************** AV::Sound ********************/ AV::Sound::Sound(AV & av) - : m_av(av), - m_buff(1) + : m_av(av) { m_rwops = NULL; m_ss = NULL; @@ -255,29 +254,20 @@ AV::Sound::~Sound() } } -bool AV::Sound::load(FileLoader & fileLoader, const FileLoader::Path & path) +bool AV::Sound::load(unsigned char *data, unsigned int size) { - m_buff = fileLoader.load(path); - if (m_buff.size > 0) + m_rwops = SDL_RWFromMem(data, size); + Sound_AudioInfo desired; + desired.channels = CHANNELS; + desired.format = AUDIO_S16SYS; + desired.rate = SOUND_RATE; + m_ss = Sound_NewSample(m_rwops, NULL, &desired, + CALLBACK_SAMPLES * BYTES_PER_SAMPLE); + if (m_ss != NULL) { - m_rwops = SDL_RWFromMem(m_buff.data, m_buff.size); - Sound_AudioInfo desired; - desired.channels = CHANNELS; - desired.format = AUDIO_S16SYS; - desired.rate = SOUND_RATE; - m_ss = Sound_NewSample(m_rwops, NULL, &desired, - CALLBACK_SAMPLES * BYTES_PER_SAMPLE); - if (m_ss != NULL) - { - return true; - } - else - { - cerr << "Error loading sound " << path.toString() << ": " - << Sound_GetError() << endl; - m_rwops = NULL; - } + return true; } + m_rwops = NULL; return false; } diff --git a/src/AV.h b/src/AV.h index 8d2c760..cd2c3f2 100644 --- a/src/AV.h +++ b/src/AV.h @@ -8,7 +8,6 @@ #include -#include "FileLoader/FileLoader.h" #include "refptr/refptr.h" #define AV_SOUND_FORMAT AUDIO_S16SYS @@ -28,8 +27,7 @@ class AV public: Sound(AV & av); ~Sound(); - bool load(FileLoader & fileLoader, - const FileLoader::Path & path); + bool load(unsigned char *data, unsigned int size); void play(); void resume(); void stop(); @@ -42,7 +40,6 @@ class AV AV & m_av; SDL_RWops * m_rwops; Sound_Sample * m_ss; - FileLoader::Buffer m_buff; int m_loop_count; int m_buff_bytes_left; float m_volume;