Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 13, 2009, 12:11:40 AM (14 years ago)
Author:
rgrieder
Message:

Improved SoundBuffer class design and removed its pooling property (just a boolean).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/orxonox/sound/SoundBuffer.cc

    r6270 r6332  
    3333#include <vorbis/vorbisfile.h>
    3434
     35#include "util/Clock.h"
     36#include "core/Game.h"
    3537#include "util/Exception.h"
    3638#include "util/StringUtils.h"
     
    4042namespace orxonox
    4143{
    42     SoundBuffer::SoundBuffer(const std::string& filename)
     44    SoundBuffer::SoundBuffer(const std::string& filename, std::list<shared_ptr<SoundBuffer> >::iterator poolIterator)
    4345        : filename_(filename)
    4446        , audioBuffer_(AL_NONE)
     47        , poolIterator_(poolIterator)
    4548    {
    4649        if (this->filename_.empty())
     
    6063        if (getLowercase(extension) == "ogg")
    6164        {
     65            int before = Game::getInstance().getGameClock().getRealMicroseconds();
    6266            // Try ogg loader
    6367            this->loadOgg(fileInfo, dataStream);
     68            int after = Game::getInstance().getGameClock().getRealMicroseconds();
     69            COUT(0) << filename << ": " << (after - before) << std::endl;
    6470        }
    6571        else
     
    8086        ALint size;
    8187        alGetBufferi(this->audioBuffer_, AL_SIZE, &size);
    82         if (!alGetError())
    83             return size;
    84         else
    85             return 0;
     88        return alGetError() ? 0 : size;
    8689    }
    8790
     
    108111    {
    109112        Ogre::DataStream* stream = static_cast<Ogre::DataStream*>(datasource);
    110         int offset_beg = offset;
    111         if (whence == SEEK_CUR)
    112             offset_beg = stream->tell() + offset;
    113         else if (whence == SEEK_END)
    114             offset_beg = stream->size() + offset;
    115         else if (whence != SEEK_SET)
     113        switch (whence)
     114        {
     115        case SEEK_SET:
     116            stream->seek(offset);
     117            break;
     118        case SEEK_CUR:
     119            stream->skip(offset);
     120            break;
     121        case SEEK_END:
     122            stream->seek(stream->size() + offset);
     123            break;
     124        default:
    116125            return -1;
    117         stream->seek(offset_beg);
     126        }
    118127        return 0;
    119128    }
Note: See TracChangeset for help on using the changeset viewer.