Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3184


Ignore:
Timestamp:
Jun 15, 2009, 11:45:29 PM (15 years ago)
Author:
rgrieder
Message:

Converted SoundManager into a more suitable singleton.

Location:
code/branches/pch/src/orxonox
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pch/src/orxonox/gamestates/GSGraphics.cc

    r3182 r3184  
    5252#include "overlays/console/InGameConsole.h"
    5353#include "gui/GUIManager.h"
     54#include "sound/SoundManager.h"
    5455#include "GraphicsManager.h"
    5556
     
    6465        , guiManager_(0)
    6566        , graphicsManager_(0)
     67        , soundManager_(0)
    6668        , masterKeyBinder_(0)
    6769        , masterInputState_(0)
     
    9597        \li creates input manager
    9698        \li loads master key bindings
     99        \li loads the SoundManager
    97100        \li loads ingame console
    98101        \li loads GUI interface (GUIManager)
     
    128131        masterKeyBinder_->loadBindings("masterKeybindings.ini");
    129132        masterInputState_->setKeyHandler(masterKeyBinder_);
     133
     134        // Load the SoundManager
     135        soundManager_ = new SoundManager();
    130136
    131137        // Load the InGameConsole
     
    173179        delete this->debugOverlay_;
    174180
     181        delete this->soundManager_;
     182
    175183        delete this->inputManager_;
    176184        this->inputManager_ = 0;
  • code/branches/pch/src/orxonox/gamestates/GSGraphics.h

    r3177 r3184  
    7272        GUIManager*           guiManager_;          //!< Interface to GUI
    7373        GraphicsManager*      graphicsManager_;     //!< Interface to Ogre
     74        SoundManager*         soundManager_;        //!< Keeps track of SoundBase objects
    7475
    7576        KeyBinder*            masterKeyBinder_;     //!< Key binder for master key bindings
  • code/branches/pch/src/orxonox/sound/SoundBase.cc

    r3157 r3184  
    4141namespace orxonox
    4242{
    43     SoundManager* SoundBase::soundmanager_s = NULL;
    44 
    4543    SoundBase::SoundBase(WorldEntity* entity)
    4644    {
    47         if(SoundBase::soundmanager_s == NULL)
    48         {
    49             SoundBase::soundmanager_s = new SoundManager();
    50         }
    51 
    5245        this->source_ = 0;
    5346        this->buffer_ = 0;
    5447        this->entity_ = entity;
    5548
    56         SoundBase::soundmanager_s->addSound(this);
     49        SoundManager::getInstance().addSound(this);
    5750    }
    5851
     
    144137        filename = Core::getMediaPathString() + "/audio/" + filename;
    145138
    146         if(!SoundBase::soundmanager_s->isSoundAvailable())
     139        if(!SoundManager::getInstance().isSoundAvailable())
    147140        {
    148141            COUT(3) << "Sound: not available, skipping " << filename << std::endl;
  • code/branches/pch/src/orxonox/sound/SoundBase.h

    r3167 r3184  
    6464
    6565        ALint getSourceState();
    66 
    67         static SoundManager* soundmanager_s;
    6866    }; // class SoundBase
    6967} // namepsace orxonox
  • code/branches/pch/src/orxonox/sound/SoundManager.cc

    r3133 r3184  
    3838namespace orxonox
    3939{
     40    SoundManager* SoundManager::singletonRef_s = NULL;
    4041    ALCdevice* SoundManager::device_s = NULL;
    4142
     
    4546    SoundManager::SoundManager()
    4647    {
     48        assert(singletonRef_s == NULL);
     49        singletonRef_s = this;
     50
    4751        this->soundavailable_ = true;
    4852        if(!alutInitWithoutContext(NULL,NULL))
     
    9195    SoundManager::~SoundManager()
    9296    {
     97        assert(singletonRef_s != NULL);
     98        singletonRef_s = NULL;
     99
    93100        alcDestroyContext(this->context_);
    94101        alcCloseDevice(SoundManager::device_s);
  • code/branches/pch/src/orxonox/sound/SoundManager.h

    r3177 r3184  
    3030#include "OrxonoxPrereqs.h"
    3131
     32#include <cassert>
    3233#include <list>
    3334#include "interfaces/Tickable.h"
     
    5152        bool isSoundAvailable();
    5253
     54        static SoundManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
     55
    5356    private:
    5457        static ALCdevice* device_s;
     
    5760        bool soundavailable_;
    5861
     62        static SoundManager* singletonRef_s;
    5963    }; // class SoundManager
    6064} // namespace orxonox
Note: See TracChangeset for help on using the changeset viewer.