Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6476 for code/branches/sound4


Ignore:
Timestamp:
Mar 6, 2010, 3:08:19 PM (15 years ago)
Author:
erwin
Message:

Tried to hack ths sound streaming part in… sound doesn't work at all now.

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

Legend:

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

    r6417 r6476  
    3535#include "core/XMLPort.h"
    3636#include "SoundManager.h"
     37#include "SoundStreamer.h"
    3738
    3839namespace orxonox
     
    120121            shared_ptr<ResourceInfo> fileInfo = Resource::getInfo(path);
    121122            if (fileInfo != NULL)
    122                 this->setSource(path);
     123                this->setStreamSource(path);
    123124            else
    124125                COUT(3) << "Sound: " << this->ambientSource_ << ": Not a valid name! Ambient sound will not change." << std::endl;
     
    141142            this->stop();
    142143    }
     144
     145    // hacky solution for file streaming
     146    void AmbientSound::setStreamSource(const std::string& source)
     147    {
     148        this->audioSource_ = SoundManager::getInstance().getSoundSource(this);
     149        if (this->source_ == source)
     150        {
     151            return;
     152        }
     153
     154        this->source_ = source;
     155        // Don't load ""
     156        if (source_.empty())
     157            return;
     158
     159        if (this->soundstreamthread_.get_id() != boost::thread::id())
     160        {
     161            this->soundstreamthread_.interrupt(); // unhandled interruptions lead to thread terminating ;-)
     162        }
     163        // Get resource info
     164        shared_ptr<ResourceInfo> fileInfo = Resource::getInfo(source);
     165        if (fileInfo == NULL)
     166        {
     167            COUT(2) << "Sound: Warning: Sound file '" << source << "' not found" << std::endl;
     168            return;
     169        }
     170        // Open data stream
     171        DataStreamPtr dataStream = Resource::open(fileInfo);
     172
     173        this->soundstreamthread_ = boost::thread(SoundStreamer(), this->audioSource_, dataStream);
     174    }
    143175}
  • code/branches/sound4/src/orxonox/sound/AmbientSound.h

    r6435 r6476  
    3030#ifndef _AmbientSound_H__
    3131#define _AmbientSound_H__
     32
     33#include <boost/thread.hpp>
    3234
    3335#include "sound/SoundPrereqs.h"
     
    8385        std::string ambientSource_; //!< Analogous to source_, but mood independent
    8486        bool        bPlayOnLoad_;   //!< Play the sound immediately when loaded
     87
     88        boost::thread soundstreamthread_; // hacky solution for streaming
     89        void setStreamSource(const std::string& source);
    8590    };
    8691}
  • code/branches/sound4/src/orxonox/sound/SoundStreamer.cc

    r6435 r6476  
    3030#include <vorbis/vorbisfile.h>
    3131#include "SoundManager.h"
     32#include "util/Sleep.h"
    3233
    3334namespace orxonox
     
    121122                    COUT(2) << "Sound Warning: Couldn't queue buffers: " << getALErrorString(error) << std::endl;
    122123            }
     124            msleep(250); // perhaps another value here is better
    123125        }
    124126    }
Note: See TracChangeset for help on using the changeset viewer.