Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 13, 2009, 5:39:22 PM (15 years ago)
Author:
rgrieder
Message:

Fixed bug: Ambient sounds were sometimes not played at all (caused by the source management changes).
And removed some debug output.

Location:
code/branches/presentation2/src/orxonox/sound
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/orxonox/sound/BaseSound.cc

    r6327 r6340  
    224224
    225225        this->source_ = source;
     226        // Don't load ""
    226227        if (source_.empty())
    227228            return;
    228229
     230        // Get new sound buffer
    229231        this->soundBuffer_ = SoundManager::getInstance().getSoundBuffer(this->source_);
    230232        if (this->soundBuffer_ == NULL)
    231233            return;
    232234
    233         if (alIsSource(this->audioSource_))
    234         {
     235        if (alIsSource(this->audioSource_)) // already playing or paused
     236        {
     237            // Set new buffer
    235238            alSourcei(this->audioSource_, AL_BUFFER, this->soundBuffer_->getBuffer());
    236239            if (ALuint error = alGetError())
     
    240243            }
    241244
    242             if (this->isPlaying() || this->isPaused())
    243             {
    244                 alSourcePlay(this->audioSource_);
    245                 if (int error = alGetError())
    246                     COUT(2) << "Sound: Error playing sound: " << SoundManager::getALErrorString(error) << std::endl;
    247             }
     245            // Sound was already playing or paused because there was a source acquired
     246            assert(this->isPlaying() || this->isPaused());
     247            alSourcePlay(this->audioSource_);
     248            if (int error = alGetError())
     249                COUT(2) << "Sound: Error playing sound: " << SoundManager::getALErrorString(error) << std::endl;
    248250            if (this->isPaused())
    249251                alSourcePause(this->audioSource_);
     252        }
     253        else // No source acquired so far, but might be set to playing or paused
     254        {
     255            State state = this->state_; // save
     256            if (this->isPlaying() || this->isPaused())
     257                BaseSound::play();
     258            if (state == Paused)
     259            {
     260                this->state_ = Paused;
     261                BaseSound::pause();
     262            }
    250263        }
    251264    }
  • code/branches/presentation2/src/orxonox/sound/SoundBuffer.cc

    r6332 r6340  
    3333#include <vorbis/vorbisfile.h>
    3434
    35 #include "util/Clock.h"
    36 #include "core/Game.h"
    3735#include "util/Exception.h"
    3836#include "util/StringUtils.h"
     
    6361        if (getLowercase(extension) == "ogg")
    6462        {
    65             int before = Game::getInstance().getGameClock().getRealMicroseconds();
    6663            // Try ogg loader
    6764            this->loadOgg(fileInfo, dataStream);
    68             int after = Game::getInstance().getGameClock().getRealMicroseconds();
    69             COUT(0) << filename << ": " << (after - before) << std::endl;
    7065        }
    7166        else
Note: See TracChangeset for help on using the changeset viewer.