OpenAL.cpp
1 /******************************************************************************
2 
3  nomlib - C++11 cross-platform game engine
4 
5 Copyright (c) 2013, Jeffrey Carpenter <jeffrey.carp@gmail.com>
6 All rights reserved.
7 
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
10 
11 1. Redistributions of source code must retain the above copyright notice, this
12  list of conditions and the following disclaimer.
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 ******************************************************************************/
29 #include "nomlib/audio/AL/OpenAL.hpp"
30 
31 // OpenAL Error Handling
32 
33 namespace nom {
34  namespace priv {
35 
36 void al_err ( const std::string& file, uint32 line )
37 {
38  ALenum error_code = alGetError();
39 
40  if ( error_code != AL_NO_ERROR )
41  {
42  std::string error, description;
43 
44  switch ( error_code )
45  {
46  default:
47  {
48  error = "Unknown";
49  description = "An unknown error has occurred.";
50  }
51  break;
52 
53  case AL_INVALID_NAME:
54  {
55  error = "AL_INVALID_NAME";
56  description = "Invalid name (identifier).";
57  }
58  break;
59 
60  case AL_INVALID_ENUM:
61  {
62  error = "AL_INVALID_ENUM";
63  description = "Invalid enumeration (attribute).";
64  }
65  break;
66 
67  case AL_INVALID_VALUE:
68  {
69  error = "AL_INVALID_VALUE";
70  description = "Invalid value.";
71  }
72  break;
73 
74  case AL_INVALID_OPERATION:
75  {
76  error = "AL_INVALID_OPERATION";
77  description = "Requested operation is not valid.";
78  }
79  break;
80 
81  case AL_OUT_OF_MEMORY:
82  {
83  error = "AL_OUT_OF_MEMORY";
84  description = "Requested operation resulted in OpenAL running out of memory";
85  }
86  break;
87  } // end switch
88 
89  std::cout << "NOM_LOG_ERR at " << getCurrentTime() << "In file " << file << ":" << line << std::endl << "Error: " << error << ", " << description << std::endl << std::endl;
90 
91  } // end if AL_NO_ERROR
92 }
93 
94 
95  } // namespace priv
96 } // namespace nom