hopefully last fix
authorkoda
Sun, 11 Oct 2009 22:17:50 +0000
changeset 2421 a4b039ee2eb0
parent 2420 b7390a3040f8
child 2422 656245c2b1c5
hopefully last fix
QTfrontend/CMakeLists.txt
openalbridge/errlib.h
openalbridge/globals.h
openalbridge/loaders.c
openalbridge/loaders.h
openalbridge/oggvorbis.h
openalbridge/openalbridge.c
openalbridge/openalbridge.h
openalbridge/wrappers.h
--- a/QTfrontend/CMakeLists.txt	Sun Oct 11 20:40:03 2009 +0000
+++ b/QTfrontend/CMakeLists.txt	Sun Oct 11 22:17:50 2009 +0000
@@ -17,7 +17,6 @@
 
 # Configure for SDL
 find_package(SDL REQUIRED)
-find_package(Sparkle)
 
 include_directories(.)
 include_directories(${SDL_INCLUDE_DIR})
@@ -139,6 +138,8 @@
 	)
 
 if(APPLE)
+find_package(Sparkle)
+
 set(hwfr_src ${hwfr_src} InstallController.cpp CocoaInitializer.mm M3Panel.mm M3InstallController.m NSWorkspace_RBAdditions.m)
 if(SPARKLE_FOUND)
 set(hwfr_src ${hwfr_src} AutoUpdater.cpp SparkleAutoUpdater.mm)
--- a/openalbridge/errlib.h	Sun Oct 11 20:40:03 2009 +0000
+++ b/openalbridge/errlib.h	Sun Oct 11 22:17:50 2009 +0000
@@ -20,13 +20,9 @@
         extern int daemon_proc;
         
         void err_msg (const char *fmt, ...);
-        
         void err_quit (const char *fmt, ...);
-        
         void err_ret (const char *fmt, ...);
-        
         void err_sys (const char *fmt, ...);
-        
         void err_dump (const char *fmt, ...);
         
 #ifdef __CPLUSPLUS
--- a/openalbridge/globals.h	Sun Oct 11 20:40:03 2009 +0000
+++ b/openalbridge/globals.h	Sun Oct 11 22:17:50 2009 +0000
@@ -23,20 +23,24 @@
 #include <stdlib.h>
 #include <stdint.h>
 #include <stdarg.h>
-#include <syslog.h>
 #include <string.h>
 #include <errno.h>
 
 #ifndef _WIN32
 #include <pthread.h>
+#include <syslog.h>
 #else
 #include <process.h>
+#define syslog(x,y) fprintf(stderr,y)
+#define LOG_INFO 6
+#define LOG_ERR 3
 #endif
 
 #include "al.h"
 #include "errlib.h"
 
 
+/*control debug verbosity*/
 #ifdef TRACE
 #ifndef DEBUG
 #define DEBUG
@@ -67,6 +71,7 @@
 #endif
 #endif /* _SLEEP_H */
 
+
 /* check compiler requirements */    /*FIXME*/
 #if !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
 #warning __BIG_ENDIAN__ or __LITTLE_ENDIAN__ not found, going to set __LITTLE_ENDIAN__ as default
@@ -81,7 +86,7 @@
 #else        
 #define bswap_16(x)	((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8))
 #define bswap_32(x)	((((x) & 0xFF000000) >> 24) | (((x) & 0x00FF0000) >> 8)  | \
-                         (((x) & 0x0000FF00) << 8)  | (((x) & 0x000000FF) << 24) )
+(((x) & 0x0000FF00) << 8)  | (((x) & 0x000000FF) << 24) )
 #endif /* HAVE_BYTESWAP_H */
 
 /* swap numbers accordingly to architecture automatically */
