Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.