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
al_globals.h
Go to the documentation of this file.
1 #ifndef AL_GLOBALS_H_
2 #define AL_GLOBALS_H_
3 
4 /* #undef SOUND_DEBUG */
5 
6 #ifdef HAVE_AL
7 #ifdef __APPLE__
8 #include <al.h>
9 #else
10 #include <AL/al.h>
11 #endif
12 #include <string>
13 #include <vector>
14 
15 class Vector;
16 
17 struct OurSound
18 {
19  ALuint source;
20  ALuint buffer;
21  Vector pos;
22  Vector vel;
23  float gain;
24  ALboolean looping;
25  bool music;
26  OurSound( ALuint source, ALuint buffername )
27  {
28  buffer = buffername;
29  pos.Set( 0, 0, 0 );
30  vel.Set( 0, 0, 0 );
31  gain = 1.0f;
32  }
33 };
34 
35 extern float scalepos;
36 extern float scalevel;
37 template < typename a, typename b, int c >
38 class Hashtable;
39 
40 extern std::vector< ALuint > unusedsrcs;
41 extern std::vector< ALuint > buffers;
42 extern std::vector< OurSound >sounds;
44 float AUDDistanceSquared( const int sound );
45 typedef ALboolean (mp3Loader)( ALuint, ALvoid*, ALint );
46 extern mp3Loader *alutLoadMP3p;
47 extern unsigned int maxallowedsingle;
48 extern unsigned int maxallowedtotal;
49 extern bool usedoppler;
50 extern bool usepositional;
51 char AUDQueryAudability( const int sound, const Vector &pos, const Vector &vel, const float gain );
52 void AUDAddWatchedPlayed( const int sound, const Vector &pos );
53 
54 struct AUDSoundProperties
55 {
56  //Hashing.
57  //Set even if AUDLoadSoundFile fails so that a hash entry can be written.
58  bool shared;
59  std::string hashname;
60 
61  //OpenAL properties.
62  ALenum format;
63  ALsizei size;
64  ALsizei freq;
65  void *wave;
66  ALboolean looping; //can be set by caller.
67 
68  bool success;
69  AUDSoundProperties()
70  {
71  wave = NULL;
72  looping = false;
73  shared = false;
74  success = false;
75  size = 0;
76  freq = 22050;
77  }
78 };
79 
80 bool AUDLoadSoundFile( const char *s, struct AUDSoundProperties *info, bool use_fileptr = false );
81 
82 //It is up to the caller to free(info.wave) after using!!!
83 int AUDBufferSound( const struct AUDSoundProperties *info, bool music );
84 
85 #endif
86 #endif
87