| 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 |
SMACsdec.h |
|---|
| 40 |
|
|---|
| 41 |
=============================================================================*/ |
|---|
| 42 |
#if !defined(__SMACsdec_h__) |
|---|
| 43 |
#define __SMACsdec_h__ |
|---|
| 44 |
|
|---|
| 45 |
//============================================================================= |
|---|
| 46 |
// Includes |
|---|
| 47 |
//============================================================================= |
|---|
| 48 |
#include <CAConditionalMacros.h> |
|---|
| 49 |
|
|---|
| 50 |
#if TARGET_API_MAC_OSX && !USE_QTML_HEADERS |
|---|
| 51 |
#include <Carbon/Carbon.h> |
|---|
| 52 |
#else |
|---|
| 53 |
#include <Sound.h> |
|---|
| 54 |
#endif |
|---|
| 55 |
|
|---|
| 56 |
#if TARGET_API_MAC_OSX |
|---|
| 57 |
#include "CAMutex.h" |
|---|
| 58 |
#endif |
|---|
| 59 |
|
|---|
| 60 |
#include "AudioCodec.h" |
|---|
| 61 |
#include <stdio.h> |
|---|
| 62 |
|
|---|
| 63 |
//#define CaptureDataToFile 1 |
|---|
| 64 |
|
|---|
| 65 |
//============================================================================= |
|---|
| 66 |
// SMACsdec |
|---|
| 67 |
//============================================================================= |
|---|
| 68 |
|
|---|
| 69 |
class SMACsdec |
|---|
| 70 |
{ |
|---|
| 71 |
|
|---|
| 72 |
// Construction/Destruction |
|---|
| 73 |
public: |
|---|
| 74 |
SMACsdec(ComponentInstance inSelf); |
|---|
| 75 |
virtual ~SMACsdec(); |
|---|
| 76 |
|
|---|
| 77 |
// Sound Component Methods |
|---|
| 78 |
public: |
|---|
| 79 |
virtual void SetSource(SoundSource inSourceID, ComponentInstance inSourceComponent); |
|---|
| 80 |
virtual void SetOutput(SoundComponentData* inRequested, SoundComponentData** inActual); |
|---|
| 81 |
|
|---|
| 82 |
virtual void PlaySourceBuffer(SoundSource inSourceID, SoundParamBlock* inPB, SInt32 inActions); |
|---|
| 83 |
virtual void StopSource(SInt16 inNumberSources, SoundSource* inSources); |
|---|
| 84 |
|
|---|
| 85 |
virtual void GetInfo(SoundSource inSourceID, OSType inSelector, void* outData); |
|---|
| 86 |
virtual void SetInfo(SoundSource inSourceID, OSType inSelector, void* inData); |
|---|
| 87 |
|
|---|
| 88 |
virtual void GetSourceData(SoundComponentData** outData); |
|---|
| 89 |
|
|---|
| 90 |
// Implementation |
|---|
| 91 |
protected: |
|---|
| 92 |
virtual void GetCompressionInfo(CompressionInfo& outCompressionInfo) = 0; |
|---|
| 93 |
virtual void GetDecompressionParams(void* outData) = 0; |
|---|
| 94 |
virtual ComponentInstance SetDecompressionParams(const void* inData) = 0; |
|---|
| 95 |
|
|---|
| 96 |
virtual void GetCurrentInputPacket(void*& outPacketData, UInt32& outPacketDataSize, UInt32& outPacketDataFrameSize); |
|---|
| 97 |
virtual void ConsumeCurrentInputPacket(UInt32 inPacketDataByteSize, UInt32 inPacketDataFrameSize); |
|---|
| 98 |
|
|---|
| 99 |
ComponentInstance mSelf; |
|---|
| 100 |
ComponentInstance mSourceComponent; |
|---|
| 101 |
AudioCodec mDecoder; |
|---|
| 102 |
SoundSource mSourceID; |
|---|
| 103 |
SoundComponentData* mSourceData; |
|---|
| 104 |
SoundComponentData mOutputData; |
|---|
| 105 |
UInt32 mPacketFrameSize; |
|---|
| 106 |
float * mFloatBuffer; |
|---|
| 107 |
Byte* mOutputBuffer; |
|---|
| 108 |
Boolean mHasAltiVec; |
|---|
| 109 |
|
|---|
| 110 |
#if TARGET_API_MAC_OSX |
|---|
| 111 |
CAMutex* mThreadStateMutex; |
|---|
| 112 |
#endif |
|---|
| 113 |
|
|---|
| 114 |
#if CaptureDataToFile |
|---|
| 115 |
SInt16 mOutputFileRefNum; |
|---|
| 116 |
#endif |
|---|
| 117 |
|
|---|
| 118 |
#if USE_DIRECT_ADEC |
|---|
| 119 |
protected: |
|---|
| 120 |
// pure virtual interface to redirect audio codec calls thru derived class |
|---|
| 121 |
|
|---|
| 122 |
virtual ComponentResult DirectAudioCodecVersion(AudioCodec inCodec) |
|---|
| 123 |
= NULL; |
|---|
| 124 |
|
|---|
| 125 |
virtual ComponentResult DirectAudioCodecGetPropertyInfo(AudioCodec inCodec, |
|---|
| 126 |
AudioCodecPropertyID inPropertyID, |
|---|
| 127 |
UInt32* outSize, |
|---|
| 128 |
Boolean* outWritable) |
|---|
| 129 |
= NULL; |
|---|
| 130 |
|
|---|
| 131 |
virtual ComponentResult DirectAudioCodecGetProperty(AudioCodec inCodec, |
|---|
| 132 |
AudioCodecPropertyID inPropertyID, |
|---|
| 133 |
UInt32* ioPropertyDataSize, |
|---|
| 134 |
void* outPropertyData) |
|---|
| 135 |
= NULL; |
|---|
| 136 |
|
|---|
| 137 |
virtual ComponentResult DirectAudioCodecSetProperty(AudioCodec inCodec, |
|---|
| 138 |
AudioCodecPropertyID inPropertyID, |
|---|
| 139 |
UInt32 inPropertyDataSize, |
|---|
| 140 |
const void* inPropertyData) |
|---|
| 141 |
= NULL; |
|---|
| 142 |
|
|---|
| 143 |
virtual ComponentResult DirectAudioCodecInitialize(AudioCodec inCodec, |
|---|
| 144 |
const AudioStreamBasicDescription* inInputFormat, |
|---|
| 145 |
const AudioStreamBasicDescription* inOutputFormat, |
|---|
| 146 |
const void* inMagicCookie, |
|---|
| 147 |
UInt32 inMagicCookieByteSize) |
|---|
| 148 |
= NULL; |
|---|
| 149 |
|
|---|
| 150 |
virtual ComponentResult DirectAudioCodecUninitialize(AudioCodec inCodec) |
|---|
| 151 |
= NULL; |
|---|
| 152 |
|
|---|
| 153 |
virtual ComponentResult DirectAudioCodecAppendInputData(AudioCodec inCodec, |
|---|
| 154 |
const void* inInputData, |
|---|
| 155 |
UInt32* ioInputDataByteSize, |
|---|
| 156 |
UInt32* ioNumberPackets, |
|---|
| 157 |
const AudioStreamPacketDescription* inPacketDescription) |
|---|
| 158 |
= NULL; |
|---|
| 159 |
|
|---|
| 160 |
virtual ComponentResult DirectAudioCodecProduceOutputPackets(AudioCodec inCodec, |
|---|
| 161 |
void* outOutputData, |
|---|
| 162 |
UInt32* ioOutputDataByteSize, |
|---|
| 163 |
UInt32* ioNumberPackets, |
|---|
| 164 |
AudioStreamPacketDescription* outPacketDescription, |
|---|
| 165 |
UInt32* outStatus) |
|---|
| 166 |
= NULL; |
|---|
| 167 |
|
|---|
| 168 |
virtual ComponentResult DirectAudioCodecReset(AudioCodec inCodec) |
|---|
| 169 |
= NULL; |
|---|
| 170 |
|
|---|
| 171 |
virtual ComponentResult DirectAudioCodecClose(AudioCodec inCodec) |
|---|
| 172 |
{ return noErr; } // not pure virtual, because it's called in our destructor |
|---|
| 173 |
|
|---|
| 174 |
#endif |
|---|
| 175 |
|
|---|
| 176 |
}; |
|---|
| 177 |
|
|---|
| 178 |
#endif |
|---|