Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 4, 2009, 3:40:08 PM (15 years ago)
Author:
erwin
Message:

ambient sound loading for levels

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/sound/src/sound/SoundBase.cc

    r2932 r2950  
    3434namespace orxonox
    3535{
     36    SoundBase::SoundBase()
     37    {
     38        this->source_ = 0;
     39        this->buffer_ = 0;
     40        this->entity_ = NULL;
     41    }
    3642    SoundBase::SoundBase(WorldEntity* entity)
    3743    {
     
    3945        this->buffer_ = 0;
    4046        this->entity_ = entity;
    41 
    42         if(SoundBase::soundmanager_s == NULL)
    43             SoundBase::soundmanager_s = SoundManager::instance();
    4447    }
    4548
     
    5154
    5255    void SoundBase::update() {
    53         if(alIsSource(this->source_)) {
     56        if(this->entity_ != NULL && alIsSource(this->source_)) {
    5457            Vector3 pos = this->entity_->getPosition();
    5558            alSource3f(this->source_, AL_POSITION, pos.x, pos.y, pos.z);
     
    99102            return getSourceState() == AL_PLAYING;
    100103        }
     104        return false;
    101105    }
    102106
     
    105109            return getSourceState() == AL_PAUSED;
    106110        }
     111        return true;
    107112    }
    108113
     
    111116            return getSourceState() == AL_INITIAL || getSourceState() == AL_STOPPED;
    112117        }
     118        return true;
    113119    }
    114120
    115121    bool SoundBase::loadFile(std::string filename) {
     122        COUT(3) << "OpenAL ALUT: loading file " << filename << std::endl;
    116123        this->buffer_ = alutCreateBufferFromFile(filename.c_str());
    117124        if(this->buffer_ == AL_NONE) {
    118             COUT(2) << "OpenAL ALUT: " << alutGetErrorString(alutGetError());
     125            COUT(2) << "OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl;
    119126            return false;
    120127        }
     
    123130        alSourcei(this->source_, AL_BUFFER, this->buffer_);
    124131        if(alGetError() != AL_NO_ERROR) {
    125             COUT(2) << "OpenAL: Error loading sample file";
     132            COUT(2) << "OpenAL: Error loading sample file" << std::endl;
    126133            return false;
    127134        }
Note: See TracChangeset for help on using the changeset viewer.