Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6872 in orxonox.OLD for trunk/src/lib/sound


Ignore:
Timestamp:
Jan 30, 2006, 9:56:40 PM (19 years ago)
Author:
bensch
Message:

trunk: oggPlayer

Location:
trunk/src/lib/sound
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/sound/ogg_player.cc

    r6842 r6872  
    4747}
    4848
     49OggPlayer::~ OggPlayer()
     50{
     51  this->release();
     52}
     53
    4954/**
    5055 * opens a file for playback
     
    6469    return false;
    6570  }
    66   printf("OK\n");
    6771
    6872  int result;
    6973
    7074  if(!(oggFile = fopen(fileName, "rb")))
     75  {
    7176    PRINTF(2)("Could not open Ogg file.");
     77    return false;
     78  }
    7279
    7380  if((result = ov_open(oggFile, &oggStream, NULL, 0)) < 0)
     
    7683
    7784    PRINTF(2)("Could not open Ogg stream. %s", errorString(result));
     85    fclose(oggFile);
     86    return false;
    7887  }
    7988
     
    102111void OggPlayer::release()
    103112{
     113  if (!this->trackLoaded)
     114    return;
    104115  alSourceStop(source);
    105116  empty();
     
    162173bool OggPlayer::update()
    163174{
    164   if (!this->trackLoaded)
     175  if (unlikely(!this->trackLoaded))
    165176    return false;
    166177
     
    238249  }
    239250}
    240 
    241 /**
    242  * checks for errors
    243  */
    244 void OggPlayer::check()
    245 {
    246   int error = alGetError();
    247 
    248   if(error != AL_NO_ERROR)
    249     PRINTF(2)("OpenAL error was raised.");
    250 }
    251 
    252251
    253252
     
    274273}
    275274
     275/**
     276 * checks for errors
     277 */
     278void OggPlayer::check()
     279{
     280  int error = alGetError();
     281  if(error != AL_NO_ERROR)
     282    PRINTF(2)("OpenAL error was raised.");
     283}
    276284
    277285/**
  • trunk/src/lib/sound/ogg_player.h

    r6871 r6872  
    2828public:
    2929  OggPlayer(const char* fileName = NULL);
     30  ~OggPlayer();
    3031
    3132  bool open(const char* fileName);
     
    4445
    4546private:
    46 
    4747  FILE*               oggFile;              //!< general file-handler, to open the sound-file
    4848  OggVorbis_File      oggStream;            //!< The stream this Ogg-player is playing back
Note: See TracChangeset for help on using the changeset viewer.