src/ResourceManager/SoundResource.cpp

Go to the documentation of this file.
00001 /* Crown and Cutlass
00002  * SoundResource Code
00003  */
00004 
00005 #include <string>
00006 #include <AL/al.h>
00007 #include "../soundfile.h"
00008 #include "../Log.h"
00009 #include "IResource.h"
00010 #include "SoundResource.h"
00011 
00012 using namespace std;
00013 
00014 const string SoundResource::s_type = string("Sound");
00015 
00016 SoundResource::SoundResource(string name, string filename): IResource(name) {
00017   m_filename = filename;
00018   m_buffer = AL_NONE;
00019 
00020   Log::s_log->Message("SoundResource %s created (Key: %s)", m_filename.c_str(), GetKey().c_str());
00021 }
00022 
00023 SoundResource::~SoundResource() {
00024   if (m_buffer != AL_NONE) {
00025     Log::s_log->Message("Warning: %f sound resource deleted before unload", m_filename.c_str());
00026     Unload();
00027   }
00028   Log::s_log->Message("SoundResource %s destroyed", m_filename.c_str());
00029 }
00030 
00031 string SoundResource::GetType() {
00032   return s_type;
00033 }
00034 
00035 void SoundResource::Load() {
00036   LoadOgg(m_filename.c_str(), &m_buffer);
00037   Log::s_log->Message("SoundResource %s loaded", m_filename.c_str());
00038 }
00039 
00040 void SoundResource::Unload() {
00041   alDeleteBuffers(1, &m_buffer);
00042   m_buffer = AL_NONE;
00043   Log::s_log->Message("SoundResource %s unloaded", m_filename.c_str());
00044 }
00045 
00046 ALuint SoundResource::GetBuffer() {
00047   return m_buffer;
00048 }

Generated on Mon Jan 8 22:34:12 2007 for CrownandCutlass by  doxygen 1.4.7