--- a/openalbridge/loaders.c	Sun Oct 11 20:40:03 2009 +0000
+++ b/openalbridge/loaders.c	Sun Oct 11 22:17:50 2009 +0000
@@ -22,220 +22,226 @@
 #ifdef __CPLUSPLUS
 extern "C" {
 #endif 
-    
-    int load_wavpcm (const char *filename, ALenum *format, char ** data, ALsizei *bitsize, ALsizei *freq) {
-        WAV_header_t WAVHeader;
-        FILE *wavfile;
-        int32_t t;
-        uint32_t n = 0;
-        uint8_t sub0, sub1, sub2, sub3;
         
-        wavfile = Fopen(filename, "rb");
-        
-        fread(&WAVHeader.ChunkID, sizeof(uint32_t), 1, wavfile);                /*RIFF*/
-        fread(&WAVHeader.ChunkSize, sizeof(uint32_t), 1, wavfile);
-        fread(&WAVHeader.Format, sizeof(uint32_t), 1, wavfile);                 /*WAVE*/
-        
+        int load_wavpcm (const char *filename, ALenum *format, char ** data, ALsizei *bitsize, ALsizei *freq) {
+                WAV_header_t WAVHeader;
+                FILE *wavfile;
+                int32_t t;
+                uint32_t n = 0;
+                uint8_t sub0, sub1, sub2, sub3;
+                
+                wavfile = Fopen(filename, "rb");
+                
+                fread(&WAVHeader.ChunkID, sizeof(uint32_t), 1, wavfile);                /*RIFF*/
+                fread(&WAVHeader.ChunkSize, sizeof(uint32_t), 1, wavfile);
+                fread(&WAVHeader.Format, sizeof(uint32_t), 1, wavfile);                 /*WAVE*/
+                
 #ifdef DEBUG
-        fprintf(stderr, "ChunkID: %X\n", ENDIAN_BIG_32(WAVHeader.ChunkID));
-        fprintf(stderr, "ChunkSize: %d\n", ENDIAN_LITTLE_32(WAVHeader.ChunkSize));
-        fprintf(stderr, "Format: %X\n", ENDIAN_BIG_32(WAVHeader.Format));
+                fprintf(stderr, "ChunkID: %X\n", ENDIAN_BIG_32(WAVHeader.ChunkID));
+                fprintf(stderr, "ChunkSize: %d\n", ENDIAN_LITTLE_32(WAVHeader.ChunkSize));
+                fprintf(stderr, "Format: %X\n", ENDIAN_BIG_32(WAVHeader.Format));
+#endif
+                
+                fread(&WAVHeader.Subchunk1ID, sizeof(uint32_t), 1, wavfile);            /*fmt */
+                fread(&WAVHeader.Subchunk1Size, sizeof(uint32_t), 1, wavfile);
+                fread(&WAVHeader.AudioFormat, sizeof(uint16_t), 1, wavfile);
+                fread(&WAVHeader.NumChannels, sizeof(uint16_t), 1, wavfile);
+                fread(&WAVHeader.SampleRate, sizeof(uint32_t), 1, wavfile);
+                fread(&WAVHeader.ByteRate, sizeof(uint32_t), 1, wavfile);
+                fread(&WAVHeader.BlockAlign, sizeof(uint16_t), 1, wavfile);
+                fread(&WAVHeader.BitsPerSample, sizeof(uint16_t), 1, wavfile);
+                
+#ifdef DEBUG
+                fprintf(stderr, "Subchunk1ID: %X\n", ENDIAN_BIG_32(WAVHeader.Subchunk1ID));
+                fprintf(stderr, "Subchunk1Size: %d\n", ENDIAN_LITTLE_32(WAVHeader.Subchunk1Size));
+                fprintf(stderr, "AudioFormat: %d\n", ENDIAN_LITTLE_16(WAVHeader.AudioFormat));
+                fprintf(stderr, "NumChannels: %d\n", ENDIAN_LITTLE_16(WAVHeader.NumChannels));
+                fprintf(stderr, "SampleRate: %d\n", ENDIAN_LITTLE_32(WAVHeader.SampleRate));
+                fprintf(stderr, "ByteRate: %d\n", ENDIAN_LITTLE_32(WAVHeader.ByteRate));
+                fprintf(stderr, "BlockAlign: %d\n", ENDIAN_LITTLE_16(WAVHeader.BlockAlign));
+                fprintf(stderr, "BitsPerSample: %d\n", ENDIAN_LITTLE_16(WAVHeader.BitsPerSample));
 #endif
-        
-        fread(&WAVHeader.Subchunk1ID, sizeof(uint32_t), 1, wavfile);            /*fmt */
-        fread(&WAVHeader.Subchunk1Size, sizeof(uint32_t), 1, wavfile);
-        fread(&WAVHeader.AudioFormat, sizeof(uint16_t), 1, wavfile);
-        fread(&WAVHeader.NumChannels, sizeof(uint16_t), 1, wavfile);
-        fread(&WAVHeader.SampleRate, sizeof(uint32_t), 1, wavfile);
-        fread(&WAVHeader.ByteRate, sizeof(uint32_t), 1, wavfile);
-        fread(&WAVHeader.BlockAlign, sizeof(uint16_t), 1, wavfile);
-        fread(&WAVHeader.BitsPerSample, sizeof(uint16_t), 1, wavfile);
-        
+                
+                /*remove useless header chunks by looking for the WAV_HEADER_SUBCHUNK2ID integer */
+                do {
+                        t = fread(&sub0, sizeof(uint8_t), 1, wavfile);
+                        if(sub0 == 0x64) {
+                                t = fread(&sub1, sizeof(uint8_t), 1, wavfile);
+                                if(sub1 == 0x61) {
+                                        t = fread(&sub2, sizeof(uint8_t), 1, wavfile);
+                                        if(sub2 == 0x74) {
+                                                t = fread(&sub3, sizeof(uint8_t), 1, wavfile);
+                                                if(sub3 == 0x61) {
+                                                        WAVHeader.Subchunk2ID = WAV_HEADER_SUBCHUNK2ID;
+                                                        break;                                                
+                                                } 
+                                        }       
+                                }
+                        }
+                        
+                        if (t <= 0) { 
+                                /*eof*/
+                                errno = EILSEQ;
+                                err_ret("(%s) ERROR - wrong WAV header", prog);
+                                return AL_FALSE;
+                        }
+                } while (1);
+                
+                fread(&WAVHeader.Subchunk2Size, sizeof(uint32_t), 1, wavfile);
+                
 #ifdef DEBUG
-        fprintf(stderr, "Subchunk1ID: %X\n", ENDIAN_BIG_32(WAVHeader.Subchunk1ID));
-        fprintf(stderr, "Subchunk1Size: %d\n", ENDIAN_LITTLE_32(WAVHeader.Subchunk1Size));
-        fprintf(stderr, "AudioFormat: %d\n", ENDIAN_LITTLE_16(WAVHeader.AudioFormat));
-        fprintf(stderr, "NumChannels: %d\n", ENDIAN_LITTLE_16(WAVHeader.NumChannels));
-        fprintf(stderr, "SampleRate: %d\n", ENDIAN_LITTLE_32(WAVHeader.SampleRate));
-        fprintf(stderr, "ByteRate: %d\n", ENDIAN_LITTLE_32(WAVHeader.ByteRate));
-        fprintf(stderr, "BlockAlign: %d\n", ENDIAN_LITTLE_16(WAVHeader.BlockAlign));
-        fprintf(stderr, "BitsPerSample: %d\n", ENDIAN_LITTLE_16(WAVHeader.BitsPerSample));
+                fprintf(stderr, "Subchunk2ID: %X\n", ENDIAN_LITTLE_32(WAVHeader.Subchunk2ID));
+                fprintf(stderr, "Subchunk2Size: %d\n", ENDIAN_LITTLE_32(WAVHeader.Subchunk2Size));
+#endif
+                
+                *data = (char*) Malloc (sizeof(char) * ENDIAN_LITTLE_32(WAVHeader.Subchunk2Size));
+                
+                /*read the actual sound data*/
+                do {
+                        n += fread(&((*data)[n]), sizeof(uint8_t), 4, wavfile);
+                } while (n < ENDIAN_LITTLE_32(WAVHeader.Subchunk2Size));
+                
+                fclose(wavfile);	
+                
+#ifdef DEBUG
+                err_msg("(%s) INFO - WAV data loaded", prog);
 #endif
-
-        /*remove useless header chunks by looking for the WAV_HEADER_SUBCHUNK2ID integer */
-        do {
-                t = fread(&sub0, sizeof(uint8_t), 1, wavfile);
-                if(sub0 == 0x64) {
-                        t = fread(&sub1, sizeof(uint8_t), 1, wavfile);
-                        if(sub1 == 0x61) {
-                                t = fread(&sub2, sizeof(uint8_t), 1, wavfile);
-                                if(sub2 == 0x74) {
-                                        t = fread(&sub3, sizeof(uint8_t), 1, wavfile);
-                                        if(sub3 == 0x61) {
-                                                WAVHeader.Subchunk2ID = WAV_HEADER_SUBCHUNK2ID;
-                                                break;                                                
-                                        } 
-                                }       
+                
+                /*set parameters for OpenAL*/
+                /*Valid formats are AL_FORMAT_MONO8, AL_FORMAT_MONO16, AL_FORMAT_STEREO8, and AL_FORMAT_STEREO16*/
+                if (ENDIAN_LITTLE_16(WAVHeader.NumChannels) == 1) {
+                        if (ENDIAN_LITTLE_16(WAVHeader.BitsPerSample) == 8)
+                                *format = AL_FORMAT_MONO8;
+                        else {
+                                if (ENDIAN_LITTLE_16(WAVHeader.BitsPerSample) == 16)
+                                        *format = AL_FORMAT_MONO16;
+                                else {
+                                        errno = EILSEQ;
+                                        err_ret("(%s) ERROR - wrong WAV header [bitsample value]", prog);
+                                        return AL_FALSE;
+                                }
+                        } 
+                } else {
+                        if (ENDIAN_LITTLE_16(WAVHeader.NumChannels) == 2) {
+                                if (ENDIAN_LITTLE_16(WAVHeader.BitsPerSample) == 8)
+                                        *format = AL_FORMAT_STEREO8;
+                                else {
+                                        if (ENDIAN_LITTLE_16(WAVHeader.BitsPerSample) == 16)
+                                                *format = AL_FORMAT_STEREO16;
+                                        else {
+                                                errno = EILSEQ;
+                                                err_ret("(%s) ERROR - wrong WAV header [bitsample value]", prog);
+                                                return AL_FALSE;
+                                        }				
+                                }
+                        } else {
+                                errno = EILSEQ;
+                                err_ret("(%s) ERROR - wrong WAV header [format value]", prog); 
+                                return AL_FALSE;
                         }
                 }
                 
-                if (t <= 0) { 
-                        /*eof*/
-                        errno = EILSEQ;
-                        err_ret("(%s) ERROR - wrong WAV header", prog);
-                        return AL_FALSE;
-                }
-        } while (1);
-            
-        fread(&WAVHeader.Subchunk2Size, sizeof(uint32_t), 1, wavfile);
-        
-#ifdef DEBUG
-        fprintf(stderr, "Subchunk2ID: %X\n", ENDIAN_LITTLE_32(WAVHeader.Subchunk2ID));
-        fprintf(stderr, "Subchunk2Size: %d\n", ENDIAN_LITTLE_32(WAVHeader.Subchunk2Size));
-#endif
-        
-        *data = (char*) Malloc (sizeof(char) * ENDIAN_LITTLE_32(WAVHeader.Subchunk2Size));
-        
-        /*read the actual sound data*/
-        do {
-                n += fread(&((*data)[n]), sizeof(uint8_t), 4, wavfile);
-        } while (n < ENDIAN_LITTLE_32(WAVHeader.Subchunk2Size));
-        
-        fclose(wavfile);	
-            
-#ifdef DEBUG
-    err_msg("(%s) INFO - WAV data loaded", prog);
-#endif
-            
-        /*set parameters for OpenAL*/
-        /*Valid formats are AL_FORMAT_MONO8, AL_FORMAT_MONO16, AL_FORMAT_STEREO8, and AL_FORMAT_STEREO16*/
-        if (ENDIAN_LITTLE_16(WAVHeader.NumChannels) == 1) {
-            if (ENDIAN_LITTLE_16(WAVHeader.BitsPerSample) == 8)
-                *format = AL_FORMAT_MONO8;
-            else {
-                if (ENDIAN_LITTLE_16(WAVHeader.BitsPerSample) == 16)
-                    *format = AL_FORMAT_MONO16;
-                else {
-                        errno = EILSEQ;
-                        err_ret("(%s) ERROR - wrong WAV header [bitsample value]", prog);
-                        return AL_FALSE;
-                }
-            } 
-        } else {
-            if (ENDIAN_LITTLE_16(WAVHeader.NumChannels) == 2) {
-                if (ENDIAN_LITTLE_16(WAVHeader.BitsPerSample) == 8)
-                    *format = AL_FORMAT_STEREO8;
-                else {
-                    if (ENDIAN_LITTLE_16(WAVHeader.BitsPerSample) == 16)
-                        *format = AL_FORMAT_STEREO16;
-                    else {
-                            errno = EILSEQ;
-                            err_ret("(%s) ERROR - wrong WAV header [bitsample value]", prog);
-                        return AL_FALSE;
-                    }				
-                }
-            } else {
-                    errno = EILSEQ;
-                    err_ret("(%s) ERROR - wrong WAV header [format value]", prog); 
-                    return AL_FALSE;
-            }
+                *bitsize = ENDIAN_LITTLE_32(WAVHeader.Subchunk2Size);
+                *freq    = ENDIAN_LITTLE_32(WAVHeader.SampleRate);
+                return AL_TRUE;
         }
         
-        *bitsize = ENDIAN_LITTLE_32(WAVHeader.Subchunk2Size);
-        *freq    = ENDIAN_LITTLE_32(WAVHeader.SampleRate);
-        return AL_TRUE;
-    }
-    
-
-    int load_oggvorbis (const char *filename, ALenum *format, char **data, ALsizei *bitsize, ALsizei *freq) {
-            /*implementation inspired from http://www.devmaster.net/forums/showthread.php?t=1153 */
-            OggVorbis_File  oggStream; /*stream handle*/
-            vorbis_info	*vorbisInfo;   /*some formatting data*/
-            int64_t pcm_length;	       /*length of the decoded data*/
-            int section, result, size, endianness;
+        
+        int load_oggvorbis (const char *filename, ALenum *format, char **data, ALsizei *bitsize, ALsizei *freq) {
+                /*implementation inspired from http://www.devmaster.net/forums/showthread.php?t=1153 */
+                
+                /*stream handle*/
+                OggVorbis_File  oggStream; 
+                /*some formatting data*/
+                vorbis_info *vorbisInfo; 
+                /*length of the decoded data*/
+                int64_t pcm_length;
+                /*other vars*/
+                int section, result, size, endianness;
 #ifdef DEBUG
-            int i;
-            vorbis_comment *vorbisComment; /*other less useful data*/
+                int i;
+                /*other less useful data*/
+                vorbis_comment *vorbisComment;
 #endif
-
-	result = ov_fopen((char*) filename, &oggStream);
-	if (result < 0) {
-                errno = EINVAL;
-                err_ret("(%s) ERROR - ov_fopen() failed with %X", prog, result);
-                ov_clear(&oggStream);
-		return AL_FALSE;
-	}
-
-        /*load OGG header and determine the decoded data size*/
-        vorbisInfo = ov_info(&oggStream, -1);
-        pcm_length = ov_pcm_total(&oggStream, -1) << vorbisInfo->channels;	
-        
+                
+                result = ov_fopen((char*) filename, &oggStream);
+                if (result < 0) {
+                        errno = EINVAL;
+                        err_ret("(%s) ERROR - ov_fopen() failed with %X", prog, result);
+                        ov_clear(&oggStream);
+                        return AL_FALSE;
+                }
+                
+                /*load OGG header and determine the decoded data size*/
+                vorbisInfo = ov_info(&oggStream, -1);
+                pcm_length = ov_pcm_total(&oggStream, -1) << vorbisInfo->channels;	
+                
 #ifdef DEBUG
-        vorbisComment = ov_comment(&oggStream, -1);
-        fprintf(stderr, "Version: %d\n", vorbisInfo->version);
-        fprintf(stderr, "Channels: %d\n", vorbisInfo->channels);
-        fprintf(stderr, "Rate (Hz): %ld\n", vorbisInfo->rate);
-        fprintf(stderr, "Bitrate Upper: %ld\n", vorbisInfo->bitrate_upper);
-        fprintf(stderr, "Bitrate Nominal: %ld\n", vorbisInfo->bitrate_nominal);
-        fprintf(stderr, "Bitrate Lower: %ld\n", vorbisInfo->bitrate_lower);
-        fprintf(stderr, "Bitrate Windows: %ld\n", vorbisInfo->bitrate_window);
-        fprintf(stderr, "Vendor: %s\n", vorbisComment->vendor);
-        fprintf(stderr, "PCM data size: %lld\n", pcm_length);
-        fprintf(stderr, "# comment: %d\n", vorbisComment->comments);
-        for (i = 0; i < vorbisComment->comments; i++)
-                fprintf(stderr, "\tComment %d: %s\n", i, vorbisComment->user_comments[i]);
+                vorbisComment = ov_comment(&oggStream, -1);
+                fprintf(stderr, "Version: %d\n", vorbisInfo->version);
+                fprintf(stderr, "Channels: %d\n", vorbisInfo->channels);
+                fprintf(stderr, "Rate (Hz): %ld\n", vorbisInfo->rate);
+                fprintf(stderr, "Bitrate Upper: %ld\n", vorbisInfo->bitrate_upper);
+                fprintf(stderr, "Bitrate Nominal: %ld\n", vorbisInfo->bitrate_nominal);
+                fprintf(stderr, "Bitrate Lower: %ld\n", vorbisInfo->bitrate_lower);
+                fprintf(stderr, "Bitrate Windows: %ld\n", vorbisInfo->bitrate_window);
+                fprintf(stderr, "Vendor: %s\n", vorbisComment->vendor);
+                fprintf(stderr, "PCM data size: %lld\n", pcm_length);
+                fprintf(stderr, "# comment: %d\n", vorbisComment->comments);
+                for (i = 0; i < vorbisComment->comments; i++)
+                        fprintf(stderr, "\tComment %d: %s\n", i, vorbisComment->user_comments[i]);
 #endif
-        
-            /*allocates enough room for the decoded data*/
-            *data = (char*) Malloc (sizeof(char) * pcm_length);
-        
-            /*there *should* not be ogg at 8 bits*/
-            if (vorbisInfo->channels == 1)
-                    *format = AL_FORMAT_MONO16;
-            else {
-                    if (vorbisInfo->channels == 2)
-                            *format = AL_FORMAT_STEREO16;
-                    else {
-                            errno = EILSEQ;
-                            err_ret("(%s) ERROR - wrong OGG header [channel %d]", prog, vorbisInfo->channels);
-                            ov_clear(&oggStream);
-                            return AL_FALSE;
-                    }
-            }
-        
-            size = 0;
+                
+                /*allocates enough room for the decoded data*/
+                *data = (char*) Malloc (sizeof(char) * pcm_length);
+                
+                /*there *should* not be ogg at 8 bits*/
+                if (vorbisInfo->channels == 1)
+                        *format = AL_FORMAT_MONO16;
+                else {
+                        if (vorbisInfo->channels == 2)
+                                *format = AL_FORMAT_STEREO16;
+                        else {
+                                errno = EILSEQ;
+                                err_ret("(%s) ERROR - wrong OGG header [channel %d]", prog, vorbisInfo->channels);
+                                ov_clear(&oggStream);
+                                return AL_FALSE;
+                        }
+                }
+                
+                size = 0;
 #ifdef __LITTLE_ENDIAN__
-            endianness = 0;
+                endianness = 0;
 #elif __BIG_ENDIAN__
-            endianness = 1;
+                endianness = 1;
 #endif
-        while (size < pcm_length) {
-            /*ov_read decodes the ogg stream and storse the pcm in data*/
-            result = ov_read (&oggStream, *data + size, pcm_length - size, endianness, 2, 1, &section);
-            if (result > 0) {
-                size += result;
-            } else {
-                if (result == 0)
-                    break;
-                else { 
-                        errno = EILSEQ;
-                        err_ret("(%s) ERROR - End of file from OGG stream", prog);
-                    ov_clear(&oggStream);
-                    return AL_FALSE;
+                while (size < pcm_length) {
+                        /*ov_read decodes the ogg stream and storse the pcm in data*/
+                        result = ov_read (&oggStream, *data + size, pcm_length - size, endianness, 2, 1, &section);
+                        if (result > 0) {
+                                size += result;
+                        } else {
+                                if (result == 0)
+                                        break;
+                                else { 
+                                        errno = EILSEQ;
+                                        err_ret("(%s) ERROR - End of file from OGG stream", prog);
+                                        ov_clear(&oggStream);
+                                        return AL_FALSE;
+                                }
+                        }
                 }
-            }
+                
+                /*set the last fields*/
+                *bitsize = size;
+                *freq    = vorbisInfo->rate;
+                
+                /*cleaning time*/
+                ov_clear(&oggStream);
+                
+                return AL_TRUE;
         }
         
-        /*set the last fields*/
-        *bitsize = size;
-        *freq    = vorbisInfo->rate;
-        
-	/*cleaning time*/
-        ov_clear(&oggStream);
-
-        return AL_TRUE;
-    }
-    
 #ifdef __CPLUSPLUS
 }
 #endif	
--- a/openalbridge/loaders.h	Sun Oct 11 20:40:03 2009 +0000
+++ b/openalbridge/loaders.h	Sun Oct 11 22:17:50 2009 +0000
@@ -27,10 +27,10 @@
 #ifdef __CPLUSPLUS
 extern "C" {
 #endif 
-    
-    int load_wavpcm	(const char *filename, ALenum *format, char **data, ALsizei *bitsize, ALsizei *freq);
-    int load_oggvorbis	(const char *filename, ALenum *format, char **data, ALsizei *bitsize, ALsizei *freq);
-    
+        
+        int load_wavpcm     (const char *filename, ALenum *format, char **data, ALsizei *bitsize, ALsizei *freq);
+        int load_oggvorbis  (const char *filename, ALenum *format, char **data, ALsizei *bitsize, ALsizei *freq);
+        
 #ifdef __CPLUSPLUS
 }
 #endif
--- a/openalbridge/oggvorbis.h	Sun Oct 11 20:40:03 2009 +0000
+++ b/openalbridge/oggvorbis.h	Sun Oct 11 22:17:50 2009 +0000
@@ -17,149 +17,150 @@
 #ifndef ogg_int64_t	
 #define ogg_int64_t int64_t
 #endif
+
 typedef struct {
-    unsigned char *data;
-    int storage;
-    int fill;
-    int returned;
-    int unsynced;
-    int headerbytes;
-    int bodybytes;
+        unsigned char *data;
+        int storage;
+        int fill;
+        int returned;
+        int unsynced;
+        int headerbytes;
+        int bodybytes;
 } ogg_sync_state;
 typedef struct vorbis_info{
-    int version;
-    int channels;
-    long rate;
-    /* The below bitrate declarations are *hints*.
-     Combinations of the three values carry the following implications: all three set to the same value: implies a fixed rate bitstream
-     only nominal set: implies a VBR stream that averages the nominal bitrate.  No hard upper/lower limit
-     upper and or lower set: implies a VBR bitstream that obeys the bitrate limits. nominal may also be set to give a nominal rate.
-     none set: the coder does not care to speculate. */
-    long bitrate_upper;
-    long bitrate_nominal;
-    long bitrate_lower;
-    long bitrate_window;
-    void *codec_setup;
+        int version;
+        int channels;
+        long rate;
+        /* The below bitrate declarations are *hints*.
+         Combinations of the three values carry the following implications: all three set to the same value: implies a fixed rate bitstream
+         only nominal set: implies a VBR stream that averages the nominal bitrate.  No hard upper/lower limit
+         upper and or lower set: implies a VBR bitstream that obeys the bitrate limits. nominal may also be set to give a nominal rate.
+         none set: the coder does not care to speculate. */
+        long bitrate_upper;
+        long bitrate_nominal;
+        long bitrate_lower;
+        long bitrate_window;
+        void *codec_setup;
 } vorbis_info;
 typedef struct vorbis_comment{
-    /* unlimited user comment fields.  libvorbis writes 'libvorbis' whatever vendor is set to in encode */
-    char **user_comments;
-    int   *comment_lengths;
-    int    comments;
-    char  *vendor;
+        /* unlimited user comment fields.  libvorbis writes 'libvorbis' whatever vendor is set to in encode */
+        char **user_comments;
+        int   *comment_lengths;
+        int    comments;
+        char  *vendor;
 } vorbis_comment;
 typedef struct {
-    unsigned char   *body_data;    /* bytes from packet bodies */
-    long    body_storage;          /* storage elements allocated */
-    long    body_fill;             /* elements stored; fill mark */
-    long    body_returned;         /* elements of fill returned */
-    int     *lacing_vals;      	   /* The values that will go to the segment table */
-    ogg_int64_t *granule_vals; 
-    /* granulepos values for headers. Not compact this way, but it is simple coupled to the lacing fifo */
-    long    lacing_storage;
-    long    lacing_fill;
-    long    lacing_packet;
-    long    lacing_returned;
-    unsigned char    header[282];      /* working space for header encode */
-    int              header_fill;
-    int     e_o_s;          /* set when we have buffered the last packet in the logical bitstream */
-    int     b_o_s;          /* set after we've written the initial page of a logical bitstream */
-    long    serialno;
-    long    pageno;
-    ogg_int64_t  packetno;      
-    /* sequence number for decode; the framing knows where there's a hole in the data,
-     but we need coupling so that the codec (which is in a seperate abstraction layer) also knows about the gap */
-    ogg_int64_t   granulepos;
+        unsigned char   *body_data;    /* bytes from packet bodies */
+        long    body_storage;          /* storage elements allocated */
+        long    body_fill;             /* elements stored; fill mark */
+        long    body_returned;         /* elements of fill returned */
+        int     *lacing_vals;      	   /* The values that will go to the segment table */
+        ogg_int64_t *granule_vals; 
+        /* granulepos values for headers. Not compact this way, but it is simple coupled to the lacing fifo */
+        long    lacing_storage;
+        long    lacing_fill;
+        long    lacing_packet;
+        long    lacing_returned;
+        unsigned char    header[282];      /* working space for header encode */
+        int              header_fill;
+        int     e_o_s;          /* set when we have buffered the last packet in the logical bitstream */
+        int     b_o_s;          /* set after we've written the initial page of a logical bitstream */
+        long    serialno;
+        long    pageno;
+        ogg_int64_t  packetno;      
+        /* sequence number for decode; the framing knows where there's a hole in the data,
+         but we need coupling so that the codec (which is in a seperate abstraction layer) also knows about the gap */
+        ogg_int64_t   granulepos;
 } ogg_stream_state;
 typedef struct vorbis_dsp_state{
-    int analysisp;
-    vorbis_info *vi;
-    float **pcm;
-    float **pcmret;
-    int  pcm_storage;
-    int  pcm_current;
-    int  pcm_returned;
-    int  preextrapolate;
-    int  eofflag;
-    long lW;
-    long W;
-    long nW;
-    long centerW;
-    ogg_int64_t granulepos;
-    ogg_int64_t sequence;
-    ogg_int64_t glue_bits;
-    ogg_int64_t time_bits;
-    ogg_int64_t floor_bits;
-    ogg_int64_t res_bits;
-    void       *backend_state;
+        int analysisp;
+        vorbis_info *vi;
+        float **pcm;
+        float **pcmret;
+        int  pcm_storage;
+        int  pcm_current;
+        int  pcm_returned;
+        int  preextrapolate;
+        int  eofflag;
+        long lW;
+        long W;
+        long nW;
+        long centerW;
+        ogg_int64_t granulepos;
+        ogg_int64_t sequence;
+        ogg_int64_t glue_bits;
+        ogg_int64_t time_bits;
+        ogg_int64_t floor_bits;
+        ogg_int64_t res_bits;
+        void       *backend_state;
 } vorbis_dsp_state;
 typedef struct {
-    long endbyte;
-    int  endbit;
-    unsigned char *buffer;
-    unsigned char *ptr;
-    long storage;
+        long endbyte;
+        int  endbit;
+        unsigned char *buffer;
+        unsigned char *ptr;
+        long storage;
 } oggpack_buffer;
 typedef struct vorbis_block{
-    /* necessary stream state for linking to the framing abstraction */
-    float **pcm;       /* this is a pointer into local storage */
-    oggpack_buffer opb;
-    long  lW;
-    long  W;
-    long  nW;
-    int   pcmend;
-    int   mode;
-    int   eofflag;
-    ogg_int64_t granulepos;
-    ogg_int64_t sequence;
-    vorbis_dsp_state *vd; /* For read-only access of configuration */
-    /* local storage to avoid remallocing; it's up to the mapping to structure it */
-    void  *localstore;
-    long  localtop;
-    long  localalloc;
-    long  totaluse;
-    struct alloc_chain *reap;
-    /* bitmetrics for the frame */
-    long glue_bits;
-    long time_bits;
-    long floor_bits;
-    long res_bits;
-    void *internal;
+        /* necessary stream state for linking to the framing abstraction */
+        float **pcm;       /* this is a pointer into local storage */
+        oggpack_buffer opb;
+        long  lW;
+        long  W;
+        long  nW;
+        int   pcmend;
+        int   mode;
+        int   eofflag;
+        ogg_int64_t granulepos;
+        ogg_int64_t sequence;
+        vorbis_dsp_state *vd; /* For read-only access of configuration */
+        /* local storage to avoid remallocing; it's up to the mapping to structure it */
+        void  *localstore;
+        long  localtop;
+        long  localalloc;
+        long  totaluse;
+        struct alloc_chain *reap;
+        /* bitmetrics for the frame */
+        long glue_bits;
+        long time_bits;
+        long floor_bits;
+        long res_bits;
+        void *internal;
 } vorbis_block;
 typedef struct {
-    size_t (*read_func)  (void *ptr, size_t size, size_t nmemb, void *datasource);
-    int    (*seek_func)  (void *datasource, ogg_int64_t offset, int whence);
-    int    (*close_func) (void *datasource);
-    long   (*tell_func)  (void *datasource);
+        size_t (*read_func)  (void *ptr, size_t size, size_t nmemb, void *datasource);
+        int    (*seek_func)  (void *datasource, ogg_int64_t offset, int whence);
+        int    (*close_func) (void *datasource);
+        long   (*tell_func)  (void *datasource);
 } ov_callbacks;
 typedef struct OggVorbis_File {
-    void            *datasource; /* Pointer to a FILE *, etc. */
-    int              seekable;
-    ogg_int64_t      offset;
-    ogg_int64_t      end;
-    ogg_sync_state   oy;
-    /* If the FILE handle isn't seekable (eg, a pipe), only the current stream appears */
-    int              links;
-    ogg_int64_t     *offsets;
-    ogg_int64_t     *dataoffsets;
-    long            *serialnos;
-    ogg_int64_t     *pcmlengths; 
-    /* overloaded to maintain binary
-     compatability; x2 size, stores both
-     beginning and end values */
-    vorbis_info     *vi;
-    vorbis_comment  *vc;
-    /* Decoding working state local storage */
-    ogg_int64_t      pcm_offset;
-    int              ready_state;
-    long             current_serialno;
-    int              current_link;
-    double           bittrack;
-    double           samptrack;
-    ogg_stream_state os; /* take physical pages, weld into a logical stream of packets */
-    vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
-    vorbis_block     vb; /* local working space for packet->PCM decode */
-    ov_callbacks callbacks;
+        void            *datasource; /* Pointer to a FILE *, etc. */
+        int              seekable;
+        ogg_int64_t      offset;
+        ogg_int64_t      end;
+        ogg_sync_state   oy;
+        /* If the FILE handle isn't seekable (eg, a pipe), only the current stream appears */
+        int              links;
+        ogg_int64_t     *offsets;
+        ogg_int64_t     *dataoffsets;
+        long            *serialnos;
+        ogg_int64_t     *pcmlengths; 
+        /* overloaded to maintain binary
+         compatability; x2 size, stores both
+         beginning and end values */
+        vorbis_info     *vi;
+        vorbis_comment  *vc;
+        /* Decoding working state local storage */
+        ogg_int64_t      pcm_offset;
+        int              ready_state;
+        long             current_serialno;
+        int              current_link;
+        double           bittrack;
+        double           samptrack;
+        ogg_stream_state os; /* take physical pages, weld into a logical stream of packets */
+        vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
+        vorbis_block     vb; /* local working space for packet->PCM decode */
+        ov_callbacks callbacks;
 } OggVorbis_File;
 
 
--- a/openalbridge/openalbridge.c	Sun Oct 11 20:40:03 2009 +0000
+++ b/openalbridge/openalbridge.c	Sun Oct 11 22:17:50 2009 +0000
@@ -74,7 +74,6 @@
                 
                 prog = programname;
                 
-                
                 /*Position of the listener*/
                 ALfloat ListenerPos[] = { 0.0, 0.0, 0.0 };
                 /*Velocity of the listener*/
@@ -88,7 +87,7 @@
                         return AL_FALSE;
                 }
                 
-                if (usehardware)
+                if (usehardware = AL_TRUE)
                         device = alcOpenDevice(NULL);
                 else
                         device = alcOpenDevice("Generic Software");
@@ -273,8 +272,9 @@
                 }
                 
                 /*Set volume for sound number index*/
-                if (index >= globalindex) {
-                        fprintf(stderr, "ERROR 'openal_setvolume()': index out of bounds (got %d, max %d)\n", index, globalindex);
+                if (index >= globalsize) {
+                        errno = EINVAL;
+                        err_ret("(%s) ERROR - Index out of bounds (got %d, max %d)", prog, index, globalindex);
                         return AL_FALSE;
                 }
                 
--- a/openalbridge/openalbridge.h	Sun Oct 11 20:40:03 2009 +0000
+++ b/openalbridge/openalbridge.h	Sun Oct 11 22:17:50 2009 +0000
@@ -28,23 +28,23 @@
 #ifdef __CPLUSPLUS
 extern "C" {
 #endif 
-    
-    ALboolean openal_init		(char* programname, ALboolean usehardware, unsigned int memorysize);
-    ALboolean openal_close		(void);
-    ALboolean openal_ready		(void);
-    ALint     openal_loadfile           (const char *filename);
-    ALboolean openal_toggleloop         (unsigned int index);
-    ALboolean openal_setposition	(unsigned int index, float x, float y, float z);
-    ALboolean openal_setvolume          (unsigned int index, unsigned char percentage);
-    ALboolean openal_setglobalvolume	(unsigned char percentage);
-    ALboolean openal_togglemute         (void);
-    ALboolean openal_fadeout            (unsigned int index, unsigned short int quantity);
-    ALboolean openal_fadein             (unsigned int index, unsigned short int quantity);
-    ALboolean openal_fade               (unsigned int index, unsigned short int quantity, ALboolean direction);
-    ALboolean openal_playsound          (unsigned int index);	
-    ALboolean openal_pausesound         (unsigned int index);
-    ALboolean openal_stopsound          (unsigned int index);
-    
+        
+        ALboolean   openal_init              (char* programname, ALboolean usehardware, unsigned int memorysize);
+        ALboolean   openal_close             (void);
+        ALboolean   openal_ready             (void);
+        ALint       openal_loadfile          (const char *filename);
+        ALboolean   openal_toggleloop        (unsigned int index);
+        ALboolean   openal_setposition       (unsigned int index, float x, float y, float z);
+        ALboolean   openal_setvolume         (unsigned int index, unsigned char percentage);
+        ALboolean   openal_setglobalvolume   (unsigned char percentage);
+        ALboolean   openal_togglemute        (void);
+        ALboolean   openal_fadeout           (unsigned int index, unsigned short int quantity);
+        ALboolean   openal_fadein            (unsigned int index, unsigned short int quantity);
+        ALboolean   openal_fade              (unsigned int index, unsigned short int quantity, ALboolean direction);
+        ALboolean   openal_playsound         (unsigned int index);	
+        ALboolean   openal_pausesound        (unsigned int index);
+        ALboolean   openal_stopsound         (unsigned int index);
+        
 #ifdef __CPLUSPLUS
 }
 #endif
--- a/openalbridge/wrappers.h	Sun Oct 11 20:40:03 2009 +0000
+++ b/openalbridge/wrappers.h	Sun Oct 11 22:17:50 2009 +0000
@@ -25,15 +25,15 @@
 #ifdef __CPLUSPLUS
 extern "C" {
 #endif
-    
-    void *Malloc (size_t nbytes);
-    void *Realloc (void *aptr, size_t nbytes);
-    FILE *Fopen (const char *fname, char *mode);
-    ALint AlGetError (const char *str);
-    ALint AlGetError2 (const char *str, int num);
-    void *helper_fadein (void *tmp);
-    void *helper_fadeout (void *tmp); 
-    
+        
+        void *Malloc (size_t nbytes);
+        void *Realloc (void *aptr, size_t nbytes);
+        FILE *Fopen (const char *fname, char *mode);
+        ALint AlGetError (const char *str);
+        ALint AlGetError2 (const char *str, int num);
+        void *helper_fadein (void *tmp);
+        void *helper_fadeout (void *tmp); 
+        
 #ifdef __CPLUSPLUS
 }
 #endif