130 /*implementation inspired from http://www.devmaster.net/forums/showthread.php?t=1153 */ |
130 /*implementation inspired from http://www.devmaster.net/forums/showthread.php?t=1153 */ |
131 FILE *oggFile; /*ogg handle*/ |
131 FILE *oggFile; /*ogg handle*/ |
132 OggVorbis_File oggStream; /*stream handle*/ |
132 OggVorbis_File oggStream; /*stream handle*/ |
133 vorbis_info *vorbisInfo; /*some formatting data*/ |
133 vorbis_info *vorbisInfo; /*some formatting data*/ |
134 int64_t pcm_length; /*length of the decoded data*/ |
134 int64_t pcm_length; /*length of the decoded data*/ |
135 int size = 0; |
135 int section, result, size = 0; |
136 int section, result; |
|
137 #ifdef DEBUG |
136 #ifdef DEBUG |
138 int i; |
137 int i; |
139 vorbis_comment *vorbisComment; /*other less useful data*/ |
138 vorbis_comment *vorbisComment; /*other less useful data*/ |
140 #endif |
139 #endif |
141 |
140 |
142 oggFile = Fopen(filename, "rb"); |
141 oggFile = Fopen(filename, "rb"); |
143 result = ov_open(oggFile, &oggStream, NULL, 0); /*TODO: check returning value of result*/ |
142 result = ov_open(oggFile, &oggStream, NULL, 0); /*TODO: check returning value of result*/ |
144 fclose(oggFile); |
|
145 |
143 |
146 vorbisInfo = ov_info(&oggStream, -1); |
144 vorbisInfo = ov_info(&oggStream, -1); |
147 pcm_length = ov_pcm_total(&oggStream, -1) << vorbisInfo->channels; |
145 pcm_length = ov_pcm_total(&oggStream, -1) << vorbisInfo->channels; |
148 |
146 |
149 #ifdef DEBUG |
147 #ifdef DEBUG |
171 else { |
169 else { |
172 if (vorbisInfo->channels == 2) |
170 if (vorbisInfo->channels == 2) |
173 *format = AL_FORMAT_STEREO16; |
171 *format = AL_FORMAT_STEREO16; |
174 else { |
172 else { |
175 fprintf(stderr, "ERROR: wrong OGG header - channel value (%d)\n", vorbisInfo->channels); |
173 fprintf(stderr, "ERROR: wrong OGG header - channel value (%d)\n", vorbisInfo->channels); |
|
174 ov_clear (&oggStream); |
|
175 fclose(oggFile); |
176 return AL_FALSE; |
176 return AL_FALSE; |
177 } |
177 } |
178 } |
178 } |
179 |
179 |
180 while(size < pcm_length) { |
180 while(size < pcm_length) { |