update AV to remove FileLoader
This commit is contained in:
parent
6e29f8adf6
commit
e40a79435d
34
src/AV.cc
34
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;
|
||||
}
|
||||
|
||||
|
5
src/AV.h
5
src/AV.h
@ -8,7 +8,6 @@
|
||||
|
||||
#include <set>
|
||||
|
||||
#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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user