]> git.jsancho.org Git - lugaru.git/blobdiff - Source/openal_wrapper.cpp
Drop Open_Stream
[lugaru.git] / Source / openal_wrapper.cpp
index 883a5abbfa4630ac0f30352a161b2002a0e9c828..4dddfd59df1d7c72f14b5e6c0cf1222fbd86a7b9 100644 (file)
@@ -112,33 +112,13 @@ typedef struct OPENAL_SAMPLE
     ALuint bid;  // buffer id.
     int mode;
     int is2d;
-    float min_distance;
 } OPENAL_SAMPLE;
 
-typedef struct OPENAL_STREAM
-{
-    char *name;
-    ALuint bid;  // buffer id.
-    int mode;
-    int is2d;
-} OPENAL_STREAM;
-
 static size_t num_channels = 0;
 static OPENAL_Channels *channels = NULL;
 static bool initialized = false;
 static float listener_position[3];
 
-static inline bool source_too_close(const int channel)
-{
-    const OPENAL_Channels *chan = &channels[channel];
-    const float *pos = chan->position;
-    const float distance = sqrtf(powf((pos[0] - listener_position[0]), 2.0f) +
-                                 powf((pos[1] - listener_position[1]), 2.0f) +
-                                 powf((pos[2] - listener_position[2]), 2.0f));
-    return (distance <= chan->sample->min_distance);
-}
-
-
 static void set_channel_position(const int channel, const float x,
                                  const float y, const float z)
 {
@@ -153,7 +133,7 @@ static void set_channel_position(const int channel, const float x,
         return;
 
     const ALuint sid = chan->sid;
-    const bool no_attenuate = ((sptr->is2d) || (source_too_close(channel)));
+    const bool no_attenuate = sptr->is2d;
 
     if (no_attenuate)
     {
@@ -374,7 +354,7 @@ static void *decode_to_pcm(const char *_fname, ALenum &format, ALsizei &size, AL
     char *fname = (char *) alloca(strlen(_fname) + 16);
     strcpy(fname, _fname);
     char *ptr = strchr(fname, '.');
-    if (ptr) *ptr = NULL;
+    if (ptr) *ptr = '\0';
     strcat(fname, ".ogg");
 
     // just in case...
@@ -521,27 +501,6 @@ AL_API signed char OPENAL_Sample_SetMode(OPENAL_SAMPLE *sptr, unsigned int mode)
     return true;
 }
 
-AL_API signed char OPENAL_Sample_SetMinMaxDistance(OPENAL_SAMPLE *sptr, float mindist, float maxdist)
-{
-    if (!initialized) return false;
-    if (sptr == NULL) return false;
-    sptr->min_distance = mindist;
-    // we ignore maxdist. It's not really important to this game, and the
-    //  FMOD docs suggest that it's worthless anyhow.
-
-    // recalc sources to see if we need to adjust attenuation.
-    for (int i = 0; i < num_channels; i++)
-    {
-        if (channels[i].sample == sptr)
-        {
-            const float *p = channels[i].position;
-            set_channel_position(i, p[0], p[1], p[2]);
-        }
-    }
-
-    return 0;
-}
-
 AL_API signed char OPENAL_SetFrequency(int channel, int freq)
 {
     if (!initialized) return false;
@@ -633,12 +592,7 @@ AL_API signed char OPENAL_StopSound(int channel)
     return true;
 }
 
-AL_API OPENAL_STREAM *OPENAL_Stream_Open(const char *name_or_data, unsigned int mode, int offset, int length)
-{
-    return (OPENAL_STREAM *) OPENAL_Sample_Load(OPENAL_FREE, name_or_data, mode, offset, length);
-}
-
-AL_API signed char OPENAL_Stream_Close(OPENAL_STREAM *stream)
+AL_API void OPENAL_Stream_Close(OPENAL_STREAM *stream)
 {
     OPENAL_Sample_Free((OPENAL_SAMPLE *) stream);
 }