annotate decoders/quicktime.c @ 394:b495d05a88b3

Updated.
author Ryan C. Gordon <icculus@icculus.org>
date Thu, 11 Jul 2002 04:33:17 +0000
parents cbb15ecf423a
children c66080364dff
rev   line source
318
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1 /*
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
2 * SDL_sound -- An abstract sound format decoding API.
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
3 * Copyright (C) 2001 Ryan C. Gordon.
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
4 *
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
8 * version 2.1 of the License, or (at your option) any later version.
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
9 *
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
13 * Lesser General Public License for more details.
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
14 *
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
18 */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
19
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
20 /*
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
21 * QuickTime decoder for sound formats that QuickTime supports.
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
22 * April 28, 2002
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
23 *
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
24 * This driver handles .mov files with a sound track. In
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
25 * theory, it could handle any format that QuickTime supports.
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
26 * In practice, it may only handle a select few of these formats.
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
27 *
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
28 * It seems able to play back AIFF and other standard Mac formats.
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
29 * Rewinding is not supported yet.
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
30 *
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
31 * The routine QT_create_data_ref() needs to be
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
32 * tweaked to support different media types.
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
33 * This code was originally written to get MP3 support,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
34 * as it turns out, this isn't possible using this method.
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
35 *
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
36 * The only way to get streaming MP3 support through QuickTime,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
37 * and hence support for SDL_RWops, is to write
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
38 * a DataHandler component, which suddenly gets much more difficult :-(
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
39 *
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
40 * This file was written by Darrell Walisser (walisser@mac.com)
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
41 * Portions have been borrowed from the "MP3Player" sample code,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
42 * courtesy of Apple.
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
43 */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
44
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
45 #if HAVE_CONFIG_H
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
46 # include <config.h>
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
47 #endif
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
48
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
49 #ifdef SOUND_SUPPORTS_QUICKTIME
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
50 #ifdef macintosh
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
51 typedef long int32_t;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
52 # define OPAQUE_UPP_TYPES 0
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
53 # include <QuickTime.h>
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
54 #else
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
55 # include <QuickTime/QuickTime.h>
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
56 # include <Carbon/Carbon.h>
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
57 #endif
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
58
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
59 #include <stdio.h>
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
60 #include <stdlib.h>
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
61 #include <stdint.h>
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
62 #include <string.h>
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
63
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
64 #include "SDL_sound.h"
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
65
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
66 #define __SDL_SOUND_INTERNAL__
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
67 #include "SDL_sound_internal.h"
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
68
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
69 static int QT_init(void);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
70 static void QT_quit(void);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
71 static int QT_open(Sound_Sample *sample, const char *ext);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
72 static void QT_close(Sound_Sample *sample);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
73 static Uint32 QT_read(Sound_Sample *sample);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
74 static int QT_rewind(Sound_Sample *sample);
328
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
75 static int QT_seek(Sound_Sample *sample, Uint32 ms);
318
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
76
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
77 #define QT_MAX_INPUT_BUFFER (32*1024) /* Maximum size of internal buffer (internal->buffer_size) */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
78
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
79 static const char *extensions_quicktime[] = { "mov", NULL };
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
80 const Sound_DecoderFunctions __Sound_DecoderFunctions_QuickTime =
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
81 {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
82 {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
83 extensions_quicktime,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
84 "QuickTime format",
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
85 "Darrell Walisser <dwaliss1@purdue.edu>",
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
86 "http://www.icculus.org/SDL_sound/"
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
87 },
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
88
328
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
89 QT_init, /* init() method */
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
90 QT_quit, /* quit() method */
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
91 QT_open, /* open() method */
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
92 QT_close, /* close() method */
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
93 QT_read, /* read() method */
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
94 QT_rewind, /* rewind() method */
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
95 QT_seek /* seek() method */
318
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
96 };
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
97
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
98 typedef struct {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
99
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
100 ExtendedSoundComponentData compData;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
101 Handle hSource; /* source media buffer */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
102 Media sourceMedia; /* sound media identifier */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
103 TimeValue getMediaAtThisTime;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
104 TimeValue sourceDuration;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
105 Boolean isThereMoreSource;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
106 UInt32 maxBufferSize;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
107
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
108 } SCFillBufferData, *SCFillBufferDataPtr;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
109
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
110 typedef struct {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
111
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
112 Movie movie;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
113 Track track;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
114 Media media;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
115 AudioFormatAtomPtr atom;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
116 SoundComponentData source_format;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
117 SoundComponentData dest_format;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
118 SoundConverter converter;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
119 SCFillBufferData buffer_data;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
120 SoundConverterFillBufferDataUPP fill_buffer_proc;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
121
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
122 } qt_t;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
123
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
124
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
125
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
126
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
127 /*
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
128 * This procedure creates a description of the raw data
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
129 * read from SDL_RWops so that QuickTime can identify
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
130 * the codec it needs to use to decompress it.
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
131 */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
132 static Handle QT_create_data_ref (const char *file_extension) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
133
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
134 Handle tmp_handle, data_ref;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
135 StringPtr file_name = "\p"; /* empty since we don't know the file name! */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
136 OSType file_type;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
137 StringPtr mime_type;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
138 long atoms[3];
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
139
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
140 /*
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
141 if (__Sound_strcasecmp (file_extension, "mp3")==0) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
142 file_type = 'MPEG';
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
143 mime_type = "\pvideo/mpeg";
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
144 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
145 else {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
146
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
147 return NULL;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
148 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
149 */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
150
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
151 if (__Sound_strcasecmp (file_extension, "mov") == 0) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
152
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
153 file_type = 'MooV';
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
154 mime_type = "\pvideo/quicktime";
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
155 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
156 else {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
157
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
158 return NULL;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
159 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
160
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
161 tmp_handle = NewHandle(0);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
162 assert (tmp_handle != NULL);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
163 assert (noErr == PtrToHand (&tmp_handle, &data_ref, sizeof(Handle)));
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
164 assert (noErr == PtrAndHand (file_name, data_ref, file_name[0]+1));
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
165
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
166 atoms[0] = EndianU32_NtoB (sizeof(long) * 3);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
167 atoms[1] = EndianU32_NtoB (kDataRefExtensionMacOSFileType);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
168 atoms[2] = EndianU32_NtoB (file_type);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
169
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
170 assert (noErr == PtrAndHand (atoms, data_ref, sizeof(long)*3));
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
171
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
172 atoms[0] = EndianU32_NtoB (sizeof(long)*2 + mime_type[0]+1);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
173 atoms[1] = EndianU32_NtoB (kDataRefExtensionMIMEType);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
174
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
175 assert (noErr == PtrAndHand (atoms, data_ref, sizeof(long)*2));
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
176 assert (noErr == PtrAndHand (mime_type, data_ref, mime_type[0]+1));
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
177
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
178 return data_ref;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
179 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
180
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
181 /*
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
182 * This procedure is a hook for QuickTime to grab data from the
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
183 * SDL_RWOps data structure when it needs it
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
184 */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
185 static pascal OSErr QT_get_movie_data_proc (long offset, long size,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
186 void *data, void *user_data)
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
187 {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
188 SDL_RWops* rw = (SDL_RWops*)user_data;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
189 OSErr error;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
190
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
191 if (offset == SDL_RWseek (rw, offset, SEEK_SET)) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
192
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
193 if (size == SDL_RWread (rw, data, 1, size)) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
194 error = noErr;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
195 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
196 else {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
197 error = notEnoughDataErr;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
198 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
199 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
200 else {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
201 error = fileOffsetTooBigErr;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
202 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
203
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
204 return (error);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
205 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
206
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
207 /* * ----------------------------
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
208 * SoundConverterFillBufferDataProc
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
209 *
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
210 * the callback routine that provides the source data for conversion -
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
211 * it provides data by setting outData to a pointer to a properly
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
212 * filled out ExtendedSoundComponentData structure
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
213 */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
214 static pascal Boolean QT_sound_converter_fill_buffer_data_proc (SoundComponentDataPtr *outData, void *inRefCon)
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
215 {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
216 SCFillBufferDataPtr pFillData = (SCFillBufferDataPtr)inRefCon;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
217
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
218 OSErr err = noErr;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
219
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
220 /* if after getting the last chunk of data the total time is over
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
221 * the duration, we're done
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
222 */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
223 if (pFillData->getMediaAtThisTime >= pFillData->sourceDuration) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
224 pFillData->isThereMoreSource = false;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
225 pFillData->compData.desc.buffer = NULL;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
226 pFillData->compData.desc.sampleCount = 0;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
227 pFillData->compData.bufferSize = 0;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
228 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
229
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
230 if (pFillData->isThereMoreSource) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
231
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
232 long sourceBytesReturned;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
233 long numberOfSamples;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
234 TimeValue sourceReturnedTime, durationPerSample;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
235
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
236 HUnlock(pFillData->hSource);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
237
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
238 err = GetMediaSample
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
239 (pFillData->sourceMedia,/* specifies the media for this operation */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
240 pFillData->hSource, /* function returns the sample data into this handle */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
241 pFillData->maxBufferSize, /* maximum number of bytes of sample data to be returned */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
242 &sourceBytesReturned, /* the number of bytes of sample data returned */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
243 pFillData->getMediaAtThisTime,/* starting time of the sample to
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
244 be retrieved (must be in
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
245 Media's TimeScale) */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
246 &sourceReturnedTime,/* indicates the actual time of the returned sample data */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
247 &durationPerSample, /* duration of each sample in the media */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
248 NULL, /* sample description corresponding to the returned sample data (NULL to ignore) */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
249 NULL, /* index value to the sample description that corresponds
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
250 to the returned sample data (NULL to ignore) */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
251 0, /* maximum number of samples to be returned (0 to use a
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
252 value that is appropriate for the media) */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
253 &numberOfSamples, /* number of samples it actually returned */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
254 NULL); /* flags that describe the sample (NULL to ignore) */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
255
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
256 HLock(pFillData->hSource);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
257
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
258 if ((noErr != err) || (sourceBytesReturned == 0)) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
259 pFillData->isThereMoreSource = false;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
260 pFillData->compData.desc.buffer = NULL;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
261 pFillData->compData.desc.sampleCount = 0;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
262
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
263 if ((err != noErr) && (sourceBytesReturned > 0))
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
264 DebugStr("\pGetMediaSample - Failed in FillBufferDataProc");
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
265 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
266
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
267 pFillData->getMediaAtThisTime = sourceReturnedTime + (durationPerSample * numberOfSamples);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
268 pFillData->compData.bufferSize = sourceBytesReturned;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
269 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
270
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
271 /* set outData to a properly filled out ExtendedSoundComponentData struct */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
272 *outData = (SoundComponentDataPtr)&pFillData->compData;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
273
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
274 return (pFillData->isThereMoreSource);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
275 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
276
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
277
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
278 static int QT_init_internal () {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
279
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
280 OSErr error;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
281
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
282 error = EnterMovies(); /* initialize the movie toolbox */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
283
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
284 return (error == noErr);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
285 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
286
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
287 static void QT_quit_internal () {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
288
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
289 ExitMovies();
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
290 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
291
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
292 static qt_t* QT_open_internal (Sound_Sample *sample, const char *extension)
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
293 {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
294 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
295
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
296 qt_t *instance;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
297 OSErr error;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
298 Movie movie;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
299 Track sound_track;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
300 Media sound_track_media;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
301 AudioFormatAtomPtr source_sound_decomp_atom;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
302
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
303 SoundDescriptionV1Handle source_sound_description;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
304 Handle source_sound_description_extension;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
305 Size source_sound_description_extension_size;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
306 Handle data_ref;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
307
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
308 data_ref = QT_create_data_ref (extension);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
309
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
310 /* create a movie that will read data using SDL_RWops */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
311 error = NewMovieFromUserProc
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
312 (&movie,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
313 0,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
314 NULL,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
315 NewGetMovieUPP(QT_get_movie_data_proc),
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
316 (void*) internal->rw,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
317 data_ref,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
318 'hndl');
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
319
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
320 if (error != noErr) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
321
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
322 return NULL;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
323 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
324
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
325 /* get the first sound track of the movie; other tracks will be ignored */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
326 sound_track = GetMovieIndTrackType (movie, 1, SoundMediaType, movieTrackMediaType);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
327 if (sound_track == NULL) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
328
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
329 /* movie needs a sound track! */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
330
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
331 return NULL;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
332 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
333
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
334 /* get and return the sound track media */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
335 sound_track_media = GetTrackMedia (sound_track);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
336 if (sound_track_media == NULL) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
337
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
338 return NULL;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
339 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
340
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
341 /* create a description of the source sound so we can convert it later */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
342 source_sound_description = (SoundDescriptionV1Handle)NewHandle(0);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
343 assert (source_sound_description != NULL); /* out of memory */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
344
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
345 GetMediaSampleDescription (sound_track_media, 1,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
346 (SampleDescriptionHandle)source_sound_description);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
347 error = GetMoviesError();
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
348 if (error != noErr) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
349
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
350 return NULL;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
351 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
352
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
353 source_sound_description_extension = NewHandle(0);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
354 assert (source_sound_description_extension != NULL); /* out of memory */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
355
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
356 error = GetSoundDescriptionExtension ((SoundDescriptionHandle) source_sound_description,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
357 &source_sound_description_extension,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
358 siDecompressionParams);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
359
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
360 if (error == noErr) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
361
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
362 /* copy extension to atom format description if we have an extension */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
363
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
364 source_sound_description_extension_size =
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
365 GetHandleSize (source_sound_description_extension);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
366 HLock (source_sound_description_extension);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
367
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
368 source_sound_decomp_atom = (AudioFormatAtom*)
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
369 NewPtr (source_sound_description_extension_size);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
370 assert (source_sound_decomp_atom != NULL); /* out of memory */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
371
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
372 BlockMoveData (*source_sound_description_extension,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
373 source_sound_decomp_atom,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
374 source_sound_description_extension_size);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
375
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
376 HUnlock (source_sound_description_extension);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
377 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
378
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
379 else {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
380
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
381 source_sound_decomp_atom = NULL;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
382 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
383
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
384 instance = (qt_t*) malloc (sizeof(*instance));
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
385 assert (instance != NULL); /* out of memory */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
386
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
387 instance->movie = movie;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
388 instance->track = sound_track;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
389 instance->media = sound_track_media;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
390 instance->atom = source_sound_decomp_atom;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
391
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
392 instance->source_format.flags = 0;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
393 instance->source_format.format = (*source_sound_description)->desc.dataFormat;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
394 instance->source_format.numChannels = (*source_sound_description)->desc.numChannels;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
395 instance->source_format.sampleSize = (*source_sound_description)->desc.sampleSize;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
396 instance->source_format.sampleRate = (*source_sound_description)->desc.sampleRate;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
397 instance->source_format.sampleCount = 0;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
398 instance->source_format.buffer = NULL;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
399 instance->source_format.reserved = 0;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
400
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
401 instance->dest_format.flags = 0;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
402 instance->dest_format.format = kSoundNotCompressed;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
403 instance->dest_format.numChannels = (*source_sound_description)->desc.numChannels;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
404 instance->dest_format.sampleSize = (*source_sound_description)->desc.sampleSize;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
405 instance->dest_format.sampleRate = (*source_sound_description)->desc.sampleRate;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
406 instance->dest_format.sampleCount = 0;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
407 instance->dest_format.buffer = NULL;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
408 instance->dest_format.reserved = 0;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
409
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
410 sample->actual.channels = (*source_sound_description)->desc.numChannels;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
411 sample->actual.rate = (*source_sound_description)->desc.sampleRate >> 16;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
412
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
413 if ((*source_sound_description)->desc.sampleSize == 16) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
414
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
415 sample->actual.format = AUDIO_S16SYS;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
416 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
417 else if ((*source_sound_description)->desc.sampleSize == 8) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
418
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
419 sample->actual.format = AUDIO_U8;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
420 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
421 else {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
422
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
423 /* 24-bit or others... (which SDL can't handle) */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
424 return NULL;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
425 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
426
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
427 DisposeHandle (source_sound_description_extension);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
428 DisposeHandle ((Handle)source_sound_description);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
429
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
430 /* This next code sets up the SoundConverter component */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
431 error = SoundConverterOpen (&instance->source_format, &instance->dest_format,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
432 &instance->converter);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
433
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
434 if (error != noErr) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
435
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
436 return NULL;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
437 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
438
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
439 error = SoundConverterSetInfo (instance->converter, siDecompressionParams,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
440 instance->atom);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
441 if (error == siUnknownInfoType) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
442
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
443 /* ignore */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
444 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
445 else if (error != noErr) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
446
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
447 /* reall error */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
448 return NULL;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
449 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
450
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
451 error = SoundConverterBeginConversion (instance->converter);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
452 if (error != noErr) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
453
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
454 return NULL;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
455 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
456
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
457 instance->buffer_data.sourceMedia = instance->media;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
458 instance->buffer_data.getMediaAtThisTime = 0;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
459 instance->buffer_data.sourceDuration = GetMediaDuration(instance->media);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
460 instance->buffer_data.isThereMoreSource = true;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
461 instance->buffer_data.maxBufferSize = QT_MAX_INPUT_BUFFER;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
462 /* allocate source media buffer */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
463 instance->buffer_data.hSource = NewHandle((long)instance->buffer_data.maxBufferSize);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
464 assert (instance->buffer_data.hSource != NULL); /* out of memory */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
465
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
466 instance->buffer_data.compData.desc = instance->source_format;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
467 instance->buffer_data.compData.desc.buffer = (Byte *)*instance->buffer_data.hSource;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
468 instance->buffer_data.compData.desc.flags = kExtendedSoundData;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
469 instance->buffer_data.compData.recordSize = sizeof(ExtendedSoundComponentData);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
470 instance->buffer_data.compData.extendedFlags =
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
471 kExtendedSoundSampleCountNotValid | kExtendedSoundBufferSizeValid;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
472 instance->buffer_data.compData.bufferSize = 0;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
473
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
474 instance->fill_buffer_proc =
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
475 NewSoundConverterFillBufferDataUPP (QT_sound_converter_fill_buffer_data_proc);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
476
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
477 return (instance);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
478
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
479 } /* QT_open_internal */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
480
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
481 static void QT_close_internal (qt_t *instance)
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
482 {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
483
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
484 } /* QT_close_internal */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
485
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
486 static Uint32 QT_read_internal(Sound_Sample *sample)
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
487 {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
488 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
489 qt_t *instance = (qt_t*) internal->decoder_private;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
490 long output_bytes, output_frames, output_flags;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
491 OSErr error;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
492
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
493 error = SoundConverterFillBuffer
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
494 (instance->converter, /* a sound converter */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
495 instance->fill_buffer_proc, /* the callback UPP */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
496 &instance->buffer_data, /* refCon passed to FillDataProc */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
497 internal->buffer, /* the decompressed data 'play' buffer */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
498 internal->buffer_size, /* size of the 'play' buffer */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
499 &output_bytes, /* number of output bytes */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
500 &output_frames, /* number of output frames */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
501 &output_flags); /* fillbuffer retured advisor flags */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
502
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
503 if (output_flags & kSoundConverterHasLeftOverData) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
504
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
505 sample->flags |= SOUND_SAMPLEFLAG_EAGAIN;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
506 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
507 else {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
508
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
509 sample->flags |= SOUND_SAMPLEFLAG_EOF;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
510 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
511
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
512 if (error != noErr) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
513
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
514 sample->flags |= SOUND_SAMPLEFLAG_ERROR;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
515 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
516
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
517 return (output_bytes);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
518
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
519 } /* QT_read_internal */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
520
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
521 static int QT_rewind_internal (Sound_Sample *sample)
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
522 {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
523
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
524 return 0;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
525
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
526 } /* QT_rewind_internal */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
527
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
528
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
529
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
530 static int QT_init(void)
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
531 {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
532 return (QT_init_internal());
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
533
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
534 } /* QT_init */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
535
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
536 static void QT_quit(void)
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
537 {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
538 QT_quit_internal();
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
539
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
540 } /* QT_quit */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
541
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
542 static int QT_open(Sound_Sample *sample, const char *ext)
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
543 {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
544 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
545 qt_t *instance;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
546
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
547 instance = QT_open_internal(sample, ext);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
548 internal->decoder_private = (void*)instance;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
549
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
550 return(instance != NULL);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
551
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
552 } /* QT_open */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
553
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
554
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
555 static void QT_close(Sound_Sample *sample)
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
556 {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
557 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
558 qt_t *instance = (qt_t *) internal->decoder_private;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
559
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
560 QT_close_internal (instance);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
561
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
562 free (instance);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
563
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
564 } /* QT_close */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
565
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
566
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
567 static Uint32 QT_read(Sound_Sample *sample)
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
568 {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
569 return(QT_read_internal(sample));
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
570
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
571 } /* QT_read */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
572
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
573
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
574 static int QT_rewind(Sound_Sample *sample)
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
575 {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
576
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
577 return(QT_rewind_internal(sample));
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
578
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
579 } /* QT_rewind */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
580
328
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
581
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
582 static int QT_seek(Sound_Sample *sample, Uint32 ms)
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
583 {
351
069ce624d6cf FIXME cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 329
diff changeset
584 BAIL_MACRO("QUICKTIME: Seeking not implemented", 0);
328
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
585 } /* QT_seek */
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
586
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
587
318
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
588 #endif /* SOUND_SUPPORTS_QUICKTIME */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
589
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
590 /* end of quicktime.c ... */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
591