Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 1, 2011, 5:10:29 AM (13 years ago)
Author:
rgrieder
Message:

Merged sound5 into sound6 branch.

Location:
code/branches/usability
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/usability

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

    r7858 r8005  
    2222 *   Author:
    2323 *       Erwin 'vaiursch' Herrsche
     24 *       
     25 *   Co-authors:
    2426 *       Kevin Young
    2527 *       Reto Grieder
    26  *   Co-authors:
    27  *      ...
    2828 *
    2929 */
     
    5252    ManageScopedSingleton(SoundManager, ScopeID::Graphics, true);
    5353
    54     std::string SoundManager::getALErrorString(ALenum code)
     54    // From SoundPrereqs.h
     55    std::string getALErrorString(ALenum code)
    5556    {
    5657        switch (code)
     
    8081
    8182        if (!alutInitWithoutContext(NULL, NULL))
    82             ThrowException(InitialisationFailed, "Sound Error: ALUT initialisation failed: " << alutGetErrorString(alutGetError()));
     83            ThrowException(InitialisationFailed, "Sound: Error: ALUT initialisation failed: " << alutGetErrorString(alutGetError()));
    8384        Loki::ScopeGuard alutExitGuard = Loki::MakeGuard(&alutExit);
    8485
     
    112113            COUT(1) << "Sound: Just getting the DLL with the dependencies is not enough for Windows (esp. Windows 7)!" << std::endl;
    113114#endif
    114             ThrowException(InitialisationFailed, "Sound Error: Could not open sound device.");
     115            ThrowException(InitialisationFailed, "Sound: Error: Could not open sound device.");
    115116        }
    116117        Loki::ScopeGuard closeDeviceGuard = Loki::MakeGuard(&alcCloseDevice, this->device_);
    117118
    118119        // Create sound context and make it the currently used one
    119         this->context_ = alcCreateContext(this->device_, NULL);
     120        const ALint contattr[]  = {ALC_SYNC, 1, 0};
     121        this->context_ = alcCreateContext(this->device_, contattr);
    120122        if (this->context_ == NULL)
    121             ThrowException(InitialisationFailed, "Sound Error: Could not create ALC context");
     123            ThrowException(InitialisationFailed, "Sound: Error: Could not create ALC context");
    122124        Loki::ScopeGuard desroyContextGuard = Loki::MakeGuard(&alcDestroyContext, this->context_);
    123125        if (!alcMakeContextCurrent(this->context_))
    124             ThrowException(InitialisationFailed, "Sound Error: Could not use ALC context");
     126            ThrowException(InitialisationFailed, "Sound: Error: Could not use ALC context");
    125127
    126128        GameMode::setPlaysSound(true);
     
    135137            COUT(4) << "Sound: --- Supported MIME Types: " << types << std::endl;
    136138        else
    137             COUT(2) << "Sound Warning: MIME Type retrieval failed: " << alutGetErrorString(alutGetError()) << std::endl;
     139            COUT(2) << "Sound: Warning: MIME Type retrieval failed: " << alutGetErrorString(alutGetError()) << std::endl;
    138140
    139141        this->mute_[SoundType::All]     = 1.0f;
     
    149151            this->availableSoundSources_.push_back(source);
    150152        else
    151             ThrowException(InitialisationFailed, "Sound Error: Could not create even a single source");
     153            ThrowException(InitialisationFailed, "Sound: Error: Could not create even a single source");
    152154        // Create a few initial sources
    153155        this->createSoundSources(this->minSources_ - 1);
     
    171173        // If there are still used buffers around, well, that's just very bad...
    172174        if (this->soundBuffers_.size() != this->effectsPool_.size())
    173             COUT(1) << "Sound Error: Some sound buffers are still in use but OpenAL is about to shut down. Fix this!" << std::endl;
     175            COUT(1) << "Sound: Error: Some sound buffers are still in use but OpenAL is about to shut down. Fix this!" << std::endl;
    174176        // Empty buffer pool and buffer list
    175177        this->effectsPool_.clear();
     
    178180        // There should not be any sources in use anymore
    179181        if (!this->usedSoundSources_.empty())
    180             COUT(1) << "Sound Error: Some sound sources are still in use but OpenAL is about to shut down. Fix this!" << std::endl;
     182            COUT(1) << "Sound: Error: Some sound sources are still in use but OpenAL is about to shut down. Fix this!" << std::endl;
    181183        while (!this->availableSoundSources_.empty())
    182184        {
     
    189191        // Relieve context to destroy it
    190192        if (!alcMakeContextCurrent(NULL))
    191             COUT(1) << "Sound Error: Could not unset ALC context" << std::endl;
     193            COUT(1) << "Sound: Error: Could not unset ALC context" << std::endl;
    192194        alcDestroyContext(this->context_);
    193195        if (ALCenum error = alcGetError(this->device_))
    194196        {
    195197            if (error == AL_INVALID_OPERATION)
    196                 COUT(1) << "Sound Error: Could not destroy ALC context because it is the current one" << std::endl;
     198                COUT(1) << "Sound: Error: Could not destroy ALC context because it is the current one" << std::endl;
    197199            else
    198                 COUT(1) << "Sound Error: Could not destroy ALC context because it is invalid" << std::endl;
     200                COUT(1) << "Sound: Error: Could not destroy ALC context because it is invalid" << std::endl;
    199201        }
    200202#ifdef AL_VERSION_1_1
    201203        if (!alcCloseDevice(this->device_))
    202             COUT(1) << "Sound Error: Could not destroy ALC device. This might be because there are still buffers in use!" << std::endl;
     204            COUT(1) << "Sound: Error: Could not destroy ALC device. This might be because there are still buffers in use!" << std::endl;
    203205#else
    204206        alcCloseDevice(this->device_);
    205207#endif
    206208        if (!alutExit())
    207             COUT(1) << "Sound Error: Closing ALUT failed: " << alutGetErrorString(alutGetError()) << std::endl;
     209            COUT(1) << "Sound: Error: Closing ALUT failed: " << alutGetErrorString(alutGetError()) << std::endl;
    208210    }
    209211
     
    251253        if (crossFadeStep_ <= 0.0 || crossFadeStep_ >= 1.0 )
    252254        {
    253             COUT(2) << "Sound warning: fade step out of range, ignoring change." << std::endl;
     255            COUT(2) << "Sound: Warning: fade step out of range, ignoring change." << std::endl;
    254256            ResetConfigValue(crossFadeStep_);
    255257        }
     
    260262        float clampedVolume = clamp(this->volume_[type], 0.0f, 1.0f);
    261263        if (clampedVolume != this->volume_[type])
    262             COUT(2) << "Sound warning: Volume setting (" << type << ") out of range, clamping." << std::endl;
     264            COUT(2) << "Sound: Warning: Volume setting (" << type << ") out of range, clamping." << std::endl;
    263265        this->updateVolume(type);
    264266    }
     
    352354                if (it->first == newAmbient)
    353355                {
    354                     COUT(2) << "Sound warning: Will not play an AmbientSound twice." << std::endl;
     356                    COUT(2) << "Sound: Warning: Will not play an AmbientSound twice." << std::endl;
    355357                    return;
    356358                }
     
    620622            alDeleteSources(1, &this->availableSoundSources_.back());
    621623            if (alGetError())
    622                 COUT(1) << "Sound Error: Failed to delete a source --> lost forever" << std::endl;
     624                COUT(1) << "Sound: Error: Failed to delete a source --> lost forever" << std::endl;
    623625            this->availableSoundSources_.pop_back();
    624626        }
Note: See TracChangeset for help on using the changeset viewer.