diff options
Diffstat (limited to 'src/Support.cpp')
-rw-r--r-- | src/Support.cpp | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/src/Support.cpp b/src/Support.cpp index f7e726a..d070faa 100644 --- a/src/Support.cpp +++ b/src/Support.cpp @@ -7,7 +7,6 @@ #include <unistd.h> #include <GLFW/glfw3.h> -#include <vorbis/vorbisfile.h> #include "Support.h" #include "Files.h" @@ -195,71 +194,3 @@ void Files::EndLoad() sFile = -1; } - -/* Read the requested Ogg file and load it into OpenAL */ -void loadOgg(char *filename, ALuint buffer, ALuint source) -{ - /* Try to find the real file (and place it in filename1) */ - char filename1[MAX_PATH]; - fix_filename(filename, filename1); - - FILE* fp = fopen(filename1, "rb"); - if (fp == NULL) { - fprintf(stderr, "ERROR: unable to open %s\n", filename1); - exit(EXIT_FAILURE); - } - - OggVorbis_File vf; - int error = -ov_open(fp, &vf, NULL, 0); - if (error > 0) { - fprintf(stderr, "ERROR: vorbis error %d opening %s\n", - error, filename1); - exit(EXIT_FAILURE); - } - - vorbis_info* vi = ov_info(&vf, -1); - if (vi == NULL) { - fprintf(stderr, - "ERROR: vorbis error opening %s (ov_info failed)\n", - filename1); - exit(EXIT_FAILURE); - } - - /* Hack around some possible ogg vorbis weirdness */ - ALsizei size = vi->channels * 2 * ov_pcm_total(&vf, -1); - ALvoid* data = malloc(((size + 2047) / 2048 + 1) * 2048); - if (data == NULL) { - fprintf(stderr, - "ERROR: could not allocate %d bytes while loading %s\n", - size, filename1); - exit(EXIT_FAILURE); - } - - char* i = (char*) data; - int section; - long ret; -#if BYTE_ORDER == BIG_ENDIAN - while (ret = ov_read(&vf, i, 1024, 1, 2, 1, §ion)) -#else - while (ret = ov_read(&vf, i, 1024, 0, 2, 1, §ion)) -#endif - if (ret > 0) /* XXX: How about negative ret? */ - i += ret; - - switch (vi->channels) { - case 1: - alBufferData(buffer, AL_FORMAT_MONO16, data, size, vi->rate); - break; - case 2: - alBufferData(buffer, AL_FORMAT_STEREO16, data, size, vi->rate); - break; - default: - fprintf(stderr, "ERROR: ogg %s has %d channels\n", - filename1, vi->channels); - exit(EXIT_FAILURE); - } - - free(data); - ov_clear(&vf); - alSourcei(source, AL_BUFFER, buffer); -} |