summaryrefslogtreecommitdiff
path: root/libs/appleutility/CoreAudio/AudioCodecs/ACPublic
diff options
context:
space:
mode:
Diffstat (limited to 'libs/appleutility/CoreAudio/AudioCodecs/ACPublic')
-rw-r--r--libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACBaseCodec.cpp580
-rw-r--r--libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACBaseCodec.h147
-rw-r--r--libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACCodec.cpp329
-rw-r--r--libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACCodec.h115
-rw-r--r--libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACCodecDispatchTypes.h259
-rw-r--r--libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACComponentResources.r196
-rw-r--r--libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACConditionalMacros.h73
-rw-r--r--libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACPlugInDispatch.cpp283
-rw-r--r--libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACPlugInDispatch.h88
-rw-r--r--libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACSimpleCodec.cpp364
-rw-r--r--libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACSimpleCodec.h105
-rw-r--r--libs/appleutility/CoreAudio/AudioCodecs/ACPublic/GetCodecBundle.cpp76
-rw-r--r--libs/appleutility/CoreAudio/AudioCodecs/ACPublic/GetCodecBundle.h60
13 files changed, 2675 insertions, 0 deletions
diff --git a/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACBaseCodec.cpp b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACBaseCodec.cpp
new file mode 100644
index 0000000000..f1ffdf7f1b
--- /dev/null
+++ b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACBaseCodec.cpp
@@ -0,0 +1,580 @@
+/*
+ File: ACBaseCodec.cpp
+ Abstract: ACBaseCodec.h
+ Version: 1.1
+
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
+ Inc. ("Apple") in consideration of your agreement to the following
+ terms, and your use, installation, modification or redistribution of
+ this Apple software constitutes acceptance of these terms. If you do
+ not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+
+ In consideration of your agreement to abide by the following terms, and
+ subject to these terms, Apple grants you a personal, non-exclusive
+ license, under Apple's copyrights in this original Apple software (the
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
+ Software, with or without modifications, in source and/or binary forms;
+ provided that if you redistribute the Apple Software in its entirety and
+ without modifications, you must retain this notice and the following
+ text and disclaimers in all such redistributions of the Apple Software.
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
+ be used to endorse or promote products derived from the Apple Software
+ without specific prior written permission from Apple. Except as
+ expressly stated in this notice, no other rights or licenses, express or
+ implied, are granted by Apple herein, including but not limited to any
+ patent rights that may be infringed by your derivative works or by other
+ works in which the Apple Software may be incorporated.
+
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+ Copyright (C) 2014 Apple Inc. All Rights Reserved.
+
+*/
+//=============================================================================
+// Includes
+//=============================================================================
+#include <algorithm>
+#include "ACBaseCodec.h"
+
+#include "CABundleLocker.h"
+
+#if TARGET_OS_WIN32
+ #include "CAWin32StringResources.h"
+#endif
+
+//=============================================================================
+// ACBaseCodec
+//=============================================================================
+
+ACBaseCodec::ACBaseCodec( AudioComponentInstance inInstance )
+:
+ ACCodec(inInstance),
+ mIsInitialized(false),
+ mInputFormatList(),
+ mInputFormat(),
+ mOutputFormatList(),
+ mOutputFormat()
+{
+ mCodecSubType = 0;
+ if (inInstance) GetSubType();
+}
+
+ACBaseCodec::~ACBaseCodec()
+{
+}
+
+void ACBaseCodec::GetPropertyInfo(AudioCodecPropertyID inPropertyID, UInt32& outPropertyDataSize, Boolean& outWritable)
+{
+ switch(inPropertyID)
+ {
+#if BUILD_ADEC_LIB
+ case kAudioCodecPropertyNameCFString:
+ case kAudioCodecPropertyFormatCFString:
+ case kAudioCodecPropertyManufacturerCFString:
+ outPropertyDataSize = 0;
+ outWritable = false;
+ break;
+#else
+ case kAudioCodecPropertyNameCFString:
+ outPropertyDataSize = SizeOf32(CFStringRef);
+ outWritable = false;
+ break;
+
+ case kAudioCodecPropertyManufacturerCFString:
+ outPropertyDataSize = SizeOf32(CFStringRef);
+ outWritable = false;
+ break;
+
+ case kAudioCodecPropertyFormatCFString:
+ outPropertyDataSize = SizeOf32(CFStringRef);
+ outWritable = false;
+ break;
+#endif
+ case kAudioCodecPropertyRequiresPacketDescription:
+ outPropertyDataSize = SizeOf32(UInt32);
+ outWritable = false;
+ break;
+
+ case kAudioCodecPropertyMinimumNumberInputPackets :
+ outPropertyDataSize = SizeOf32(UInt32);
+ outWritable = false;
+ break;
+
+ case kAudioCodecPropertyMinimumNumberOutputPackets :
+ outPropertyDataSize = SizeOf32(UInt32);
+ outWritable = false;
+ break;
+
+ case kAudioCodecPropertyCurrentInputFormat:
+ outPropertyDataSize = SizeOf32(AudioStreamBasicDescription);
+ outWritable = true;
+ break;
+
+ case kAudioCodecPropertySupportedInputFormats:
+ case kAudioCodecPropertyInputFormatsForOutputFormat:
+ outPropertyDataSize = GetNumberSupportedInputFormats() * SizeOf32(AudioStreamBasicDescription);
+ outWritable = false;
+ break;
+
+ case kAudioCodecPropertyCurrentOutputFormat:
+ outPropertyDataSize = SizeOf32(AudioStreamBasicDescription);
+ outWritable = true;
+ break;
+
+ case kAudioCodecPropertySupportedOutputFormats:
+ case kAudioCodecPropertyOutputFormatsForInputFormat:
+ outPropertyDataSize = GetNumberSupportedOutputFormats() * SizeOf32(AudioStreamBasicDescription);
+ outWritable = false;
+ break;
+
+ case kAudioCodecPropertyMagicCookie:
+ outPropertyDataSize = GetMagicCookieByteSize();
+ outWritable = true;
+ break;
+
+ case kAudioCodecPropertyInputBufferSize:
+ outPropertyDataSize = SizeOf32(UInt32);
+ outWritable = false;
+ break;
+
+ case kAudioCodecPropertyUsedInputBufferSize:
+ outPropertyDataSize = SizeOf32(UInt32);
+ outWritable = false;
+ break;
+
+ case kAudioCodecPropertyIsInitialized:
+ outPropertyDataSize = SizeOf32(UInt32);
+ outWritable = false;
+ break;
+
+ case kAudioCodecPropertyAvailableNumberChannels:
+ outPropertyDataSize = SizeOf32(UInt32) * 2; // Mono, stereo
+ outWritable = false;
+ break;
+
+ case kAudioCodecPropertyPrimeMethod:
+ outPropertyDataSize = SizeOf32(UInt32);
+ outWritable = false;
+ break;
+
+ case kAudioCodecPropertyPrimeInfo:
+ outPropertyDataSize = SizeOf32(AudioCodecPrimeInfo);
+ outWritable = false;
+ break;
+
+ case kAudioCodecPropertyDoesSampleRateConversion:
+ outPropertyDataSize = SizeOf32(UInt32);
+ outWritable = false;
+ break;
+
+ default:
+ CODEC_THROW(kAudioCodecUnknownPropertyError);
+ break;
+
+ };
+}
+
+void ACBaseCodec::GetProperty(AudioCodecPropertyID inPropertyID, UInt32& ioPropertyDataSize, void* outPropertyData)
+{
+ UInt32 thePacketsToGet;
+
+ switch(inPropertyID)
+ {
+#if !BUILD_ADEC_LIB
+ case kAudioCodecPropertyNameCFString:
+ {
+ if (ioPropertyDataSize != SizeOf32(CFStringRef)) CODEC_THROW(kAudioCodecBadPropertySizeError);
+
+ CABundleLocker lock;
+ CFStringRef name = CFCopyLocalizedStringFromTableInBundle(CFSTR("unknown codec"), CFSTR("CodecNames"), GetCodecBundle(), CFSTR(""));
+ *(CFStringRef*)outPropertyData = name;
+ break;
+ }
+
+ case kAudioCodecPropertyManufacturerCFString:
+ {
+ if (ioPropertyDataSize != SizeOf32(CFStringRef)) CODEC_THROW(kAudioCodecBadPropertySizeError);
+
+ CABundleLocker lock;
+ CFStringRef name = CFCopyLocalizedStringFromTableInBundle(CFSTR("Apple, Inc."), CFSTR("CodecNames"), GetCodecBundle(), CFSTR(""));
+ *(CFStringRef*)outPropertyData = name;
+ break;
+ }
+#else
+ // If called on the device these should return nothing but 0
+ case kAudioCodecPropertyNameCFString:
+ case kAudioCodecPropertyFormatCFString:
+ case kAudioCodecPropertyManufacturerCFString:
+ ioPropertyDataSize = 0;
+ outPropertyData = 0;
+ break;
+#endif
+ case kAudioCodecPropertyRequiresPacketDescription:
+ if(ioPropertyDataSize == SizeOf32(UInt32))
+ {
+ *reinterpret_cast<UInt32*>(outPropertyData) = 0;
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+
+ case kAudioCodecPropertyMinimumNumberInputPackets :
+ if(ioPropertyDataSize != SizeOf32(UInt32)) CODEC_THROW(kAudioCodecBadPropertySizeError);
+ *(UInt32*)outPropertyData = 1;
+ break;
+
+ case kAudioCodecPropertyMinimumNumberOutputPackets :
+ if(ioPropertyDataSize != SizeOf32(UInt32)) CODEC_THROW(kAudioCodecBadPropertySizeError);
+ *(UInt32*)outPropertyData = 1;
+ break;
+
+ case kAudioCodecPropertyCurrentInputFormat:
+ if(ioPropertyDataSize == SizeOf32(AudioStreamBasicDescription))
+ {
+ GetCurrentInputFormat(*reinterpret_cast<AudioStreamBasicDescription*>(outPropertyData));
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+
+ case kAudioCodecPropertySupportedInputFormats:
+ case kAudioCodecPropertyInputFormatsForOutputFormat:
+ thePacketsToGet = ioPropertyDataSize / SizeOf32(AudioStreamBasicDescription);
+ GetSupportedInputFormats(reinterpret_cast<AudioStreamBasicDescription*>(outPropertyData), thePacketsToGet);
+ ioPropertyDataSize = thePacketsToGet * SizeOf32(AudioStreamBasicDescription);
+ break;
+
+ case kAudioCodecPropertyCurrentOutputFormat:
+ if(ioPropertyDataSize == SizeOf32(AudioStreamBasicDescription))
+ {
+ GetCurrentOutputFormat(*reinterpret_cast<AudioStreamBasicDescription*>(outPropertyData));
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+
+ case kAudioCodecPropertySupportedOutputFormats:
+ case kAudioCodecPropertyOutputFormatsForInputFormat:
+ thePacketsToGet = ioPropertyDataSize / SizeOf32(AudioStreamBasicDescription);
+ GetSupportedOutputFormats(reinterpret_cast<AudioStreamBasicDescription*>(outPropertyData), thePacketsToGet);
+ ioPropertyDataSize = thePacketsToGet * SizeOf32(AudioStreamBasicDescription);
+ break;
+
+ case kAudioCodecPropertyMagicCookie:
+ if(ioPropertyDataSize >= GetMagicCookieByteSize())
+ {
+ GetMagicCookie(outPropertyData, ioPropertyDataSize);
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+
+ case kAudioCodecPropertyInputBufferSize:
+ if(ioPropertyDataSize == SizeOf32(UInt32))
+ {
+ *reinterpret_cast<UInt32*>(outPropertyData) = GetInputBufferByteSize();
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+
+ case kAudioCodecPropertyUsedInputBufferSize:
+ if(ioPropertyDataSize == SizeOf32(UInt32))
+ {
+ *reinterpret_cast<UInt32*>(outPropertyData) = GetUsedInputBufferByteSize();
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+
+ case kAudioCodecPropertyIsInitialized:
+ if(ioPropertyDataSize == SizeOf32(UInt32))
+ {
+ *reinterpret_cast<UInt32*>(outPropertyData) = IsInitialized() ? 1 : 0;
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+
+ case kAudioCodecPropertyAvailableNumberChannels:
+ if(ioPropertyDataSize == SizeOf32(UInt32) * 2)
+ {
+ (reinterpret_cast<UInt32*>(outPropertyData))[0] = 1;
+ (reinterpret_cast<UInt32*>(outPropertyData))[1] = 2;
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+
+ case kAudioCodecPropertyPrimeMethod:
+ if(ioPropertyDataSize == SizeOf32(UInt32))
+ {
+ *reinterpret_cast<UInt32*>(outPropertyData) = (UInt32)kAudioCodecPrimeMethod_None;
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+
+ case kAudioCodecPropertyPrimeInfo:
+ if(ioPropertyDataSize == SizeOf32(AudioCodecPrimeInfo) )
+ {
+ (reinterpret_cast<AudioCodecPrimeInfo*>(outPropertyData))->leadingFrames = 0;
+ (reinterpret_cast<AudioCodecPrimeInfo*>(outPropertyData))->trailingFrames = 0;
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+
+ case kAudioCodecPropertyDoesSampleRateConversion:
+ if(ioPropertyDataSize == SizeOf32(UInt32))
+ {
+ *reinterpret_cast<UInt32*>(outPropertyData) = 0;
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+
+ default:
+ CODEC_THROW(kAudioCodecUnknownPropertyError);
+ break;
+
+ };
+}
+
+void ACBaseCodec::SetProperty(AudioCodecPropertyID inPropertyID, UInt32 inPropertyDataSize, const void* inPropertyData)
+{
+ // No property can be set when the codec is initialized
+ if(mIsInitialized)
+ {
+ CODEC_THROW(kAudioCodecIllegalOperationError);
+ }
+
+ switch(inPropertyID)
+ {
+ case kAudioCodecPropertyCurrentInputFormat:
+ if(inPropertyDataSize == SizeOf32(AudioStreamBasicDescription))
+ {
+ SetCurrentInputFormat(*reinterpret_cast<const AudioStreamBasicDescription*>(inPropertyData));
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+
+ case kAudioCodecPropertyCurrentOutputFormat:
+ if(inPropertyDataSize == SizeOf32(AudioStreamBasicDescription))
+ {
+ SetCurrentOutputFormat(*reinterpret_cast<const AudioStreamBasicDescription*>(inPropertyData));
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+
+ case kAudioCodecPropertyMagicCookie:
+ SetMagicCookie(inPropertyData, inPropertyDataSize);
+ break;
+
+ case kAudioCodecPropertyMinimumNumberOutputPackets :
+ case kAudioCodecPropertyMinimumNumberInputPackets :
+ case kAudioCodecPropertyInputBufferSize:
+ case kAudioCodecPropertyNameCFString:
+ case kAudioCodecPropertyManufacturerCFString:
+ case kAudioCodecPropertyFormatCFString:
+ case kAudioCodecPropertySupportedInputFormats:
+ case kAudioCodecPropertySupportedOutputFormats:
+ case kAudioCodecPropertyUsedInputBufferSize:
+ case kAudioCodecPropertyIsInitialized:
+ case kAudioCodecPropertyAvailableNumberChannels:
+ case kAudioCodecPropertyPrimeMethod:
+ case kAudioCodecPropertyPrimeInfo:
+ case kAudioCodecPropertyOutputFormatsForInputFormat:
+ case kAudioCodecPropertyInputFormatsForOutputFormat:
+ case kAudioCodecPropertyDoesSampleRateConversion:
+ case kAudioCodecPropertyRequiresPacketDescription:
+ CODEC_THROW(kAudioCodecIllegalOperationError);
+ break;
+
+ default:
+ CODEC_THROW(kAudioCodecUnknownPropertyError);
+ break;
+ };
+}
+
+void ACBaseCodec::Initialize(const AudioStreamBasicDescription* /* inInputFormat */, const AudioStreamBasicDescription* /* inOutputFormat */, const void* /* inMagicCookie */, UInt32 /* inMagicCookieByteSize */)
+{
+ mIsInitialized = true;
+}
+
+void ACBaseCodec::Uninitialize()
+{
+ mIsInitialized = false;
+}
+
+void ACBaseCodec::Reset()
+{
+}
+
+UInt32 ACBaseCodec::GetNumberSupportedInputFormats() const
+{
+ return (UInt32)mInputFormatList.size();
+}
+
+void ACBaseCodec::GetSupportedInputFormats(AudioStreamBasicDescription* outInputFormats, UInt32& ioNumberInputFormats) const
+{
+ UInt32 theNumberFormats = (UInt32)mInputFormatList.size();
+ ioNumberInputFormats = (theNumberFormats < ioNumberInputFormats) ? theNumberFormats : ioNumberInputFormats;
+
+ FormatList::const_iterator theIterator = mInputFormatList.begin();
+ theNumberFormats = ioNumberInputFormats;
+ while((theNumberFormats > 0) && (theIterator != mInputFormatList.end()))
+ {
+ *outInputFormats = *theIterator;
+
+ ++outInputFormats;
+ --theNumberFormats;
+ std::advance(theIterator, 1);
+ }
+}
+
+void ACBaseCodec::GetCurrentInputFormat(AudioStreamBasicDescription& outInputFormat)
+{
+ outInputFormat = mInputFormat;
+}
+
+void ACBaseCodec::SetCurrentInputFormat(const AudioStreamBasicDescription& inInputFormat)
+{
+ if(!mIsInitialized)
+ {
+ mInputFormat = inInputFormat;
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecStateError);
+ }
+}
+
+UInt32 ACBaseCodec::GetNumberSupportedOutputFormats() const
+{
+ return (UInt32)mOutputFormatList.size();
+}
+
+void ACBaseCodec::GetSupportedOutputFormats(AudioStreamBasicDescription* outOutputFormats, UInt32& ioNumberOutputFormats) const
+{
+ UInt32 theNumberFormats = (UInt32)mOutputFormatList.size();
+ ioNumberOutputFormats = (theNumberFormats < ioNumberOutputFormats) ? theNumberFormats : ioNumberOutputFormats;
+
+ FormatList::const_iterator theIterator = mOutputFormatList.begin();
+ theNumberFormats = ioNumberOutputFormats;
+ while((theNumberFormats > 0) && (theIterator != mOutputFormatList.end()))
+ {
+ *outOutputFormats = *theIterator;
+
+ ++outOutputFormats;
+ --theNumberFormats;
+ std::advance(theIterator, 1);
+ }
+}
+
+void ACBaseCodec::GetCurrentOutputFormat(AudioStreamBasicDescription& outOutputFormat)
+{
+ outOutputFormat = mOutputFormat;
+}
+
+void ACBaseCodec::SetCurrentOutputFormat(const AudioStreamBasicDescription& inOutputFormat)
+{
+ if(!mIsInitialized)
+ {
+ mOutputFormat = inOutputFormat;
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecStateError);
+ }
+}
+
+UInt32 ACBaseCodec::GetMagicCookieByteSize() const
+{
+ return 0;
+}
+
+void ACBaseCodec::GetMagicCookie(void* /* outMagicCookieData */, UInt32& ioMagicCookieDataByteSize) const
+{
+ ioMagicCookieDataByteSize = 0;
+}
+
+void ACBaseCodec::SetMagicCookie(const void* /* outMagicCookieData */, UInt32 /* inMagicCookieDataByteSize */)
+{
+ if(mIsInitialized)
+ {
+ CODEC_THROW(kAudioCodecStateError);
+ }
+}
+
+void ACBaseCodec::AddInputFormat(const AudioStreamBasicDescription& inInputFormat)
+{
+ FormatList::iterator theIterator = std::find(mInputFormatList.begin(), mInputFormatList.end(), inInputFormat);
+ if(theIterator == mInputFormatList.end())
+ {
+ theIterator = std::lower_bound(mInputFormatList.begin(), mInputFormatList.end(), inInputFormat);
+ mInputFormatList.insert(theIterator, inInputFormat);
+ }
+}
+
+void ACBaseCodec::AddOutputFormat(const AudioStreamBasicDescription& inOutputFormat)
+{
+ FormatList::iterator theIterator = std::find(mOutputFormatList.begin(), mOutputFormatList.end(), inOutputFormat);
+ if(theIterator == mOutputFormatList.end())
+ {
+ theIterator = std::lower_bound(mOutputFormatList.begin(), mOutputFormatList.end(), inOutputFormat);
+ mOutputFormatList.insert(theIterator, inOutputFormat);
+ }
+}
+
+OSType ACBaseCodec::GetSubType()
+{
+ if (!mCodecSubType)
+ {
+ AudioComponentDescription desc = GetComponentDescription();
+ mCodecSubType = desc.componentSubType;
+ }
+ return mCodecSubType;
+}
diff --git a/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACBaseCodec.h b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACBaseCodec.h
new file mode 100644
index 0000000000..6689d91fbe
--- /dev/null
+++ b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACBaseCodec.h
@@ -0,0 +1,147 @@
+/*
+ File: ACBaseCodec.h
+ Abstract: Part of CoreAudio Utility Classes
+ Version: 1.1
+
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
+ Inc. ("Apple") in consideration of your agreement to the following
+ terms, and your use, installation, modification or redistribution of
+ this Apple software constitutes acceptance of these terms. If you do
+ not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+
+ In consideration of your agreement to abide by the following terms, and
+ subject to these terms, Apple grants you a personal, non-exclusive
+ license, under Apple's copyrights in this original Apple software (the
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
+ Software, with or without modifications, in source and/or binary forms;
+ provided that if you redistribute the Apple Software in its entirety and
+ without modifications, you must retain this notice and the following
+ text and disclaimers in all such redistributions of the Apple Software.
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
+ be used to endorse or promote products derived from the Apple Software
+ without specific prior written permission from Apple. Except as
+ expressly stated in this notice, no other rights or licenses, express or
+ implied, are granted by Apple herein, including but not limited to any
+ patent rights that may be infringed by your derivative works or by other
+ works in which the Apple Software may be incorporated.
+
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+ Copyright (C) 2014 Apple Inc. All Rights Reserved.
+
+*/
+#if !defined(__ACBaseCodec_h__)
+#define __ACBaseCodec_h__
+
+//=============================================================================
+// Includes
+//=============================================================================
+
+#include "ACCodec.h"
+#include "CAStreamBasicDescription.h"
+#include <vector>
+#include "GetCodecBundle.h"
+
+//=============================================================================
+// ACBaseCodec
+//
+// An abstract subclass of ACCodec that implements all the nuts and bolts
+// of the ACCodec interface, except for buffer handling. This class does
+// the proper dispatching of property requests and manages the list of
+// input and output formats.
+//=============================================================================
+
+class ACBaseCodec
+:
+ public ACCodec
+{
+
+// Construction/Destruction
+public:
+ ACBaseCodec( AudioComponentInstance inInstance );
+ virtual ~ACBaseCodec();
+
+// Property Management
+public:
+ virtual void GetPropertyInfo(AudioCodecPropertyID inPropertyID, UInt32& outPropertyDataSize, Boolean& outWritable);
+ virtual void GetProperty(AudioCodecPropertyID inPropertyID, UInt32& ioPropertyDataSize, void* outPropertyData);
+ virtual void SetProperty(AudioCodecPropertyID inPropertyID, UInt32 inPropertyDataSize, const void* inPropertyData);
+
+// Data Handling
+public:
+ bool IsInitialized() const { return mIsInitialized; }
+ virtual void Initialize(const AudioStreamBasicDescription* inInputFormat, const AudioStreamBasicDescription* inOutputFormat, const void* inMagicCookie, UInt32 inMagicCookieByteSize);
+ virtual void Uninitialize();
+ virtual void Reset();
+ virtual UInt32 GetInputBufferByteSize() const = 0;
+ virtual UInt32 GetUsedInputBufferByteSize() const = 0;
+
+protected:
+ virtual void ReallocateInputBuffer(UInt32 inInputBufferByteSize) = 0;
+
+ bool mIsInitialized;
+
+// Format Management
+public:
+ UInt32 GetNumberSupportedInputFormats() const;
+ void GetSupportedInputFormats(AudioStreamBasicDescription* outInputFormats, UInt32& ioNumberInputFormats) const;
+
+ void GetCurrentInputFormat(AudioStreamBasicDescription& outInputFormat);
+ virtual void SetCurrentInputFormat(const AudioStreamBasicDescription& inInputFormat);
+
+ UInt32 GetNumberSupportedOutputFormats() const;
+ void GetSupportedOutputFormats(AudioStreamBasicDescription* outOutputFormats, UInt32& ioNumberOutputFormats) const;
+
+ void GetCurrentOutputFormat(AudioStreamBasicDescription& outOutputFormat);
+ virtual void SetCurrentOutputFormat(const AudioStreamBasicDescription& inOutputFormat);
+
+ virtual UInt32 GetMagicCookieByteSize() const;
+ virtual void GetMagicCookie(void* outMagicCookieData, UInt32& ioMagicCookieDataByteSize) const;
+ virtual void SetMagicCookie(const void* outMagicCookieData, UInt32 inMagicCookieDataByteSize);
+
+ virtual bool ImplementsFeature(UInt32 /* feature */) const { return false; }
+ virtual void AppendInputBufferList(const AudioBufferList * /* ioBufferList */, UInt32& /* ioNumberPackets */, const AudioStreamPacketDescription * /* inPacketDescription */, UInt32 * /* outBytesConsumed */) { CODEC_THROW(-4); /*unimpErr*/ }
+ virtual UInt32 ProduceOutputBufferList(AudioBufferList * /* ioBufferList */, UInt32& /* ioNumberPackets */, AudioStreamPacketDescription * /* outPacketDescription */) { CODEC_THROW(-4); /*unimpErr*/ }
+protected:
+ void AddInputFormat(const AudioStreamBasicDescription& inInputFormat);
+ void AddOutputFormat(const AudioStreamBasicDescription& inOutputFormat);
+
+ OSType GetSubType();
+
+ typedef std::vector<CAStreamBasicDescription> FormatList;
+
+ FormatList mInputFormatList;
+#if TARGET_OS_WIN32
+ // VC 2005 screws up if this is not aligned to 8-byte boundaries
+ __declspec(align(8)) CAStreamBasicDescription mInputFormat;
+#else
+ CAStreamBasicDescription mInputFormat;
+#endif
+
+ FormatList mOutputFormatList;
+#if TARGET_OS_WIN32
+ // VC 2005 screws up if this is not aligned to 8-byte boundaries
+ __declspec(align(8)) CAStreamBasicDescription mOutputFormat;
+#else
+ CAStreamBasicDescription mOutputFormat;
+#endif
+ OSType mCodecSubType;
+ UInt32 mPadding[3]; // Align this with 16-byte boundaries
+
+};
+
+#endif
diff --git a/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACCodec.cpp b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACCodec.cpp
new file mode 100644
index 0000000000..512f93842a
--- /dev/null
+++ b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACCodec.cpp
@@ -0,0 +1,329 @@
+/*
+ File: ACCodec.cpp
+ Abstract: ACCodec.h
+ Version: 1.1
+
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
+ Inc. ("Apple") in consideration of your agreement to the following
+ terms, and your use, installation, modification or redistribution of
+ this Apple software constitutes acceptance of these terms. If you do
+ not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+
+ In consideration of your agreement to abide by the following terms, and
+ subject to these terms, Apple grants you a personal, non-exclusive
+ license, under Apple's copyrights in this original Apple software (the
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
+ Software, with or without modifications, in source and/or binary forms;
+ provided that if you redistribute the Apple Software in its entirety and
+ without modifications, you must retain this notice and the following
+ text and disclaimers in all such redistributions of the Apple Software.
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
+ be used to endorse or promote products derived from the Apple Software
+ without specific prior written permission from Apple. Except as
+ expressly stated in this notice, no other rights or licenses, express or
+ implied, are granted by Apple herein, including but not limited to any
+ patent rights that may be infringed by your derivative works or by other
+ works in which the Apple Software may be incorporated.
+
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+ Copyright (C) 2014 Apple Inc. All Rights Reserved.
+
+*/
+//=============================================================================
+// Includes
+//=============================================================================
+
+#include "ACCodec.h"
+
+//=============================================================================
+// ACCodec
+//=============================================================================
+
+ACCodec::ACCodec(AudioComponentInstance inInstance) : ComponentBase(inInstance)
+{
+}
+
+ACCodec::~ACCodec()
+{
+}
+
+#if !CA_USE_AUDIO_PLUGIN_ONLY && !TARGET_OS_IPHONE
+
+#if TARGET_OS_MAC
+ #if __LP64__
+ // comp instance, parameters in forward order
+ #define PARAM(_typ, _name, _index, _nparams) \
+ _typ _name = *(_typ *)((void*)&inParameters->params[_index + 1]);
+ #else
+ // parameters in reverse order, then comp instance
+ #define PARAM(_typ, _name, _index, _nparams) \
+ _typ _name = *(_typ *)((void*)&inParameters->params[_nparams - 1 - _index]);
+ #endif
+#elif TARGET_OS_WIN32
+ // (no comp instance), parameters in forward order
+ #define PARAM(_typ, _name, _index, _nparams) \
+ _typ _name = *(_typ *)&inParameters->params[_index];
+#endif
+
+OSStatus ACCodec::ComponentEntryDispatch(ComponentParameters *inParameters, ACCodec *inThis)
+{
+ OSStatus theError = kAudioCodecNoError;
+
+ try
+ {
+ switch (inParameters->what)
+ {
+ // these selectors don't use the object pointer
+
+ case kComponentOpenSelect:
+ case kComponentCloseSelect:
+ theError = ComponentBase::ComponentEntryDispatch(inParameters, inThis);
+ break;
+
+ case kComponentCanDoSelect:
+ {
+ switch (GetSelectorForCanDo(inParameters))
+ {
+ case kAudioCodecGetPropertyInfoSelect:
+ case kAudioCodecGetPropertySelect:
+ case kAudioCodecSetPropertySelect:
+ case kAudioCodecInitializeSelect:
+ case kAudioCodecUninitializeSelect: // was missing -- why?
+ case kAudioCodecAppendInputDataSelect:
+ case kAudioCodecProduceOutputDataSelect:
+ case kAudioCodecResetSelect:
+ theError = 1;
+ break;
+ default:
+ theError = ComponentBase::ComponentEntryDispatch(inParameters, inThis);
+ break;
+ }
+ }
+ break;
+
+ default:
+ // these selectors use the object pointer
+ if(inThis != NULL)
+ {
+ switch (inParameters->what)
+ {
+ case kComponentVersionSelect:
+ theError = inThis->Version();
+ break;
+
+ case kAudioCodecGetPropertyInfoSelect:
+ {
+ PARAM(AudioCodecPropertyID, inPropertyID, 0, 3);
+ PARAM(UInt32 *, outSize, 1, 3);
+ PARAM(Boolean *, outWritable, 2, 3);
+
+ UInt32 theSize = 0;
+ Boolean isWritable = false;
+
+ inThis->GetPropertyInfo(inPropertyID, theSize, isWritable);
+ if(outSize != NULL)
+ {
+ *outSize = theSize;
+ }
+ if(outWritable != NULL)
+ {
+ *outWritable = isWritable ? 1 : 0;
+ }
+ }
+ break;
+
+ case kAudioCodecGetPropertySelect:
+ {
+ PARAM(AudioCodecPropertyID, inPropertyID, 0, 3);
+ PARAM(UInt32 *, ioPropertyDataSize, 1, 3);
+ PARAM(void *, outPropertyData, 2, 3);
+
+ if((ioPropertyDataSize != NULL) && (outPropertyData != NULL))
+ {
+ inThis->GetProperty(inPropertyID, *ioPropertyDataSize, outPropertyData);
+ }
+ else
+ {
+ theError = kAudio_ParamError;
+ }
+ }
+ break;
+
+ case kAudioCodecSetPropertySelect:
+ {
+ PARAM(AudioCodecPropertyID, inPropertyID, 0, 3);
+ PARAM(UInt32, inPropertyDataSize, 1, 3);
+ PARAM(const void *, inPropertyData, 2, 3);
+
+ if(inPropertyData != NULL)
+ {
+ inThis->SetProperty(inPropertyID, inPropertyDataSize, inPropertyData);
+ }
+ else
+ {
+ theError = kAudio_ParamError;
+ }
+ }
+ break;
+
+ case kAudioCodecInitializeSelect:
+ {
+ PARAM(const AudioStreamBasicDescription *, inInputFormat, 0, 4);
+ PARAM(const AudioStreamBasicDescription *, inOutputFormat, 1, 4);
+ PARAM(const void *, inMagicCookie, 2, 4);
+ PARAM(UInt32, inMagicCookieByteSize, 3, 4);
+
+ inThis->Initialize(inInputFormat, inOutputFormat, inMagicCookie, inMagicCookieByteSize);
+ }
+ break;
+
+ case kAudioCodecUninitializeSelect:
+ {
+ inThis->Uninitialize();
+ }
+ break;
+
+ case kAudioCodecAppendInputDataSelect:
+ {
+ PARAM(const void *, inInputData, 0, 4);
+ PARAM(UInt32 *, ioInputDataByteSize, 1, 4);
+ PARAM(UInt32 *, ioNumberPackets, 2, 4);
+ PARAM(const AudioStreamPacketDescription *, inPacketDescription, 3, 4);
+
+ if((inInputData != NULL) && (ioInputDataByteSize != NULL))
+ {
+ if(ioNumberPackets != NULL)
+ {
+ inThis->AppendInputData(inInputData, *ioInputDataByteSize, *ioNumberPackets, inPacketDescription);
+ }
+ else
+ {
+ UInt32 theNumberPackets = 0;
+ inThis->AppendInputData(inInputData, *ioInputDataByteSize, theNumberPackets, inPacketDescription);
+ }
+ }
+ else
+ {
+ theError = kAudio_ParamError;
+ }
+ }
+ break;
+
+ case kAudioCodecProduceOutputDataSelect:
+ {
+ PARAM(void *, outOutputData, 0, 5);
+ PARAM(UInt32 *, ioOutputDataByteSize, 1, 5);
+ PARAM(UInt32 *, ioNumberPackets, 2, 5);
+ PARAM(AudioStreamPacketDescription *, outPacketDescription, 3, 5);
+ PARAM(UInt32 *, outStatus, 4, 5);
+
+ if((outOutputData != NULL) && (ioOutputDataByteSize != NULL) && (ioNumberPackets != NULL) && (outStatus != NULL))
+ {
+ *outStatus = inThis->ProduceOutputPackets(outOutputData, *ioOutputDataByteSize, *ioNumberPackets, outPacketDescription);
+ if(kAudioCodecProduceOutputPacketFailure == *outStatus)
+ {
+ theError = kAudio_ParamError;
+ }
+ }
+ else
+ {
+ theError = kAudio_ParamError;
+ }
+ }
+ break;
+
+#if AC_NON_INTERLEAVED_SUPPORT
+ case kAudioCodecAppendInputBufferListSelect:
+ {
+ PARAM(const AudioBufferList *, inBufferList, 0, 4);
+ PARAM(UInt32 *, ioNumberPackets, 1, 4);
+ PARAM(const AudioStreamPacketDescription *, inPacketDescription, 2, 4);
+ PARAM(UInt32 *, outBytesConsumed, 3, 4);
+
+ if((inBufferList != NULL) && (outBytesConsumed != NULL))
+ {
+ if(ioNumberPackets != NULL)
+ {
+ inThis->AppendInputBufferList(inBufferList, *ioNumberPackets, inPacketDescription, outBytesConsumed);
+ }
+ else
+ {
+ UInt32 theNumberPackets = 0;
+ inThis->AppendInputBufferList(inBufferList, theNumberPackets, inPacketDescription, outBytesConsumed);
+ }
+ }
+ else
+ {
+ theError = kAudio_ParamError;
+ }
+ }
+ break;
+
+ case kAudioCodecProduceOutputBufferListSelect:
+ {
+ PARAM(AudioBufferList *, ioBufferList, 0, 4);
+ PARAM(UInt32 *, ioNumberPackets, 1, 4);
+ PARAM(AudioStreamPacketDescription *, outPacketDescription, 2, 4);
+ PARAM(UInt32 *, outStatus, 3, 4);
+
+ if((ioBufferList != NULL) && (ioNumberPackets != NULL) && (outStatus != NULL))
+ {
+ *outStatus = inThis->ProduceOutputBufferList(ioBufferList, *ioNumberPackets, outPacketDescription);
+ if(kAudioCodecProduceOutputPacketFailure == *outStatus)
+ {
+ theError = kAudio_ParamError;
+ }
+ }
+ else
+ {
+ theError = kAudio_ParamError;
+ }
+ }
+ break;
+#endif // AC_NON_INTERLEAVED_SUPPORT
+
+ case kAudioCodecResetSelect:
+ {
+ inThis->Reset();
+ }
+ break;
+
+ default:
+ theError = badComponentSelector;
+ break;
+ };
+ }
+ else
+ {
+ theError = kAudio_ParamError;
+ }
+ break;
+ };
+ }
+ catch(OSStatus inErrorCode)
+ {
+ theError = inErrorCode;
+ }
+ catch(...)
+ {
+ theError = kAudioCodecUnspecifiedError;
+ }
+
+ return theError;
+}
+#endif // !CA_USE_AUDIO_PLUGIN_ONLY && !TARGET_OS_IPHONE
diff --git a/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACCodec.h b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACCodec.h
new file mode 100644
index 0000000000..b0d93165ab
--- /dev/null
+++ b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACCodec.h
@@ -0,0 +1,115 @@
+/*
+ File: ACCodec.h
+ Abstract: Part of CoreAudio Utility Classes
+ Version: 1.1
+
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
+ Inc. ("Apple") in consideration of your agreement to the following
+ terms, and your use, installation, modification or redistribution of
+ this Apple software constitutes acceptance of these terms. If you do
+ not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+
+ In consideration of your agreement to abide by the following terms, and
+ subject to these terms, Apple grants you a personal, non-exclusive
+ license, under Apple's copyrights in this original Apple software (the
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
+ Software, with or without modifications, in source and/or binary forms;
+ provided that if you redistribute the Apple Software in its entirety and
+ without modifications, you must retain this notice and the following
+ text and disclaimers in all such redistributions of the Apple Software.
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
+ be used to endorse or promote products derived from the Apple Software
+ without specific prior written permission from Apple. Except as
+ expressly stated in this notice, no other rights or licenses, express or
+ implied, are granted by Apple herein, including but not limited to any
+ patent rights that may be infringed by your derivative works or by other
+ works in which the Apple Software may be incorporated.
+
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+ Copyright (C) 2014 Apple Inc. All Rights Reserved.
+
+*/
+#if !defined(__ACCodec_h__)
+#define __ACCodec_h__
+
+//=============================================================================
+// Includes
+//=============================================================================
+
+
+
+#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
+ #include <AudioUnit/AudioCodec.h>
+#else
+ #include "AudioCodec.h"
+#endif
+
+#include "ComponentBase.h"
+
+//=============================================================================
+// ACCodec
+//
+// A totally abstract base class for implementing components that conform to
+// the AudioCodec API.
+//=============================================================================
+
+class ACCodec : public ComponentBase
+{
+
+// Construction/Destruction
+public:
+ ACCodec(AudioComponentInstance inInstance);
+ virtual ~ACCodec();
+
+#if !CA_USE_AUDIO_PLUGIN_ONLY && !TARGET_OS_IPHONE
+ static OSStatus ComponentEntryDispatch(ComponentParameters *p, ACCodec *This);
+#endif
+
+// Property Management
+public:
+ virtual void GetPropertyInfo(AudioCodecPropertyID inPropertyID, UInt32& outSize, Boolean& outWritable) = 0;
+ virtual void GetProperty(AudioCodecPropertyID inPropertyID, UInt32& ioPropertyDataSize, void* outPropertyData) = 0;
+ virtual void SetProperty(AudioCodecPropertyID inPropertyID, UInt32 inPropertyDataSize, const void* inPropertyData) = 0;
+
+// Data Handling
+public:
+ virtual void Initialize(const AudioStreamBasicDescription* inInputFormat, const AudioStreamBasicDescription* inOutputFormat, const void* inMagicCookie, UInt32 inMagicCookieByteSize) = 0;
+ virtual void Uninitialize() = 0;
+ virtual void Reset() = 0;
+
+ virtual void AppendInputData(const void* inInputData, UInt32& ioInputDataByteSize, UInt32& ioNumberPackets, const AudioStreamPacketDescription* inPacketDescription) = 0;
+ virtual void AppendInputBufferList(const AudioBufferList *ioBufferList, UInt32& ioNumberPackets, const AudioStreamPacketDescription *inPacketDescription, UInt32 *outBytesConsumed) = 0;
+
+ virtual UInt32 ProduceOutputPackets(void* outOutputData, UInt32& ioOutputDataByteSize, UInt32& ioNumberPackets, AudioStreamPacketDescription* outPacketDescription) = 0;
+ virtual UInt32 ProduceOutputBufferList(AudioBufferList *ioBufferList, UInt32& ioNumberPackets, AudioStreamPacketDescription *outPacketDescription) = 0;
+
+// Component Support
+public:
+// used internally
+ virtual bool ImplementsFeature(UInt32 feature) const = 0;
+};
+
+// when throwing static_cast to OSStatus so the catch will grab the error code correctly
+#define CODEC_THROW(err) \
+ throw static_cast<OSStatus>(err)
+
+#define CODEC_THROW_IF(cond, err) \
+ if(bool(cond)) CODEC_THROW(err);
+
+
+#endif
diff --git a/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACCodecDispatchTypes.h b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACCodecDispatchTypes.h
new file mode 100644
index 0000000000..42c2bc5ba6
--- /dev/null
+++ b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACCodecDispatchTypes.h
@@ -0,0 +1,259 @@
+/*
+ File: ACCodecDispatchTypes.h
+ Abstract: Part of CoreAudio Utility Classes
+ Version: 1.1
+
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
+ Inc. ("Apple") in consideration of your agreement to the following
+ terms, and your use, installation, modification or redistribution of
+ this Apple software constitutes acceptance of these terms. If you do
+ not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+
+ In consideration of your agreement to abide by the following terms, and
+ subject to these terms, Apple grants you a personal, non-exclusive
+ license, under Apple's copyrights in this original Apple software (the
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
+ Software, with or without modifications, in source and/or binary forms;
+ provided that if you redistribute the Apple Software in its entirety and
+ without modifications, you must retain this notice and the following
+ text and disclaimers in all such redistributions of the Apple Software.
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
+ be used to endorse or promote products derived from the Apple Software
+ without specific prior written permission from Apple. Except as
+ expressly stated in this notice, no other rights or licenses, express or
+ implied, are granted by Apple herein, including but not limited to any
+ patent rights that may be infringed by your derivative works or by other
+ works in which the Apple Software may be incorporated.
+
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+ Copyright (C) 2014 Apple Inc. All Rights Reserved.
+
+*/
+#if !defined(__ACCodecDispatchTypes_h__)
+#define __ACCodecDispatchTypes_h__
+
+//=============================================================================
+// Includes
+//=============================================================================
+
+// note that AudioCodec.h needs to be included prior to including this file
+#if !defined(__AudioCodec_h__)
+ #error AudioCodec.h needs to be included prior to including this file
+#endif
+
+//=============================================================================
+// Parameter Blocks for AudioCodec Component Routines
+//
+// Note that the arguments for all the AudioCodec component routines are
+// 4 bytes in size (assuming pointers are 4 bytes). This means that even on
+// Windows (where all arguments are forced into SInt32s), we can get away with
+// mass casting the argument list through the appropriate paramblock structure.
+// This gets around the fact that the component glue passes the arguments in
+// a different order depending on the platform and therefore makes writing the
+// calling glue and the dispatcher much simpler.
+//=============================================================================
+
+#if PRAGMA_STRUCT_ALIGN
+ #pragma options align=mac68k
+#elif PRAGMA_STRUCT_PACKPUSH
+ #pragma pack(push, 2)
+#elif PRAGMA_STRUCT_PACK
+ #pragma pack(2)
+#endif
+
+#define AudioCodecStandardGluePBFields UInt8 componentFlags; UInt8 componentParamSize; SInt16 componentWhat
+
+#if !TARGET_OS_WIN32
+struct AudioCodecOpenGluePB {
+ AudioCodecStandardGluePBFields;
+ AudioCodec inCodec;
+ void* unused;
+};
+#else
+struct AudioCodecOpenGluePB {
+ AudioCodecStandardGluePBFields;
+ AudioCodec inCodec;
+};
+#endif
+typedef struct AudioCodecOpenGluePB AudioCodecOpenGluePB;
+
+#if !TARGET_OS_WIN32
+struct AudioCodecGetPropertyInfoGluePB
+{
+ AudioCodecStandardGluePBFields;
+ Boolean* outWritable;
+ UInt32* outSize;
+ AudioCodecPropertyID inPropertyID;
+ AudioCodec inCodec;
+};
+#else
+struct AudioCodecGetPropertyInfoGluePB
+{
+ AudioCodecStandardGluePBFields;
+ AudioCodecPropertyID inPropertyID;
+ UInt32* outSize;
+ Boolean* outWritable;
+};
+#endif
+typedef struct AudioCodecGetPropertyInfoGluePB AudioCodecGetPropertyInfoGluePB;
+
+#if !TARGET_OS_WIN32
+struct AudioCodecGetPropertyGluePB
+{
+ AudioCodecStandardGluePBFields;
+ void* outPropertyData;
+ UInt32* ioPropertyDataSize;
+ AudioCodecPropertyID inPropertyID;
+ AudioCodec inCodec;
+};
+#else
+struct AudioCodecGetPropertyGluePB
+{
+ AudioCodecStandardGluePBFields;
+ AudioCodecPropertyID inPropertyID;
+ UInt32* ioPropertyDataSize;
+ void* outPropertyData;
+};
+#endif
+typedef struct AudioCodecGetPropertyGluePB AudioCodecGetPropertyGluePB;
+
+#if !TARGET_OS_WIN32
+struct AudioCodecSetPropertyGluePB
+{
+ AudioCodecStandardGluePBFields;
+ const void* inPropertyData;
+ UInt32 inPropertyDataSize;
+ AudioCodecPropertyID inPropertyID;
+ AudioCodec inCodec;
+};
+#else
+struct AudioCodecSetPropertyGluePB
+{
+ AudioCodecStandardGluePBFields;
+ AudioCodecPropertyID inPropertyID;
+ UInt32 inPropertyDataSize;
+ const void* inPropertyData;
+};
+#endif
+typedef struct AudioCodecSetPropertyGluePB AudioCodecSetPropertyGluePB;
+
+#if !TARGET_OS_WIN32
+struct AudioCodecInitializeGluePB
+{
+ AudioCodecStandardGluePBFields;
+ UInt32 inMagicCookieByteSize;
+ const void* inMagicCookie;
+ const AudioStreamBasicDescription* inOutputFormat;
+ const AudioStreamBasicDescription* inInputFormat;
+ AudioCodec inCodec;
+};
+#else
+struct AudioCodecInitializeGluePB
+{
+ AudioCodecStandardGluePBFields;
+ const AudioStreamBasicDescription* inInputFormat;
+ const AudioStreamBasicDescription* inOutputFormat;
+ const void* inMagicCookie;
+ UInt32 inMagicCookieByteSize;
+};
+#endif
+typedef struct AudioCodecInitializeGluePB AudioCodecInitializeGluePB;
+
+#if !TARGET_OS_WIN32
+struct AudioCodecUninitializeGluePB
+{
+ AudioCodecStandardGluePBFields;
+ AudioCodec inCodec;
+};
+#else
+struct AudioCodecUninitializeGluePB
+{
+ AudioCodecStandardGluePBFields;
+};
+#endif
+typedef struct AudioCodecUninitializeGluePB AudioCodecUninitializeGluePB;
+
+#if !TARGET_OS_WIN32
+struct AudioCodecAppendInputDataGluePB
+{
+ AudioCodecStandardGluePBFields;
+ const AudioStreamPacketDescription* inPacketDescription;
+ UInt32* ioNumberPackets;
+ UInt32* ioInputDataByteSize;
+ const void* inInputData;
+ AudioCodec inCodec;
+};
+#else
+struct AudioCodecAppendInputDataGluePB
+{
+ AudioCodecStandardGluePBFields;
+ const void* inInputData;
+ UInt32* ioInputDataByteSize;
+ UInt32* ioNumberPackets;
+ const AudioStreamPacketDescription* inPacketDescription;
+};
+#endif
+typedef struct AudioCodecAppendInputDataGluePB AudioCodecAppendInputDataGluePB;
+
+#if !TARGET_OS_WIN32
+struct AudioCodecProduceOutputPacketsGluePB
+{
+ AudioCodecStandardGluePBFields;
+ UInt32* outStatus;
+ AudioStreamPacketDescription* outPacketDescription;
+ UInt32* ioNumberPackets;
+ UInt32* ioOutputDataByteSize;
+ void* outOutputData;
+ AudioCodec inCodec;
+};
+#else
+struct AudioCodecProduceOutputPacketsGluePB
+{
+ AudioCodecStandardGluePBFields;
+ void* outOutputData;
+ UInt32* ioOutputDataByteSize;
+ UInt32* ioNumberPackets;
+ AudioStreamPacketDescription* outPacketDescription;
+ UInt32* outStatus;
+};
+#endif
+typedef struct AudioCodecProduceOutputPacketsGluePB AudioCodecProduceOutputPacketsGluePB;
+
+#if !TARGET_OS_WIN32
+struct AudioCodecResetGluePB
+{
+ AudioCodecStandardGluePBFields;
+ AudioCodec inCodec;
+};
+#else
+struct AudioCodecResetGluePB
+{
+ AudioCodecStandardGluePBFields;
+};
+#endif
+typedef struct AudioCodecResetGluePB AudioCodecResetGluePB;
+
+#if PRAGMA_STRUCT_ALIGN
+ #pragma options align=reset
+#elif PRAGMA_STRUCT_PACKPUSH
+ #pragma pack(pop)
+#elif PRAGMA_STRUCT_PACK
+ #pragma pack()
+#endif
+
+#endif
diff --git a/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACComponentResources.r b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACComponentResources.r
new file mode 100644
index 0000000000..a84fd11ad9
--- /dev/null
+++ b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACComponentResources.r
@@ -0,0 +1,196 @@
+/*
+ File: ACComponentResources.r
+ Abstract: ACComponentResources.r
+ Version: 1.1
+
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
+ Inc. ("Apple") in consideration of your agreement to the following
+ terms, and your use, installation, modification or redistribution of
+ this Apple software constitutes acceptance of these terms. If you do
+ not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+
+ In consideration of your agreement to abide by the following terms, and
+ subject to these terms, Apple grants you a personal, non-exclusive
+ license, under Apple's copyrights in this original Apple software (the
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
+ Software, with or without modifications, in source and/or binary forms;
+ provided that if you redistribute the Apple Software in its entirety and
+ without modifications, you must retain this notice and the following
+ text and disclaimers in all such redistributions of the Apple Software.
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
+ be used to endorse or promote products derived from the Apple Software
+ without specific prior written permission from Apple. Except as
+ expressly stated in this notice, no other rights or licenses, express or
+ implied, are granted by Apple herein, including but not limited to any
+ patent rights that may be infringed by your derivative works or by other
+ works in which the Apple Software may be incorporated.
+
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+ Copyright (C) 2014 Apple Inc. All Rights Reserved.
+
+*/
+#ifndef GEN_MISSING
+ #define GEN_MISSING 0
+#endif
+
+#ifndef thng_RezTemplateVersion
+ #define thng_RezTemplateVersion 2
+#endif
+
+//=============================================================================
+// Includes
+//=============================================================================
+
+#include "ConditionalMacros.r"
+#include "MacTypes.r"
+#include "Components.r"
+
+//=============================================================================
+// Platform constants for the thng resources
+//=============================================================================
+
+#if TARGET_OS_MAC && TARGET_API_MAC_OSX
+ #define Target_PlatformType 1000
+ #define Target_CodeResType 'dlle'
+ #define kUseDLLEResource 1
+#elif TARGET_OS_WIN32
+ #define Target_PlatformType platformWin32
+ #define Target_CodeResType 'dlle'
+ #define kUseDLLEResource 1
+#else
+ #define Target_PlatformType platformPowerPC
+ #define Target_CodeResType 'tppc'
+ #define kUseDLLEResource 0
+#endif
+
+#if kComponentIsThreadSafe
+ #ifndef cmpThreadSafeOnMac // so we don't need Panther headers to build
+ #define cmpThreadSafeOnMac 0x10000000
+ #endif
+ #define COMPONENT_FLAGS cmpThreadSafeOnMac
+#else
+ #define COMPONENT_FLAGS 0
+#endif
+
+//=============================================================================
+// The thng and related resources
+//
+// The definitions below use the following macros, all of which must be
+// defined. Note that kPrimaryResourceID is used to define two 'STR '
+// resources with consecutive IDs so be sure to space them at least two'
+// apart. Here's a sample of how to do the defines:
+//
+// #define kPrimaryResourceID 128
+// #define kComponentType 'aenc'
+// #define kComponentSubtype 'ima4'
+// #define kComponentManufacturer 'appl'
+// #define kComponentFlags 0
+// #define kComponentVersion 0x00010000
+// #define kComponentName "Apple IMA4 Encoder"
+// #define kComponentInfo "An AudioCodec that encodes linear PCM data into IMA4"
+// #define kComponentEntryPoint "ACAppleIMA4EncoderEntry"
+// #define kComponentPublicResourceMapType 0
+// #define kComponentIsThreadSafe 1
+//=============================================================================
+
+#ifndef AC_LOCALIZED
+resource 'strn' (kPrimaryResourceID, purgeable)
+{
+ kComponentName
+};
+
+resource 'stri' (kPrimaryResourceID, purgeable)
+{
+ kComponentInfo
+};
+#endif
+
+#if !GEN_MISSING
+
+#if kUseDLLEResource
+
+ resource 'dlle' (kPrimaryResourceID)
+ {
+ kComponentEntryPoint
+ };
+
+#endif
+
+#define kComponentRegistrationFlags componentHasMultiplePlatforms | componentDoAutoVersion | componentLoadResident
+resource 'thng' (kPrimaryResourceID, kComponentName)
+{
+ kComponentType, // Component type
+ kComponentSubtype, // Component subtype
+ kComponentManufacturer, // Component manufacturer
+ kComponentFlags, // Component flags
+ 0, // Component flags mask
+ 0, 0, // Code type, Code ID
+ 'strn', kPrimaryResourceID, // Name resource type, resource ID
+ 'stri', kPrimaryResourceID, // Info resource type, resource ID
+ 0, 0, // Icon resource type, resource ID
+ kComponentVersion, // Component version
+ kComponentRegistrationFlags, // Registration flags
+ 0, // Icon family resource ID
+ { // Beginning of platform info
+ COMPONENT_FLAGS, // Component flags
+ Target_CodeResType, kPrimaryResourceID, // Code resource type, resource ID
+ Target_PlatformType, // Platform type
+ },
+#if thng_RezTemplateVersion >= 2
+ kComponentPublicResourceMapType, kPrimaryResourceID // Resource map type, resource map ID
+#endif
+};
+
+#else // GEN_MISSING
+
+resource 'thga' (kPrimaryResourceID) {
+ kComponentType, // Component type
+ kComponentSubtype, // Component subtype
+ kComponentManufacturer, // Component manufacturer
+ kComponentFlags, // Component flags
+ 0, // Component flags mask
+ 0, 0, // Code type, Code ID
+ 'strn', kPrimaryResourceID, // Name resource type, resource ID
+ 'stri', kPrimaryResourceID, // Info resource type, resource ID
+ 0, 0, // Icon resource type, resource ID
+ 'miss', // Alias component type
+ 'base', // Alias component subtype
+ 0, // Alias component manufacturer
+ 0, // Alias component flags
+ 0, // Alias component flags mask
+#if thng_RezTemplateVersion >= 2
+ kComponentPublicResourceMapType, kPrimaryResourceID, // Resource map type, resource map ID
+ cmpAliasNoFlags // Alias flags
+#endif
+};
+
+#endif // GEN_MISSING
+
+#undef kPrimaryResourceID
+#undef kComponentType
+#undef kComponentSubtype
+#undef kComponentManufacturer
+#undef kComponentVersion
+#undef kComponentRegistrationFlags
+#undef kComponentName
+#undef kComponentInfo
+#undef kComponentEntryPoint
+#undef kComponentPublicResourceMapType
+#undef Target_PlatformType
+#undef Target_CodeResType
+#undef kUseDLLEResource
diff --git a/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACConditionalMacros.h b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACConditionalMacros.h
new file mode 100644
index 0000000000..2cff483fde
--- /dev/null
+++ b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACConditionalMacros.h
@@ -0,0 +1,73 @@
+/*
+ File: ACConditionalMacros.h
+ Abstract: Part of CoreAudio Utility Classes
+ Version: 1.1
+
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
+ Inc. ("Apple") in consideration of your agreement to the following
+ terms, and your use, installation, modification or redistribution of
+ this Apple software constitutes acceptance of these terms. If you do
+ not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+
+ In consideration of your agreement to abide by the following terms, and
+ subject to these terms, Apple grants you a personal, non-exclusive
+ license, under Apple's copyrights in this original Apple software (the
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
+ Software, with or without modifications, in source and/or binary forms;
+ provided that if you redistribute the Apple Software in its entirety and
+ without modifications, you must retain this notice and the following
+ text and disclaimers in all such redistributions of the Apple Software.
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
+ be used to endorse or promote products derived from the Apple Software
+ without specific prior written permission from Apple. Except as
+ expressly stated in this notice, no other rights or licenses, express or
+ implied, are granted by Apple herein, including but not limited to any
+ patent rights that may be infringed by your derivative works or by other
+ works in which the Apple Software may be incorporated.
+
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+ Copyright (C) 2014 Apple Inc. All Rights Reserved.
+
+*/
+#if !defined(__ACConditionalMacros_h__)
+#define __ACConditionalMacros_h__
+
+//=============================================================================
+// This file exists to make figuring out how to include system headers
+// easier. We throw in an include of the standard ConditionalMacros too.
+//=============================================================================
+
+// TargetConditionals.h defines the bare minimum we need
+#include "TargetConditionals.h"
+
+// Determine whether or not to use framework style includes for system headers
+#if !defined(AC_Use_Framework_Includes)
+ #if TARGET_OS_MAC && TARGET_RT_MAC_MACHO
+ #define AC_Use_Framework_Includes 1
+ #else
+ #define AC_Use_Framework_Includes 0
+ #endif
+#endif
+
+#if AC_Use_Framework_Includes
+ #include <CoreServices/../Frameworks/CarbonCore.framework/Headers/ConditionalMacros.h>
+#else
+ #include "ConditionalMacros.h"
+#endif
+
+#endif
diff --git a/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACPlugInDispatch.cpp b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACPlugInDispatch.cpp
new file mode 100644
index 0000000000..de9599b186
--- /dev/null
+++ b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACPlugInDispatch.cpp
@@ -0,0 +1,283 @@
+/*
+ File: ACPlugInDispatch.cpp
+ Abstract: ACPlugInDispatch.h
+ Version: 1.1
+
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
+ Inc. ("Apple") in consideration of your agreement to the following
+ terms, and your use, installation, modification or redistribution of
+ this Apple software constitutes acceptance of these terms. If you do
+ not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+
+ In consideration of your agreement to abide by the following terms, and
+ subject to these terms, Apple grants you a personal, non-exclusive
+ license, under Apple's copyrights in this original Apple software (the
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
+ Software, with or without modifications, in source and/or binary forms;
+ provided that if you redistribute the Apple Software in its entirety and
+ without modifications, you must retain this notice and the following
+ text and disclaimers in all such redistributions of the Apple Software.
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
+ be used to endorse or promote products derived from the Apple Software
+ without specific prior written permission from Apple. Except as
+ expressly stated in this notice, no other rights or licenses, express or
+ implied, are granted by Apple herein, including but not limited to any
+ patent rights that may be infringed by your derivative works or by other
+ works in which the Apple Software may be incorporated.
+
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+ Copyright (C) 2014 Apple Inc. All Rights Reserved.
+
+*/
+#if AUDIOCODECS_SUPPORT_PLUGINS
+#include "ACPlugInDispatch.h"
+#include "CAXException.h"
+#include "ACCodec.h"
+#include <new>
+
+#define ACPI ((AudioComponentPlugInInstance *)self)
+#define ACC ((ACCodec *)&ACPI->mInstanceStorage)
+
+static OSStatus GetPropertyInfo(void *self, AudioCodecPropertyID inPropertyID, UInt32 *outSize, Boolean *outWritable)
+{
+ OSStatus result = noErr;
+ try {
+ UInt32 size;
+ Boolean writable;
+ ACC->GetPropertyInfo(inPropertyID, size, writable);
+ if (outSize) *outSize = size;
+ if (outWritable) *outWritable = writable;
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus GetProperty(void *self, AudioCodecPropertyID inPropertyID, UInt32 *ioPropertyDataSize, void *outPropertyData)
+{
+ OSStatus result = noErr;
+ try {
+ ACC->GetProperty(inPropertyID, *ioPropertyDataSize, outPropertyData);
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus SetProperty(void *self, AudioCodecPropertyID inPropertyID, UInt32 inPropertyDataSize, const void *inPropertyData)
+{
+ OSStatus result = noErr;
+ try {
+ ACC->SetProperty(inPropertyID, inPropertyDataSize, inPropertyData);
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+
+static OSStatus Initialize(void *self, const AudioStreamBasicDescription *inInputFormat, const AudioStreamBasicDescription *inOutputFormat, const void *inMagicCookie, UInt32 inMagicCookieByteSize)
+{
+ OSStatus result = noErr;
+ try {
+ ACC->Initialize(inInputFormat, inOutputFormat, inMagicCookie, inMagicCookieByteSize);
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus Uninitialize(void *self)
+{
+ OSStatus result = noErr;
+ try {
+ ACC->Uninitialize();
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus AppendInputData(void *self, const void *inInputData, UInt32 *ioInputDataByteSize, UInt32 *ioNumberPackets, const AudioStreamPacketDescription *inPacketDescription)
+{
+ OSStatus result = noErr;
+ try {
+ UInt32 npackets = (ioNumberPackets != NULL) ? *ioNumberPackets : 0;
+ ACC->AppendInputData(inInputData, *ioInputDataByteSize, npackets, inPacketDescription);
+ if(ioNumberPackets != NULL)
+ *ioNumberPackets = npackets;
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus ProduceOutputPackets(void *self, void *outOutputData, UInt32 *ioOutputDataByteSize, UInt32 *ioNumberPackets, AudioStreamPacketDescription *outPacketDescription, UInt32 *outStatus)
+{
+ OSStatus result = noErr;
+ try {
+ *outStatus = ACC->ProduceOutputPackets(outOutputData, *ioOutputDataByteSize, *ioNumberPackets, outPacketDescription);
+ if (*outStatus == kAudioCodecProduceOutputPacketFailure)
+ result = kAudio_ParamError;
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus Reset(void *self)
+{
+ OSStatus result = noErr;
+ try {
+ ACC->Reset();
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+#if AC_NON_INTERLEAVED_SUPPORT
+static OSStatus AppendInputBufferList(void *self, const AudioBufferList *ioBufferList, UInt32 *inNumberPackets, const AudioStreamPacketDescription *inPacketDescription, UInt32 *outBytesConsumed)
+{
+ OSStatus result = noErr;
+ try {
+ if((ioBufferList != NULL) && (outBytesConsumed != NULL))
+ {
+ if(inNumberPackets != NULL)
+ {
+ ACC->AppendInputBufferList(ioBufferList, *inNumberPackets, inPacketDescription, outBytesConsumed);
+ }
+ else
+ {
+ UInt32 theNumberPackets = 0;
+ ACC->AppendInputBufferList(ioBufferList, theNumberPackets, inPacketDescription, outBytesConsumed);
+ }
+ }
+ else
+ {
+ result = kAudio_ParamError;
+ }
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus ProduceOutputBufferList(void *self, AudioBufferList *ioBufferList, UInt32 *ioNumberPackets, AudioStreamPacketDescription *outPacketDescription, UInt32 *outStatus)
+{
+ OSStatus result = noErr;
+ try {
+ if((ioBufferList != NULL) && (ioNumberPackets != NULL) && (outStatus != NULL))
+ {
+ *outStatus = ACC->ProduceOutputBufferList(ioBufferList, *ioNumberPackets, outPacketDescription);
+ if(kAudioCodecProduceOutputPacketFailure == *outStatus)
+ {
+ result = kAudio_ParamError;
+ }
+ }
+ else
+ {
+ result = kAudio_ParamError;
+ }
+ }
+ COMPONENT_CATCH
+ return result;
+}
+#endif
+
+#if TARGET_OS_IPHONE && AUDIOCONV_HAVE_AMC
+// The ACTransformerCodecBase class is the base for ALL hardware codecs.
+// No need to check for ImplementFeature...
+#include "ACTransformerManager.h"
+#define ACTM ((ACTransformerCodecBase*)&ACPI->mInstanceStorage)
+
+static OSStatus AcquireHardware(void *self)
+{
+ OSStatus result = noErr;
+ try {
+ ACTM->AcquireHardware();
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus ReleaseHardware(void *self)
+{
+ OSStatus result = noErr;
+ try {
+ ACTM->ReleaseHardware();
+ }
+ COMPONENT_CATCH
+ return result;
+}
+#endif // TARGET_OS_IPHONE && AUDIOCONV_HAVE_AMC
+
+
+AudioComponentMethod AudioCodecLookup::Lookup (SInt16 selector)
+{
+ switch (selector) {
+ case kAudioCodecGetPropertyInfoSelect: return (AudioComponentMethod)GetPropertyInfo;
+ case kAudioCodecGetPropertySelect: return (AudioComponentMethod)GetProperty;
+ case kAudioCodecSetPropertySelect: return (AudioComponentMethod)SetProperty;
+ case kAudioCodecInitializeSelect: return (AudioComponentMethod)Initialize;
+ case kAudioCodecUninitializeSelect: return (AudioComponentMethod)Uninitialize;
+ case kAudioCodecAppendInputDataSelect: return (AudioComponentMethod)AppendInputData;
+ case kAudioCodecProduceOutputDataSelect: return (AudioComponentMethod)ProduceOutputPackets;
+ case kAudioCodecResetSelect: return (AudioComponentMethod)Reset;
+ default:
+ break;
+ }
+ return NULL;
+}
+
+#if AC_NON_INTERLEAVED_SUPPORT
+AudioComponentMethod AudioCodecNonInterleavedEncoderLookup::Lookup (SInt16 selector)
+{
+ AudioComponentMethod method = AudioCodecLookup::Lookup(selector);
+ if (method)
+ return method;
+
+ if (selector == kAudioCodecAppendInputBufferListSelect)
+ return (AudioComponentMethod)AppendInputBufferList;
+
+ return NULL;
+}
+
+AudioComponentMethod AudioCodecNonInterleavedDecoderLookup::Lookup (SInt16 selector)
+{
+ AudioComponentMethod method = AudioCodecLookup::Lookup(selector);
+ if (method)
+ return method;
+
+ if (selector == kAudioCodecProduceOutputBufferListSelect)
+ return (AudioComponentMethod)ProduceOutputBufferList;
+
+ return NULL;
+}
+#endif
+
+#if TARGET_OS_IPHONE && AUDIOCONV_HAVE_AMC
+#include "AudioCodecPriv.h"
+
+AudioComponentMethod AudioCodecHWCodecLookup::Lookup (SInt16 selector)
+{
+ AudioComponentMethod method = AudioCodecLookup::Lookup(selector);
+ if (method) return method;
+
+ switch (selector) {
+ case kAudioCodecAcquireHardwareSelect: return (AudioComponentMethod)AcquireHardware;
+ case kAudioCodecReleaseHardwareSelect: return (AudioComponentMethod)ReleaseHardware;
+ default:
+ break;
+ }
+ return NULL;
+}
+#endif // TARGET_OS_IPHONE && AUDIOCONV_HAVE_AMC
+
+#endif // AUDIOCODECS_SUPPORT_PLUGINS
diff --git a/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACPlugInDispatch.h b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACPlugInDispatch.h
new file mode 100644
index 0000000000..252a4af0aa
--- /dev/null
+++ b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACPlugInDispatch.h
@@ -0,0 +1,88 @@
+/*
+ File: ACPlugInDispatch.h
+ Abstract: Part of CoreAudio Utility Classes
+ Version: 1.1
+
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
+ Inc. ("Apple") in consideration of your agreement to the following
+ terms, and your use, installation, modification or redistribution of
+ this Apple software constitutes acceptance of these terms. If you do
+ not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+
+ In consideration of your agreement to abide by the following terms, and
+ subject to these terms, Apple grants you a personal, non-exclusive
+ license, under Apple's copyrights in this original Apple software (the
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
+ Software, with or without modifications, in source and/or binary forms;
+ provided that if you redistribute the Apple Software in its entirety and
+ without modifications, you must retain this notice and the following
+ text and disclaimers in all such redistributions of the Apple Software.
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
+ be used to endorse or promote products derived from the Apple Software
+ without specific prior written permission from Apple. Except as
+ expressly stated in this notice, no other rights or licenses, express or
+ implied, are granted by Apple herein, including but not limited to any
+ patent rights that may be infringed by your derivative works or by other
+ works in which the Apple Software may be incorporated.
+
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+ Copyright (C) 2014 Apple Inc. All Rights Reserved.
+
+*/
+#ifndef __ACPlugInDispatch_h__
+#define __ACPlugInDispatch_h__
+
+#include "ComponentBase.h"
+
+struct AudioCodecLookup {
+ static AudioComponentMethod Lookup (SInt16 selector);
+};
+template <class Implementor>
+class AudioCodecFactory : public APFactory<AudioCodecLookup, Implementor>
+{
+};
+
+#if AC_NON_INTERLEAVED_SUPPORT
+struct AudioCodecNonInterleavedEncoderLookup {
+ static AudioComponentMethod Lookup (SInt16 selector);
+};
+template <class Implementor>
+class AudioCodecNonInterleavedEncoderFactory : public APFactory<AudioCodecNonInterleavedEncoderLookup, Implementor>
+{
+};
+
+struct AudioCodecNonInterleavedDecoderLookup {
+ static AudioComponentMethod Lookup (SInt16 selector);
+};
+template <class Implementor>
+class AudioCodecNonInterleavedDecoderFactory : public APFactory<AudioCodecNonInterleavedDecoderLookup, Implementor>
+{
+};
+#endif
+
+#if TARGET_OS_IPHONE
+struct AudioCodecHWCodecLookup {
+ static AudioComponentMethod Lookup (SInt16 selector);
+};
+template <class Implementor>
+class AudioCodecHWCodecFactory : public APFactory<AudioCodecHWCodecLookup, Implementor>
+{
+};
+#endif // TARGET_OS_IPHONE
+
+#endif // __ACPlugInDispatch_h__
diff --git a/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACSimpleCodec.cpp b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACSimpleCodec.cpp
new file mode 100644
index 0000000000..b10add9dac
--- /dev/null
+++ b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACSimpleCodec.cpp
@@ -0,0 +1,364 @@
+/*
+ File: ACSimpleCodec.cpp
+ Abstract: ACSimpleCodec.h
+ Version: 1.1
+
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
+ Inc. ("Apple") in consideration of your agreement to the following
+ terms, and your use, installation, modification or redistribution of
+ this Apple software constitutes acceptance of these terms. If you do
+ not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+
+ In consideration of your agreement to abide by the following terms, and
+ subject to these terms, Apple grants you a personal, non-exclusive
+ license, under Apple's copyrights in this original Apple software (the
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
+ Software, with or without modifications, in source and/or binary forms;
+ provided that if you redistribute the Apple Software in its entirety and
+ without modifications, you must retain this notice and the following
+ text and disclaimers in all such redistributions of the Apple Software.
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
+ be used to endorse or promote products derived from the Apple Software
+ without specific prior written permission from Apple. Except as
+ expressly stated in this notice, no other rights or licenses, express or
+ implied, are granted by Apple herein, including but not limited to any
+ patent rights that may be infringed by your derivative works or by other
+ works in which the Apple Software may be incorporated.
+
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+ Copyright (C) 2014 Apple Inc. All Rights Reserved.
+
+*/
+//=============================================================================
+// Includes
+//=============================================================================
+
+#include "ACSimpleCodec.h"
+#include <string.h>
+
+//=============================================================================
+// ACSimpleCodec
+//=============================================================================
+
+static const UInt32 kBufferPad = 64; // this is used to prevent end from passing start.
+
+ACSimpleCodec::ACSimpleCodec(UInt32 inInputBufferByteSize, AudioComponentInstance inInstance)
+:
+ ACBaseCodec(inInstance),
+ mInputBuffer(NULL),
+ mInputBufferByteSize(inInputBufferByteSize+kBufferPad),
+ mInputBufferStart(0),
+ mInputBufferEnd(0)
+{
+}
+
+ACSimpleCodec::~ACSimpleCodec()
+{
+ delete[] mInputBuffer;
+}
+
+void ACSimpleCodec::Initialize(const AudioStreamBasicDescription* inInputFormat, const AudioStreamBasicDescription* inOutputFormat, const void* inMagicCookie, UInt32 inMagicCookieByteSize)
+{
+ ReallocateInputBuffer(mInputBufferByteSize - kBufferPad);
+
+ // By definition CBR has this greater than 0. We must avoid a div by 0 error in AppendInputData()
+ // Note this will cause us to fail initialization which is intended
+ if (mInputFormat.mBytesPerPacket == 0)
+ {
+ CODEC_THROW(kAudioCodecUnsupportedFormatError);
+ }
+
+ ACBaseCodec::Initialize(inInputFormat, inOutputFormat, inMagicCookie, inMagicCookieByteSize);
+}
+
+void ACSimpleCodec::Uninitialize()
+{
+ // get rid of the buffer
+ delete[] mInputBuffer;
+ mInputBuffer = NULL;
+
+ // reset the ring buffer state
+ mInputBufferStart = 0;
+ mInputBufferEnd = 0;
+
+ ACBaseCodec::Uninitialize();
+}
+
+void ACSimpleCodec::Reset()
+{
+ // clear the entire input buffer
+ if (mInputBuffer) { // could be called before allocated.
+ memset(mInputBuffer, 0, mInputBufferByteSize);
+ }
+
+ // reset the ring buffer state
+ mInputBufferStart = 0;
+ mInputBufferEnd = 0;
+
+ ACBaseCodec::Reset();
+}
+
+UInt32 ACSimpleCodec::GetInputBufferByteSize() const
+{
+ return mInputBufferByteSize - kBufferPad; // minus kBufferPad to prevent end moving past start
+}
+
+UInt32 ACSimpleCodec::GetUsedInputBufferByteSize() const
+{
+ UInt32 theAnswer = 0;
+
+ // this object uses a ring buffer
+ if(mInputBufferStart <= mInputBufferEnd)
+ {
+ // the active region is contiguous
+ theAnswer = mInputBufferEnd - mInputBufferStart;
+ }
+ else
+ {
+ // the active region wraps around
+ theAnswer = (mInputBufferByteSize - mInputBufferStart) + mInputBufferEnd;
+ }
+
+ return theAnswer;
+}
+
+
+void ACSimpleCodec::AppendInputData(const void* inInputData, UInt32& ioInputDataByteSize, UInt32& ioNumberPackets, const AudioStreamPacketDescription* inPacketDescription)
+{
+ // this buffer handling code doesn't care about such things as the packet descriptions
+ if(!mIsInitialized) CODEC_THROW(kAudioCodecStateError);
+
+ // this is a ring buffer we're dealing with, so we need to set up a few things
+ UInt32 theUsedByteSize = GetUsedInputBufferByteSize();
+ UInt32 theAvailableByteSize = GetInputBufferByteSize() - theUsedByteSize;
+
+ UInt32 theMaxAvailableInputBytes = ioInputDataByteSize; // we can't consume more than we get
+
+ const Byte* theInputData = static_cast<const Byte*>(inInputData);
+
+ // >>jamesmcc: added this because ioNumberPackets was not being updated if less was taken than given.
+ // THIS ASSUMES CBR!
+ UInt32 bytesPerPacketOfInput = mInputFormat.mBytesPerPacket;
+ UInt32 theAvailablePacketSize = theAvailableByteSize / bytesPerPacketOfInput;
+
+ UInt32 minPacketSize = ioNumberPackets < theAvailablePacketSize ? ioNumberPackets : theAvailablePacketSize;
+ UInt32 minByteSize = minPacketSize * bytesPerPacketOfInput;
+
+ // we can copy only as much data as there is or up to how much space is availiable
+ ioNumberPackets = minPacketSize;
+ ioInputDataByteSize = minByteSize;
+
+ // ioInputDataByteSize had better be <= to theMaxAvailableInputBytes or we're screwed
+ if (ioInputDataByteSize > theMaxAvailableInputBytes)
+ {
+ CODEC_THROW(kAudioCodecStateError);
+ }
+ // <<jamesmcc
+
+ // now we have to copy the data taking into account the wrap around and where the start is
+ if(mInputBufferEnd + ioInputDataByteSize < mInputBufferByteSize)
+ {
+ // no wrap around here
+ memcpy(mInputBuffer + mInputBufferEnd, theInputData, ioInputDataByteSize);
+
+ // adjust the end point
+ mInputBufferEnd += ioInputDataByteSize;
+ }
+ else
+ {
+ // the copy will wrap
+
+ // copy the first part
+ UInt32 theBeforeWrapByteSize = mInputBufferByteSize - mInputBufferEnd;
+ memcpy(mInputBuffer + mInputBufferEnd, theInputData, theBeforeWrapByteSize);
+
+ // and the rest
+ UInt32 theAfterWrapByteSize = ioInputDataByteSize - theBeforeWrapByteSize;
+ memcpy(mInputBuffer, theInputData + theBeforeWrapByteSize, theAfterWrapByteSize);
+
+ // adjust the end point
+ mInputBufferEnd = theAfterWrapByteSize;
+ }
+
+}
+
+
+void ACSimpleCodec::ZeroPadInputData(UInt32& ioNumberPackets, const AudioStreamPacketDescription* inPacketDescription)
+{
+ // this buffer handling code doesn't care about such things as the packet descriptions
+ if(!mIsInitialized) CODEC_THROW(kAudioCodecStateError);
+
+
+ // this is a ring buffer we're dealing with, so we need to set up a few things
+ UInt32 theUsedByteSize = GetUsedInputBufferByteSize();
+ UInt32 theAvailableByteSize = GetInputBufferByteSize() - theUsedByteSize;
+
+ // >>jamesmcc: added this because ioNumberPackets was not being updated if less was taken than given.
+ // THIS ASSUMES CBR!
+ UInt32 bytesPerPacketOfInput = mInputFormat.mBytesPerPacket;
+ UInt32 theAvailablePacketSize = theAvailableByteSize / bytesPerPacketOfInput;
+
+ UInt32 minPacketSize = ioNumberPackets < theAvailablePacketSize ? ioNumberPackets : theAvailablePacketSize;
+ UInt32 minByteSize = minPacketSize * bytesPerPacketOfInput;
+
+ // we can copy only as much data as there is or up to how much space is availiable
+ ioNumberPackets = minPacketSize;
+
+ // <<jamesmcc
+
+ // now we have to copy the data taking into account the wrap around and where the start is
+ if(mInputBufferEnd + minByteSize < mInputBufferByteSize)
+ {
+ // no wrap around here
+ memset(mInputBuffer + mInputBufferEnd, 0, minByteSize);
+
+ // adjust the end point
+ mInputBufferEnd += minByteSize;
+ }
+ else
+ {
+ // the copy will wrap
+
+ // copy the first part
+ UInt32 theBeforeWrapByteSize = mInputBufferByteSize - mInputBufferEnd;
+ memset(mInputBuffer + mInputBufferEnd, 0, theBeforeWrapByteSize);
+
+ // and the rest
+ UInt32 theAfterWrapByteSize = minByteSize - theBeforeWrapByteSize;
+ memset(mInputBuffer, 0, theAfterWrapByteSize);
+
+ // adjust the end point
+ mInputBufferEnd = theAfterWrapByteSize;
+ }
+}
+
+
+void ACSimpleCodec::ConsumeInputData(UInt32 inConsumedByteSize)
+{
+ // this is a convenience routine to make maintaining the ring buffer state easy
+ UInt32 theContiguousRange = GetInputBufferContiguousByteSize();
+
+ if(inConsumedByteSize > GetUsedInputBufferByteSize()) CODEC_THROW(kAudioCodecUnspecifiedError);
+
+ if(inConsumedByteSize <= theContiguousRange)
+ {
+ // the region to consume doesn't wrap
+
+ // figure out how much to consume
+ inConsumedByteSize = (theContiguousRange < inConsumedByteSize) ? theContiguousRange : inConsumedByteSize;
+
+ // clear the consumed bits
+ memset(mInputBuffer + mInputBufferStart, 0, inConsumedByteSize);
+
+ // adjust the start
+ mInputBufferStart += inConsumedByteSize;
+ }
+ else
+ {
+ // the region to consume will wrap
+
+ // clear the bits to the end of the buffer
+ memset(mInputBuffer + mInputBufferStart, 0, theContiguousRange);
+
+ // now clear the bits left from the start
+ memset(mInputBuffer, 0, inConsumedByteSize - theContiguousRange);
+
+ // adjust the start
+ mInputBufferStart = inConsumedByteSize - theContiguousRange;
+ }
+}
+
+
+Byte* ACSimpleCodec::GetBytes(UInt32& ioNumberBytes) const
+{
+ // if a client's algorithm has to have contiguous data and mInputBuffer wraps, then someone has to make a copy.
+ // I can do it more efficiently than the client.
+
+ if(!mIsInitialized) CODEC_THROW(kAudioCodecStateError);
+
+ UInt32 theUsedByteSize = GetUsedInputBufferByteSize();
+ //UInt32 theAvailableByteSize = GetInputBufferByteSize() - theUsedByteSize;
+
+ if (ioNumberBytes > theUsedByteSize) ioNumberBytes = theUsedByteSize;
+
+ SInt32 leftOver = mInputBufferStart + ioNumberBytes - mInputBufferByteSize;
+
+ if(leftOver > 0)
+ {
+ // need to copy beginning of buffer to the end.
+ // We cleverly over allocated our buffer space to make this possible.
+ memmove(mInputBuffer + mInputBufferByteSize, mInputBuffer, leftOver);
+ }
+
+ return GetInputBufferStart();
+}
+
+
+void ACSimpleCodec::ReallocateInputBuffer(UInt32 inInputBufferByteSize)
+{
+ mInputBufferByteSize = inInputBufferByteSize + kBufferPad;
+
+ // toss the old buffer
+ delete[] mInputBuffer;
+ mInputBuffer = NULL;
+
+ // allocate the new one
+ // allocate extra in order to allow making contiguous data.
+ UInt32 allocSize = 2*inInputBufferByteSize + kBufferPad;
+ mInputBuffer = new Byte[allocSize];
+ memset(mInputBuffer, 0, allocSize);
+
+ // reset the ring buffer state
+ mInputBufferStart = 0;
+ mInputBufferEnd = 0;
+}
+
+void ACSimpleCodec::GetPropertyInfo(AudioCodecPropertyID inPropertyID, UInt32& outPropertyDataSize, Boolean& outWritable)
+{
+ switch(inPropertyID)
+ {
+ case kAudioCodecPropertyInputBufferSize:
+ outPropertyDataSize = SizeOf32(UInt32);
+ outWritable = true;
+ break;
+ default:
+ ACBaseCodec::GetPropertyInfo(inPropertyID, outPropertyDataSize, outWritable);
+ break;
+ }
+
+}
+
+void ACSimpleCodec::SetProperty(AudioCodecPropertyID inPropertyID, UInt32 inPropertyDataSize, const void* inPropertyData)
+{
+ switch(inPropertyID)
+ {
+ case kAudioCodecPropertyInputBufferSize:
+ if(inPropertyDataSize == sizeof(UInt32))
+ {
+ ReallocateInputBuffer(*reinterpret_cast<const UInt32*>(inPropertyData));
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+ default:
+ ACBaseCodec::SetProperty(inPropertyID, inPropertyDataSize, inPropertyData);
+ break;
+ }
+}
diff --git a/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACSimpleCodec.h b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACSimpleCodec.h
new file mode 100644
index 0000000000..f41fe54b93
--- /dev/null
+++ b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/ACSimpleCodec.h
@@ -0,0 +1,105 @@
+/*
+ File: ACSimpleCodec.h
+ Abstract: Part of CoreAudio Utility Classes
+ Version: 1.1
+
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
+ Inc. ("Apple") in consideration of your agreement to the following
+ terms, and your use, installation, modification or redistribution of
+ this Apple software constitutes acceptance of these terms. If you do
+ not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+
+ In consideration of your agreement to abide by the following terms, and
+ subject to these terms, Apple grants you a personal, non-exclusive
+ license, under Apple's copyrights in this original Apple software (the
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
+ Software, with or without modifications, in source and/or binary forms;
+ provided that if you redistribute the Apple Software in its entirety and
+ without modifications, you must retain this notice and the following
+ text and disclaimers in all such redistributions of the Apple Software.
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
+ be used to endorse or promote products derived from the Apple Software
+ without specific prior written permission from Apple. Except as
+ expressly stated in this notice, no other rights or licenses, express or
+ implied, are granted by Apple herein, including but not limited to any
+ patent rights that may be infringed by your derivative works or by other
+ works in which the Apple Software may be incorporated.
+
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+ Copyright (C) 2014 Apple Inc. All Rights Reserved.
+
+*/
+#if !defined(__ACSimpleCodec_h__)
+#define __ACSimpleCodec_h__
+
+//=============================================================================
+// Includes
+//=============================================================================
+
+#include "ACBaseCodec.h"
+
+//=============================================================================
+// ACSimpleCodec
+//
+// This extension of ACBaseCodec provides for a simple ring buffer to handle
+// input data.
+//=============================================================================
+
+class ACSimpleCodec
+:
+ public ACBaseCodec
+{
+
+// Construction/Destruction
+public:
+ ACSimpleCodec(UInt32 inInputBufferByteSize, AudioComponentInstance inInstance);
+ virtual ~ACSimpleCodec();
+
+// Data Handling
+public:
+ virtual void Initialize(const AudioStreamBasicDescription* inInputFormat, const AudioStreamBasicDescription* inOutputFormat, const void* inMagicCookie, UInt32 inMagicCookieByteSize) = 0;
+ virtual void Uninitialize();
+ virtual void Reset();
+
+ virtual void AppendInputData(const void* inInputData, UInt32& ioInputDataByteSize, UInt32& ioNumberPackets, const AudioStreamPacketDescription* inPacketDescription);
+ virtual void ZeroPadInputData(UInt32& ioNumberPackets, const AudioStreamPacketDescription* inPacketDescription);
+ virtual UInt32 GetInputBufferByteSize() const;
+ virtual UInt32 GetUsedInputBufferByteSize() const;
+ virtual void GetPropertyInfo(AudioCodecPropertyID inPropertyID, UInt32& outPropertyDataSize, Boolean& outWritable);
+ virtual void SetProperty(AudioCodecPropertyID inPropertyID, UInt32 inPropertyDataSize, const void* inPropertyData);
+
+protected:
+ void ConsumeInputData(UInt32 inConsumedByteSize);
+ Byte* GetInputBufferStart() const { return mInputBuffer + mInputBufferStart; }
+ UInt32 GetInputBufferContiguousByteSize() const { return (mInputBufferStart <= mInputBufferEnd) ? (mInputBufferEnd - mInputBufferStart) : (mInputBufferByteSize - mInputBufferStart); }
+ virtual void ReallocateInputBuffer(UInt32 inInputBufferByteSize);
+
+ // returns a pointer to contiguous bytes.
+ // will do some copying if the request wraps around the internal buffer.
+ // request must be less than available bytes
+ Byte* GetBytes(UInt32& ioNumberBytes) const;
+
+private:
+ Byte* mInputBuffer;
+ UInt32 mInputBufferByteSize;
+ UInt32 mInputBufferStart;
+ UInt32 mInputBufferEnd;
+
+};
+
+#endif
diff --git a/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/GetCodecBundle.cpp b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/GetCodecBundle.cpp
new file mode 100644
index 0000000000..8954c8dd56
--- /dev/null
+++ b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/GetCodecBundle.cpp
@@ -0,0 +1,76 @@
+/*
+ File: GetCodecBundle.cpp
+ Abstract: GetCodecBundle.h
+ Version: 1.1
+
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
+ Inc. ("Apple") in consideration of your agreement to the following
+ terms, and your use, installation, modification or redistribution of
+ this Apple software constitutes acceptance of these terms. If you do
+ not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+
+ In consideration of your agreement to abide by the following terms, and
+ subject to these terms, Apple grants you a personal, non-exclusive
+ license, under Apple's copyrights in this original Apple software (the
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
+ Software, with or without modifications, in source and/or binary forms;
+ provided that if you redistribute the Apple Software in its entirety and
+ without modifications, you must retain this notice and the following
+ text and disclaimers in all such redistributions of the Apple Software.
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
+ be used to endorse or promote products derived from the Apple Software
+ without specific prior written permission from Apple. Except as
+ expressly stated in this notice, no other rights or licenses, express or
+ implied, are granted by Apple herein, including but not limited to any
+ patent rights that may be infringed by your derivative works or by other
+ works in which the Apple Software may be incorporated.
+
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+ Copyright (C) 2014 Apple Inc. All Rights Reserved.
+
+*/
+#include "GetCodecBundle.h"
+
+#if TARGET_OS_WIN32
+ #include "CAWin32StringResources.h"
+#endif
+
+#if TARGET_OS_WIN32
+#define kCodecBundleID "com.apple.audio.codecs.Components"
+#else
+const CFStringRef kCodecBundleID = CFSTR("com.apple.audio.codecs.Components");
+#endif
+
+CFBundleRef GetCodecBundle()
+{
+ static CFBundleRef sAudioCodecBundle = 0;
+ if (!sAudioCodecBundle)
+ {
+ #if TARGET_OS_WIN32
+ sAudioCodecBundle = CFBundleGetBundleWithIdentifier(CFSTR(kCodecBundleID));
+ #else
+ sAudioCodecBundle = CFBundleGetBundleWithIdentifier(kCodecBundleID);
+ #endif
+ if (sAudioCodecBundle)
+ {
+ CFRetain(sAudioCodecBundle);
+ }
+ }
+ return sAudioCodecBundle;
+}
+
diff --git a/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/GetCodecBundle.h b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/GetCodecBundle.h
new file mode 100644
index 0000000000..96e3d9e2b4
--- /dev/null
+++ b/libs/appleutility/CoreAudio/AudioCodecs/ACPublic/GetCodecBundle.h
@@ -0,0 +1,60 @@
+/*
+ File: GetCodecBundle.h
+ Abstract: Part of CoreAudio Utility Classes
+ Version: 1.1
+
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
+ Inc. ("Apple") in consideration of your agreement to the following
+ terms, and your use, installation, modification or redistribution of
+ this Apple software constitutes acceptance of these terms. If you do
+ not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+
+ In consideration of your agreement to abide by the following terms, and
+ subject to these terms, Apple grants you a personal, non-exclusive
+ license, under Apple's copyrights in this original Apple software (the
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
+ Software, with or without modifications, in source and/or binary forms;
+ provided that if you redistribute the Apple Software in its entirety and
+ without modifications, you must retain this notice and the following
+ text and disclaimers in all such redistributions of the Apple Software.
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
+ be used to endorse or promote products derived from the Apple Software
+ without specific prior written permission from Apple. Except as
+ expressly stated in this notice, no other rights or licenses, express or
+ implied, are granted by Apple herein, including but not limited to any
+ patent rights that may be infringed by your derivative works or by other
+ works in which the Apple Software may be incorporated.
+
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+ Copyright (C) 2014 Apple Inc. All Rights Reserved.
+
+*/
+#ifndef _GetCodecBundle_
+#define _GetCodecBundle_
+
+#include <TargetConditionals.h>
+
+#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
+ #include <CoreFoundation/CFBundle.h>
+#else
+ #include "CFBundle.h"
+#endif
+
+CFBundleRef GetCodecBundle();
+
+#endif