From: Matze B. <mat...@us...> - 2002-08-21 17:14:13
|
Update of /cvsroot/planeshift/planeshift/src/client/sound In directory usw-pr-cvs1:/tmp/cvs-serv10175/src/client/sound Modified Files: pssoundmngr.cpp pssoundmngr.h Log Message: some smaller cleanups Index: pssoundmngr.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/sound/pssoundmngr.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** pssoundmngr.cpp 18 May 2002 23:31:11 -0000 1.17 --- pssoundmngr.cpp 21 Aug 2002 17:14:10 -0000 1.18 *************** *** 66,75 **** { SCF_CONSTRUCT_IBASE (iParent); - - snd = NULL; - backsound = NULL; - engine = NULL; - object_reg = NULL; - backhandle = NULL; } --- 66,69 ---- *************** *** 77,87 **** { if (backsound) - { backsound->Stop (); - backsound->DecRef(); - } - SCF_DEC_REF(backhandle); - SCF_DEC_REF(snd); - SCF_DEC_REF(engine); } --- 71,75 ---- *************** *** 95,121 **** bool psSoundManager::Setup() { ! snd = CS_QUERY_REGISTRY(object_reg, iSoundRender); ! if (!snd) ! goto nosound; ! ! engine = CS_QUERY_REGISTRY(object_reg, iEngine); if(!engine) ! goto nosound; if (!sndmngr.Initialize()) ! goto nosound; if (!sndmngr.LoadSoundLib("/planeshift/art/soundlib.xml")) ! goto nosound; return true; - - nosound: - csReport (object_reg, CS_REPORTER_SEVERITY_ERROR, "planeshift.sound", - "Warning: Couldn't initialize soundplugin."); - SCF_DEC_REF(snd); - snd=NULL; - SCF_DEC_REF(engine); - engine=NULL; - return false; } --- 83,106 ---- bool psSoundManager::Setup() { ! if (snd) ! return true; ! ! engine.Take (CS_QUERY_REGISTRY(object_reg, iEngine)); if(!engine) ! return false; if (!sndmngr.Initialize()) ! return false; if (!sndmngr.LoadSoundLib("/planeshift/art/soundlib.xml")) ! { ! printf ("Couldn't load Soundlib!\n"); ! return false; ! } ! ! snd.Take (CS_QUERY_REGISTRY(object_reg, iSoundRender)); ! if (!snd) ! return false; return true; } *************** *** 158,162 **** return false; ! if( backsound ) { if (!strcmp (backhandle->GetName(), name)) --- 143,147 ---- return false; ! if(backsound) { if (!strcmp (backhandle->GetName(), name)) *************** *** 171,181 **** return false; } ! ! SCF_DEC_REF(backsound); ! SCF_DEC_REF(backhandle); backsound = handle->src->Play (loop); ! backhandle = handle; ! if (backsound) ! backsound->IncRef(); return true; --- 156,162 ---- return false; } ! backsound = handle->src->Play (loop); ! backhandle.Take (handle); return true; *************** *** 193,213 **** : parent(nparent) { - sndloader = NULL; - vfs = NULL; } psSoundManager::psSndSourceMngr::~psSndSourceMngr() { - SCF_DEC_REF(sndloader); - SCF_DEC_REF(vfs); } bool psSoundManager::psSndSourceMngr::Initialize() { ! sndloader = CS_QUERY_REGISTRY(parent->object_reg, iSoundLoader); if (!sndloader) return false; ! vfs = CS_QUERY_REGISTRY(parent->object_reg, iVFS); if (!vfs) return false; --- 174,190 ---- : parent(nparent) { } psSoundManager::psSndSourceMngr::~psSndSourceMngr() { } bool psSoundManager::psSndSourceMngr::Initialize() { ! sndloader.Take (CS_QUERY_REGISTRY(parent->object_reg, iSoundLoader)); if (!sndloader) return false; ! vfs.Take (CS_QUERY_REGISTRY(parent->object_reg, iVFS)); if (!vfs) return false; *************** *** 254,258 **** iSoundHandle* psSoundManager::psSndSourceMngr::LoadSound(const char* fname) { ! iDataBuffer* buf = vfs->ReadFile(fname); if (!buf || !buf->GetSize()) { --- 231,236 ---- iSoundHandle* psSoundManager::psSndSourceMngr::LoadSound(const char* fname) { ! csRef<iDataBuffer> buf; ! buf.Take (vfs->ReadFile(fname)); if (!buf || !buf->GetSize()) { *************** *** 261,268 **** } ! iSoundData* sounddata = NULL; ! sounddata = sndloader->LoadSound(buf->GetUint8 (), buf->GetSize ()); ! ! buf->DecRef (); if (!sounddata) --- 239,244 ---- } ! csRef<iSoundData> sounddata; ! sounddata.Take (sndloader->LoadSound (buf->GetUint8 (), buf->GetSize ())); if (!sounddata) *************** *** 272,276 **** } ! iSoundHandle* sndhandle = parent->snd->RegisterSound(sounddata); if (!sndhandle) --- 248,253 ---- } ! csRef<iSoundHandle> sndhandle; ! sndhandle = parent->snd->RegisterSound(sounddata); if (!sndhandle) *************** *** 280,291 **** } - sounddata->DecRef(); return sndhandle; } psSoundHandle* psSoundManager::psSndSourceMngr::CreateSound ! (const char* name, bool incref) { ! psTemplateRes* res = CreateResource(name, incref); if (!res) return NULL; --- 257,267 ---- } return sndhandle; } psSoundHandle* psSoundManager::psSndSourceMngr::CreateSound ! (const char* name) { ! psTemplateRes* res = CreateResource(name, true); if (!res) return NULL; *************** *** 302,308 **** { if (!strcmp(info->name, name)) - { break; - } } if (!info) --- 278,282 ---- Index: pssoundmngr.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/sound/pssoundmngr.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pssoundmngr.h 14 Apr 2002 15:14:23 -0000 1.6 --- pssoundmngr.h 21 Aug 2002 17:14:10 -0000 1.7 *************** *** 22,25 **** --- 22,26 ---- // CS includes #include <cssys/sysfunc.h> + #include <csutil/ref.h> #include <iutil/eventh.h> #include <iutil/comp.h> *************** *** 63,67 **** bool LoadSoundLib(const char* fname); iSoundHandle* LoadSound(const char* fname); ! psSoundHandle* CreateSound (const char* name, bool incref=true); protected: --- 64,68 ---- bool LoadSoundLib(const char* fname); iSoundHandle* LoadSound(const char* fname); ! psSoundHandle* CreateSound (const char* name); protected: *************** *** 69,82 **** csHashMap sndfiles; psSoundManager* parent; ! iSoundLoader* sndloader; ! iVFS* vfs; } sndmngr; friend class psSndSourceMngr; ! iSoundRender *snd; ! iSoundSource *backsound; ! psSoundHandle* backhandle; ! iEngine *engine; ! iObjectRegistry *object_reg; }; --- 70,83 ---- csHashMap sndfiles; psSoundManager* parent; ! csRef<iSoundLoader> sndloader; ! csRef<iVFS> vfs; } sndmngr; friend class psSndSourceMngr; ! csRef<iSoundRender> snd; ! csRef<iSoundSource> backsound; ! csRef<psSoundHandle> backhandle; ! csRef<iEngine> engine; ! csRef<iObjectRegistry> object_reg; }; |