Mercurial > SDL_sound_CoreAudio
annotate decoders/aiff.c @ 169:a1255c02bab1
Updated.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Mon, 26 Nov 2001 04:41:18 +0000 |
parents | 1df5c106504e |
children | db3f0ee7aac0 |
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 |
47
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
60 static int AIFF_init(void); |
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
61 static void AIFF_quit(void); |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
62 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
|
63 static void AIFF_close(Sound_Sample *sample); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
64 static Uint32 AIFF_read(Sound_Sample *sample); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
65 |
149
1df5c106504e
Decoders can now list multiple file extensions.
Ryan C. Gordon <icculus@icculus.org>
parents:
116
diff
changeset
|
66 static const char *extensions_aiff[] = { "AIFF", NULL }; |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
67 const Sound_DecoderFunctions __Sound_DecoderFunctions_AIFF = |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
68 { |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
69 { |
149
1df5c106504e
Decoders can now list multiple file extensions.
Ryan C. Gordon <icculus@icculus.org>
parents:
116
diff
changeset
|
70 extensions_aiff, |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
71 "Audio Interchange File Format", |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
72 "Torbjörn Andersson <d91tan@Update.UU.SE>", |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
73 "http://www.icculus.org/SDL_sound/" |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
74 }, |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
75 |
47
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
76 AIFF_init, /* init() method */ |
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
77 AIFF_quit, /* quit() method */ |
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
78 AIFF_open, /* open() method */ |
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
79 AIFF_close, /* close() method */ |
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
80 AIFF_read /* read() method */ |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
81 }; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
82 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
83 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
84 /* this is what we store in our internal->decoder_private field... */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
85 typedef struct { |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
86 Sint32 bytesLeft; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
87 } aiff_t; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
88 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
89 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
90 /* Chunk management code... */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
91 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
92 #define formID 0x4d524f46 /* "FORM", in ascii. */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
93 #define aiffID 0x46464941 /* "AIFF", in ascii. */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
94 #define aifcID 0x43464941 /* "AIFC", in ascii. */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
95 #define ssndID 0x444e5353 /* "SSND", in ascii. */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
96 #define commID 0x4d4d4f43 /* "COMM", in ascii. */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
97 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
98 #define noneID 0x454e4f4e /* "NONE", in ascii. */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
99 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
100 typedef struct |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
101 { |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
102 Uint32 ckID; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
103 Uint32 ckDataSize; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
104 Uint16 numChannels; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
105 Uint32 numSampleFrames; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
106 Uint16 sampleSize; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
107 Uint32 sampleRate; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
108 /* |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
109 * 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
|
110 * interested the allowed compression types are supposed to be |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
111 * |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
112 * compressionType compressionName meaning |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
113 * --------------------------------------------------------------- |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
114 * 'NONE' "not compressed" uncompressed, that is, |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
115 * straight digitized samples |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
116 * '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
|
117 * Compression / Expansion) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
118 * '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
|
119 * Compression / Expansion) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
120 * '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
|
121 * Compression / Expansion |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
122 * '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
|
123 * Compression / Expansion |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
124 * |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
125 * 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
|
126 * 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
|
127 * 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
|
128 * 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
|
129 * 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
|
130 * byte is not reflected in the count." |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
131 * |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
132 * 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
|
133 * good as mine. |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
134 */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
135 Uint32 compressionType; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
136 #if 0 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
137 pstring compressionName; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
138 #endif |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
139 } comm_t; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
140 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
141 |
47
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
142 |
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
143 static int AIFF_init(void) |
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
144 { |
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
145 return(1); /* always succeeds. */ |
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
146 } /* AIFF_init */ |
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
147 |
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
148 |
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
149 static void AIFF_quit(void) |
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
150 { |
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
151 /* it's a no-op. */ |
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
152 } /* AIFF_quit */ |
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
153 |
ea58bc3b15d7
Added init() and quit() methods.
Ryan C. Gordon <icculus@icculus.org>
parents:
41
diff
changeset
|
154 |
62
b13fafb976be
Changed _D macro to DBGSND.
Ryan C. Gordon <icculus@icculus.org>
parents:
47
diff
changeset
|
155 /* |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
156 * Sample rate is encoded as an "80 bit IEEE Standard 754 floating point |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
157 * number (Standard Apple Numeric Environment [SANE] data type Extended)". |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
158 * Whose bright idea was that? |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
159 * |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
160 * This function was adapted from libsndfile, and while I do know a little |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
161 * bit about the IEEE floating point standard I don't pretend to fully |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
162 * understand this. |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
163 */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
164 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
165 static Uint32 SANE_to_Uint32 (Uint8 *sanebuf) |
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 /* Is the frequency outside of what we can represent with Uint32? */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
168 if ( (sanebuf[0] & 0x80) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
169 || (sanebuf[0] <= 0x3F) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
170 || (sanebuf[0] > 0x40) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
171 || (sanebuf[0] == 0x40 && sanebuf[1] > 0x1C) ) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
172 return 0; |
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 return ((sanebuf[2] << 23) | (sanebuf[3] << 15) | (sanebuf[4] << 7) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
175 | (sanebuf[5] >> 1)) >> (29 - sanebuf[1]); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
176 } /* SANE_to_Uint32 */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
177 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
178 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
179 /* |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
180 * 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
|
181 * 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
|
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 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
|
185 { |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
186 Uint8 sampleRate[10]; |
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 /* 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
|
189 comm->ckID = commID; |
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 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
|
192 return(0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
193 comm->ckDataSize = SDL_SwapBE32(comm->ckDataSize); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
194 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
195 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
|
196 return(0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
197 comm->numChannels = SDL_SwapBE16(comm->numChannels); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
198 |
41
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
199 if (SDL_RWread(rw, &comm->numSampleFrames, |
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
200 sizeof (comm->numSampleFrames), 1) != 1) |
34
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->numSampleFrames = SDL_SwapBE32(comm->numSampleFrames); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
203 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
204 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
|
205 return(0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
206 comm->sampleSize = SDL_SwapBE16(comm->sampleSize); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
207 |
41
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
208 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
|
209 return(0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
210 comm->sampleRate = SANE_to_Uint32(sampleRate); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
211 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
212 if (comm->ckDataSize > sizeof(comm->numChannels) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
213 + sizeof(comm->numSampleFrames) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
214 + sizeof(comm->sampleSize) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
215 + sizeof(sampleRate)) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
216 { |
41
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
217 if (SDL_RWread(rw, &comm->compressionType, |
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
218 sizeof (comm->compressionType), 1) != 1) |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
219 return(0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
220 comm->compressionType = SDL_SwapBE32(comm->compressionType); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
221 } /* if */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
222 else |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
223 comm->compressionType = noneID; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
224 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
225 return(1); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
226 } /* read_comm_chunk */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
227 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
228 typedef struct |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
229 { |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
230 Uint32 ckID; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
231 Uint32 ckDataSize; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
232 Uint32 offset; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
233 Uint32 blockSize; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
234 /* |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
235 * 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
|
236 * length from numSampleFrames than from ckDataSize.) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
237 */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
238 } ssnd_t; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
239 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
240 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
241 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
|
242 { |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
243 /* 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
|
244 ssnd->ckID = ssndID; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
245 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
246 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
|
247 return(0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
248 ssnd->ckDataSize = SDL_SwapBE32(ssnd->ckDataSize); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
249 |
41
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
250 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
|
251 return(0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
252 ssnd->offset = SDL_SwapBE32(ssnd->offset); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
253 |
41
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
254 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
|
255 return(0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
256 ssnd->blockSize = SDL_SwapBE32(ssnd->blockSize); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
257 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
258 /* 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
|
259 /* !!! FIXME: Int? Really? */ |
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
260 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
|
261 return(0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
262 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
263 return(1); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
264 } /* read_ssnd_chunk */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
265 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
266 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
267 static int find_chunk(SDL_RWops *rw, Uint32 id) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
268 { |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
269 Sint32 siz = 0; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
270 Uint32 _id = 0; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
271 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
272 while (1) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
273 { |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
274 BAIL_IF_MACRO(SDL_RWread(rw, &_id, sizeof (_id), 1) != 1, NULL, 0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
275 if (SDL_SwapLE32(_id) == id) |
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 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
278 BAIL_IF_MACRO(SDL_RWread(rw, &siz, sizeof (siz), 1) != 1, NULL, 0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
279 siz = SDL_SwapBE32(siz); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
280 assert(siz > 0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
281 BAIL_IF_MACRO(SDL_RWseek(rw, siz, SEEK_CUR) == -1, NULL, 0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
282 } /* while */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
283 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
284 return(0); /* shouldn't hit this, but just in case... */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
285 } /* find_chunk */ |
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 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
288 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
|
289 { |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
290 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
291 SDL_RWops *rw = internal->rw; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
292 Uint32 chunk_id; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
293 int bytes_per_sample; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
294 long pos; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
295 comm_t c; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
296 ssnd_t s; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
297 aiff_t *a; |
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 BAIL_IF_MACRO(SDL_ReadLE32(rw) != formID, "AIFF: Not a FORM file.", 0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
300 SDL_ReadBE32(rw); /* throw the length away; we don't need it. */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
301 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
302 chunk_id = SDL_ReadLE32(rw); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
303 BAIL_IF_MACRO(chunk_id != aiffID && chunk_id != aifcID, |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
304 "AIFF: Not an AIFF or AIFC file.", 0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
305 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
306 /* Chunks may appear in any order, so we establish base camp here. */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
307 pos = SDL_RWtell(rw); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
308 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
309 BAIL_IF_MACRO(!find_chunk(rw, commID), "AIFF: No common chunk.", 0); |
41
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
310 BAIL_IF_MACRO(!read_comm_chunk(rw, &c), |
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
311 "AIFF: Can't read common chunk.", 0); |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
312 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
313 /* !!! FIXME: This will have to change for compression types... */ |
41
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
314 BAIL_IF_MACRO(c.compressionType != noneID, |
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
315 "AIFF: Unsupported encoding.", 0); |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
316 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
317 BAIL_IF_MACRO(c.sampleRate == 0, "AIFF: Unsupported sample rate.", 0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
318 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
319 sample->actual.channels = (Uint8) c.numChannels; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
320 sample->actual.rate = c.sampleRate; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
321 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
322 if (c.sampleSize <= 8) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
323 { |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
324 sample->actual.format = AUDIO_S8; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
325 bytes_per_sample = 1; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
326 } /* if */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
327 else if (c.sampleSize <= 16) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
328 { |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
329 sample->actual.format = AUDIO_S16MSB; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
330 bytes_per_sample = 2; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
331 } /* if */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
332 else |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
333 BAIL_MACRO("AIFF: Unsupported sample size.", 0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
334 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
335 SDL_RWseek(rw, pos, SEEK_SET); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
336 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
337 BAIL_IF_MACRO(!find_chunk(rw, ssndID), "AIFF: No sound data chunk.", 0); |
41
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
338 BAIL_IF_MACRO(!read_ssnd_chunk(rw, &s), |
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
339 "AIFF: Can't read sound data chunk.", 0); |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
340 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
341 a = (aiff_t *) malloc(sizeof(aiff_t)); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
342 BAIL_IF_MACRO(a == NULL, ERR_OUT_OF_MEMORY, 0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
343 a->bytesLeft = bytes_per_sample * c.numSampleFrames; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
344 internal->decoder_private = (void *) a; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
345 |
41
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
346 sample->flags = SOUND_SAMPLEFLAG_NONE; |
0d5ff5679523
Cleanups from Torbj�rn Andersson.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
347 |
62
b13fafb976be
Changed _D macro to DBGSND.
Ryan C. Gordon <icculus@icculus.org>
parents:
47
diff
changeset
|
348 SNDDBG(("AIFF: Accepting data stream.\n")); |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
349 return(1); /* we'll handle this data. */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
350 } /* AIFF_open */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
351 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
352 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
353 static void AIFF_close(Sound_Sample *sample) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
354 { |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
355 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
356 free(internal->decoder_private); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
357 } /* WAV_close */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
358 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
359 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
360 static Uint32 AIFF_read(Sound_Sample *sample) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
361 { |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
362 Uint32 retval; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
363 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
364 aiff_t *a = (aiff_t *) internal->decoder_private; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
365 Uint32 max = (internal->buffer_size < (Uint32) a->bytesLeft) ? |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
366 internal->buffer_size : (Uint32) a->bytesLeft; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
367 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
368 assert(max > 0); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
369 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
370 /* |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
371 * 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
|
372 * directly into the internal buffer... |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
373 */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
374 retval = SDL_RWread(internal->rw, internal->buffer, 1, max); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
375 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
376 a->bytesLeft -= retval; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
377 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
378 /* Make sure the read went smoothly... */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
379 if ((retval == 0) || (a->bytesLeft == 0)) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
380 sample->flags |= SOUND_SAMPLEFLAG_EOF; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
381 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
382 else if (retval == -1) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
383 sample->flags |= SOUND_SAMPLEFLAG_ERROR; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
384 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
385 /* (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
|
386 else if (retval < internal->buffer_size) |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
387 sample->flags |= SOUND_SAMPLEFLAG_EAGAIN; |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
388 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
389 return(retval); |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
390 } /* AIFF_read */ |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
391 |
64
40006625142a
Changes in preparation of autoconf support.
Ryan C. Gordon <icculus@icculus.org>
parents:
62
diff
changeset
|
392 #endif /* SOUND_SUPPORTS_AIFF */ |
40006625142a
Changes in preparation of autoconf support.
Ryan C. Gordon <icculus@icculus.org>
parents:
62
diff
changeset
|
393 |
34
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
394 |
938ef560c7bf
Initial add. Thanks, Torbj�rn!
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
395 /* end of aiff.c ... */ |