00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "stdsound.h"
00027 #include "async_file_manager_sound.h"
00028 #include "nel/misc/async_file_manager.h"
00029 #include "driver/sound_driver.h"
00030
00031 using namespace NLMISC;
00032
00033 namespace NLSOUND
00034 {
00035
00036 CAsyncFileManagerSound *CAsyncFileManagerSound::_Singleton;
00037
00038
00039 CAsyncFileManagerSound &CAsyncFileManagerSound::getInstance()
00040 {
00041 if (_Singleton == NULL)
00042 {
00043 _Singleton = new CAsyncFileManagerSound();
00044 }
00045 return *_Singleton;
00046 }
00047
00048
00049 void CAsyncFileManagerSound::terminate()
00050 {
00051 if (_Singleton != NULL)
00052 {
00053 delete &getInstance();
00054 _Singleton = NULL;
00055 }
00056 }
00057
00058 void CAsyncFileManagerSound::loadWavFile(IBuffer *pdestBuffer, const std::string &filename)
00059 {
00060 CAsyncFileManager::getInstance().addLoadTask(new CLoadWavFile(pdestBuffer, filename));
00061 }
00062
00063
00064 class CCancelLoadWavFile : public CAsyncFileManager::ICancelCallback
00065 {
00066 std::string _Filename;
00067
00068 bool callback(const NLMISC::IRunnable *prunnable) const
00069 {
00070 const CAsyncFileManagerSound::CLoadWavFile *pLWF = dynamic_cast<const CAsyncFileManagerSound::CLoadWavFile*>(prunnable);
00071
00072 if (pLWF != NULL)
00073 {
00074 if (pLWF->_Filename == _Filename)
00075 return true;
00076 }
00077 return false;
00078 }
00079
00080 public:
00081 CCancelLoadWavFile (const std::string &filename)
00082 : _Filename (filename)
00083 {}
00084 };
00085
00086 void CAsyncFileManagerSound::cancelLoadWaveFile(const std::string &filename)
00087 {
00088
00089 }
00090
00091
00092
00093 void CAsyncFileManagerSound::loadFile (const std::string &fileName, uint8 **pPtr)
00094 {
00095 CAsyncFileManager::getInstance().loadFile(fileName, pPtr);
00096 }
00097
00098 void CAsyncFileManagerSound::loadFiles (const std::vector<std::string> &vFileNames, const std::vector<uint8**> &vPtrs)
00099 {
00100 CAsyncFileManager::getInstance().loadFiles(vFileNames, vPtrs);
00101 }
00102
00103 void CAsyncFileManagerSound::signal (bool *pSgn)
00104 {
00105 CAsyncFileManager::getInstance().signal(pSgn);
00106 }
00107
00108 void CAsyncFileManagerSound::cancelSignal (bool *pSgn)
00109 {
00110 CAsyncFileManager::getInstance().cancelSignal(pSgn);
00111 }
00112
00113
00114
00115 CAsyncFileManagerSound::CLoadWavFile::CLoadWavFile (IBuffer *pdestBuffer, const std::string &filename)
00116 :_Filename(filename), _pDestbuffer(pdestBuffer)
00117 {}
00118
00119 void CAsyncFileManagerSound::CLoadWavFile::run (void)
00120 {
00121 nldebug("Loading sample %s...", _Filename.c_str());
00122
00123 CAudioMixerUser::instance()->getSoundDriver()->loadWavFile(_pDestbuffer, _Filename.c_str());
00124 }
00125
00126
00127
00128 }