Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4203 in orxonox.OLD


Ignore:
Timestamp:
May 17, 2005, 1:47:04 AM (19 years ago)
Author:
bensch
Message:

orxonox/branches/openAL: better error-check

Location:
orxonox/branches/openAL/src/lib/sound
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/openAL/src/lib/sound/sound_engine.cc

    r4200 r4203  
    1212   main-programmer: Benjamin Grauer
    1313   co-programmer: ...
     14
     15   code has been taken from http://www.devmaster.net/articles.php?catID=6
     16   The code has been applied to our needs, and many things have been changed.
    1417*/
    1518
     
    2023#include "p_node.h"
    2124#include "list.h"
     25#include "AL/alc.h"
    2226
    2327using namespace std;
     
    3842  ALvoid* data;
    3943  ALsizei freq;
    40 
     44 
     45  ALenum result;
     46
     47  // generate a Buffer
    4148  alGenBuffers(1, &this->bufferID);
     49  if ((result = alGetError()) != AL_NO_ERROR)
     50    SoundEngine::PrintALErrorString(result);
     51
     52  // read in the wav data
    4253  alutLoadWAVFile((ALbyte*)fileName, &format, &data, &this->size, &freq, &this->loop);
     54  if ((result = alGetError()) != AL_NO_ERROR)
     55    SoundEngine::PrintALErrorString(result);
     56 
     57  // send the loaded wav data to the buffer
    4358  alBufferData(this->bufferID, format, data, this->size, freq);
     59  if ((result = alGetError()) != AL_NO_ERROR)
     60    SoundEngine::PrintALErrorString(result);
     61
     62  // remove the wav data (redundant)
    4463  alutUnloadWAV(format, data, this->size, freq);
     64  if ((result = alGetError()) != AL_NO_ERROR)
     65    SoundEngine::PrintALErrorString(result);
    4566}
    4667
     
    5980SoundSource::SoundSource(SoundBuffer* buffer, PNode* sourceNode)
    6081{
     82  ALenum result;
     83
     84  // adding the Source to the SourcesList of the SoundEngine
    6185  SoundEngine::getInstance()->addSource(this);
    6286
     
    6589
    6690  alGenSources(1, &this->sourceID);
    67 
    68   if(alGetError() != AL_NO_ERROR)
    69     PRINTF(1)("error initializing SoundSource\n"); //return AL_FALSE;
    70  
     91  if ((result = alGetError()) != AL_NO_ERROR)
     92    SoundEngine::PrintALErrorString(result);
    7193  alSourcei (this->sourceID, AL_BUFFER,   this->buffer->getID());
    7294  alSourcef (this->sourceID, AL_PITCH,    1.0      );
    7395  alSourcef (this->sourceID, AL_GAIN,     1.0      );
    74   //  alSourcefv(sourceID, AL_POSITION, SourcePos);
    75   //  alSourcefv(sourceID, AL_VELOCITY, SourceVel);
    7696  alSourcei (sourceID, AL_LOOPING,  true     );
    7797}
     
    230250}
    231251
     252void SoundEngine::PrintALErrorString(ALenum err)
     253{
     254  switch(err)
     255    {
     256    case AL_NO_ERROR:
     257      PRINTF(4)("AL_NO_ERROR\n");
     258      break;
     259     
     260    case AL_INVALID_NAME:
     261      PRINTF(2)("AL_INVALID_NAME\n");
     262      break;
     263
     264    case AL_INVALID_ENUM:
     265      PRINTF(2)("AL_INVALID_ENUM\n");
     266      break;
     267
     268    case AL_INVALID_VALUE:
     269      PRINTF(2)("AL_INVALID_VALUE\n");
     270      break;
     271
     272    case AL_INVALID_OPERATION:
     273      PRINTF(2)("AL_INVALID_OPERATION\n");
     274      break;
     275
     276    case AL_OUT_OF_MEMORY:
     277      PRINTF(2)("AL_OUT_OF_MEMORY\n");
     278      break;
     279    };
     280}
     281
     282
     283void SoundEngine::PrintALCErrorString(ALenum err)
     284{
     285  switch(err)
     286    {
     287    case ALC_NO_ERROR:
     288      PRINTF(4)("AL_NO_ERROR\n");
     289      break;
     290
     291    case ALC_INVALID_DEVICE:
     292      PRINTF(2)("ALC_INVALID_DEVICE\n");
     293      break;
     294
     295    case ALC_INVALID_CONTEXT:
     296      PRINTF(2)("ALC_INVALID_CONTEXT\n");
     297      break;
     298
     299    case ALC_INVALID_ENUM:
     300      PRINTF(2)("ALC_INVALID_ENUM\n");
     301      break;
     302
     303    case ALC_INVALID_VALUE:
     304      PRINTF(2)("ALC_INVALID_VALUE\n");
     305      break;
     306
     307    case ALC_OUT_OF_MEMORY:
     308      PRINTF(2)("ALC_OUT_OF_MEMORY\n");
     309      break;
     310    };
     311}
  • orxonox/branches/openAL/src/lib/sound/sound_engine.h

    r4200 r4203  
    1212
    1313
    14 #define SOUND_DOPPLER_FACTOR     0.1
     14#define SOUND_DOPPLER_FACTOR     0.01
    1515#define SOUND_DOPPLER_VELOCITY   500000000
    1616
     
    8181  void update(void);
    8282
     83
     84  // error handling:
     85  static void PrintALErrorString(ALenum err);
     86  static void PrintALCErrorString(ALenum err);
     87
    8388 private:
    8489  SoundEngine(void);
Note: See TracChangeset for help on using the changeset viewer.