equal
deleted
inserted
replaced
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
17 */ |
17 */ |
18 |
18 |
19 #include "loaders.h" |
19 #include "loaders.h" |
20 |
20 |
|
21 |
21 #ifdef __CPLUSPLUS |
22 #ifdef __CPLUSPLUS |
22 extern "C" { |
23 extern "C" { |
23 #endif |
24 #endif |
24 |
25 |
25 int load_wavpcm (const char *filename, ALenum *format, char ** data, ALsizei *bitsize, ALsizei *freq) { |
26 int load_wavpcm (const char *filename, ALenum *format, char ** data, ALsizei *bitsize, ALsizei *freq) { |
78 } |
79 } |
79 } |
80 } |
80 |
81 |
81 if (t <= 0) { |
82 if (t <= 0) { |
82 /*eof*/ |
83 /*eof*/ |
83 fprintf(stderr, "ERROR 'load_wavpcm()': wrong WAV header\n"); |
84 errno = EILSEQ; |
|
85 err_ret("(%s) ERROR - wrong WAV header", prog); |
84 return AL_FALSE; |
86 return AL_FALSE; |
85 } |
87 } |
86 } while (1); |
88 } while (1); |
87 |
89 |
88 fread(&WAVHeader.Subchunk2Size, sizeof(uint32_t), 1, wavfile); |
90 fread(&WAVHeader.Subchunk2Size, sizeof(uint32_t), 1, wavfile); |
155 |
157 |
156 result = ov_fopen((char*) filename, &oggStream); |
158 result = ov_fopen((char*) filename, &oggStream); |
157 if (result < 0) { |
159 if (result < 0) { |
158 fprintf (stderr, "ERROR 'load_oggvorbis()': ov_fopen failed with %X", result); |
160 fprintf (stderr, "ERROR 'load_oggvorbis()': ov_fopen failed with %X", result); |
159 ov_clear(&oggStream); |
161 ov_clear(&oggStream); |
160 return -1; |
162 return AL_FALSE; |
161 } |
163 } |
162 |
164 |
163 /*load OGG header and determine the decoded data size*/ |
165 /*load OGG header and determine the decoded data size*/ |
164 vorbisInfo = ov_info(&oggStream, -1); |
166 vorbisInfo = ov_info(&oggStream, -1); |
165 pcm_length = ov_pcm_total(&oggStream, -1) << vorbisInfo->channels; |
167 pcm_length = ov_pcm_total(&oggStream, -1) << vorbisInfo->channels; |
188 *format = AL_FORMAT_MONO16; |
190 *format = AL_FORMAT_MONO16; |
189 else { |
191 else { |
190 if (vorbisInfo->channels == 2) |
192 if (vorbisInfo->channels == 2) |
191 *format = AL_FORMAT_STEREO16; |
193 *format = AL_FORMAT_STEREO16; |
192 else { |
194 else { |
193 fprintf(stderr, "ERROR 'load_oggvorbis()': wrong OGG header - channel value (%d)\n", vorbisInfo->channels); |
195 errno = EILSEQ; |
|
196 err_ret("(%s) ERROR - wrong OGG header [channel %d]", prog, vorbisInfo->channels); |
194 ov_clear(&oggStream); |
197 ov_clear(&oggStream); |
195 return AL_FALSE; |
198 return AL_FALSE; |
196 } |
199 } |
197 } |
200 } |
198 |
201 |