File vegastrike-src-0.5.1.r1-r13498-al_fix.patch of Package vegastrike
Index: src/aldrv/al_globals.h
===================================================================
--- src/aldrv/al_globals.h (revision 13497)
+++ src/aldrv/al_globals.h (revision 13499)
@@ -3,15 +3,55 @@
/* #undef SOUND_DEBUG */
+#include <string>
+#include <vector>
+
#ifdef HAVE_AL
#ifdef __APPLE__
#include <al.h>
#else
#include <AL/al.h>
#endif
-#include <string>
-#include <vector>
+#endif
+struct AUDSoundProperties
+{
+ // Keep here all that is AL-independent
+
+ bool success;
+
+ //Hashing.
+ //Set even if AUDLoadSoundFile fails so that a hash entry can be written.
+ bool shared;
+ std::string hashname;
+
+ void *wave;
+
+ // From here on, AL-dependent stuff
+
+#ifdef HAVE_AL
+ //OpenAL properties.
+ ALenum format;
+ ALsizei size;
+ ALsizei freq;
+ ALboolean looping; //can be set by caller.
+#endif
+
+ AUDSoundProperties()
+ {
+ shared = false;
+ success = false;
+ wave = NULL;
+#ifdef HAVE_AL
+ looping = false;
+ size = 0;
+ freq = 22050;
+#endif
+ }
+};
+
+#ifdef HAVE_AL
+
class Vector;
struct OurSound
@@ -41,47 +81,22 @@
extern std::vector< ALuint > buffers;
extern std::vector< OurSound >sounds;
extern Hashtable< std::string, ALuint, 127 >soundHash;
-float AUDDistanceSquared( const int sound );
typedef ALboolean (mp3Loader)( ALuint, ALvoid*, ALint );
extern mp3Loader *alutLoadMP3p;
extern unsigned int maxallowedsingle;
extern unsigned int maxallowedtotal;
extern bool usedoppler;
extern bool usepositional;
+
+#endif
+
+float AUDDistanceSquared( const int sound );
char AUDQueryAudability( const int sound, const Vector &pos, const Vector &vel, const float gain );
void AUDAddWatchedPlayed( const int sound, const Vector &pos );
-
-struct AUDSoundProperties
-{
- //Hashing.
- //Set even if AUDLoadSoundFile fails so that a hash entry can be written.
- bool shared;
- std::string hashname;
-
- //OpenAL properties.
- ALenum format;
- ALsizei size;
- ALsizei freq;
- void *wave;
- ALboolean looping; //can be set by caller.
-
- bool success;
- AUDSoundProperties()
- {
- wave = NULL;
- looping = false;
- shared = false;
- success = false;
- size = 0;
- freq = 22050;
- }
-};
-
bool AUDLoadSoundFile( const char *s, struct AUDSoundProperties *info, bool use_fileptr = false );
//It is up to the caller to free(info.wave) after using!!!
int AUDBufferSound( const struct AUDSoundProperties *info, bool music );
#endif
-#endif
Index: src/aldrv/al_sound.cpp
===================================================================
--- src/aldrv/al_sound.cpp (revision 13497)
+++ src/aldrv/al_sound.cpp (revision 13499)
@@ -411,6 +411,8 @@
VSFileSystem::vs_dprintf(3, "Loading sound file %s\n", s);
info->success = false;
+
+#ifdef HAVE_AL
vector< char >dat;
if (use_fileptr) {
FILE *f = fopen( s, "rb" );
@@ -472,17 +474,22 @@
info->success = true;
return true;
+#else
+ return false;
+#endif
}
int AUDBufferSound( const struct AUDSoundProperties *info, bool music )
{
+#ifdef HAVE_AL
ALuint wavbuf = 0;
-#ifdef HAVE_AL
alGenBuffers( 1, &wavbuf );
if (!wavbuf) printf( "OpenAL Error in alGenBuffers: %d\n", alGetError() );
alBufferData( wavbuf, info->format, info->wave, info->size, info->freq );
+ return LoadSound( wavbuf, info->looping, music );
+#else
+ return -1;
#endif
- return LoadSound( wavbuf, info->looping, music );
}
#ifdef HAVE_AL