From: <wha...@us...> - 2011-06-08 21:01:00
|
Revision: 7380 http://planeshift.svn.sourceforge.net/planeshift/?rev=7380&view=rev Author: whacko88 Date: 2011-06-08 21:00:51 +0000 (Wed, 08 Jun 2011) Log Message: ----------- Added documentation of iSoundControl implemented SoundControl's type Modified Paths: -------------- soc/2011/sound/include/isoundctrl.h soc/2011/sound/include/isoundmngr.h soc/2011/sound/src/plugins/common/soundmanager/manager.cpp soc/2011/sound/src/plugins/common/soundmanager/manager.h soc/2011/sound/src/plugins/common/soundmanager/pssoundsector.h soc/2011/sound/src/plugins/common/soundmanager/soundctrl.cpp soc/2011/sound/src/plugins/common/soundmanager/soundctrl.h soc/2011/sound/src/plugins/common/soundmanager/soundmanager.cpp Modified: soc/2011/sound/include/isoundctrl.h =================================================================== --- soc/2011/sound/include/isoundctrl.h 2011-06-08 20:54:47 UTC (rev 7379) +++ soc/2011/sound/include/isoundctrl.h 2011-06-08 21:00:51 UTC (rev 7380) @@ -17,8 +17,8 @@ * */ -#ifndef __ISOUNDCONTROL_H__ -#define __ISOUNDCONTROL_H__ +#ifndef _ISOUNDCONTROL_H_ +#define _ISOUNDCONTROL_H_ enum SndCtrl_Type @@ -29,60 +29,77 @@ }; -/** API for the sound control plugin. -* API for the sound control plugin. -*/ +/** This interface defines the sound controller used by the application. + * + * The API allows the user to control the volume and the state of a group + * of sounds. The user can define a different SoundControl for each type + * of sound is needed to be controlled differently. For example one can + * use a SoundControl to manage voices and another one for the GUI's sounds. + * + * Every SoundControl has a type as defined in the enum SndCtrl_Type. There + * are two special types: SNDCTRL_TYPE_AMBIENT and SNDCTRL_TYPE_MUSIC that + * control the ambient and the music sounds respectively. There can be only + * one SoundControl of these two types at the same time while there can be + * an unlimited number of SoundControls with type SNDCTRL_TYPE_NORMAL. + * + * @see iSoundManager creates SoundControls. + */ struct iSoundControl { /** - * Returns the SoundControl's ID. - */ + * Get the SoundControl's ID. + */ virtual int GetID() const=0; /** - * Returns current Volume as float. - */ + * Get the SoundControl's type. + */ + virtual int GetType() const=0; + + /** + * Get the current Volume as float. + */ virtual float GetVolume() const=0; /** - * Sets volume to the given float. - * @param vol Volume as float - */ + * Set volume to the given float. + * @param vol the volume to be set. + */ virtual void SetVolume(float vol)=0; /** - * Unmute this. - */ + * Unmute sounds controlled by this SoundControl. + */ virtual void Unmute()=0; /** - * Mute this - */ + * Mute sounds controlled by this SoundControl. + */ virtual void Mute()=0; /** - * Get current Toggle state. - * Returns isEnabled - */ + * Get the current Toggle state. + * @return true if sounds controlled by this SoundControl are activated, + * false otherwise. + */ virtual bool GetToggle() const=0; /** - * Sets Toggle. - * @param value true or false - */ + * Set the current Toggle state. + * @param toggle true to activate the sounds controlled by this SoundControl, + * false otherwise. + */ virtual void SetToggle(bool toggle)=0; /** - * deactivates Toggle. - * Sets isEnabled to false - */ + * Deactivate sounds controlled by this SoundControl. + */ virtual void DeactivateToggle()=0; /** - * activates Toggle. - * Sets isEnabled to true - */ + * Activate sounds controlled by this SoundControl. + */ virtual void ActivateToggle()=0; }; -#endif // __ISOUNDCONTROL_H__ \ No newline at end of file +#endif // _ISOUNDCONTROL_H_ \ No newline at end of file Modified: soc/2011/sound/include/isoundmngr.h =================================================================== --- soc/2011/sound/include/isoundmngr.h 2011-06-08 20:54:47 UTC (rev 7379) +++ soc/2011/sound/include/isoundmngr.h 2011-06-08 21:00:51 UTC (rev 7380) @@ -17,8 +17,8 @@ * */ -#ifndef __ISOUNDMANAGER_H__ -#define __ISOUNDMANAGER_H__ +#ifndef _ISOUNDMANAGER_H_ +#define _ISOUNDMANAGER_H_ //==================================================================================== // Crystal Space Includes @@ -27,11 +27,6 @@ #include <csutil/scf_implementation.h> //==================================================================================== -// Project Includes -//==================================================================================== -// TODO is it needed? - -//==================================================================================== // Local Includes //==================================================================================== #include "isoundctrl.h" @@ -107,4 +102,4 @@ virtual void UpdateListener(iView* view)=0; }; -#endif // __ISOUNDMANAGER_H__ \ No newline at end of file +#endif // _ISOUNDMANAGER_H_ \ No newline at end of file Modified: soc/2011/sound/src/plugins/common/soundmanager/manager.cpp =================================================================== --- soc/2011/sound/src/plugins/common/soundmanager/manager.cpp 2011-06-08 20:54:47 UTC (rev 7379) +++ soc/2011/sound/src/plugins/common/soundmanager/manager.cpp 2011-06-08 21:00:51 UTC (rev 7380) @@ -43,7 +43,7 @@ // Create a new SoundSystem, SoundData Instance and the main SoundControl soundSystem = new SoundSystem; soundData = new SoundData; - mainSndCtrl = new SoundControl(-1); + mainSndCtrl = new SoundControl(-1, SNDCTRL_TYPE_NORMAL); if(soundSystem->Initialize(objectReg) && soundData->Initialize(objectReg)) @@ -341,7 +341,7 @@ soundSystem->UpdateListener(v, f, t); } -SoundControl* SoundSystemManager::AddSoundControl(int ctrlID) +SoundControl* SoundSystemManager::AddSoundControl(int ctrlID, int type) { SoundControl* newControl; @@ -350,7 +350,7 @@ return 0; } - newControl = new SoundControl(ctrlID); + newControl = new SoundControl(ctrlID, type); soundControllers.Put(ctrlID, newControl); return newControl; Modified: soc/2011/sound/src/plugins/common/soundmanager/manager.h =================================================================== --- soc/2011/sound/src/plugins/common/soundmanager/manager.h 2011-06-08 20:54:47 UTC (rev 7379) +++ soc/2011/sound/src/plugins/common/soundmanager/manager.h 2011-06-08 21:00:51 UTC (rev 7380) @@ -145,7 +145,7 @@ * a internal list of all existing SoundControls. But atm there * is no way to recover a lost SoundControl. */ - SoundControl* AddSoundControl(int ctrlID); + SoundControl* AddSoundControl(int ctrlID, int type); void RemoveSoundControl(SoundControl* sndCtrl); SoundControl* GetSoundControl(int ctrlID) const; Modified: soc/2011/sound/src/plugins/common/soundmanager/pssoundsector.h =================================================================== --- soc/2011/sound/src/plugins/common/soundmanager/pssoundsector.h 2011-06-08 20:54:47 UTC (rev 7379) +++ soc/2011/sound/src/plugins/common/soundmanager/pssoundsector.h 2011-06-08 21:00:51 UTC (rev 7380) @@ -1,33 +1,33 @@ /* -* pssoundsector.h -* -* Copyright (C) 2001-2010 Atomic Blue (in...@pl..., http://www.planeshift.it) -* -* Credits : Mathias 'AgY' Voeroes <ag...@op...> -* and all past and present planeshift coders -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation (version 2 of the License. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* -*/ + * pssoundsector.h + * + * Copyright (C) 2001-2010 Atomic Blue (in...@pl..., http://www.planeshift.it) + * + * Credits : Mathias 'AgY' Voeroes <ag...@op...> + * and all past and present planeshift coders + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation (version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ #ifndef _PSSOUNDSECTOR_H_ #define _PSSOUNDSECTOR_H_ /** -* work in progress - Looks like a mishap. I hope find a object where i -* can merge this into -*/ + * work in progress - Looks like a mishap. I hope find a object where i + * can merge this into + */ class psSoundSector { public: @@ -46,15 +46,15 @@ csRandomGen rng; ///< random number generator /** - * Constructor - * @param sector documentnode that contains all sector data - */ + * Constructor + * @param sector documentnode that contains all sector data + */ psSoundSector(csRef<iDocumentNode> sector, iObjectRegistry* objReg); /** - * Destructor. - * Cleans all arrays - */ + * Destructor. + * Cleans all arrays + */ ~psSoundSector(); void AddAmbient(csRef<iDocumentNode> Node); void UpdateAmbient(int type, SoundControl* &ctrl); Modified: soc/2011/sound/src/plugins/common/soundmanager/soundctrl.cpp =================================================================== --- soc/2011/sound/src/plugins/common/soundmanager/soundctrl.cpp 2011-06-08 20:54:47 UTC (rev 7379) +++ soc/2011/sound/src/plugins/common/soundmanager/soundctrl.cpp 2011-06-08 21:00:51 UTC (rev 7380) @@ -29,9 +29,10 @@ #include "manager.h" -SoundControl::SoundControl(int ID) +SoundControl::SoundControl(int ID, int t) { id = ID; + type = t; isEnabled = true; isMuted = false; volume = VOLUME_NORM; @@ -68,6 +69,16 @@ return id; } +int SoundControl::GetType() const +{ + return type; +} + +void SoundControl::SetType(int t) +{ + type = t; +} + void SoundControl::ActivateToggle() { isEnabled = true; Modified: soc/2011/sound/src/plugins/common/soundmanager/soundctrl.h =================================================================== --- soc/2011/sound/src/plugins/common/soundmanager/soundctrl.h 2011-06-08 20:54:47 UTC (rev 7379) +++ soc/2011/sound/src/plugins/common/soundmanager/soundctrl.h 2011-06-08 21:00:51 UTC (rev 7380) @@ -51,7 +51,7 @@ * Constructor. * Defaults are unmuted, enabled and volume is set to 1.0f. */ - SoundControl(int ID); + SoundControl(int ID, int type); /** * Destructor @@ -78,6 +78,17 @@ virtual int GetID() const; /** + * Get the SoundControl's type. + */ + virtual int GetType() const; + + /** + * Set the SoundControl's type. Note that it does not affect + * the callback. The callback must be managed separately. + */ + void SetType(int type); + + /** * Returns current Volume as float. */ virtual float GetVolume() const; @@ -124,6 +135,7 @@ private: int id; ///< id of this control + int type; ///< type of this control bool isEnabled; ///< is it enabled? true or false float volume; ///< current volume as float bool isMuted; ///< is it muted? true or false Modified: soc/2011/sound/src/plugins/common/soundmanager/soundmanager.cpp =================================================================== --- soc/2011/sound/src/plugins/common/soundmanager/soundmanager.cpp 2011-06-08 20:54:47 UTC (rev 7379) +++ soc/2011/sound/src/plugins/common/soundmanager/soundmanager.cpp 2011-06-08 21:00:51 UTC (rev 7380) @@ -229,25 +229,27 @@ } /* -* WARNING: if a sound control with the same type already exists +* NOTE: if a sound control with the same type already exists * it is overwritten (i.e. the old sound control becomes a normal * sound control with type = SNDCTRL_TYPE_NORMAL). */ iSoundControl* SoundManager::AddSndCtrl(int ctrlID, int type) { - SoundControl* sc = sndSysMgr->AddSoundControl(ctrlID); + SoundControl* sc = sndSysMgr->AddSoundControl(ctrlID, type); if(sc == 0) { return 0; } + // Handle Ambient and Music SoundControls. switch(type) { case SNDCTRL_TYPE_AMBIENT: sc->SetCallback(this, &UpdateAmbientCallback); if(ambientSndCtrl != 0) { + ambientSndCtrl->SetType(SNDCTRL_TYPE_NORMAL); ambientSndCtrl->RemoveCallback(); } ambientSndCtrl = sc; @@ -257,6 +259,7 @@ sc->SetCallback(this, &UpdateMusicCallback); if(musicSndCtrl != 0) { + musicSndCtrl->SetType(SNDCTRL_TYPE_NORMAL); musicSndCtrl->RemoveCallback(); } musicSndCtrl = sc; @@ -274,17 +277,16 @@ return; } - int sndId = sndCtrl->GetID(); - // check if it is the ambientSndCtrl or the musicSndCtrl - if(sndId == ambientSndCtrl->GetID()) + switch(sndCtrl->GetType()) { + case SNDCTRL_TYPE_AMBIENT: ambientSndCtrl = 0; - } + break; - if(sndId == musicSndCtrl->GetID()) - { + case SNDCTRL_TYPE_MUSIC: musicSndCtrl = 0; + break; } SoundControl* sndControl = static_cast<SoundControl*>(sndCtrl); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |