equal
deleted
inserted
replaced
152 /*implementation inspired from http://www.devmaster.net/forums/showthread.php?t=1153 */ |
152 /*implementation inspired from http://www.devmaster.net/forums/showthread.php?t=1153 */ |
153 |
153 |
154 /*ogg handle*/ |
154 /*ogg handle*/ |
155 FILE *oggFile; |
155 FILE *oggFile; |
156 /*stream handle*/ |
156 /*stream handle*/ |
157 OggVorbis_File oggStream; |
157 OggVorbis_File oggStream; |
158 /*some formatting data*/ |
158 /*some formatting data*/ |
159 vorbis_info *vorbisInfo; |
159 vorbis_info *vorbisInfo; |
160 /*length of the decoded data*/ |
160 /*length of the decoded data*/ |
161 int64_t pcm_length; |
161 int64_t pcm_length; |
162 /*other vars*/ |
162 /*other vars*/ |
171 result = ov_open_callbacks(oggFile, &oggStream, NULL, 0, OV_CALLBACKS_DEFAULT); |
171 result = ov_open_callbacks(oggFile, &oggStream, NULL, 0, OV_CALLBACKS_DEFAULT); |
172 if (result < 0) { |
172 if (result < 0) { |
173 errno = EINVAL; |
173 errno = EINVAL; |
174 err_ret("(%s) ERROR - ov_fopen() failed with %X", prog, result); |
174 err_ret("(%s) ERROR - ov_fopen() failed with %X", prog, result); |
175 ov_clear(&oggStream); |
175 ov_clear(&oggStream); |
176 return AL_FALSE; |
176 return -1; |
177 } |
177 } |
178 |
178 |
179 /*load OGG header and determine the decoded data size*/ |
179 /*load OGG header and determine the decoded data size*/ |
180 vorbisInfo = ov_info(&oggStream, -1); |
180 vorbisInfo = ov_info(&oggStream, -1); |
181 pcm_length = ov_pcm_total(&oggStream, -1) << vorbisInfo->channels; |
181 pcm_length = ov_pcm_total(&oggStream, -1) << vorbisInfo->channels; |
207 *format = AL_FORMAT_STEREO16; |
207 *format = AL_FORMAT_STEREO16; |
208 else { |
208 else { |
209 errno = EILSEQ; |
209 errno = EILSEQ; |
210 err_ret("(%s) ERROR - wrong OGG header [channel %d]", prog, vorbisInfo->channels); |
210 err_ret("(%s) ERROR - wrong OGG header [channel %d]", prog, vorbisInfo->channels); |
211 ov_clear(&oggStream); |
211 ov_clear(&oggStream); |
212 return AL_FALSE; |
212 return -1; |
213 } |
213 } |
214 } |
214 } |
215 |
215 |
216 size = 0; |
216 size = 0; |
217 #ifdef __LITTLE_ENDIAN__ |
217 #ifdef __LITTLE_ENDIAN__ |
229 break; |
229 break; |
230 else { |
230 else { |
231 errno = EILSEQ; |
231 errno = EILSEQ; |
232 err_ret("(%s) ERROR - End of file from OGG stream", prog); |
232 err_ret("(%s) ERROR - End of file from OGG stream", prog); |
233 ov_clear(&oggStream); |
233 ov_clear(&oggStream); |
234 return AL_FALSE; |
234 return -1; |
235 } |
235 } |
236 } |
236 } |
237 } |
237 } |
238 |
238 |
239 /*set the last fields*/ |
239 /*set the last fields*/ |
240 *bitsize = size; |
240 *bitsize = size; |
241 *freq = vorbisInfo->rate; |
241 *freq = vorbisInfo->rate; |
242 |
242 |
243 /*cleaning time*/ |
243 /*cleaning time (ov_clear also closes file handler)*/ |
244 ov_clear(&oggStream); |
244 ov_clear(&oggStream); |
245 |
245 |
246 return AL_TRUE; |
246 return 0; |
247 } |
247 } |
248 |
248 |
249 #ifdef __CPLUSPLUS |
249 #ifdef __CPLUSPLUS |
250 } |
250 } |
251 #endif |
251 #endif |