Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Audio::__impl::OpenAL Namespace Reference

Classes

struct  RendererData
 

Functions

void _checkAlErrorAt (ALenum error, const char *filename, int lineno) throw (Exception)
 
void _clearAlError () throw ()
 
ALenum asALFormat (const Format &format) throw (Exception)
 

Function Documentation

void Audio::__impl::OpenAL::_checkAlErrorAt ( ALenum  error,
const char *  filename,
int  lineno 
)
throw (Exception
)

Definition at line 20 of file OpenALHelpers.cpp.

References error, and fprintf.

22  {
23  switch(error) {
24  case AL_NO_ERROR : return;
25  default:
26  {
27  const char* errdesc = (const char *)alGetString(error);
28  char s_lineno[32];
29  char s_errcode_buf[32];
30  const char *s_errcode;
31  sprintf(s_lineno, "%d", lineno);
32 
33  switch (error) {
34  case ALC_INVALID_DEVICE: s_errcode = "(Invalid device)"; break;
35  case ALC_INVALID_CONTEXT:s_errcode = "(Invalid context id)"; break;
36  case ALC_INVALID_ENUM: s_errcode = "(Bad enum)"; break;
37  case ALC_INVALID_VALUE: s_errcode = "(Bad value)"; break;
38  case ALC_OUT_OF_MEMORY: s_errcode = "(Out of memory)"; break;
39  default:
40  sprintf(s_errcode_buf, "(0x%x)", error);
41  s_errcode = s_errcode_buf;
42  };
43 
44  std::string error("OpenAL error: ");
45  error += std::string(errdesc ? errdesc : "unknown") + s_errcode + " at " + filename + ":" + s_lineno;
46  fprintf(stderr, "%s\n", error.c_str());
47  throw Exception(error);
48  }
49  }
50  }
void Audio::__impl::OpenAL::_clearAlError ( )
throw (
)

Definition at line 52 of file OpenALHelpers.cpp.

54  {
55  alGetError();
56  }
ALenum Audio::__impl::OpenAL::asALFormat ( const Format &  format)
throw (Exception
)

Definition at line 58 of file OpenALHelpers.cpp.

Referenced by Audio::OpenALSimpleSound::loadImpl(), and Audio::OpenALStreamingSound::readAndFlip().

60  {
61  ALenum alformat;
62  switch(format.bitsPerSample) {
63  case 8:
64  switch(format.channels) {
65  case 1: alformat = AL_FORMAT_MONO8; break;
66  case 2: alformat = AL_FORMAT_STEREO8; break;
67  default: throw Exception("internal error - unexpected number of channels");
68  };
69  break;
70  case 16:
71  switch(format.channels) {
72  case 1: alformat = AL_FORMAT_MONO16; break;
73  case 2: alformat = AL_FORMAT_STEREO16; break;
74  default: throw Exception("internal error - unexpected number of channels");
75  };
76  break;
77  default:
78  throw Exception("internal error - unexpected bit depth");
79  };
80 
81  return alformat;
82  }