Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6562


Ignore:
Timestamp:
Mar 18, 2010, 3:48:49 PM (14 years ago)
Author:
erwin
Message:

More tries to fix the sound: there seems to be no context in the stream thread…

Location:
code/branches/sound5/src/orxonox/sound
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/sound5/src/orxonox/sound/AmbientSound.cc

    r6511 r6562  
    175175
    176176        this->soundstreamthread_ = boost::thread(SoundStreamer(), this->audioSource_, dataStream);
     177        if(this->soundstreamthread_ == boost::thread())
     178            COUT(2) << "Sound: Failed to create thread." << std::endl;
     179
    177180
    178181        this->updateVolume();
  • code/branches/sound5/src/orxonox/sound/SoundManager.cc

    r6510 r6562  
    116116
    117117        // Create sound context and make it the currently used one
    118         this->context_ = alcCreateContext(this->device_, NULL);
     118        const ALint contattr[]  = {ALC_SYNC, 1, 0};
     119        this->context_ = alcCreateContext(this->device_, contattr);
    119120        if (this->context_ == NULL)
    120121            ThrowException(InitialisationFailed, "Sound: Error: Could not create ALC context");
  • code/branches/sound5/src/orxonox/sound/SoundStreamer.cc

    r6506 r6562  
    2828
    2929#include <al.h>
     30#include <alc.h>
    3031#include <vorbis/vorbisfile.h>
    3132#include "SoundManager.h"
     
    6768        ALuint initbuffers[4];
    6869        alGenBuffers(4, initbuffers);
     70        if (ALint error = alGetError()) {
     71            COUT(2) << "Sound: Streamer: Could not generate buffer:" << getALErrorString(error) << std::endl;
     72            return;
     73        }
    6974        int current_section;
    7075
     
    8489
    8590            alBufferData(initbuffers[i], format, &inbuffer, ret, vorbisInfo->rate);
     91            alGetError();
    8692        }
    8793        alSourceQueueBuffers(audioSource, 4, initbuffers);
     94        if (ALint error = alGetError()) {
     95            COUT(2) << "Sound: Warning: Couldn't queue buffers: " << getALErrorString(error) << std::endl;
     96        }
    8897
    8998        while(true) // Stream forever, control through thread control
    9099        {
    91100            int processed;
     101
     102        if(alcGetCurrentContext() == NULL)
     103            COUT(2) << "This should not be!" << std::endl;
     104
    92105            alGetSourcei(audioSource, AL_BUFFERS_PROCESSED, &processed);
    93106            if (ALint error = alGetError())
    94             COUT(2) << "Sound Warning: Couldn't get number of processed buffers: " << getALErrorString(error) << std::endl;
     107            COUT(2) << "Sound: Warning: Couldn't get number of processed buffers: " << getALErrorString(error) << std::endl;
    95108
    96109            if(processed > 0)
     
    99112                alSourceUnqueueBuffers(audioSource, processed, buffers);
    100113                if (ALint error = alGetError())
    101                     COUT(2) << "Sound Warning: Couldn't unqueue buffers: " << getALErrorString(error) << std::endl;
     114                    COUT(2) << "Sound: Warning: Couldn't unqueue buffers: " << getALErrorString(error) << std::endl;
    102115
    103116                for(int i = 0; i < processed; i++)
     
    116129
    117130                    alBufferData(buffers[i], format, &inbuffer, ret, vorbisInfo->rate);
     131                    alGetError();
    118132                }
    119133
    120134                alSourceQueueBuffers(audioSource, processed, buffers);
    121135                if (ALint error = alGetError())
    122                     COUT(2) << "Sound Warning: Couldn't queue buffers: " << getALErrorString(error) << std::endl;
     136                    COUT(2) << "Sound: Warning: Couldn't queue buffers: " << getALErrorString(error) << std::endl;
    123137            }
    124             msleep(250); // perhaps another value here is better
     138            msleep(100); // perhaps another value here is better
    125139        }
    126140    }
Note: See TracChangeset for help on using the changeset viewer.