Mercurial > SDL_sound_CoreAudio
annotate decoders/aiff.c @ 181:993dd477eb4c
Updated.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Mon, 17 Dec 2001 00:25:46 +0000 |
parents | db3f0ee7aac0 |
children | 47cc2de2ae36 |
rev | line source |
---|---|
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
1 /* |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
2 * SDL_sound -- An abstract sound format decoding API. |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
3 * Copyright (C) 2001 Ryan C. Gordon. |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
4 * |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
5 * This library is free software; you can redistribute it and/or |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
6 * modify it under the terms of the GNU Lesser General Public |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
7 * License as published by the Free Software Foundation; either |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
8 * version 2.1 of the License, or (at your option) any later version. |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
9 * |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
10 * This library is distributed in the hope that it will be useful, |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
13 * Lesser General Public License for more details. |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
14 * |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU Lesser General Public |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
16 * License along with this library; if not, write to the Free Software |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
18 */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
19 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
20 /* |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
21 * AIFF decoder for SDL_sound |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
22 * |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
23 * [Insert something profound about the AIFF file format here.] |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
24 * |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
25 * This code was ripped from a decoder I had written for SDL_mixer, which was |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
26 * based on SDL_mixer's old AIFF music loader. (This loader was unfortunately |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
27 * completely broken, but it was still useful because all the pieces were |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
28 * still there, so to speak.) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
29 * |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
30 * When rewriting it for SDL_sound, I changed its structure to be more like |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
31 * the WAV loader Ryan wrote. Had they not both been part of the same project |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
32 * it would have been embarrassing how similar they are. |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
33 * |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
34 * It is not the most feature-complete AIFF loader the world has ever seen. |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
35 * For instance, it only makes a token attempt at implementing the AIFF-C |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
36 * standard; basically the parts of it that I can easily understand and test. |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
37 * It's a start, though. |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
38 * |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
39 * Please see the file LICENSE in the source's root directory. |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
40 * |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
41 * This file was written by Torbjörn Andersson. (d91tan@Update.UU.SE) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
42 */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
43 |
106
40de367eb59e
Changing my include structure to do this right.
Ryan C. Gordon <icculus@icculus.org>
parents:
104
diff
changeset
|
44 #if HAVE_CONFIG_H |
40de367eb59e
Changing my include structure to do this right.
Ryan C. Gordon <icculus@icculus.org>
parents:
104
diff
changeset
|
45 # include <config.h> |
40de367eb59e
Changing my include structure to do this right.
Ryan C. Gordon <icculus@icculus.org>
parents:
104
diff
changeset
|
46 #endif |
100
6d9fdec2f708
added config.h, added --enable-debug flag, various other changes to the build system
fingolfin
parents:
64
diff
changeset
|
47 |
104
103cfcb3c014
Updated to fix build system problem.
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
48 #ifdef SOUND_SUPPORTS_AIFF |
103cfcb3c014
Updated to fix build system problem.
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
49 |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
50 #include <stdio.h> |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
51 #include <stdlib.h> |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
52 #include <string.h> |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
53 #include <assert.h> |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
54 |
106
40de367eb59e
Changing my include structure to do this right.
Ryan C. Gordon <icculus@icculus.org>
parents:
104
diff
changeset
|
55 #include "SDL_sound.h" |
40de367eb59e
Changing my include structure to do this right.
Ryan C. Gordon <icculus@icculus.org>
parents:
104
diff
changeset
|
56 |
40de367eb59e
Changing my include structure to do this right.
Ryan C. Gordon <icculus@icculus.org>
parents:
104
diff
changeset
|
57 #define __SDL_SOUND_INTERNAL__ |
40de367eb59e
Changing my include structure to do this right.
Ryan C. Gordon <icculus@icculus.org>
parents:
104
diff
changeset
|
58 #include "SDL_sound_internal.h" |
40de367eb59e
Changing my include structure to do this right.
Ryan C. Gordon <icculus@icculus.org>
parents:
104
diff
changeset
|
59 |
180
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
60 static Uint32 SANE_to_Uint32 (Uint8 *sanebuf); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
61 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
62 |
47
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
63 static int AIFF_init(void); |
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
64 static void AIFF_quit(void); |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
65 static int AIFF_open(Sound_Sample *sample, const char *ext); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
66 static void AIFF_close(Sound_Sample *sample); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
67 static Uint32 AIFF_read(Sound_Sample *sample); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
68 |
149
1df5c106504e
Decoders can now list multiple file extensions.
Ryan C. Gordon <icculus@icculus.org>
parents:
116
diff
changeset
|
69 static const char *extensions_aiff[] = { "AIFF", NULL }; |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
70 const Sound_DecoderFunctions __Sound_DecoderFunctions_AIFF = |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
71 { |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
72 { |
149
1df5c106504e
Decoders can now list multiple file extensions.
Ryan C. Gordon <icculus@icculus.org>
parents:
116
diff
changeset
|
73 extensions_aiff, |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
74 "Audio Interchange File Format", |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
75 "Torbjörn Andersson <d91tan@Update.UU.SE>", |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
76 "http://www.icculus.org/SDL_sound/" |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
77 }, |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
78 |
47
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
79 AIFF_init, /* init() method */ |
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
80 AIFF_quit, /* quit() method */ |
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
81 AIFF_open, /* open() method */ |
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
82 AIFF_close, /* close() method */ |
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
83 AIFF_read /* read() method */ |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
84 }; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
85 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
86 |
180
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
87 /***************************************************************************** |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
88 * aiff_t is what we store in our internal->decoder_private field... * |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
89 *****************************************************************************/ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
90 typedef struct S_AIFF_FMT_T |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
91 { |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
92 Uint32 type; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
93 void (*free)(struct S_AIFF_FMT_T *fmt); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
94 Uint32(*read_sample)(Sound_Sample *sample); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
95 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
96 #if 0 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
97 /* |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
98 this is ripped from wav.c as ann example of format-specific data. |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
99 please replace with something more appropriate when the need arises. |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
100 */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
101 union |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
102 { |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
103 struct |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
104 { |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
105 Uint16 cbSize; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
106 Uint16 wSamplesPerBlock; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
107 Uint16 wNumCoef; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
108 ADPCMCOEFSET *aCoeff; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
109 } adpcm; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
110 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
111 /* put other format-specific data here... */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
112 } fmt; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
113 #endif |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
114 } fmt_t; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
115 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
116 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
117 typedef struct |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
118 { |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
119 fmt_t fmt; |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
120 Sint32 bytesLeft; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
121 } aiff_t; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
122 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
123 |
180
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
124 |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
125 /* Chunk management code... */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
126 |
180
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
127 #define formID 0x4D524F46 /* "FORM", in ascii. */ |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
128 #define aiffID 0x46464941 /* "AIFF", in ascii. */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
129 #define aifcID 0x43464941 /* "AIFC", in ascii. */ |
180
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
130 #define ssndID 0x444E5353 /* "SSND", in ascii. */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
131 |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
132 |
180
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
133 /***************************************************************************** |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
134 * The COMM chunk... * |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
135 *****************************************************************************/ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
136 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
137 #define commID 0x4D4D4F43 /* "COMM", in ascii. */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
138 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
139 /* format/compression types... */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
140 #define noneID 0x454E4F4E /* "NONE", in ascii. */ |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
141 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
142 typedef struct |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
143 { |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
144 Uint32 ckID; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
145 Uint32 ckDataSize; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
146 Uint16 numChannels; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
147 Uint32 numSampleFrames; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
148 Uint16 sampleSize; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
149 Uint32 sampleRate; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
150 /* |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
151 * We don't handle AIFF-C compressed audio yet, but for those |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
152 * interested the allowed compression types are supposed to be |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
153 * |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
154 * compressionType compressionName meaning |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
155 * --------------------------------------------------------------- |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
156 * 'NONE' "not compressed" uncompressed, that is, |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
157 * straight digitized samples |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
158 * 'ACE2' "ACE 2-to-1" 2-to-1 IIGS ACE (Audio |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
159 * Compression / Expansion) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
160 * 'ACE8' "ACE 8-to-3" 8-to-3 IIGS ACE (Audio |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
161 * Compression / Expansion) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
162 * 'MAC3' "MACE 3-to-1" 3-to-1 Macintosh Audio |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
163 * Compression / Expansion |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
164 * 'MAC6' "MACE 6-to-1" 6-to-1 Macintosh Audio |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
165 * Compression / Expansion |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
166 * |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
167 * A pstring is a "Pascal-style string", that is, "one byte followed |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
168 * by test bytes followed when needed by one pad byte. The total |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
169 * number of bytes in a pstring must be even. The pad byte is |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
170 * included when the number of text bytes is even, so the total of |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
171 * text bytes + one count byte + one pad byte will be even. This pad |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
172 * byte is not reflected in the count." |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
173 * |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
174 * As for how these compression algorithms work, your guess is as |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
175 * good as mine. |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
176 */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
177 Uint32 compressionType; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
178 #if 0 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
179 pstring compressionName; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
180 #endif |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
181 } comm_t; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
182 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
183 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
184 /* |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
185 * Read in a comm_t from disk. This makes this process safe regardless of |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
186 * the processor's byte order or how the comm_t structure is packed. |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
187 */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
188 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
189 static int read_comm_chunk(SDL_RWops *rw, comm_t *comm) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
190 { |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
191 Uint8 sampleRate[10]; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
192 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
193 /* skip reading the chunk ID, since it was already read at this point... */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
194 comm->ckID = commID; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
195 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
196 if (SDL_RWread(rw, &comm->ckDataSize, sizeof (comm->ckDataSize), 1) != 1) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
197 return(0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
198 comm->ckDataSize = SDL_SwapBE32(comm->ckDataSize); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
199 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
200 if (SDL_RWread(rw, &comm->numChannels, sizeof (comm->numChannels), 1) != 1) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
201 return(0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
202 comm->numChannels = SDL_SwapBE16(comm->numChannels); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
203 |
41
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
204 if (SDL_RWread(rw, &comm->numSampleFrames, |
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
205 sizeof (comm->numSampleFrames), 1) != 1) |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
206 return(0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
207 comm->numSampleFrames = SDL_SwapBE32(comm->numSampleFrames); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
208 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
209 if (SDL_RWread(rw, &comm->sampleSize, sizeof (comm->sampleSize), 1) != 1) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
210 return(0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
211 comm->sampleSize = SDL_SwapBE16(comm->sampleSize); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
212 |
41
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
213 if (SDL_RWread(rw, sampleRate, sizeof (sampleRate), 1) != 1) |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
214 return(0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
215 comm->sampleRate = SANE_to_Uint32(sampleRate); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
216 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
217 if (comm->ckDataSize > sizeof(comm->numChannels) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
218 + sizeof(comm->numSampleFrames) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
219 + sizeof(comm->sampleSize) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
220 + sizeof(sampleRate)) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
221 { |
41
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
222 if (SDL_RWread(rw, &comm->compressionType, |
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
223 sizeof (comm->compressionType), 1) != 1) |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
224 return(0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
225 comm->compressionType = SDL_SwapBE32(comm->compressionType); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
226 } /* if */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
227 else |
180
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
228 { |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
229 comm->compressionType = noneID; |
180
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
230 } /* else */ |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
231 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
232 return(1); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
233 } /* read_comm_chunk */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
234 |
180
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
235 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
236 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
237 /***************************************************************************** |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
238 * The SSND chunk... * |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
239 *****************************************************************************/ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
240 |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
241 typedef struct |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
242 { |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
243 Uint32 ckID; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
244 Uint32 ckDataSize; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
245 Uint32 offset; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
246 Uint32 blockSize; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
247 /* |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
248 * Then, comm->numSampleFrames sample frames. (It's better to get the |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
249 * length from numSampleFrames than from ckDataSize.) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
250 */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
251 } ssnd_t; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
252 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
253 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
254 static int read_ssnd_chunk(SDL_RWops *rw, ssnd_t *ssnd) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
255 { |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
256 /* skip reading the chunk ID, since it was already read at this point... */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
257 ssnd->ckID = ssndID; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
258 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
259 if (SDL_RWread(rw, &ssnd->ckDataSize, sizeof (ssnd->ckDataSize), 1) != 1) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
260 return(0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
261 ssnd->ckDataSize = SDL_SwapBE32(ssnd->ckDataSize); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
262 |
41
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
263 if (SDL_RWread(rw, &ssnd->offset, sizeof (ssnd->offset), 1) != 1) |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
264 return(0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
265 ssnd->offset = SDL_SwapBE32(ssnd->offset); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
266 |
41
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
267 if (SDL_RWread(rw, &ssnd->blockSize, sizeof (ssnd->blockSize), 1) != 1) |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
268 return(0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
269 ssnd->blockSize = SDL_SwapBE32(ssnd->blockSize); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
270 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
271 /* Leave the SDL_RWops position indicator at the start of the samples */ |
41
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
272 /* !!! FIXME: Int? Really? */ |
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
273 if (SDL_RWseek(rw, (int) ssnd->offset, SEEK_CUR) == -1) |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
274 return(0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
275 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
276 return(1); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
277 } /* read_ssnd_chunk */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
278 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
279 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
280 |
180
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
281 /***************************************************************************** |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
282 * Normal, uncompressed aiff handler... * |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
283 *****************************************************************************/ |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
284 |
180
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
285 static Uint32 read_sample_fmt_normal(Sound_Sample *sample) |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
286 { |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
287 Uint32 retval; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
288 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
289 aiff_t *a = (aiff_t *) internal->decoder_private; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
290 Uint32 max = (internal->buffer_size < (Uint32) a->bytesLeft) ? |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
291 internal->buffer_size : (Uint32) a->bytesLeft; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
292 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
293 assert(max > 0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
294 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
295 /* |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
296 * We don't actually do any decoding, so we read the AIFF data |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
297 * directly into the internal buffer... |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
298 */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
299 retval = SDL_RWread(internal->rw, internal->buffer, 1, max); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
300 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
301 a->bytesLeft -= retval; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
302 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
303 /* Make sure the read went smoothly... */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
304 if ((retval == 0) || (a->bytesLeft == 0)) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
305 sample->flags |= SOUND_SAMPLEFLAG_EOF; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
306 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
307 else if (retval == -1) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
308 sample->flags |= SOUND_SAMPLEFLAG_ERROR; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
309 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
310 /* (next call this EAGAIN may turn into an EOF or error.) */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
311 else if (retval < internal->buffer_size) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
312 sample->flags |= SOUND_SAMPLEFLAG_EAGAIN; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
313 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
314 return(retval); |
180
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
315 } /* read_sample_fmt_normal */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
316 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
317 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
318 static void free_fmt_normal(fmt_t *fmt) |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
319 { |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
320 /* it's a no-op. */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
321 } /* free_fmt_normal */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
322 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
323 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
324 static int read_fmt_normal(SDL_RWops *rw, fmt_t *fmt) |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
325 { |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
326 /* (don't need to read more from the RWops...) */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
327 fmt->free = free_fmt_normal; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
328 fmt->read_sample = read_sample_fmt_normal; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
329 return(1); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
330 } /* read_fmt_normal */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
331 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
332 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
333 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
334 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
335 /***************************************************************************** |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
336 * Everything else... * |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
337 *****************************************************************************/ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
338 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
339 static int AIFF_init(void) |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
340 { |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
341 return(1); /* always succeeds. */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
342 } /* AIFF_init */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
343 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
344 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
345 static void AIFF_quit(void) |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
346 { |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
347 /* it's a no-op. */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
348 } /* AIFF_quit */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
349 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
350 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
351 /* |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
352 * Sample rate is encoded as an "80 bit IEEE Standard 754 floating point |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
353 * number (Standard Apple Numeric Environment [SANE] data type Extended)". |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
354 * Whose bright idea was that? |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
355 * |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
356 * This function was adapted from libsndfile, and while I do know a little |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
357 * bit about the IEEE floating point standard I don't pretend to fully |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
358 * understand this. |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
359 */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
360 static Uint32 SANE_to_Uint32 (Uint8 *sanebuf) |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
361 { |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
362 /* Is the frequency outside of what we can represent with Uint32? */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
363 if ( (sanebuf[0] & 0x80) |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
364 || (sanebuf[0] <= 0x3F) |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
365 || (sanebuf[0] > 0x40) |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
366 || (sanebuf[0] == 0x40 && sanebuf[1] > 0x1C) ) |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
367 return 0; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
368 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
369 return ((sanebuf[2] << 23) | (sanebuf[3] << 15) | (sanebuf[4] << 7) |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
370 | (sanebuf[5] >> 1)) >> (29 - sanebuf[1]); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
371 } /* SANE_to_Uint32 */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
372 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
373 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
374 static int find_chunk(SDL_RWops *rw, Uint32 id) |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
375 { |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
376 Sint32 siz = 0; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
377 Uint32 _id = 0; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
378 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
379 while (1) |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
380 { |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
381 BAIL_IF_MACRO(SDL_RWread(rw, &_id, sizeof (_id), 1) != 1, NULL, 0); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
382 if (SDL_SwapLE32(_id) == id) |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
383 return(1); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
384 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
385 BAIL_IF_MACRO(SDL_RWread(rw, &siz, sizeof (siz), 1) != 1, NULL, 0); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
386 siz = SDL_SwapBE32(siz); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
387 assert(siz > 0); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
388 BAIL_IF_MACRO(SDL_RWseek(rw, siz, SEEK_CUR) == -1, NULL, 0); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
389 } /* while */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
390 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
391 return(0); /* shouldn't hit this, but just in case... */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
392 } /* find_chunk */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
393 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
394 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
395 static int read_fmt(SDL_RWops *rw, comm_t *c, fmt_t *fmt) |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
396 { |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
397 fmt->type = c->compressionType; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
398 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
399 /* if it's in this switch statement, we support the format. */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
400 switch (fmt->type) |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
401 { |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
402 case noneID: |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
403 SNDDBG(("AIFF: Appears to be uncompressed audio.\n")); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
404 return(read_fmt_normal(rw, fmt)); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
405 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
406 /* add other types here. */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
407 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
408 default: |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
409 SNDDBG(("AIFF: Format %lu is unknown.\n", |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
410 (unsigned int) fmt->type)); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
411 Sound_SetError("AIFF: Unsupported format"); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
412 return(0); /* not supported whatsoever. */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
413 } /* switch */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
414 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
415 assert(0); /* shouldn't hit this point. */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
416 return(0); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
417 } /* read_fmt */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
418 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
419 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
420 static int AIFF_open(Sound_Sample *sample, const char *ext) |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
421 { |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
422 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
423 SDL_RWops *rw = internal->rw; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
424 Uint32 chunk_id; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
425 int bytes_per_sample; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
426 long pos; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
427 comm_t c; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
428 ssnd_t s; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
429 aiff_t *a; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
430 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
431 BAIL_IF_MACRO(SDL_ReadLE32(rw) != formID, "AIFF: Not a FORM file.", 0); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
432 SDL_ReadBE32(rw); /* throw the length away; we don't need it. */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
433 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
434 chunk_id = SDL_ReadLE32(rw); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
435 BAIL_IF_MACRO(chunk_id != aiffID && chunk_id != aifcID, |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
436 "AIFF: Not an AIFF or AIFC file.", 0); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
437 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
438 /* Chunks may appear in any order, so we establish base camp here. */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
439 pos = SDL_RWtell(rw); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
440 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
441 BAIL_IF_MACRO(!find_chunk(rw, commID), "AIFF: No common chunk.", 0); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
442 BAIL_IF_MACRO(!read_comm_chunk(rw, &c), |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
443 "AIFF: Can't read common chunk.", 0); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
444 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
445 sample->actual.channels = (Uint8) c.numChannels; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
446 sample->actual.rate = c.sampleRate; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
447 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
448 if (c.sampleSize <= 8) |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
449 { |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
450 sample->actual.format = AUDIO_S8; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
451 bytes_per_sample = 1; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
452 } /* if */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
453 else if (c.sampleSize <= 16) |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
454 { |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
455 sample->actual.format = AUDIO_S16MSB; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
456 bytes_per_sample = 2; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
457 } /* if */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
458 else |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
459 { |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
460 BAIL_MACRO("AIFF: Unsupported sample size.", 0); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
461 } /* else */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
462 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
463 BAIL_IF_MACRO(c.sampleRate == 0, "AIFF: Unsupported sample rate.", 0); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
464 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
465 a = (aiff_t *) malloc(sizeof(aiff_t)); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
466 BAIL_IF_MACRO(a == NULL, ERR_OUT_OF_MEMORY, 0); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
467 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
468 if (!read_fmt(rw, &c, &(a->fmt))) |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
469 { |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
470 free(a); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
471 return(0); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
472 } /* if */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
473 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
474 SDL_RWseek(rw, pos, SEEK_SET); /* if the seek fails, let it go... */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
475 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
476 if (!find_chunk(rw, ssndID)) |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
477 { |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
478 Sound_SetError("AIFF: No sound data chunk."); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
479 free(a); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
480 return(0); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
481 } /* if */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
482 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
483 if (!read_ssnd_chunk(rw, &s)) |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
484 { |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
485 Sound_SetError("AIFF: Can't read sound data chunk."); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
486 free(a); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
487 return(0); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
488 } /* if */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
489 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
490 a->bytesLeft = bytes_per_sample * c.numSampleFrames; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
491 internal->decoder_private = (void *) a; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
492 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
493 sample->flags = SOUND_SAMPLEFLAG_NONE; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
494 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
495 SNDDBG(("AIFF: Accepting data stream.\n")); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
496 return(1); /* we'll handle this data. */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
497 } /* AIFF_open */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
498 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
499 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
500 static void AIFF_close(Sound_Sample *sample) |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
501 { |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
502 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
503 aiff_t *a = (aiff_t *) internal->decoder_private; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
504 a->fmt.free(&(a->fmt)); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
505 free(a); |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
506 } /* WAV_close */ |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
507 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
508 |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
509 static Uint32 AIFF_read(Sound_Sample *sample) |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
510 { |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
511 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
512 aiff_t *a = (aiff_t *) internal->decoder_private; |
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
513 return(a->fmt.read_sample(sample)); |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
514 } /* AIFF_read */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
515 |
64
40006625142a
Changes in preparation of autoconf support.
Ryan C. Gordon <icculus@icculus.org>
parents:
62
diff
changeset
|
516 #endif /* SOUND_SUPPORTS_AIFF */ |
40006625142a
Changes in preparation of autoconf support.
Ryan C. Gordon <icculus@icculus.org>
parents:
62
diff
changeset
|
517 |
180
db3f0ee7aac0
Modified to more easily allow for different compression types.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
518 /* end of aiff.c ... */ |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
519 |