annotate decoders/quicktime.c @ 363:0b0457462ccc

Updated.
author Ryan C. Gordon <icculus@icculus.org>
date Thu, 13 Jun 2002 23:15:15 +0000
parents 069ce624d6cf
children cbb15ecf423a
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 #include <assert.h>
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
64
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
65 #include "SDL_sound.h"
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
66
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
67 #define __SDL_SOUND_INTERNAL__
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
68 #include "SDL_sound_internal.h"
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
69
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
70 static int QT_init(void);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
71 static void QT_quit(void);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
72 static int QT_open(Sound_Sample *sample, const char *ext);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
73 static void QT_close(Sound_Sample *sample);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
74 static Uint32 QT_read(Sound_Sample *sample);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
75 static int QT_rewind(Sound_Sample *sample);
328
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
76 static int QT_seek(Sound_Sample *sample, Uint32 ms);
318
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
77
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
78 #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
79
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
80 static const char *extensions_quicktime[] = { "mov", NULL };
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
81 const Sound_DecoderFunctions __Sound_DecoderFunctions_QuickTime =
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 {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
84 extensions_quicktime,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
85 "QuickTime format",
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
86 "Darrell Walisser <dwaliss1@purdue.edu>",
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
87 "http://www.icculus.org/SDL_sound/"
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
88 },
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
89
328
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
90 QT_init, /* init() method */
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
91 QT_quit, /* quit() method */
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
92 QT_open, /* open() method */
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
93 QT_close, /* close() method */
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
94 QT_read, /* read() method */
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
95 QT_rewind, /* rewind() method */
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
96 QT_seek /* seek() method */
318
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
99 typedef struct {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
100
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
101 ExtendedSoundComponentData compData;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
102 Handle hSource; /* source media buffer */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
103 Media sourceMedia; /* sound media identifier */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
104 TimeValue getMediaAtThisTime;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
105 TimeValue sourceDuration;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
106 Boolean isThereMoreSource;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
107 UInt32 maxBufferSize;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
108
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
109 } SCFillBufferData, *SCFillBufferDataPtr;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
110
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
111 typedef struct {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
112
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
113 Movie movie;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
114 Track track;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
115 Media media;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
116 AudioFormatAtomPtr atom;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
117 SoundComponentData source_format;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
118 SoundComponentData dest_format;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
119 SoundConverter converter;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
120 SCFillBufferData buffer_data;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
121 SoundConverterFillBufferDataUPP fill_buffer_proc;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
122
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
123 } qt_t;
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 /*
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
129 * This procedure creates a description of the raw data
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
130 * read from SDL_RWops so that QuickTime can identify
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
131 * the codec it needs to use to decompress it.
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
132 */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
133 static Handle QT_create_data_ref (const char *file_extension) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
134
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
135 Handle tmp_handle, data_ref;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
136 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
137 OSType file_type;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
138 StringPtr mime_type;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
139 long atoms[3];
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 /*
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
142 if (__Sound_strcasecmp (file_extension, "mp3")==0) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
143 file_type = 'MPEG';
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
144 mime_type = "\pvideo/mpeg";
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
145 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
146 else {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
147
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
148 return NULL;
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
152 if (__Sound_strcasecmp (file_extension, "mov") == 0) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
153
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
154 file_type = 'MooV';
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
155 mime_type = "\pvideo/quicktime";
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
156 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
157 else {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
158
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
159 return NULL;
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
162 tmp_handle = NewHandle(0);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
163 assert (tmp_handle != NULL);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
164 assert (noErr == PtrToHand (&tmp_handle, &data_ref, sizeof(Handle)));
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
165 assert (noErr == PtrAndHand (file_name, data_ref, file_name[0]+1));
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
166
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
167 atoms[0] = EndianU32_NtoB (sizeof(long) * 3);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
168 atoms[1] = EndianU32_NtoB (kDataRefExtensionMacOSFileType);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
169 atoms[2] = EndianU32_NtoB (file_type);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
170
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
171 assert (noErr == PtrAndHand (atoms, data_ref, sizeof(long)*3));
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
172
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
173 atoms[0] = EndianU32_NtoB (sizeof(long)*2 + mime_type[0]+1);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
174 atoms[1] = EndianU32_NtoB (kDataRefExtensionMIMEType);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
175
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
176 assert (noErr == PtrAndHand (atoms, data_ref, sizeof(long)*2));
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
177 assert (noErr == PtrAndHand (mime_type, data_ref, mime_type[0]+1));
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
178
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
179 return data_ref;
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 /*
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
183 * This procedure is a hook for QuickTime to grab data from the
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
184 * SDL_RWOps data structure when it needs it
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
185 */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
186 static pascal OSErr QT_get_movie_data_proc (long offset, long size,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
187 void *data, void *user_data)
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
188 {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
189 SDL_RWops* rw = (SDL_RWops*)user_data;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
190 OSErr error;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
191
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
192 if (offset == SDL_RWseek (rw, offset, SEEK_SET)) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
193
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
194 if (size == SDL_RWread (rw, data, 1, size)) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
195 error = noErr;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
196 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
197 else {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
198 error = notEnoughDataErr;
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 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
201 else {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
202 error = fileOffsetTooBigErr;
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
205 return (error);
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 /* * ----------------------------
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
209 * SoundConverterFillBufferDataProc
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
210 *
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
211 * the callback routine that provides the source data for conversion -
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
212 * it provides data by setting outData to a pointer to a properly
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
213 * filled out ExtendedSoundComponentData structure
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
214 */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
215 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
216 {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
217 SCFillBufferDataPtr pFillData = (SCFillBufferDataPtr)inRefCon;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
218
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
219 OSErr err = noErr;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
220
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
221 /* 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
222 * the duration, we're done
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
223 */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
224 if (pFillData->getMediaAtThisTime >= pFillData->sourceDuration) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
225 pFillData->isThereMoreSource = false;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
226 pFillData->compData.desc.buffer = NULL;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
227 pFillData->compData.desc.sampleCount = 0;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
228 pFillData->compData.bufferSize = 0;
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
231 if (pFillData->isThereMoreSource) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
232
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
233 long sourceBytesReturned;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
234 long numberOfSamples;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
235 TimeValue sourceReturnedTime, durationPerSample;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
236
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
237 HUnlock(pFillData->hSource);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
238
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
239 err = GetMediaSample
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
240 (pFillData->sourceMedia,/* specifies the media for this operation */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
241 pFillData->hSource, /* function returns the sample data into this handle */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
242 pFillData->maxBufferSize, /* maximum number of bytes of sample data to be returned */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
243 &sourceBytesReturned, /* the number of bytes of sample data returned */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
244 pFillData->getMediaAtThisTime,/* starting time of the sample to
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
245 be retrieved (must be in
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
246 Media's TimeScale) */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
247 &sourceReturnedTime,/* indicates the actual time of the returned sample data */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
248 &durationPerSample, /* duration of each sample in the media */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
249 NULL, /* sample description corresponding to the returned sample data (NULL to ignore) */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
250 NULL, /* index value to the sample description that corresponds
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
251 to the returned sample data (NULL to ignore) */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
252 0, /* maximum number of samples to be returned (0 to use a
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
253 value that is appropriate for the media) */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
254 &numberOfSamples, /* number of samples it actually returned */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
255 NULL); /* flags that describe the sample (NULL to ignore) */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
256
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
257 HLock(pFillData->hSource);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
258
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
259 if ((noErr != err) || (sourceBytesReturned == 0)) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
260 pFillData->isThereMoreSource = false;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
261 pFillData->compData.desc.buffer = NULL;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
262 pFillData->compData.desc.sampleCount = 0;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
263
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
264 if ((err != noErr) && (sourceBytesReturned > 0))
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
265 DebugStr("\pGetMediaSample - Failed in FillBufferDataProc");
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
268 pFillData->getMediaAtThisTime = sourceReturnedTime + (durationPerSample * numberOfSamples);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
269 pFillData->compData.bufferSize = sourceBytesReturned;
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
272 /* set outData to a properly filled out ExtendedSoundComponentData struct */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
273 *outData = (SoundComponentDataPtr)&pFillData->compData;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
274
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
275 return (pFillData->isThereMoreSource);
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
279 static int QT_init_internal () {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
280
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
281 OSErr error;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
282
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
283 error = EnterMovies(); /* initialize the movie toolbox */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
284
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
285 return (error == noErr);
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
288 static void QT_quit_internal () {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
289
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
290 ExitMovies();
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
293 static qt_t* QT_open_internal (Sound_Sample *sample, const char *extension)
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
294 {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
295 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
296
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
297 qt_t *instance;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
298 OSErr error;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
299 Movie movie;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
300 Track sound_track;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
301 Media sound_track_media;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
302 AudioFormatAtomPtr source_sound_decomp_atom;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
303
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
304 SoundDescriptionV1Handle source_sound_description;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
305 Handle source_sound_description_extension;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
306 Size source_sound_description_extension_size;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
307 Handle data_ref;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
308
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
309 data_ref = QT_create_data_ref (extension);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
310
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
311 /* create a movie that will read data using SDL_RWops */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
312 error = NewMovieFromUserProc
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
313 (&movie,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
314 0,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
315 NULL,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
316 NewGetMovieUPP(QT_get_movie_data_proc),
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
317 (void*) internal->rw,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
318 data_ref,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
319 'hndl');
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
320
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
321 if (error != noErr) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
322
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
323 return NULL;
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
326 /* 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
327 sound_track = GetMovieIndTrackType (movie, 1, SoundMediaType, movieTrackMediaType);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
328 if (sound_track == NULL) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
329
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
330 /* movie needs a sound track! */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
331
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
332 return NULL;
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
335 /* get and return the sound track media */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
336 sound_track_media = GetTrackMedia (sound_track);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
337 if (sound_track_media == NULL) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
338
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
339 return NULL;
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
342 /* 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
343 source_sound_description = (SoundDescriptionV1Handle)NewHandle(0);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
344 assert (source_sound_description != NULL); /* out of memory */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
345
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
346 GetMediaSampleDescription (sound_track_media, 1,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
347 (SampleDescriptionHandle)source_sound_description);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
348 error = GetMoviesError();
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
349 if (error != noErr) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
350
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
351 return NULL;
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
354 source_sound_description_extension = NewHandle(0);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
355 assert (source_sound_description_extension != NULL); /* out of memory */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
356
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
357 error = GetSoundDescriptionExtension ((SoundDescriptionHandle) source_sound_description,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
358 &source_sound_description_extension,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
359 siDecompressionParams);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
360
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
361 if (error == noErr) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
362
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
363 /* copy extension to atom format description if we have an extension */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
364
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
365 source_sound_description_extension_size =
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
366 GetHandleSize (source_sound_description_extension);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
367 HLock (source_sound_description_extension);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
368
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
369 source_sound_decomp_atom = (AudioFormatAtom*)
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
370 NewPtr (source_sound_description_extension_size);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
371 assert (source_sound_decomp_atom != NULL); /* out of memory */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
372
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
373 BlockMoveData (*source_sound_description_extension,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
374 source_sound_decomp_atom,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
375 source_sound_description_extension_size);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
376
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
377 HUnlock (source_sound_description_extension);
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
380 else {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
381
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
382 source_sound_decomp_atom = NULL;
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
385 instance = (qt_t*) malloc (sizeof(*instance));
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
386 assert (instance != NULL); /* out of memory */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
387
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
388 instance->movie = movie;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
389 instance->track = sound_track;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
390 instance->media = sound_track_media;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
391 instance->atom = source_sound_decomp_atom;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
392
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
393 instance->source_format.flags = 0;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
394 instance->source_format.format = (*source_sound_description)->desc.dataFormat;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
395 instance->source_format.numChannels = (*source_sound_description)->desc.numChannels;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
396 instance->source_format.sampleSize = (*source_sound_description)->desc.sampleSize;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
397 instance->source_format.sampleRate = (*source_sound_description)->desc.sampleRate;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
398 instance->source_format.sampleCount = 0;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
399 instance->source_format.buffer = NULL;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
400 instance->source_format.reserved = 0;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
401
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
402 instance->dest_format.flags = 0;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
403 instance->dest_format.format = kSoundNotCompressed;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
404 instance->dest_format.numChannels = (*source_sound_description)->desc.numChannels;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
405 instance->dest_format.sampleSize = (*source_sound_description)->desc.sampleSize;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
406 instance->dest_format.sampleRate = (*source_sound_description)->desc.sampleRate;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
407 instance->dest_format.sampleCount = 0;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
408 instance->dest_format.buffer = NULL;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
409 instance->dest_format.reserved = 0;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
410
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
411 sample->actual.channels = (*source_sound_description)->desc.numChannels;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
412 sample->actual.rate = (*source_sound_description)->desc.sampleRate >> 16;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
413
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
414 if ((*source_sound_description)->desc.sampleSize == 16) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
415
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
416 sample->actual.format = AUDIO_S16SYS;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
417 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
418 else if ((*source_sound_description)->desc.sampleSize == 8) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
419
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
420 sample->actual.format = AUDIO_U8;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
421 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
422 else {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
423
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
424 /* 24-bit or others... (which SDL can't handle) */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
425 return NULL;
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
428 DisposeHandle (source_sound_description_extension);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
429 DisposeHandle ((Handle)source_sound_description);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
430
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
431 /* This next code sets up the SoundConverter component */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
432 error = SoundConverterOpen (&instance->source_format, &instance->dest_format,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
433 &instance->converter);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
434
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
435 if (error != noErr) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
436
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
437 return NULL;
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
440 error = SoundConverterSetInfo (instance->converter, siDecompressionParams,
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
441 instance->atom);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
442 if (error == siUnknownInfoType) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
443
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
444 /* ignore */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
445 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
446 else if (error != noErr) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
447
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
448 /* reall error */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
449 return NULL;
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
452 error = SoundConverterBeginConversion (instance->converter);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
453 if (error != noErr) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
454
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
455 return NULL;
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
458 instance->buffer_data.sourceMedia = instance->media;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
459 instance->buffer_data.getMediaAtThisTime = 0;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
460 instance->buffer_data.sourceDuration = GetMediaDuration(instance->media);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
461 instance->buffer_data.isThereMoreSource = true;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
462 instance->buffer_data.maxBufferSize = QT_MAX_INPUT_BUFFER;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
463 /* allocate source media buffer */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
464 instance->buffer_data.hSource = NewHandle((long)instance->buffer_data.maxBufferSize);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
465 assert (instance->buffer_data.hSource != NULL); /* out of memory */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
466
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
467 instance->buffer_data.compData.desc = instance->source_format;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
468 instance->buffer_data.compData.desc.buffer = (Byte *)*instance->buffer_data.hSource;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
469 instance->buffer_data.compData.desc.flags = kExtendedSoundData;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
470 instance->buffer_data.compData.recordSize = sizeof(ExtendedSoundComponentData);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
471 instance->buffer_data.compData.extendedFlags =
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
472 kExtendedSoundSampleCountNotValid | kExtendedSoundBufferSizeValid;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
473 instance->buffer_data.compData.bufferSize = 0;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
474
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
475 instance->fill_buffer_proc =
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
476 NewSoundConverterFillBufferDataUPP (QT_sound_converter_fill_buffer_data_proc);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
477
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
478 return (instance);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
479
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
480 } /* QT_open_internal */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
481
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
482 static void QT_close_internal (qt_t *instance)
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
485 } /* QT_close_internal */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
486
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
487 static Uint32 QT_read_internal(Sound_Sample *sample)
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
488 {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
489 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
490 qt_t *instance = (qt_t*) internal->decoder_private;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
491 long output_bytes, output_frames, output_flags;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
492 OSErr error;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
493
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
494 error = SoundConverterFillBuffer
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
495 (instance->converter, /* a sound converter */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
496 instance->fill_buffer_proc, /* the callback UPP */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
497 &instance->buffer_data, /* refCon passed to FillDataProc */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
498 internal->buffer, /* the decompressed data 'play' buffer */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
499 internal->buffer_size, /* size of the 'play' buffer */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
500 &output_bytes, /* number of output bytes */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
501 &output_frames, /* number of output frames */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
502 &output_flags); /* fillbuffer retured advisor flags */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
503
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
504 if (output_flags & kSoundConverterHasLeftOverData) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
505
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
506 sample->flags |= SOUND_SAMPLEFLAG_EAGAIN;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
507 }
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
508 else {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
509
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
510 sample->flags |= SOUND_SAMPLEFLAG_EOF;
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
513 if (error != noErr) {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
514
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
515 sample->flags |= SOUND_SAMPLEFLAG_ERROR;
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
518 return (output_bytes);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
519
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
520 } /* QT_read_internal */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
521
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
522 static int QT_rewind_internal (Sound_Sample *sample)
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
525 return 0;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
526
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
527 } /* QT_rewind_internal */
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
531 static int QT_init(void)
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
532 {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
533 return (QT_init_internal());
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
534
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
535 } /* QT_init */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
536
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
537 static void QT_quit(void)
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
538 {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
539 QT_quit_internal();
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
540
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
541 } /* QT_quit */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
542
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
543 static int QT_open(Sound_Sample *sample, const char *ext)
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
544 {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
545 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
546 qt_t *instance;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
547
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
548 instance = QT_open_internal(sample, ext);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
549 internal->decoder_private = (void*)instance;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
550
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
551 return(instance != NULL);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
552
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
553 } /* QT_open */
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
556 static void QT_close(Sound_Sample *sample)
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
557 {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
558 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
559 qt_t *instance = (qt_t *) internal->decoder_private;
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
560
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
561 QT_close_internal (instance);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
562
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
563 free (instance);
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
564
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
565 } /* QT_close */
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
568 static Uint32 QT_read(Sound_Sample *sample)
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
569 {
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
570 return(QT_read_internal(sample));
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
571
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
572 } /* QT_read */
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
575 static int QT_rewind(Sound_Sample *sample)
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
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
578 return(QT_rewind_internal(sample));
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
579
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
580 } /* QT_rewind */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
581
328
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
582
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
583 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
584 {
351
069ce624d6cf FIXME cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 329
diff changeset
585 BAIL_MACRO("QUICKTIME: Seeking not implemented", 0);
328
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
586 } /* QT_seek */
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
587
a7c1dbcf5e00 Added a seek method stub.
Ryan C. Gordon <icculus@icculus.org>
parents: 318
diff changeset
588
318
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
589 #endif /* SOUND_SUPPORTS_QUICKTIME */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
590
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
591 /* end of quicktime.c ... */
df024df56996 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
592