Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 10, 2016, 1:54:11 PM (9 years ago)
Author:
landauf
Message:

merged branch cpp11_v2 into cpp11_v3

Location:
code/branches/cpp11_v3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v3

  • code/branches/cpp11_v3/src/orxonox/sound/SoundManager.cc

    r10624 r11054  
    8383            ThrowException(InitialisationAborted, "Sound: Not loading at all");
    8484#if !defined(ORXONOX_PLATFORM_APPLE)
    85         if (!alutInitWithoutContext(NULL, NULL))
     85        if (!alutInitWithoutContext(nullptr, nullptr))
    8686            ThrowException(InitialisationFailed, "Sound Error: ALUT initialisation failed: " << alutGetErrorString(alutGetError()));
    8787        Loki::ScopeGuard alutExitGuard = Loki::MakeGuard(&alutExit);
     
    9090/*
    9191        // Get list of available sound devices and display them
    92         const char* devices = alcGetString(NULL, ALC_DEVICE_SPECIFIER);
     92        const char* devices = alcGetString(nullptr, ALC_DEVICE_SPECIFIER);
    9393        char* device = new char[strlen(devices)+1];
    9494        strcpy(device, devices);
     
    110110        this->device_ = alcOpenDevice(renderDevice.c_str());
    111111*/
    112         this->device_ = alcOpenDevice(NULL);
    113         if (this->device_ == NULL)
     112        this->device_ = alcOpenDevice(nullptr);
     113        if (this->device_ == nullptr)
    114114            ThrowException(InitialisationFailed, "Sound Error: Could not open sound device.");
    115115        Loki::ScopeGuard closeDeviceGuard = Loki::MakeGuard(&alcCloseDevice, this->device_);
    116116
    117117        // Create sound context and make it the currently used one
    118         this->context_ = alcCreateContext(this->device_, NULL);
    119         if (this->context_ == NULL)
     118        this->context_ = alcCreateContext(this->device_, nullptr);
     119        if (this->context_ == nullptr)
    120120            ThrowException(InitialisationFailed, "Sound Error: Could not create ALC context");
    121121        Loki::ScopeGuard desroyContextGuard = Loki::MakeGuard(&alcDestroyContext, this->context_);
     
    189189
    190190        // Relieve context to destroy it
    191         if (!alcMakeContextCurrent(NULL))
     191        if (!alcMakeContextCurrent(nullptr))
    192192            orxout(internal_error, context::sound) << "Could not unset ALC context" << endl;
    193193        alcDestroyContext(this->context_);
     
    294294        {
    295295        case SoundType::All:
    296             for (ObjectList<BaseSound>::iterator it = ObjectList<BaseSound>::begin(); it != ObjectList<BaseSound>::end(); ++it)
    297                 (*it)->updateVolume();
     296            for (BaseSound* sound : ObjectList<BaseSound>())
     297                sound->updateVolume();
    298298            break;
    299299        case SoundType::Music:
    300             for (ObjectList<AmbientSound>::iterator it = ObjectList<AmbientSound>::begin(); it != ObjectList<AmbientSound>::end(); ++it)
    301                 (*it)->updateVolume();
     300            for (AmbientSound* sound : ObjectList<AmbientSound>())
     301                sound->updateVolume();
    302302            break;
    303303        case SoundType::Effects:
    304             for (ObjectList<WorldSound>::iterator it = ObjectList<WorldSound>::begin(); it != ObjectList<WorldSound>::end(); ++it)
    305                 (*it)->updateVolume();
     304            for (WorldSound* sound : ObjectList<WorldSound>())
     305                sound->updateVolume();
    306306            break;
    307307        default:
     
    350350    void SoundManager::registerAmbientSound(AmbientSound* newAmbient)
    351351    {
    352         if (newAmbient != NULL && !this->bDestructorCalled_)
     352        if (newAmbient != nullptr && !this->bDestructorCalled_)
    353353        {
    354354            for (AmbientList::const_iterator it = this->ambientSounds_.begin(); it != this->ambientSounds_.end(); ++it)
     
    373373    void SoundManager::unregisterAmbientSound(AmbientSound* oldAmbient)
    374374    {
    375         if (oldAmbient == NULL || ambientSounds_.empty() || this->bDestructorCalled_)
     375        if (oldAmbient == nullptr || ambientSounds_.empty() || this->bDestructorCalled_)
    376376            return;
    377377
     
    405405    void SoundManager::pauseAmbientSound(AmbientSound* ambient)
    406406    {
    407         if (ambient != NULL)
    408         {
    409             for (AmbientList::iterator it = this->ambientSounds_.begin(); it != this->ambientSounds_.end(); ++it)
    410             {
    411                 if (it->first == ambient)
     407        if (ambient != nullptr)
     408        {
     409            for (std::pair<AmbientSound*, bool>& pair : this->ambientSounds_)
     410            {
     411                if (pair.first == ambient)
    412412                {
    413                     it->second = true;
    414                     this->fadeOut(it->first);
     413                    pair.second = true;
     414                    this->fadeOut(pair.first);
    415415                    return;
    416416                }
     
    422422    {
    423423        // If we're already fading out --> remove that
    424         for (std::list<StrongPtr<AmbientSound> >::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); it++)
     424        for (std::list<StrongPtr<AmbientSound>>::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); it++)
    425425        {
    426426            if (*it == sound)
     
    438438    {
    439439        // If we're already fading in --> remove that
    440         for (std::list<StrongPtr<AmbientSound> >::iterator it = this->fadeInList_.begin(); it != this->fadeInList_.end(); it++)
     440        for (std::list<StrongPtr<AmbientSound>>::iterator it = this->fadeInList_.begin(); it != this->fadeInList_.end(); it++)
    441441        {
    442442            if (*it == sound)
     
    461461
    462462        // FADE IN
    463         for (std::list<StrongPtr<AmbientSound> >::iterator it= this->fadeInList_.begin(); it != this->fadeInList_.end(); )
     463        for (std::list<StrongPtr<AmbientSound>>::iterator it= this->fadeInList_.begin(); it != this->fadeInList_.end(); )
    464464        {
    465465            if ((*it)->getVolume() + this->crossFadeStep_*dt > 1.0f)
     
    476476
    477477        // FADE OUT
    478         for (std::list<StrongPtr<AmbientSound> >::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); )
     478        for (std::list<StrongPtr<AmbientSound>>::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); )
    479479        {
    480480            if ((*it)->getVolume() - this->crossFadeStep_*dt < 0.0f)
     
    505505    }
    506506
    507     shared_ptr<SoundBuffer> SoundManager::getSoundBuffer(const std::string& filename)
    508     {
    509         shared_ptr<SoundBuffer> buffer;
     507    std::shared_ptr<SoundBuffer> SoundManager::getSoundBuffer(const std::string& filename)
     508    {
     509        std::shared_ptr<SoundBuffer> buffer;
    510510        // Check active or pooled buffers
    511511        SoundBufferMap::const_iterator it = this->soundBuffers_.find(filename);
     
    538538    }
    539539
    540     void SoundManager::releaseSoundBuffer(const shared_ptr<SoundBuffer>& buffer, bool bPoolBuffer)
     540    void SoundManager::releaseSoundBuffer(const std::shared_ptr<SoundBuffer>& buffer, bool bPoolBuffer)
    541541    {
    542542        // Check if others are still using the buffer
     
    551551                while (this->effectsPoolSize_ + it->second->getSize() > this->maxEffectsPoolSize_s && !this->effectsPool_.empty())
    552552                {
    553                     shared_ptr<SoundBuffer> bufferDel = this->effectsPool_.back();
     553                    std::shared_ptr<SoundBuffer> bufferDel = this->effectsPool_.back();
    554554                    this->effectsPoolSize_ -= bufferDel->getSize();
    555555                    bufferDel->poolIterator_ = this->effectsPool_.end();
     
    576576            ALuint source = this->availableSoundSources_.back();
    577577            this->availableSoundSources_.pop_back();
    578             this->usedSoundSources_.push_back(std::make_pair(source, object));
     578            this->usedSoundSources_.emplace_back(source, object);
    579579            return source;
    580580        }
     
    588588                if (alIsSource(source) && !alGetError())
    589589                {
    590                     this->usedSoundSources_.push_back(std::make_pair(source, object));
     590                    this->usedSoundSources_.emplace_back(source, object);
    591591                    return source;
    592592                }
     
    606606#endif
    607607        this->availableSoundSources_.push_back(source);
    608         for (std::vector<std::pair<ALuint, BaseSound*> >::iterator it = this->usedSoundSources_.begin();
     608        for (std::vector<std::pair<ALuint, BaseSound*>>::iterator it = this->usedSoundSources_.begin();
    609609            it != this->usedSoundSources_.end(); ++it)
    610610        {
Note: See TracChangeset for help on using the changeset viewer.