| 1 |
/* Copyright: © Copyright 2004 Apple Computer, Inc. All rights reserved. |
|---|
| 2 |
|
|---|
| 3 |
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. |
|---|
| 4 |
("Apple") in consideration of your agreement to the following terms, and your |
|---|
| 5 |
use, installation, modification or redistribution of this Apple software |
|---|
| 6 |
constitutes acceptance of these terms. If you do not agree with these terms, |
|---|
| 7 |
please do not use, install, modify or redistribute this Apple software. |
|---|
| 8 |
|
|---|
| 9 |
In consideration of your agreement to abide by the following terms, and subject |
|---|
| 10 |
to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs |
|---|
| 11 |
copyrights in this original Apple software (the "Apple Software"), to use, |
|---|
| 12 |
reproduce, modify and redistribute the Apple Software, with or without |
|---|
| 13 |
modifications, in source and/or binary forms; provided that if you redistribute |
|---|
| 14 |
the Apple Software in its entirety and without modifications, you must retain |
|---|
| 15 |
this notice and the following text and disclaimers in all such redistributions of |
|---|
| 16 |
the Apple Software. Neither the name, trademarks, service marks or logos of |
|---|
| 17 |
Apple Computer, Inc. may be used to endorse or promote products derived from the |
|---|
| 18 |
Apple Software without specific prior written permission from Apple. Except as |
|---|
| 19 |
expressly stated in this notice, no other rights or licenses, express or implied, |
|---|
| 20 |
are granted by Apple herein, including but not limited to any patent rights that |
|---|
| 21 |
may be infringed by your derivative works or by other works in which the Apple |
|---|
| 22 |
Software may be incorporated. |
|---|
| 23 |
|
|---|
| 24 |
The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO |
|---|
| 25 |
WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED |
|---|
| 26 |
WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|---|
| 27 |
PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN |
|---|
| 28 |
COMBINATION WITH YOUR PRODUCTS. |
|---|
| 29 |
|
|---|
| 30 |
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR |
|---|
| 31 |
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
|---|
| 32 |
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|---|
| 33 |
ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION |
|---|
| 34 |
OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT |
|---|
| 35 |
(INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN |
|---|
| 36 |
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 37 |
*/ |
|---|
| 38 |
/*============================================================================= |
|---|
| 39 |
SMACIMAscomDispatcher.cpp |
|---|
| 40 |
|
|---|
| 41 |
=============================================================================*/ |
|---|
| 42 |
|
|---|
| 43 |
// Theory of Operation |
|---|
| 44 |
// |
|---|
| 45 |
// This is largely boilerplate code. The IMA can be replaced by the appropriate |
|---|
| 46 |
// format name. |
|---|
| 47 |
|
|---|
| 48 |
//============================================================================= |
|---|
| 49 |
// Includes |
|---|
| 50 |
//============================================================================= |
|---|
| 51 |
#include <CAConditionalMacros.h> |
|---|
| 52 |
|
|---|
| 53 |
#include "SMACIMAscom.h" |
|---|
| 54 |
|
|---|
| 55 |
//============================================================================= |
|---|
| 56 |
// SMACIMAscomDispatcher |
|---|
| 57 |
// |
|---|
| 58 |
// This is the dispatcher for components implemented by the SMACIMAscom class. |
|---|
| 59 |
//============================================================================= |
|---|
| 60 |
|
|---|
| 61 |
// the component globals |
|---|
| 62 |
struct SMACIMAscomGlobals |
|---|
| 63 |
{ |
|---|
| 64 |
ComponentInstance sourceComponent; |
|---|
| 65 |
SMACIMAscom* mThis; |
|---|
| 66 |
SMACIMAscomGlobals() : sourceComponent(NULL), mThis(NULL) {} |
|---|
| 67 |
}; |
|---|
| 68 |
typedef SMACIMAscomGlobals* SMACIMAscomGlobalsPtr; |
|---|
| 69 |
|
|---|
| 70 |
// the basic defines for SoundComponentDispatch.c |
|---|
| 71 |
// The versions are such that they'll override the standard SoundManager ones |
|---|
| 72 |
#if DEBUG |
|---|
| 73 |
#define kSoundComponentVersion 0x70ff0004 |
|---|
| 74 |
#else |
|---|
| 75 |
#define kSoundComponentVersion 0x00020004 |
|---|
| 76 |
#endif |
|---|
| 77 |
#define SoundComponentBaseName() SMACIMAscom |
|---|
| 78 |
#define SoundComponentGlobals SMACIMAscomGlobals |
|---|
| 79 |
#define SoundComponentGlobalsPtr SMACIMAscomGlobalsPtr |
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
// the component routines implemented |
|---|
| 83 |
#define __SoundComponentOpenRoutine kImplemented |
|---|
| 84 |
#define __SoundComponentCloseRoutine kImplemented |
|---|
| 85 |
#define __SoundComponentSetSourceRoutine kImplemented |
|---|
| 86 |
#define __SoundComponentSetOutputRoutine kImplemented |
|---|
| 87 |
#define __SoundComponentPlaySourceBufferRoutine kImplemented |
|---|
| 88 |
#define __SoundComponentStopSourceRoutine kImplemented |
|---|
| 89 |
#define __SoundComponentGetInfoRoutine kImplemented |
|---|
| 90 |
#define __SoundComponentSetInfoRoutine kImplemented |
|---|
| 91 |
#define __SoundComponentGetSourceDataRoutine kImplemented |
|---|
| 92 |
|
|---|
| 93 |
// include SoundComponentDispatch.c to write the dispatcher |
|---|
| 94 |
extern "C" |
|---|
| 95 |
{ |
|---|
| 96 |
#include "SMACDispatch.c" |
|---|
| 97 |
|
|---|
| 98 |
static pascal ComponentResult __SoundComponentOpen(void* inUnused, ComponentInstance inSelf) |
|---|
| 99 |
{ |
|---|
| 100 |
ComponentResult theAnswer = 0; |
|---|
| 101 |
|
|---|
| 102 |
try |
|---|
| 103 |
{ |
|---|
| 104 |
// create the globals |
|---|
| 105 |
SMACIMAscomGlobals* theGlobals = new SMACIMAscomGlobals(); |
|---|
| 106 |
|
|---|
| 107 |
// creat the SMACIMAscom object |
|---|
| 108 |
theGlobals->mThis = new SMACIMAscom(inSelf); |
|---|
| 109 |
|
|---|
| 110 |
// tell the Component Manager about our globals |
|---|
| 111 |
SetComponentInstanceStorage(inSelf, (Handle)theGlobals); |
|---|
| 112 |
} |
|---|
| 113 |
catch(UInt32 theError) |
|---|
| 114 |
{ |
|---|
| 115 |
theAnswer = theError; |
|---|
| 116 |
} |
|---|
| 117 |
catch(...) |
|---|
| 118 |
{ |
|---|
| 119 |
theAnswer = -50; |
|---|
| 120 |
} |
|---|
| 121 |
|
|---|
| 122 |
return theAnswer; |
|---|
| 123 |
} |
|---|
| 124 |
|
|---|
| 125 |
static pascal ComponentResult __SoundComponentClose(SoundComponentGlobalsPtr inGlobals, ComponentInstance inSelf) |
|---|
| 126 |
{ |
|---|
| 127 |
if(inGlobals != NULL) |
|---|
| 128 |
{ |
|---|
| 129 |
// close the source component |
|---|
| 130 |
if(inGlobals->sourceComponent != NULL) |
|---|
| 131 |
{ |
|---|
| 132 |
CloseComponent(inGlobals->sourceComponent); |
|---|
| 133 |
} |
|---|
| 134 |
|
|---|
| 135 |
// dispose of the SMACIMAscom object |
|---|
| 136 |
delete inGlobals->mThis; |
|---|
| 137 |
|
|---|
| 138 |
// dispose of the globals themselves |
|---|
| 139 |
delete inGlobals; |
|---|
| 140 |
} |
|---|
| 141 |
|
|---|
| 142 |
return 0; |
|---|
| 143 |
} |
|---|
| 144 |
|
|---|
| 145 |
static pascal ComponentResult __SoundComponentSetSource(SoundComponentGlobalsPtr inGlobals, SoundSource inSourceID, ComponentInstance inSourceComponent) |
|---|
| 146 |
{ |
|---|
| 147 |
ComponentResult theAnswer = 0; |
|---|
| 148 |
|
|---|
| 149 |
try |
|---|
| 150 |
{ |
|---|
| 151 |
inGlobals->sourceComponent = inSourceComponent; |
|---|
| 152 |
inGlobals->mThis->SetSource(inSourceID, inSourceComponent); |
|---|
| 153 |
} |
|---|
| 154 |
catch(UInt32 theError) |
|---|
| 155 |
{ |
|---|
| 156 |
theAnswer = theError; |
|---|
| 157 |
} |
|---|
| 158 |
catch(...) |
|---|
| 159 |
{ |
|---|
| 160 |
theAnswer = -50; |
|---|
| 161 |
} |
|---|
| 162 |
|
|---|
| 163 |
return theAnswer; |
|---|
| 164 |
} |
|---|
| 165 |
|
|---|
| 166 |
static pascal ComponentResult __SoundComponentSetOutput(SoundComponentGlobalsPtr inGlobals, SoundComponentDataPtr inRequested, SoundComponentDataPtr* inActual) |
|---|
| 167 |
{ |
|---|
| 168 |
ComponentResult theAnswer = 0; |
|---|
| 169 |
|
|---|
| 170 |
try |
|---|
| 171 |
{ |
|---|
| 172 |
inGlobals->mThis->SetOutput(inRequested, inActual); |
|---|
| 173 |
} |
|---|
| 174 |
catch(UInt32 theError) |
|---|
| 175 |
{ |
|---|
| 176 |
theAnswer = theError; |
|---|
| 177 |
} |
|---|
| 178 |
catch(...) |
|---|
| 179 |
{ |
|---|
| 180 |
theAnswer = -50; |
|---|
| 181 |
} |
|---|
| 182 |
|
|---|
| 183 |
return theAnswer; |
|---|
| 184 |
} |
|---|
| 185 |
|
|---|
| 186 |
static pascal ComponentResult __SoundComponentPlaySourceBuffer(SoundComponentGlobalsPtr inGlobals, SoundSource inSourceID, SoundParamBlockPtr inPB, SInt32 inActions) |
|---|
| 187 |
{ |
|---|
| 188 |
ComponentResult theAnswer = 0; |
|---|
| 189 |
|
|---|
| 190 |
try |
|---|
| 191 |
{ |
|---|
| 192 |
inGlobals->mThis->PlaySourceBuffer(inSourceID, inPB, inActions); |
|---|
| 193 |
} |
|---|
| 194 |
catch(UInt32 theError) |
|---|
| 195 |
{ |
|---|
| 196 |
theAnswer = theError; |
|---|
| 197 |
} |
|---|
| 198 |
catch(...) |
|---|
| 199 |
{ |
|---|
| 200 |
theAnswer = -50; |
|---|
| 201 |
} |
|---|
| 202 |
|
|---|
| 203 |
return theAnswer; |
|---|
| 204 |
} |
|---|
| 205 |
|
|---|
| 206 |
static pascal ComponentResult __SoundComponentStopSource(SoundComponentGlobalsPtr inGlobals, SInt16 inNumberSources, SoundSource* inSources) |
|---|
| 207 |
{ |
|---|
| 208 |
ComponentResult theAnswer = 0; |
|---|
| 209 |
|
|---|
| 210 |
try |
|---|
| 211 |
{ |
|---|
| 212 |
inGlobals->mThis->StopSource(inNumberSources, inSources); |
|---|
| 213 |
} |
|---|
| 214 |
catch(UInt32 theError) |
|---|
| 215 |
{ |
|---|
| 216 |
theAnswer = theError; |
|---|
| 217 |
} |
|---|
| 218 |
catch(...) |
|---|
| 219 |
{ |
|---|
| 220 |
theAnswer = -50; |
|---|
| 221 |
} |
|---|
| 222 |
|
|---|
| 223 |
return theAnswer; |
|---|
| 224 |
} |
|---|
| 225 |
|
|---|
| 226 |
static pascal ComponentResult __SoundComponentGetInfo(SoundComponentGlobalsPtr inGlobals, SoundSource inSourceID, OSType inSelector, void* outData) |
|---|
| 227 |
{ |
|---|
| 228 |
ComponentResult theAnswer = 0; |
|---|
| 229 |
|
|---|
| 230 |
try |
|---|
| 231 |
{ |
|---|
| 232 |
inGlobals->mThis->GetInfo(inSourceID, inSelector, outData); |
|---|
| 233 |
} |
|---|
| 234 |
catch(UInt32 theError) |
|---|
| 235 |
{ |
|---|
| 236 |
theAnswer = theError; |
|---|
| 237 |
} |
|---|
| 238 |
catch(...) |
|---|
| 239 |
{ |
|---|
| 240 |
theAnswer = -50; |
|---|
| 241 |
} |
|---|
| 242 |
|
|---|
| 243 |
return theAnswer; |
|---|
| 244 |
} |
|---|
| 245 |
|
|---|
| 246 |
static pascal ComponentResult __SoundComponentSetInfo(SoundComponentGlobalsPtr inGlobals, SoundSource inSourceID, OSType inSelector, void* inData) |
|---|
| 247 |
{ |
|---|
| 248 |
ComponentResult theAnswer = 0; |
|---|
| 249 |
|
|---|
| 250 |
try |
|---|
| 251 |
{ |
|---|
| 252 |
inGlobals->mThis->SetInfo(inSourceID, inSelector, inData); |
|---|
| 253 |
} |
|---|
| 254 |
catch(UInt32 theError) |
|---|
| 255 |
{ |
|---|
| 256 |
theAnswer = theError; |
|---|
| 257 |
} |
|---|
| 258 |
catch(...) |
|---|
| 259 |
{ |
|---|
| 260 |
theAnswer = -50; |
|---|
| 261 |
} |
|---|
| 262 |
|
|---|
| 263 |
return theAnswer; |
|---|
| 264 |
} |
|---|
| 265 |
|
|---|
| 266 |
static pascal ComponentResult __SoundComponentGetSourceData(SoundComponentGlobalsPtr inGlobals, SoundComponentData** outData) |
|---|
| 267 |
{ |
|---|
| 268 |
ComponentResult theAnswer = 0; |
|---|
| 269 |
|
|---|
| 270 |
try |
|---|
| 271 |
{ |
|---|
| 272 |
inGlobals->mThis->GetSourceData(outData); |
|---|
| 273 |
} |
|---|
| 274 |
catch(UInt32 theError) |
|---|
| 275 |
{ |
|---|
| 276 |
theAnswer = theError; |
|---|
| 277 |
} |
|---|
| 278 |
catch(...) |
|---|
| 279 |
{ |
|---|
| 280 |
theAnswer = -50; |
|---|
| 281 |
} |
|---|
| 282 |
|
|---|
| 283 |
return theAnswer; |
|---|
| 284 |
} |
|---|
| 285 |
|
|---|
| 286 |
} // extern "C" |
|---|