Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 30, 2009, 2:22:00 AM (15 years ago)
Author:
rgrieder
Message:

Merged resource2 branch back to trunk.

IMPORTANT NOTE:
Upon this merge you need to specifically call your data directory "data_extern" when checking it out (when you don't provide a name, it will be just called 'trunk').
The new CMake variable is EXTERNAL_DATA_DIRECTORY. DATA_DIRECTORY now points to the one the source part of the repository.
UPDATE YOUR DATA DIRECTORY AS WELL!!!

Location:
code/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/sound/SoundBase.cc

    r3370 r5695  
    3636#include "util/Math.h"
    3737#include "core/Core.h"
     38#include "core/Resource.h"
    3839#include "orxonox/objects/worldentities/WorldEntity.h"
    3940#include "SoundManager.h"
     
    134135    }
    135136
    136     bool SoundBase::loadFile(std::string filename) {
    137         filename = Core::getMediaPathString() + "/audio/" + filename;
    138 
     137    bool SoundBase::loadFile(const std::string& filename) {
    139138        if(!SoundManager::getInstance().isSoundAvailable())
    140139        {
     
    144143
    145144        COUT(3) << "Sound: OpenAL ALUT: loading file " << filename << std::endl;
    146         this->buffer_ = alutCreateBufferFromFile(filename.c_str());
     145        // Get DataStream from the resources
     146        shared_ptr<ResourceInfo> fileInfo = Resource::getInfo(filename);
     147        if (fileInfo == NULL) {
     148            COUT(2) << "Warning: Sound file '" << filename << "' not found" << std::endl;
     149            return false;
     150        }
     151        DataStreamPtr stream = Resource::open(filename);
     152        // Read everything into a temporary buffer
     153        char* buffer = new char[fileInfo->size];
     154        stream->read(buffer, fileInfo->size);
     155
     156        this->buffer_ = alutCreateBufferFromFileImage(buffer, fileInfo->size);
     157        delete[] buffer;
     158
    147159        if(this->buffer_ == AL_NONE) {
    148160            COUT(2) << "Sound: OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl;
  • code/trunk/src/orxonox/sound/SoundBase.h

    r5693 r5695  
    5555        bool isStopped();
    5656
    57         bool loadFile(std::string filename);
     57        bool loadFile(const std::string& filename);
    5858
    5959    private:
Note: See TracChangeset for help on using the changeset viewer.