/////////////////////////////////////////////////////////////////
| 1204 | |
| 1205 | ////////////////////////////////////////////////////////////////////// |
| 1206 | ISound* CSoundSystem::LoadSound(const char *szFile, int flags) |
| 1207 | { |
| 1208 | GUARD_HEAP; |
| 1209 | FUNCTION_PROFILER( GetSystem(),PROFILE_SOUND ); |
| 1210 | |
| 1211 | CSound* pSound = NULL; |
| 1212 | |
| 1213 | if (!szFile || (!szFile[0])) |
| 1214 | return (NULL); |
| 1215 | |
| 1216 | //if (!strlen(szFile)) |
| 1217 | // return (NULL); |
| 1218 | |
| 1219 | if (flags & FLAG_SOUND_3D) // make all 3d sounds use the sw-attenuation |
| 1220 | flags|=FLAG_SOUND_RADIUS; |
| 1221 | |
| 1222 | CSoundBuffer *pSB; |
| 1223 | SSoundBufferProps name=SSoundBufferProps(szFile, flags); |
| 1224 | SoundBufferPropsMapItor nit = m_soundBuffers.find(name); |
| 1225 | if ((!(flags & FLAG_SOUND_STREAM)) && (nit!=m_soundBuffers.end())) // we cannot share streams ! |
| 1226 | { |
| 1227 | //sound is already present |
| 1228 | |
| 1229 | pSB= nit->second; |
| 1230 | |
| 1231 | if (flags & FLAG_SOUND_3D) |
| 1232 | { |
| 1233 | if (pSB->GetProps().nFlags & FLAG_SOUND_2D) |
| 1234 | { |
| 1235 | m_pILog->Log("\001 [ERROR] trying to load the same sound buffer file as 2d and 3d sound (%s)",szFile); |
| 1236 | return (NULL); |
| 1237 | } |
| 1238 | } |
| 1239 | else |
| 1240 | if (flags & FLAG_SOUND_2D) |
| 1241 | { |
| 1242 | if (pSB->GetProps().nFlags & FLAG_SOUND_3D) |
| 1243 | { |
| 1244 | m_pILog->Log("\001 [ERROR] trying to load the same sound buffer file as 2d and 3d sound (%s)",szFile); |
| 1245 | return (NULL); |
| 1246 | } |
| 1247 | } |
| 1248 | |
| 1249 | //create a new instance |
| 1250 | pSound=new CSound(this,szFile); |
| 1251 | |
| 1252 | pSound->m_pSound=pSB; |
| 1253 | |
| 1254 | AddToSoundSystem(pSound,flags); |
| 1255 | |
| 1256 | return (pSound); |
| 1257 | } |
| 1258 | |
| 1259 | // check if this is an ogg...to avoid people calling |
| 1260 | // loadsound and decompressing the entire ogg into memory (several megabytes) |
| 1261 | // but if the load sync is specified, load the sound anyway doesnt matter what |
| 1262 | if (!(flags & FLAG_SOUND_LOAD_SYNCHRONOUSLY)) |
| 1263 | { |
no test coverage detected