Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 15, 2010, 3:42:24 PM (15 years ago)
Author:
erwin
Message:

Added some hacks, now the source is playing, but there are no processed buffers…

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

Legend:

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

    r6730 r6733  
    183183        if(this->soundstreamthread_ == boost::thread())
    184184            COUT(2) << "Sound: Failed to create thread." << std::endl;
    185 
    186         if (alIsSource(this->audioSource_)) // already playing or paused
    187         {
    188             // Sound was already playing or paused because there was a source acquired
    189             assert(this->isPlaying() || this->isPaused());
    190             alSourcePlay(this->audioSource_);
    191             if (int error = alGetError())
    192                 COUT(2) << "Sound: Error playing sound: " << getALErrorString(error) << std::endl;
    193             if (this->isPaused())
    194                 alSourcePause(this->audioSource_);
    195         }
    196         else // No source acquired so far, but might be set to playing or paused
    197         {
    198             if (this->isPlaying() || this->isPaused())
    199                 doPlay();
    200             if (this->isPaused())
    201             {
    202                 doPause();
    203             }
    204         }
    205 
    206         this->updateVolume();
    207         this->setPitch(this->getPitch());
    208         this->setLooping(this->getLooping());
     185       
    209186        alSource3f(this->audioSource_, AL_POSITION,  0, 0, 0);
    210187        alSource3f(this->audioSource_, AL_VELOCITY,  0, 0, 0);
  • code/branches/sound5/src/orxonox/sound/SoundStreamer.cc

    r6729 r6733  
    4444    {
    4545        COUT(4) << "Sound: Creating thread for " << dataStream->getName() << std::endl;
     46
     47        alSourcei(audioSource, AL_BUFFER, 0);
     48
    4649        // Open file with custom streaming
    4750        ov_callbacks vorbisCallbacks;
     
    101104        }
    102105
     106        alSourcei(audioSource, AL_LOOPING, AL_TRUE);
     107
     108        alSourcePlay(audioSource);
     109        if(ALint error = alGetError())
     110            COUT(2) << "Sound: Could not start ambient sound" << std::endl;
     111
    103112        while(true) // Stream forever, control through thread control
    104113        {
    105             int processed;
     114
     115            int info;
     116            alGetSourcei(audioSource, AL_SOURCE_STATE, &info);
     117            if(info == AL_PLAYING)
     118                COUT(4) << "Sound: " << dataStream->getName() << " is playing." << std::endl;
     119            else
     120                COUT(4) << "Sound: " << dataStream->getName() << " is not playing." << std::endl;
    106121
    107122            if(alcGetCurrentContext() == NULL)
     
    111126            }
    112127
     128            int processed;
    113129            alGetSourcei(audioSource, AL_BUFFERS_PROCESSED, &processed);
    114130            if (ALint error = alGetError())
    115131                COUT(2) << "Sound: Warning: Couldn't get number of processed buffers: " << getALErrorString(error) << std::endl;
     132            COUT(4) << "Sound: processed buffers: " << processed << std::endl;
    116133
    117134            if(processed > 0)
    118135            {
    119                 COUT(4) << "Sound: " << processed << std::endl;
    120136                ALuint* buffers = new ALuint[processed];
    121137                alSourceUnqueueBuffers(audioSource, processed, buffers);
    122138                if (ALint error = alGetError())
    123139                    COUT(2) << "Sound: Warning: Couldn't unqueue buffers: " << getALErrorString(error) << std::endl;
    124 
    125                 int info;
    126                 alGetSourcei(audioSource, AL_SOURCE_STATE, &info);
    127                 if(info == AL_PLAYING)
    128                     COUT(4) << "Sound: " << dataStream->getName() << " is playing." << std::endl;
    129                 else
    130                     COUT(4) << "Sound: " << dataStream->getName() << " is not playing." << std::endl;
    131140
    132141                for(int i = 0; i < processed; i++)
     
    171180                return;
    172181            }
    173             msleep(100); // perhaps another value here is better
     182            msleep(50); // perhaps another value here is better
    174183        }
    175184    }
Note: See TracChangeset for help on using the changeset viewer.