diff --git a/src/CoreAudio/AFAVFormatComponent/AFPublic b/src/CoreAudio/AFAVFormatComponent/AFPublic
new file mode 120000
index 000000000..3654236c2
--- /dev/null
+++ b/src/CoreAudio/AFAVFormatComponent/AFPublic
@@ -0,0 +1 @@
+../CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic
\ No newline at end of file
diff --git a/src/CoreAudio/AFAVFormatComponent/AUPublic b/src/CoreAudio/AFAVFormatComponent/AUPublic
new file mode 120000
index 000000000..6f6e2053f
--- /dev/null
+++ b/src/CoreAudio/AFAVFormatComponent/AUPublic
@@ -0,0 +1 @@
+../CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic
\ No newline at end of file
diff --git a/src/CoreAudio/AFAVFormatComponent/CMakeLists.txt b/src/CoreAudio/AFAVFormatComponent/CMakeLists.txt
new file mode 100644
index 000000000..3ef6d4c82
--- /dev/null
+++ b/src/CoreAudio/AFAVFormatComponent/CMakeLists.txt
@@ -0,0 +1,32 @@
+project(AFAVFormatComponent)
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
+include_directories(BEFORE ${CMAKE_SOURCE_DIR}/src/external/libcxx/include ${CMAKE_CURRENT_BINARY_DIR})
+
+include_directories(
+ ${CMAKE_CURRENT_SOURCE_DIR}/PublicUtility
+ ${CMAKE_CURRENT_SOURCE_DIR}/AFPublic
+ ${CMAKE_CURRENT_SOURCE_DIR}/AUPublic/AUBase
+)
+
+set(component_sources
+ AFPublic/AudioFileComponentBase.cpp
+ AFPublic/AudioFileFormat.cpp
+ AFPublic/AudioFileObject.cpp
+ AFPublic/CompressedPacketTable.cpp
+ AFPublic/DataSource.cpp
+ AUPublic/AUBase/ComponentBase.cpp
+ PublicUtility/CACFDictionary.cpp
+)
+
+add_darling_bundle(AFAVFormatComponent "" ${component_sources})
+target_link_libraries(AFAVFormatComponent
+ AudioToolbox
+ cxx
+ system
+ CoreFoundation
+ avformat
+)
+set_target_properties(AFAVFormatComponent PROPERTIES OUTPUT_NAME "AFAVFormat" PREFIX "" SUFFIX "")
+install(TARGETS AFAVFormatComponent DESTINATION libexec/darling/System/Library/Components/AFAVFormat.component/Contents/MacOS)
+#install(FILES Info.plist DESTINATION libexec/darling/System/Library/Components/AFAVFormat.component/Contents)
diff --git a/src/CoreAudio/AFAVFormatComponent/PublicUtility b/src/CoreAudio/AFAVFormatComponent/PublicUtility
new file mode 120000
index 000000000..4b70d76ff
--- /dev/null
+++ b/src/CoreAudio/AFAVFormatComponent/PublicUtility
@@ -0,0 +1 @@
+../CoreAudioUtilityClasses/CoreAudio/PublicUtility
\ No newline at end of file
diff --git a/src/CoreAudio/AudioToolbox/AudioFileComponent.cpp b/src/CoreAudio/AudioToolbox/AudioFileComponent.cpp
new file mode 100644
index 000000000..705ca33c0
--- /dev/null
+++ b/src/CoreAudio/AudioToolbox/AudioFileComponent.cpp
@@ -0,0 +1,290 @@
+/*
+This file is part of Darling.
+
+Copyright (C) 2020 Lubos Dolezel
+
+Darling is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+Darling is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Darling. If not, see .
+*/
+
+#include
+#include
+
+OSStatus
+AudioFileComponentCreateURL (
+ AudioFileComponent inComponent,
+ CFURLRef inFileRef,
+ const AudioStreamBasicDescription *inFormat,
+ UInt32 inFlags)
+{
+ return unimpErr;
+}
+
+OSStatus
+AudioFileComponentOpenURL (
+ AudioFileComponent inComponent,
+ CFURLRef inFileRef,
+ SInt8 inPermissions,
+ int inFileDescriptor)
+{
+ return unimpErr;
+}
+
+OSStatus
+AudioFileComponentOpenWithCallbacks(
+ AudioFileComponent inComponent,
+ void *inClientData,
+ AudioFile_ReadProc inReadFunc,
+ AudioFile_WriteProc inWriteFunc,
+ AudioFile_GetSizeProc inGetSizeFunc,
+ AudioFile_SetSizeProc inSetSizeFunc)
+{
+ return unimpErr;
+}
+
+OSStatus
+AudioFileComponentInitializeWithCallbacks(
+ AudioFileComponent inComponent,
+ void *inClientData,
+ AudioFile_ReadProc inReadFunc,
+ AudioFile_WriteProc inWriteFunc,
+ AudioFile_GetSizeProc inGetSizeFunc,
+ AudioFile_SetSizeProc inSetSizeFunc,
+ UInt32 inFileType,
+ const AudioStreamBasicDescription *inFormat,
+ UInt32 inFlags)
+{
+ return unimpErr;
+}
+
+OSStatus
+AudioFileComponentCloseFile(
+ AudioFileComponent inComponent)
+{
+ return unimpErr;
+}
+
+
+
+OSStatus
+AudioFileComponentOptimize(
+ AudioFileComponent inComponent)
+{
+ return unimpErr;
+}
+
+OSStatus
+AudioFileComponentReadBytes(
+ AudioFileComponent inComponent,
+ Boolean inUseCache,
+ SInt64 inStartingByte,
+ UInt32 *ioNumBytes,
+ void *outBuffer)
+{
+ return unimpErr;
+}
+
+OSStatus
+AudioFileComponentWriteBytes(
+ AudioFileComponent inComponent,
+ Boolean inUseCache,
+ SInt64 inStartingByte,
+ UInt32 *ioNumBytes,
+ const void *inBuffer)
+{
+ return unimpErr;
+}
+
+OSStatus
+AudioFileComponentReadPackets(
+ AudioFileComponent inComponent,
+ Boolean inUseCache,
+ UInt32 *outNumBytes,
+ AudioStreamPacketDescription * _Nullable outPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ void *outBuffer)
+{
+ return unimpErr;
+}
+
+OSStatus
+AudioFileComponentReadPacketData(
+ AudioFileComponent inComponent,
+ Boolean inUseCache,
+ UInt32 *ioNumBytes,
+ AudioStreamPacketDescription * _Nullable outPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ void *outBuffer)
+{
+ return unimpErr;
+}
+
+OSStatus
+AudioFileComponentWritePackets(
+ AudioFileComponent inComponent,
+ Boolean inUseCache,
+ UInt32 inNumBytes,
+ const AudioStreamPacketDescription * _Nullable inPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ const void *inBuffer)
+{
+ return unimpErr;
+}
+
+OSStatus
+AudioFileComponentGetPropertyInfo(
+ AudioFileComponent inComponent,
+ AudioFileComponentPropertyID inPropertyID,
+ UInt32 * _Nullable outPropertySize,
+ UInt32 * _Nullable outWritable)
+{
+ return unimpErr;
+}
+
+OSStatus
+AudioFileComponentGetProperty(
+ AudioFileComponent inComponent,
+ AudioFileComponentPropertyID inPropertyID,
+ UInt32 *ioPropertyDataSize,
+ void *outPropertyData)
+{
+ return unimpErr;
+}
+
+OSStatus
+AudioFileComponentSetProperty(
+ AudioFileComponent inComponent,
+ AudioFileComponentPropertyID inPropertyID,
+ UInt32 inPropertyDataSize,
+ const void *inPropertyData)
+{
+ return unimpErr;
+}
+
+OSStatus
+AudioFileComponentCountUserData(
+ AudioFileComponent inComponent,
+ UInt32 inUserDataID,
+ UInt32 *outNumberItems)
+{
+ return unimpErr;
+}
+
+OSStatus
+AudioFileComponentGetUserDataSize(
+ AudioFileComponent inComponent,
+ UInt32 inUserDataID,
+ UInt32 inIndex,
+ UInt32 *outUserDataSize)
+{
+ return unimpErr;
+}
+
+OSStatus
+AudioFileComponentGetUserData(
+ AudioFileComponent inComponent,
+ UInt32 inUserDataID,
+ UInt32 inIndex,
+ UInt32 *ioUserDataSize,
+ void *outUserData)
+{
+ return unimpErr;
+}
+
+OSStatus
+AudioFileComponentSetUserData(
+ AudioFileComponent inComponent,
+ UInt32 inUserDataID,
+ UInt32 inIndex,
+ UInt32 inUserDataSize,
+ const void *inUserData)
+{
+ return unimpErr;
+}
+
+OSStatus
+AudioFileComponentRemoveUserData(
+ AudioFileComponent inComponent,
+ UInt32 inUserDataID,
+ UInt32 inIndex)
+{
+ return unimpErr;
+}
+
+OSStatus
+AudioFileComponentExtensionIsThisFormat(
+ AudioFileComponent inComponent,
+ CFStringRef inExtension,
+ UInt32 *outResult)
+{
+ return unimpErr;
+}
+
+OSStatus
+AudioFileComponentFileDataIsThisFormat(
+ AudioFileComponent inComponent,
+ UInt32 inDataByteSize,
+ const void* inData,
+ UInt32 *outResult)
+{
+ return unimpErr;
+}
+
+OSStatus
+AudioFileComponentFileIsThisFormat(
+ AudioFileComponent inComponent,
+ SInt16 inFileRefNum,
+ UInt32 *outResult)
+{
+ return unimpErr;
+}
+
+OSStatus
+AudioFileComponentDataIsThisFormat(
+ AudioFileComponent inComponent,
+ void * _Nullable inClientData,
+ AudioFile_ReadProc _Nullable inReadFunc,
+ AudioFile_WriteProc _Nullable inWriteFunc,
+ AudioFile_GetSizeProc _Nullable inGetSizeFunc,
+ AudioFile_SetSizeProc _Nullable inSetSizeFunc,
+ UInt32 *outResult)
+{
+ return unimpErr;
+}
+
+OSStatus
+AudioFileComponentGetGlobalInfoSize(
+ AudioFileComponent inComponent,
+ AudioFileComponentPropertyID inPropertyID,
+ UInt32 inSpecifierSize,
+ const void * _Nullable inSpecifier,
+ UInt32 *outPropertySize)
+{
+ return unimpErr;
+}
+
+OSStatus
+AudioFileComponentGetGlobalInfo(
+ AudioFileComponent inComponent,
+ AudioFileComponentPropertyID inPropertyID,
+ UInt32 inSpecifierSize,
+ const void * _Nullable inSpecifier,
+ UInt32 *ioPropertyDataSize,
+ void *outPropertyData)
+{
+ return unimpErr;
+}
+
diff --git a/src/CoreAudio/AudioToolbox/AudioUnit.cpp b/src/CoreAudio/AudioToolbox/AudioUnit.cpp
deleted file mode 100644
index 7f757ef7c..000000000
--- a/src/CoreAudio/AudioToolbox/AudioUnit.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-#include "darling-config.h"
-#include "AudioUnit.h"
-#include "AudioOutputUnitComponent.h"
-#include "stub.h"
-#include
-
-OSStatus AudioUnitInitialize(AudioUnit inUnit)
-{
- return ((AudioUnitComponent*)inUnit)->init();
-}
-
-OSStatus AudioUnitUninitialize(AudioUnit inUnit)
-{
- return ((AudioUnitComponent*)inUnit)->deinit();
-}
-
-OSStatus AudioUnitAddRenderNotify(AudioUnit inUnit, AURenderCallback inProc, void* opaque)
-{
- return ((AudioUnitComponent*)inUnit)->addRenderNotify(inProc, opaque);
-}
-
-OSStatus AudioUnitRemoveRenderNotify(AudioUnit inUnit, AURenderCallback inProc, void* opaque)
-{
- return ((AudioUnitComponent*)inUnit)->removeRenderNotify(inProc, opaque);
-}
-
-OSStatus AudioUnitRender(AudioUnit inUnit, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inOutputBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData)
-{
- OSStatus status;
-
- if (inUnit == nullptr)
- return paramErr;
-
- *ioActionFlags |= kAudioUnitRenderAction_PreRender;
- status = ((AudioUnitComponent*)inUnit)->notifyListeners(ioActionFlags, inTimeStamp, inOutputBusNumber, inNumberFrames, ioData);
-
- if (status != noErr)
- return status;
-
- *ioActionFlags &= ~kAudioUnitRenderAction_PreRender;
- status = ((AudioUnitComponent*)inUnit)->render(ioActionFlags, inTimeStamp, inOutputBusNumber, inNumberFrames, ioData);
-
- if (status != noErr)
- *ioActionFlags |= kAudioUnitRenderAction_PostRenderError;
-
- *ioActionFlags |= kAudioUnitRenderAction_PostRender;
- return ((AudioUnitComponent*)inUnit)->notifyListeners(ioActionFlags, inTimeStamp, inOutputBusNumber, inNumberFrames, ioData);
-}
-
-OSStatus AudioUnitReset(AudioUnit inUnit, AudioUnitScope inScope, AudioUnitElement inElement)
-{
- return ((AudioUnitComponent*)inUnit)->reset(inScope, inElement);
-}
-
-OSStatus AudioUnitGetProperty(AudioUnit inUnit, AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, void* outData, UInt32 *ioDataSize)
-{
- return ((AudioUnitComponent*)inUnit)->getProperty(inID, inScope, inElement, outData, ioDataSize);
-}
-
-OSStatus AudioUnitGetPropertyInfo(AudioUnit inUnit, AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, UInt32 *outDataSize, Boolean *outWritable)
-{
- return ((AudioUnitComponent*)inUnit)->getPropertyInfo(inID, inScope, inElement, outDataSize, outWritable);
-}
-
-OSStatus AudioUnitSetProperty(AudioUnit inUnit, AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, const void *inData, UInt32 inDataSize)
-{
- return ((AudioUnitComponent*)inUnit)->setProperty(inID, inScope, inElement, inData, inDataSize);
-}
-
-OSStatus AudioOutputUnitStart(AudioUnit inUnit)
-{
- return static_cast(inUnit)->start();
-}
-
-OSStatus AudioOutputUnitStop(AudioUnit inUnit)
-{
- return static_cast(inUnit)->stop();
-}
-
-
diff --git a/src/CoreAudio/AudioToolbox/AudioUnitBase.cpp b/src/CoreAudio/AudioToolbox/AudioUnitBase.cpp
deleted file mode 100644
index 99ad00064..000000000
--- a/src/CoreAudio/AudioToolbox/AudioUnitBase.cpp
+++ /dev/null
@@ -1,298 +0,0 @@
-#include "AudioUnitBase.h"
-#include "AudioUnitProperties.h"
-#include "AudioUnitRenderer.h"
-#include
-#include "stub.h"
-#include
-
-AudioUnitComponent::AudioUnitComponent(std::initializer_list elements)
-{
- m_inputRenderer.reset(new AudioUnitRenderer);
- m_elementNames.insert(m_elementNames.end(), elements.begin(), elements.end());
- m_config.resize(m_elementNames.size());
-
- // Default audio params
- const AudioStreamBasicDescription defaultConfig = AudioStreamBasicDescription {
- 44100.0, kAudioFormatLinearPCM, kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked,
- 4, 1, 4, 2, 16, 0
- };
-
- for (size_t i = 0; i < m_config.size(); i++)
- {
- m_config[i] = std::pair(defaultConfig, defaultConfig);
- }
-
- memset(&m_inputUnit, 0, sizeof(m_inputUnit));
-}
-
-AudioUnitComponent::~AudioUnitComponent()
-{
- if (m_contextName != nullptr)
- CFRelease(m_contextName);
- CloseComponent(m_inputUnit.sourceAudioUnit);
-}
-
-OSStatus AudioUnitComponent::getPropertyInfo(AudioUnitPropertyID prop, AudioUnitScope scope, AudioUnitElement elem, UInt32* dataSize, Boolean* writable)
-{
- switch (prop)
- {
- case kAudioUnitProperty_StreamFormat:
- *dataSize = sizeof(AudioStreamBasicDescription);
- *writable = true;
- break;
- case kAudioOutputUnitProperty_EnableIO:
- *dataSize = sizeof(UInt32);
- *writable = true;
- break;
- case kAudioUnitProperty_SetRenderCallback:
- *dataSize = sizeof(AURenderCallbackStruct);
- *writable = true;
- break;
- case kAudioUnitProperty_ShouldAllocateBuffer:
- *dataSize = sizeof(int);
- *writable = true;
- break;
- case kAudioUnitProperty_ElementCount:
- *dataSize = sizeof(UInt32);
- *writable = false;
- break;
- case kAudioUnitProperty_LastRenderError: // TODO: implement
- *dataSize = sizeof(OSStatus);
- *writable = false;
- break;
- case kAudioUnitProperty_SampleRate: // TODO: implement
- *dataSize = sizeof(Float64);
- *writable = true; // TODO: query itself on kAudioUnitProperty_StreamFormat if writable
- break;
- case kAudioUnitProperty_ElementName:
- *dataSize = sizeof(CFStringRef);
- *writable = false;
- break;
- case kAudioUnitProperty_ContextName:
- *dataSize = sizeof(CFStringRef);
- *writable = true;
- break;
- default:
- return kAudioUnitErr_InvalidProperty;
- }
-
- return noErr;
-}
-
-OSStatus AudioUnitComponent::setProperty(AudioUnitPropertyID prop, AudioUnitScope scope, AudioUnitElement elem, const void* data, UInt32 dataSize)
-{
- // TRACE5(prop, scope, elem, data, dataSize);
-
- switch (prop)
- {
- case kAudioUnitProperty_StreamFormat:
- {
- const AudioStreamBasicDescription* newConfig = static_cast(data);
-
- if (dataSize != sizeof(*newConfig))
- return kAudioUnitErr_InvalidParameter;
-
- if (elem >= m_config.size())
- return kAudioUnitErr_InvalidElement;
-
- // TODO: perform validation
-
- if (scope == kAudioUnitScope_Output) // playback
- m_config[elem].second = *newConfig;
- else if (scope == kAudioUnitScope_Input) // recording
- m_config[elem].first = *newConfig;
- else if (scope == kAudioUnitScope_Global)
- m_config[0].second = *newConfig;
- else
- return kAudioUnitErr_InvalidScope;
-
- return noErr;
- }
- case 7: // kAudioUnitProperty_SetInputCallback (do not mistake with kAudioOutputUnitProperty_SetInputCallback)
- case kAudioUnitProperty_SetRenderCallback:
- {
- if (dataSize != sizeof(AURenderCallbackStruct))
- return kAudioUnitErr_InvalidParameter;
- //if (scope == kAudioUnitScope_Input)
- //{
- if (elem != kOutputBus)
- return kAudioUnitErr_InvalidElement;
-
- *m_inputRenderer = *(AURenderCallbackStruct*) data;
- m_inputUnit.sourceOutputNumber = 0;
- m_inputUnit.destInputNumber = 0;
- m_inputUnit.sourceAudioUnit = m_inputRenderer.get();
- //}
- //else
- // return kAudioUnitErr_InvalidScope;
-
- return noErr;
- }
- case kAudioOutputUnitProperty_SetInputCallback:
- {
- // For audio recording
-
- if (elem != kInputBus)
- return kAudioUnitErr_InvalidElement;
-
- // Notification callback - the recipient needs to call AudioUnitRender to obtain microphone data
- m_outputCallback = *(AURenderCallbackStruct*) data;
- return noErr;
- }
- case kAudioUnitProperty_MakeConnection:
- {
- if (dataSize != sizeof(AudioUnitConnection))
- return kAudioUnitErr_InvalidParameter;
- if (scope != kAudioUnitScope_Input)
- return kAudioUnitErr_InvalidScope;
-
- // TODO: support multiple units!
- // TODO: reconfigure input format based on output format
-
- memcpy(&m_inputUnit, data, sizeof(AudioUnitConnection));
-
- return noErr;
- }
- case kAudioUnitProperty_ElementCount:
- {
-
- }
- case kAudioUnitProperty_ShouldAllocateBuffer:
- {
- int* b = (int*) data;
- if (dataSize < sizeof(int))
- return kAudioUnitErr_InvalidParameter;
-
- m_shouldAllocateBuffer = *b != 0;
- return noErr;
- }
- case kAudioUnitProperty_ContextName:
- {
- if (dataSize < sizeof(CFStringRef))
- return kAudioUnitErr_InvalidParameter;
-
- if (data == nullptr)
- {
- if (m_contextName != nullptr)
- {
- CFRelease(m_contextName);
- m_contextName = nullptr;
- }
- }
- else
- {
- m_contextName = (CFStringRef) data;
- CFRetain(m_contextName);
- }
- return noErr;
- }
- default:
- return kAudioUnitErr_InvalidProperty;
- }
-}
-
-OSStatus AudioUnitComponent::getProperty(AudioUnitPropertyID prop, AudioUnitScope scope, AudioUnitElement elem, void* data, UInt32* dataSize)
-{
- // TRACE5(prop, scope, elem, data, dataSize);
-
- switch (prop)
- {
- case kAudioUnitProperty_StreamFormat:
- {
- AudioStreamBasicDescription* newConfig = static_cast(data);
-
- if (*dataSize < sizeof(AudioStreamBasicDescription))
- return kAudioUnitErr_InvalidParameter;
-
- if (elem >= m_config.size())
- return kAudioUnitErr_InvalidElement;
-
- if (scope == kAudioUnitScope_Output)
- *newConfig = m_config[elem].second;
- else if (scope == kAudioUnitScope_Input)
- *newConfig = m_config[elem].first;
- else if (scope == kAudioUnitScope_Global)
- *newConfig = m_config[0].second;
- else
- return kAudioUnitErr_InvalidScope;
-
- *dataSize = sizeof(AudioStreamBasicDescription);
-
- return noErr;
- }
- case kAudioUnitProperty_ShouldAllocateBuffer:
- {
- int* out = (int*) data;
- if (*dataSize < sizeof(UInt32))
- return kAudioUnitErr_InvalidParameter;
-
- *out = m_shouldAllocateBuffer;
- return noErr;
- }
- case kAudioUnitProperty_ElementCount:
- {
- UInt32* out = (UInt32*) data;
- if (*dataSize < sizeof(UInt32))
- return kAudioUnitErr_InvalidParameter;
-
- *out = m_config.size();
- return noErr;
- }
- case kAudioUnitProperty_ElementName:
- {
- CFStringRef* out = (CFStringRef*) data;
- if (*dataSize != sizeof(CFStringRef))
- return kAudioUnitErr_InvalidParameter;
- if (elem >= m_elementNames.size())
- return kAudioUnitErr_InvalidElement;
-
- *out = m_elementNames[elem];
- return noErr;
- }
- case kAudioUnitProperty_ContextName:
- {
- CFStringRef* out = (CFStringRef*) data;
- if (*dataSize != sizeof(CFStringRef))
- return kAudioUnitErr_InvalidParameter;
-
- *out = m_contextName;
- return noErr;
- }
- default:
- return kAudioUnitErr_InvalidProperty;
- }
-}
-
-OSStatus AudioUnitComponent::addRenderNotify(AURenderCallback inProc, void* opaque)
-{
- std::lock_guard guard(m_listenersMutex);
-
- if (!inProc)
- return paramErr;
- m_listeners.insert(std::pair(inProc, opaque));
-
- return noErr;
-}
-
-OSStatus AudioUnitComponent::removeRenderNotify(AURenderCallback inProc, void* opaque)
-{
- std::lock_guard guard(m_listenersMutex);
- m_listeners.erase(std::pair(inProc, opaque));
- return noErr;
-}
-
-OSStatus AudioUnitComponent::notifyListeners(AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp,
- UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData)
-{
- std::lock_guard guard(m_listenersMutex);
- OSStatus status = noErr;
-
- for (auto p : m_listeners)
- {
- status = p.first(p.second, ioActionFlags, inTimeStamp, inBusNumber, inNumberFrames, ioData);
- if (status != noErr)
- break;
- }
-
- return status;
-}
diff --git a/src/CoreAudio/AudioToolbox/AudioUnitBase.h b/src/CoreAudio/AudioToolbox/AudioUnitBase.h
deleted file mode 100644
index 147dd8159..000000000
--- a/src/CoreAudio/AudioToolbox/AudioUnitBase.h
+++ /dev/null
@@ -1,62 +0,0 @@
-#ifndef AUDIOUNITBASE_H
-#define AUDIOUNITBASE_H
-
-#include "AudioUnit.h"
-#include "AudioUnitProperties.h"
-#include
-#include
-#include
-#include
-#include
-
-#ifndef kOutputBus
-# define kOutputBus 0 // playback
-# define kInputBus 1 // recording
-#endif
-
-class AudioUnitRenderer;
-
-class AudioUnitComponent
-{
-protected:
- AudioUnitComponent(std::initializer_list elements);
-public:
- virtual ~AudioUnitComponent();
-
- virtual OSStatus init() = 0;
- virtual OSStatus deinit() = 0;
-
- virtual OSStatus reset(AudioUnitScope inScope, AudioUnitElement inElement) = 0;
-
- virtual OSStatus render(AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData) = 0;
-
- virtual OSStatus setProperty(AudioUnitPropertyID prop, AudioUnitScope scope, AudioUnitElement elem, const void* data, UInt32 dataSize);
- virtual OSStatus getProperty(AudioUnitPropertyID prop, AudioUnitScope scope, AudioUnitElement elem, void* data, UInt32* dataSize);
- virtual OSStatus getPropertyInfo(AudioUnitPropertyID prop, AudioUnitScope scope, AudioUnitElement elem, UInt32* dataSize, Boolean* writable);
-
- OSStatus addRenderNotify(AURenderCallback inProc, void* opaque);
- OSStatus removeRenderNotify(AURenderCallback inProc, void* opaque);
- OSStatus notifyListeners(AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData);
-protected:
- std::vector m_elementNames;
- std::vector> m_config;
- //AudioStreamBasicDescription m_configOutputPlayback, m_configInputPlayback, m_configInputCapture, m_configOutputCapture;
-
- // We're simplifying things here - instead of having generic sets of input/output busses
- // and associated connections/callbacks, we have just this.
- // For kOutputBus only
- AudioUnitConnection m_inputUnit;
- std::unique_ptr m_inputRenderer;
-
- // For kInputBus only
- AURenderCallbackStruct m_outputCallback;
-
- bool m_shouldAllocateBuffer = true;
- OSStatus m_lastRenderError = 0;
- CFStringRef m_contextName = nullptr;
- std::mutex m_listenersMutex;
- std::set> m_listeners;
-};
-
-#endif
-
diff --git a/src/CoreAudio/AudioToolbox/AudioUnitCA.cpp b/src/CoreAudio/AudioToolbox/AudioUnitCA.cpp
deleted file mode 100644
index 8c074b664..000000000
--- a/src/CoreAudio/AudioToolbox/AudioUnitCA.cpp
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
-This file is part of Darling.
-
-Copyright (C) 2020 Lubos Dolezel
-
-Darling is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-Darling is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Darling. If not, see .
-*/
-#include "AudioUnitCA.h"
-
-#include
-
-AudioUnitCA::AudioUnitCA()
-{
-}
-
-AudioUnitCA::~AudioUnitCA()
-{
- deinit();
-}
-
-OSStatus AudioUnitCA::init()
-{
- OSStatus ret = noErr;
-
- // kAudioUnitErr_FailedInitialization
- if (m_enableOutput)
- {
- ret = initOutput();
-
- if (ret != noErr)
- return ret;
- }
-
- if (m_enableInput)
- ret = initInput();
-
- return ret;
-}
-
-OSStatus AudioUnitCA::initOutput()
-{
- AudioDeviceID adid;
- UInt32 propSize = sizeof(adid);
-
- AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &propSize, &adid);
-
- propSize = sizeof(m_deviceASBD);
- AudioDeviceGetProperty(adid, 0, false, kAudioDevicePropertyStreamFormat, &propSize, &m_deviceASBD);
-
- AudioDeviceCreateIOProcID(adid, playbackCallback, this, &m_outputProcID);
-
- return noErr;
-}
-
-void AudioUnitCA::requestDataForPlayback(size_t length)
-{
- AudioUnitRenderActionFlags flags;
- AudioTimeStamp ts;
- AudioBufferList* bufs;
- OSStatus err;
- std::unique_ptr data;
- const AudioStreamBasicDescription& config = m_config[kOutputBus].first;
- const UInt32 cc = config.mChannelsPerFrame;
-
-
- //TRACE() << "m_started=" << m_started;
-
- if (!m_started)
- {
- std::unique_ptr empty;
- size_t len;
- int ret;
-
- len = config.mBytesPerFrame * (config.mSampleRate / 10);
- empty.reset(new char[len]);
-
- memset(empty.get(), 0, len);
-
- //ret = pa_stream_write(m_stream, empty.get(), len,
- // nullptr, 0, PA_SEEK_RELATIVE);
-
- return;
- }
-
- memset(&ts, 0, sizeof(ts));
-
- if (isOutputPlanar())
- {
- bufs = (AudioBufferList*) operator new(sizeof(AudioBufferList) + (cc-1)*sizeof(AudioBuffer));
- bufs->mNumberBuffers = cc;
- }
- else
- {
- bufs = (AudioBufferList*) operator new(sizeof(AudioBufferList));
- bufs->mNumberBuffers = 1;
- }
-
- if (m_shouldAllocateBuffer)
- {
- if (isOutputPlanar())
- {
- UInt32 bytesPerChannel = length / cc;
-
- data.reset(new uint8_t[cc*bytesPerChannel]);
-
- for (UInt32 i = 0; i < cc; i++)
- {
- bufs->mBuffers[i].mNumberChannels = 1;
- bufs->mBuffers[i].mDataByteSize = bytesPerChannel;
- bufs->mBuffers[i].mData = data.get() + i*bytesPerChannel;
- }
- }
- else
- {
- bufs->mBuffers[0].mNumberChannels = cc;
- bufs->mBuffers[0].mDataByteSize = length;
-
- data.reset(new uint8_t[bufs->mBuffers[0].mDataByteSize]);
- bufs->mBuffers[0].mData = data.get();
- }
- }
- else
- {
- if (isOutputPlanar())
- {
- for (UInt32 i = 0; i < cc; i++)
- {
- bufs->mBuffers[i].mDataByteSize = 0;
- bufs->mBuffers[i].mData = nullptr;
- }
- }
- else
- {
- bufs->mBuffers[0].mDataByteSize = 0;
- bufs->mBuffers[0].mData = nullptr;
- }
- }
-
- err = AudioUnitRender(m_inputUnit.sourceAudioUnit, &flags, &ts, kOutputBus, length / config.mBytesPerFrame, bufs);
-
- if (err != noErr || bufs->mBuffers[0].mDataByteSize == 0)
- {
- // ERROR() << "Render callback failed with error " << err;
-
- // Fill with silence, the error may be temporary
- UInt32 bytes = length;
-
- if (!m_shouldAllocateBuffer)
- {
- if (isOutputPlanar())
- {
- data.reset(new uint8_t[bytes*cc]);
- memset(data.get(), 0, bytes*cc);
- }
- else
- {
- data.reset(new uint8_t[bytes]);
- memset(data.get(), 0, bytes);
- }
- }
-
- if (isOutputPlanar())
- {
- for (UInt32 i = 0; i < cc; i++)
- {
- bufs->mBuffers[i].mData = data.get() + bytes*i;
- bufs->mBuffers[i].mDataByteSize = bytes;
- }
- }
- else
- {
- bufs->mBuffers[0].mData = data.get();
- bufs->mBuffers[0].mDataByteSize = bytes;
- }
- }
-
- //LOG << "Rendering...\n";
- m_lastRenderError = AudioUnitRender(this, &flags, &ts, kOutputBus, length / config.mBytesPerFrame, bufs);
-
- operator delete(bufs);
-}
-
-OSStatus AudioUnitCA::render(AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData)
-{
- if (inBusNumber == kOutputBus)
- return renderOutput(ioActionFlags, inTimeStamp, inNumberFrames, ioData);
- else if (inBusNumber == kInputBus)
- return renderInput(ioActionFlags, inTimeStamp, inNumberFrames, ioData);
- else
- return paramErr;
-}
-
-OSStatus AudioUnitCA::renderOutput(AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inNumberFrames, AudioBufferList *ioData)
-{
- if (!isOutputPlanar())
- return renderInterleavedOutput(ioActionFlags, inTimeStamp, inNumberFrames, ioData);
- else
- return renderPlanarOutput(ioActionFlags, inTimeStamp, inNumberFrames, ioData);
-}
-
-OSStatus AudioUnitCA::renderInterleavedOutput(AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inNumberFrames, AudioBufferList *ioData)
-{
- const AudioStreamBasicDescription& config = m_config[kOutputBus].first;
- UInt32 framesSoFar = 0;
-
- for (UInt32 i = 0; i < ioData->mNumberBuffers; i++)
- {
- size_t bytes = std::min((inNumberFrames - framesSoFar) * config.mBytesPerFrame, ioData->mBuffers[i].mDataByteSize);
-
- if (!bytes)
- break;
-
- //LOG << "AudioUnitPA::renderInterleavedOutput(): data=" << ioData->mBuffers[i].mData << ", bytes=" << bytes << std::endl;
- //pa_stream_write(m_stream, ((char*) ioData->mBuffers[i].mData) + framesSoFar * config.mBytesPerFrame, bytes,
- // nullptr, 0, PA_SEEK_RELATIVE);
-
- framesSoFar += ioData->mBuffers[i].mDataByteSize / config.mBytesPerFrame;
- }
-
- return noErr;
-}
-
-OSStatus AudioUnitCA::renderPlanarOutput(AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inNumberFrames, AudioBufferList *ioData)
-{
- // PulseAudio doesn't support planar audio, we have to perform conversion
- return unimpErr;
-}
-
-OSStatus AudioUnitCA::renderInput(AudioUnitRenderActionFlags *ioActionFlags,const AudioTimeStamp *inTimeStamp, UInt32 inNumberFrames, AudioBufferList *ioData)
-{
- if (!m_outputCallback.inputProc)
- return noErr; // We don't push, we should be polled
-
- if (!isInputPlanar())
- return renderInterleavedInput(ioActionFlags, inTimeStamp, inNumberFrames, ioData);
- else
- return renderPlanarInput(ioActionFlags, inTimeStamp, inNumberFrames, ioData);
-}
-
-OSStatus AudioUnitCA::renderInterleavedInput(AudioUnitRenderActionFlags *ioActionFlags,const AudioTimeStamp *inTimeStamp, UInt32 inNumberFrames, AudioBufferList *ioData)
-{
- return unimpErr;
-}
-
-OSStatus AudioUnitCA::renderPlanarInput(AudioUnitRenderActionFlags *ioActionFlags,const AudioTimeStamp *inTimeStamp, UInt32 inNumberFrames, AudioBufferList *ioData)
-{
- return unimpErr;
-}
-
-
-OSStatus AudioUnitCA::reset(AudioUnitScope inScope, AudioUnitElement inElement)
-{
- return unimpErr;
-}
-
-OSStatus AudioUnitCA::deinit()
-{
- return noErr;
-}
-
-OSStatus AudioUnitCA::start()
-{
-
- return noErr;
-}
-
-OSStatus AudioUnitCA::stop()
-{
-
- m_started = false;
- return noErr;
-}
diff --git a/src/CoreAudio/AudioToolbox/AudioUnitCA.h b/src/CoreAudio/AudioToolbox/AudioUnitCA.h
deleted file mode 100644
index 2adca0d70..000000000
--- a/src/CoreAudio/AudioToolbox/AudioUnitCA.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
-This file is part of Darling.
-
-Copyright (C) 2020 Lubos Dolezel
-
-Darling is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-Darling is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Darling. If not, see .
-*/
-
-#ifndef AUDIOUNITCA_H
-#define AUDIOUNITCA_H
-#include "AudioOutputUnitComponent.h"
-#include
-
-#ifndef kOutputBus
-# define kOutputBus 0 // playback
-# define kInputBus 1 // recording
-#endif
-
-class AudioUnitCA : public AudioOutputUnitComponent
-{
-public:
- AudioUnitCA();
- virtual ~AudioUnitCA();
-
- OSStatus init() override;
- OSStatus deinit() override;
-
- OSStatus start() override;
- OSStatus stop() override;
-
- OSStatus reset(AudioUnitScope inScope, AudioUnitElement inElement) override;
-
- OSStatus render(AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData) override;
-
- int cardIndex() const override;
-private:
- OSStatus initOutput();
- OSStatus initInput();
-private:
- void requestDataForPlayback(size_t length);
-
- inline bool isOutputPlanar() const { return m_config[kOutputBus].second.mFormatFlags & kAudioFormatFlagIsNonInterleaved; }
- inline bool isInputPlanar() const { return m_config[kInputBus].first.mFormatFlags & kAudioFormatFlagIsNonInterleaved; }
-
- OSStatus renderOutput(AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inNumberFrames, AudioBufferList *ioData);
- OSStatus renderInterleavedOutput(AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inNumberFrames, AudioBufferList *ioData);
- OSStatus renderPlanarOutput(AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inNumberFrames, AudioBufferList *ioData);
-
- OSStatus renderInput(AudioUnitRenderActionFlags *ioActionFlags,const AudioTimeStamp *inTimeStamp, UInt32 inNumberFrames, AudioBufferList *ioData);
- OSStatus renderInterleavedInput(AudioUnitRenderActionFlags *ioActionFlags,const AudioTimeStamp *inTimeStamp, UInt32 inNumberFrames, AudioBufferList *ioData);
- OSStatus renderPlanarInput(AudioUnitRenderActionFlags *ioActionFlags,const AudioTimeStamp *inTimeStamp, UInt32 inNumberFrames, AudioBufferList *ioData);
-private:
-
- bool m_started = false;
- AudioStreamBasicDescription m_deviceASBD;
- AudioDeviceIOProcID m_outputProcID, m_inputProcID;
-};
-
-#endif /* AUDIOUNITPA_H */
-
diff --git a/src/CoreAudio/AudioToolbox/AudioUnitRenderer.cpp b/src/CoreAudio/AudioToolbox/AudioUnitRenderer.cpp
deleted file mode 100644
index a098e5a8d..000000000
--- a/src/CoreAudio/AudioToolbox/AudioUnitRenderer.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-#include "AudioUnitRenderer.h"
-#include
-
-AudioUnitRenderer::AudioUnitRenderer(const AURenderCallbackStruct& cb)
-: AudioUnitComponent({ CFSTR("Fake") }), m_renderCallback(cb)
-{
-}
-
-AudioUnitRenderer::AudioUnitRenderer()
-: AudioUnitComponent({ CFSTR("Fake") }), m_renderCallback({0})
-{
-}
-
-OSStatus AudioUnitRenderer::init()
-{
- return noErr;
-}
-
-OSStatus AudioUnitRenderer::deinit()
-{
- return noErr;
-}
-
-OSStatus AudioUnitRenderer::reset(AudioUnitScope inScope, AudioUnitElement inElement)
-{
- return noErr;
-}
-
-OSStatus AudioUnitRenderer::render(AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData)
-{
- return m_renderCallback.inputProc(m_renderCallback.inputProcRefCon, ioActionFlags, inTimeStamp, inBusNumber, inNumberFrames, ioData);
-}
-
diff --git a/src/CoreAudio/AudioToolbox/AudioUnitRenderer.h b/src/CoreAudio/AudioToolbox/AudioUnitRenderer.h
deleted file mode 100644
index 391941519..000000000
--- a/src/CoreAudio/AudioToolbox/AudioUnitRenderer.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef AUDIOUNITRENDERER_H
-#define AUDIOUNITRENDERER_H
-#include "AudioUnitBase.h"
-
-// Wraps AURenderCallbackStruct
-class AudioUnitRenderer : public AudioUnitComponent
-{
-public:
- AudioUnitRenderer(const AURenderCallbackStruct& cb);
- AudioUnitRenderer();
-
- AudioUnitRenderer& operator=(const AURenderCallbackStruct& cb) { m_renderCallback = cb; return *this; }
- OSStatus init() override;
- OSStatus deinit() override;
-
- OSStatus reset(AudioUnitScope inScope, AudioUnitElement inElement) override;
-
- OSStatus render(AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData) override;
-private:
- AURenderCallbackStruct m_renderCallback;
-};
-
-#endif
diff --git a/src/CoreAudio/CMakeLists.txt b/src/CoreAudio/CMakeLists.txt
index 3c83979e9..f8cb22290 100644
--- a/src/CoreAudio/CMakeLists.txt
+++ b/src/CoreAudio/CMakeLists.txt
@@ -22,3 +22,4 @@ wrap_elf(pulse libpulse.so)
add_subdirectory(CoreAudio)
add_subdirectory(AudioToolbox)
add_subdirectory(CoreAudioComponent)
+add_subdirectory(AFAVFormatComponent)
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUBase.cpp b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUBase.cpp
index dd280595e..612bc4d30 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUBase.cpp
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUBase.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: AUBase.cpp
+ Abstract: AUBase.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 "AUBase.h"
#include "AUDispatch.h"
#include "AUInputElement.h"
@@ -17,6 +55,8 @@ Part of Core Audio AUBase Classes
#include "CAVectorUnit.h"
#include "CAXException.h"
+
+
#if TARGET_OS_MAC && (TARGET_CPU_X86 || TARGET_CPU_X86_64)
// our compiler does ALL floating point with SSE
inline int GETCSR () { int _result; asm volatile ("stmxcsr %0" : "=m" (*&_result) ); return _result; }
@@ -705,6 +745,16 @@ OSStatus AUBase::DispatchGetProperty( AudioUnitPropertyID inID,
break;
#endif
#if !CA_NO_AU_UI_FEATURES
+ case kAudioUnitProperty_IconLocation:
+ {
+ CFURLRef iconLocation = CopyIconLocation();
+ if (iconLocation) {
+ *(CFURLRef*)outData = iconLocation;
+ } else
+ result = kAudioUnitErr_InvalidProperty;
+ }
+ break;
+
case kAudioUnitProperty_ContextName:
*(CFStringRef *)outData = mContextName;
if (mContextName) {
@@ -716,16 +766,6 @@ OSStatus AUBase::DispatchGetProperty( AudioUnitPropertyID inID,
}
break;
- case kAudioUnitProperty_IconLocation:
- {
- CFURLRef iconLocation = CopyIconLocation();
- if (iconLocation) {
- *(CFURLRef*)outData = iconLocation;
- } else
- result = kAudioUnitErr_InvalidProperty;
- }
- break;
-
case kAudioUnitProperty_ParameterClumpName:
{
AudioUnitParameterNameInfo * ioClumpInfo = (AudioUnitParameterNameInfo*) outData;
@@ -818,14 +858,12 @@ OSStatus AUBase::DispatchSetProperty( AudioUnitPropertyID inID,
// sizes of this struct based on aligment padding inconsistencies
memset (&newDesc, 0, sizeof(newDesc));
memcpy (&newDesc, inData, 36);
-
- ca_require(SanityCheck(newDesc), InvalidFormat);
ca_require(ValidFormat(inScope, inElement, newDesc), InvalidFormat);
const CAStreamBasicDescription curDesc = GetStreamFormat(inScope, inElement);
- if ( !curDesc.IsExactlyEqual(newDesc) ) {
+ if ( !curDesc.IsEqual(newDesc, false) ) {
ca_require(IsStreamFormatWritable(inScope, inElement), NotWritable);
result = ChangeStreamFormat(inScope, inElement, curDesc, newDesc);
}
@@ -843,7 +881,7 @@ OSStatus AUBase::DispatchSetProperty( AudioUnitPropertyID inID,
ca_require(ValidFormat(inScope, inElement, newDesc), InvalidFormat);
- if ( !curDesc.IsExactlyEqual(newDesc) ) {
+ if ( !curDesc.IsEqual(newDesc, false) ) {
ca_require(IsStreamFormatWritable(inScope, inElement), NotWritable);
result = ChangeStreamFormat(inScope, inElement, curDesc, newDesc);
}
@@ -1393,9 +1431,9 @@ OSStatus AUBase::DoRender( AudioUnitRenderActionFlags & ioActionFlags,
ca_require(IsInitialized(), Uninitialized);
ca_require(mAudioUnitAPIVersion >= 2, ParamErr);
if (inFramesToProcess > mMaxFramesPerSlice) {
- static UInt64 lastTimeMessagePrinted = 0;
- UInt64 now = CAHostTimeBase::GetCurrentTime();
- if (now - lastTimeMessagePrinted > CAHostTimeBase::GetFrequency()) { // not more than once per second.
+ static time_t lastTimeMessagePrinted = 0;
+ time_t now = time(NULL);
+ if (now != lastTimeMessagePrinted) {
lastTimeMessagePrinted = now;
syslog(LOG_ERR, "kAudioUnitErr_TooManyFramesToProcess : inFramesToProcess=%u, mMaxFramesPerSlice=%u", (unsigned)inFramesToProcess, (unsigned)mMaxFramesPerSlice);
DebugMessageN4("%s:%d inFramesToProcess=%u, mMaxFramesPerSlice=%u; TooManyFrames", __FILE__, __LINE__, (unsigned)inFramesToProcess, (unsigned)mMaxFramesPerSlice);
@@ -1491,7 +1529,7 @@ OSStatus AUBase::DoRender( AudioUnitRenderActionFlags & ioActionFlags,
}
done:
RESTORE_DENORMALS
- AUTRACE(kCATrace_AUBaseRenderEnd, mComponentInstance, (intptr_t)this, theError, ioActionFlags, CATrace_ablData(ioData));
+ AUTRACE(kCATrace_AUBaseRenderEnd, mComponentInstance, (intptr_t)this, theError, ioActionFlags, CATrace::ablData(ioData));
return theError;
@@ -1575,7 +1613,7 @@ OSStatus AUBase::DoProcess ( AudioUnitRenderActionFlags & ioActionFlags,
}
done:
RESTORE_DENORMALS
- AUTRACE(kCATrace_AUBaseRenderEnd, mComponentInstance, (intptr_t)this, theError, ioActionFlags, CATrace_ablData(ioData));
+ AUTRACE(kCATrace_AUBaseRenderEnd, mComponentInstance, (intptr_t)this, theError, ioActionFlags, CATrace::ablData(ioData));
return theError;
@@ -1767,9 +1805,7 @@ bool AUBase::ValidFormat( AudioUnitScope inScope,
AudioUnitElement inElement,
const CAStreamBasicDescription & inNewFormat)
{
- bool isInterleaved = false;
-
- return inNewFormat.IsCommonFloat32(&isInterleaved) && !isInterleaved;
+ return FormatIsCanonical(inNewFormat);
}
//_____________________________________________________________________________
@@ -1834,11 +1870,8 @@ OSStatus AUBase::SetBusCount( AudioUnitScope inScope,
OSStatus AUBase::ChangeStreamFormat( AudioUnitScope inScope,
AudioUnitElement inElement,
const CAStreamBasicDescription & inPrevFormat,
- const CAStreamBasicDescription & inNewFormat)
+ const CAStreamBasicDescription & inNewFormat)
{
- if (inNewFormat.IsExactlyEqual(inPrevFormat))
- return noErr;
-
//#warning "aliasing of global scope format should be pushed to subclasses"
AUIOElement *element;
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUBase.h b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUBase.h
index ce0290cd5..0c78221cc 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUBase.h
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUBase.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: AUBase.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 __AUBase_h__
#define __AUBase_h__
@@ -47,9 +85,7 @@ Part of Core Audio AUBase Classes
#include "AUPlugInDispatch.h"
-#ifndef CA_CANONICAL_DEPRECATED
- #define CA_CANONICAL_DEPRECATED
-#endif
+
// ________________________________________________________________________
// These are to be moved to the public AudioUnit headers
@@ -256,7 +292,7 @@ public:
UInt32 inNumberInputBufferLists,
const AudioBufferList ** inInputBufferLists,
UInt32 inNumberOutputBufferLists,
- AudioBufferList ** ioOutputBufferLists)
+ AudioBufferList ** ioOutputBufferLists)
{
return kAudio_UnimplementedError;
}
@@ -435,11 +471,9 @@ public:
/*! @method FormatIsCanonical */
- CA_CANONICAL_DEPRECATED
bool FormatIsCanonical( const CAStreamBasicDescription &format);
/*! @method MakeCanonicalFormat */
- CA_CANONICAL_DEPRECATED
void MakeCanonicalFormat( CAStreamBasicDescription & outDesc,
int numChannels = 2);
@@ -879,14 +913,12 @@ private:
};
typedef TThreadSafeList RenderCallbackList;
-protected:
#if !CA_BASIC_AU_FEATURES
enum { kNumScopes = 4 };
#else
enum { kNumScopes = 3 };
#endif
-
-private:
+
/*! @var mElementsCreated */
bool mElementsCreated;
protected:
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUDispatch.cpp b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUDispatch.cpp
index cfc63a2f0..1f0f01c7d 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUDispatch.cpp
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUDispatch.cpp
@@ -1,15 +1,55 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: AUDispatch.cpp
+ Abstract: AUDispatch.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 "AUBase.h"
#include "CAXException.h"
#include "AUDispatch.h"
+
+
#if TARGET_OS_MAC
#if __LP64__
// comp instance, parameters in forward order
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUDispatch.h b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUDispatch.h
index a43ece48a..5acd96250 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUDispatch.h
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUDispatch.h
@@ -1,14 +1,53 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: AUDispatch.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 __AUDispatch_h__
#define __AUDispatch_h__
+
#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
#include
#else
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUInputElement.cpp b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUInputElement.cpp
index f37fc1cc5..2e148e8ba 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUInputElement.cpp
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUInputElement.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: AUInputElement.cpp
+ Abstract: AUInputElement.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 "AUBase.h"
inline bool HasGoodBufferPointers(const AudioBufferList &abl, UInt32 nBytes)
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUInputElement.h b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUInputElement.h
index 18b3e5a48..891e4c60b 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUInputElement.h
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUInputElement.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: AUInputElement.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 __AUInput_h__
#define __AUInput_h__
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUOutputElement.cpp b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUOutputElement.cpp
index 80ddef034..5eb34a1c2 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUOutputElement.cpp
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUOutputElement.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: AUOutputElement.cpp
+ Abstract: AUOutputElement.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 "AUOutputElement.h"
#include "AUBase.h"
@@ -21,4 +59,4 @@ OSStatus AUOutputElement::SetStreamFormat(const CAStreamBasicDescription &desc)
if (result == AUBase::noErr)
AllocateBuffer();
return result;
-}
\ No newline at end of file
+}
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUOutputElement.h b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUOutputElement.h
index e74035ba1..3e6a938ff 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUOutputElement.h
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUOutputElement.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: AUOutputElement.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 __AUOutput_h__
#define __AUOutput_h__
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUPlugInDispatch.cpp b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUPlugInDispatch.cpp
index 17d4f5cbb..3bab19836 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUPlugInDispatch.cpp
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUPlugInDispatch.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: AUPlugInDispatch.cpp
+ Abstract: AUPlugInDispatch.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 "AUPlugInDispatch.h"
#include "CAXException.h"
#include "ComponentBase.h"
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUPlugInDispatch.h b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUPlugInDispatch.h
index 9b790fbd9..6ebea75fd 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUPlugInDispatch.h
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUPlugInDispatch.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: AUPlugInDispatch.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 __AUPlugInBase_h__
#define __AUPlugInBase_h__
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUScopeElement.cpp b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUScopeElement.cpp
index 31f45b512..24bd18e43 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUScopeElement.cpp
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUScopeElement.cpp
@@ -1,13 +1,50 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: AUScopeElement.cpp
+ Abstract: AUScopeElement.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 "AUScopeElement.h"
-#include
#include "AUBase.h"
//_____________________________________________________________________________
@@ -215,16 +252,12 @@ void AUElement::GetParameterList(AudioUnitParameterID *outList)
//_____________________________________________________________________________
//
-void AUElement::SaveState(AudioUnitScope scope, CFMutableDataRef data)
+void AUElement::SaveState(CFMutableDataRef data)
{
- AudioUnitParameterInfo paramInfo;
- CFIndex countOffset = CFDataGetLength(data);
- UInt32 nparams, nOmitted = 0, theData;
-
if(mUseIndexedParameters)
{
- nparams = static_cast(mIndexedParameters.size());
- theData = CFSwapInt32HostToBig(nparams);
+ UInt32 nparams = static_cast(mIndexedParameters.size());
+ UInt32 theData = CFSwapInt32HostToBig(nparams);
CFDataAppendBytes(data, (UInt8 *)&theData, sizeof(nparams));
for (UInt32 i = 0; i < nparams; i++)
@@ -234,15 +267,6 @@ void AUElement::SaveState(AudioUnitScope scope, CFMutableDataRef data)
//CFSwappedFloat32 value; crashes gcc3 PFE
UInt32 value; // really a big-endian float
} entry;
-
- if (mAudioUnit->GetParameterInfo(scope, i, paramInfo) == noErr) {
- if ((paramInfo.flags & kAudioUnitParameterFlag_CFNameRelease) && paramInfo.cfNameString)
- CFRelease(paramInfo.cfNameString);
- if (paramInfo.flags & kAudioUnitParameterFlag_OmitFromPresets) {
- ++nOmitted;
- continue;
- }
- }
entry.paramID = CFSwapInt32HostToBig(i);
@@ -254,9 +278,8 @@ void AUElement::SaveState(AudioUnitScope scope, CFMutableDataRef data)
}
else
{
- nparams = static_cast(mParameters.size());
- theData = CFSwapInt32HostToBig(nparams);
- CFDataAppendBytes(data, (UInt8 *)&theData, sizeof(nparams));
+ UInt32 nparams = CFSwapInt32HostToBig(static_cast(mParameters.size()));
+ CFDataAppendBytes(data, (UInt8 *)&nparams, sizeof(nparams));
for (ParameterMap::iterator i = mParameters.begin(); i != mParameters.end(); ++i) {
struct {
@@ -265,15 +288,6 @@ void AUElement::SaveState(AudioUnitScope scope, CFMutableDataRef data)
UInt32 value; // really a big-endian float
} entry;
- if (mAudioUnit->GetParameterInfo(scope, (*i).first, paramInfo) == noErr) {
- if ((paramInfo.flags & kAudioUnitParameterFlag_CFNameRelease) && paramInfo.cfNameString)
- CFRelease(paramInfo.cfNameString);
- if (paramInfo.flags & kAudioUnitParameterFlag_OmitFromPresets) {
- ++nOmitted;
- continue;
- }
- }
-
entry.paramID = CFSwapInt32HostToBig((*i).first);
AudioUnitParameterValue v = (*i).second.GetValue();
@@ -282,10 +296,6 @@ void AUElement::SaveState(AudioUnitScope scope, CFMutableDataRef data)
CFDataAppendBytes(data, (UInt8 *)&entry, sizeof(entry));
}
}
- if (nOmitted > 0) {
- theData = CFSwapInt32HostToBig(nparams - nOmitted);
- *(UInt32 *)(CFDataGetBytePtr(data) + countOffset) = theData;
- }
}
//_____________________________________________________________________________
@@ -331,9 +341,10 @@ AUIOElement::AUIOElement(AUBase *audioUnit) :
AUElement(audioUnit),
mWillAllocate (true)
{
- mStreamFormat = CAStreamBasicDescription(kAUDefaultSampleRate, 2, CAStreamBasicDescription::kPCMFormatFloat32, audioUnit->AudioUnitAPIVersion() == 1);
- // stereo
+ mStreamFormat.SetAUCanonical(2, // stereo
+ audioUnit->AudioUnitAPIVersion() == 1);
// interleaved if API version 1, deinterleaved if version 2
+ mStreamFormat.mSampleRate = kAUDefaultSampleRate;
}
//_____________________________________________________________________________
@@ -384,8 +395,8 @@ UInt32 AUIOElement::GetChannelLayoutTags (AudioChannelLayoutTag *outLayoutTags
// the AU should also return whether the property is writable (that is the client can provide any arbitrary ACL that the audio unit will then honour)
// or if the property is read only - which is the generally preferred mode.
// If the AU doesn't require an AudioChannelLayout, then just return 0.
-UInt32 AUIOElement::GetAudioChannelLayout (AudioChannelLayout *outMapPtr,
- Boolean &outWritable)
+UInt32 AUIOElement::GetAudioChannelLayout (AudioChannelLayout *outMapPtr,
+ Boolean &outWritable)
{
return 0;
}
@@ -528,7 +539,7 @@ void AUScope::SaveState(CFMutableDataRef data)
hdr.element = CFSwapInt32HostToBig(ielem);
CFDataAppendBytes(data, (UInt8 *)&hdr, sizeof(hdr));
- element->SaveState(mScope, data);
+ element->SaveState(data);
}
}
}
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUScopeElement.h b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUScopeElement.h
index 36235f425..47ebe2f33 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUScopeElement.h
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/AUScopeElement.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: AUScopeElement.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 __AUScopeElement_h__
#define __AUScopeElement_h__
@@ -20,11 +58,8 @@ Part of Core Audio AUBase Classes
#include "ComponentBase.h"
#include "AUBuffer.h"
-class AUBase;
-#ifndef CA_CANONICAL_DEPRECATED
- #define CA_CANONICAL_DEPRECATED
-#endif
+class AUBase;
// ____________________________________________________________________________
//
@@ -210,7 +245,7 @@ public:
AUBase * GetAudioUnit() const { return mAudioUnit; };
/*! @method SaveState */
- void SaveState(AudioUnitScope scope, CFMutableDataRef data);
+ void SaveState(CFMutableDataRef data);
/*! @method RestoreState */
const UInt8 * RestoreState(const UInt8 *state);
/*! @method GetName */
@@ -230,7 +265,7 @@ protected:
private:
typedef std::map > ParameterMap;
-
+
/*! @var mAudioUnit */
AUBase * mAudioUnit;
/*! @var mParameters */
@@ -302,7 +337,6 @@ public:
AudioBufferList & GetBufferList() const { return mIOBuffer.GetBufferList(); }
/*! @method GetChannelData */
- CA_CANONICAL_DEPRECATED
AudioUnitSampleType * GetChannelData(int ch) const {
if (mStreamFormat.IsInterleaved())
return static_cast(mIOBuffer.GetBufferList().mBuffers[0].mData) + ch;
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/ComponentBase.cpp b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/ComponentBase.cpp
index 574b5c8a6..fc987335d 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/ComponentBase.cpp
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/ComponentBase.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: ComponentBase.cpp
+ Abstract: ComponentBase.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 "ComponentBase.h"
#include "CAXException.h"
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/ComponentBase.h b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/ComponentBase.h
index f70cea5a6..a1654416a 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/ComponentBase.h
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUBase/ComponentBase.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: ComponentBase.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 __ComponentBase_h__
#define __ComponentBase_h__
@@ -267,10 +305,10 @@ public:
}
};
-// NOTE: The Carbon Component Manager is deprecated in Mountain Lion (10.8).
-// This macro should not be used with new audio components.
-// It is only for backwards compatibility with Lion and Snow Leopard.
-// This macro registers both an Audio Component plugin and a Carbon Component Manager version.
+// NOTE: Component Mgr is deprecated in ML.
+// this macro should not be used with new audio components
+// it is only for backwards compatibility with Lion and SL.
+// this macro registers both a plugin and a component mgr version.
#define AUDIOCOMPONENT_ENTRY(FactoryType, Class) \
extern "C" OSStatus Class##Entry(ComponentParameters *params, Class *obj); \
extern "C" OSStatus Class##Entry(ComponentParameters *params, Class *obj) { \
@@ -301,8 +339,8 @@ public:
#else
#define COMPONENT_ENTRY(Class)
#define COMPONENT_REGISTER(Class)
-// This macro is used to generate the Entry Point for a given Audio Component.
-// You should be using this macro now.
+// this macro is used to generate the Entry Point for a given Audio Plugin
+// you should be using this macro now with audio components
#define AUDIOCOMPONENT_ENTRY(FactoryType, Class) \
extern "C" void * Class##Factory(const AudioComponentDescription *inDesc); \
extern "C" void * Class##Factory(const AudioComponentDescription *inDesc) { \
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/AUInstrumentBase.cpp b/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/AUInstrumentBase.cpp
index 9056df60b..1ce8b308b 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/AUInstrumentBase.cpp
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/AUInstrumentBase.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUInstrument Base Classes
+ File: AUInstrumentBase.cpp
+ Abstract: AUInstrumentBase.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 "AUInstrumentBase.h"
#include "AUMIDIDefs.h"
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/AUInstrumentBase.h b/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/AUInstrumentBase.h
index 346c3c8d3..3ad7e03a6 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/AUInstrumentBase.h
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/AUInstrumentBase.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUInstrument Base Classes
+ File: AUInstrumentBase.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 __AUInstrumentBase__
#define __AUInstrumentBase__
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/LockFreeFIFO.h b/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/LockFreeFIFO.h
index 38a3f08dd..ea6c4c26e 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/LockFreeFIFO.h
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/LockFreeFIFO.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUInstrument Base Classes
+ File: LockFreeFIFO.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.
+
*/
-
#include
template
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/MIDIControlHandler.h b/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/MIDIControlHandler.h
index 51983696e..0f8003fcd 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/MIDIControlHandler.h
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/MIDIControlHandler.h
@@ -1,3 +1,49 @@
+/*
+ File: MIDIControlHandler.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 __MIDICONTROLHANDLER_H__
#define __MIDICONTROLHANDLER_H__
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthElement.cpp b/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthElement.cpp
index 7fa67b0db..fd329f84e 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthElement.cpp
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthElement.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUInstrument Base Classes
+ File: SynthElement.cpp
+ Abstract: SynthElement.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 "SynthElement.h"
#include "AUInstrumentBase.h"
#include "AUMIDIDefs.h"
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthElement.h b/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthElement.h
index c0049e057..4ca364310 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthElement.h
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthElement.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUInstrument Base Classes
+ File: SynthElement.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 __SynthElement__
#define __SynthElement__
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthEvent.h b/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthEvent.h
index 307bace9b..9c27aee04 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthEvent.h
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthEvent.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUInstrument Base Classes
+ File: SynthEvent.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.
+
*/
-
/* You can either fill in code here or remove this and create or add new files. */
#ifndef __SynthEvent__
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthNote.cpp b/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthNote.cpp
index 813fd4332..96a24d33c 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthNote.cpp
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthNote.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUInstrument Base Classes
+ File: SynthNote.cpp
+ Abstract: SynthNote.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 "SynthNote.h"
#include "SynthElement.h"
#include "AUInstrumentBase.h"
@@ -44,8 +82,8 @@ void SynthNote::Reset()
mGroup = 0;
mAbsoluteStartFrame = 0;
mRelativeStartFrame = 0;
- mRelativeReleaseFrame = -1;
- mRelativeKillFrame = -1;
+ mRelativeReleaseFrame = 0;
+ mRelativeKillFrame = 0;
}
void SynthNote::Kill(UInt32 inFrame)
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthNote.h b/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthNote.h
index 82e613bce..cec637721 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthNote.h
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthNote.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUInstrument Base Classes
+ File: SynthNote.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 __SynthNote__
#define __SynthNote__
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthNoteList.cpp b/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthNoteList.cpp
index 44444f423..849abd266 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthNoteList.cpp
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthNoteList.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUInstrument Base Classes
+ File: SynthNoteList.cpp
+ Abstract: SynthNoteList.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 "SynthNoteList.h"
#include
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthNoteList.h b/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthNoteList.h
index 12483f152..47a359301 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthNoteList.h
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/AUInstrumentBase/SynthNoteList.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUInstrument Base Classes
+ File: SynthNoteList.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 __SynthNoteList__
#define __SynthNoteList__
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/AUEffectBase.cpp b/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/AUEffectBase.cpp
index cc652475b..010082fc3 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/AUEffectBase.cpp
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/AUEffectBase.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: AUEffectBase.cpp
+ Abstract: AUEffectBase.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 "AUEffectBase.h"
/*
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/AUEffectBase.h b/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/AUEffectBase.h
index 66bb967e0..13ba96b39 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/AUEffectBase.h
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/AUEffectBase.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: AUEffectBase.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 __AUEffectBase_h__
#define __AUEffectBase_h__
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/AUMIDIBase.cpp b/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/AUMIDIBase.cpp
index e48574447..e5e358d68 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/AUMIDIBase.cpp
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/AUMIDIBase.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: AUMIDIBase.cpp
+ Abstract: AUMIDIBase.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 "AUMIDIBase.h"
#include
#include "CAXException.h"
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/AUMIDIBase.h b/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/AUMIDIBase.h
index a275d784a..40c6a7769 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/AUMIDIBase.h
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/AUMIDIBase.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: AUMIDIBase.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 __AUMIDIBase_h__
#define __AUMIDIBase_h__
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/AUMIDIEffectBase.cpp b/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/AUMIDIEffectBase.cpp
index ce58e5f08..dfe307c9e 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/AUMIDIEffectBase.cpp
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/AUMIDIEffectBase.cpp
@@ -1,7 +1,48 @@
/*
-
- AUMIDIEffectBase.h
-
+ File: AUMIDIEffectBase.cpp
+ Abstract: AUMIDIEffectBase.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 "AUMIDIEffectBase.h"
@@ -13,13 +54,11 @@ typedef OSStatus
UInt32 inData2,
UInt32 inOffsetSampleFrame);
-#if !CA_USE_AUDIO_PLUGIN_ONLY
static OSStatus AUMIDIEffectBaseMIDIEvent(void * inComponentStorage,
UInt32 inStatus,
UInt32 inData1,
UInt32 inData2,
UInt32 inOffsetSampleFrame);
-#endif
AUMIDIEffectBase::AUMIDIEffectBase( AudioComponentInstance inInstance,
bool inProcessesInPlace )
@@ -84,7 +123,7 @@ OSStatus AUMIDIEffectBase::SetProperty( AudioUnitPropertyID inID,
return result;
}
-#if !CA_USE_AUDIO_PLUGIN_ONLY
+
#if !TARGET_OS_IPHONE
OSStatus AUMIDIEffectBase::ComponentEntryDispatch(ComponentParameters * params,
AUMIDIEffectBase * This)
@@ -123,4 +162,3 @@ static OSStatus AUMIDIEffectBaseMIDIEvent(void * inComponentStorage,
COMPONENT_CATCH
return result;
}
-#endif
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/AUMIDIEffectBase.h b/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/AUMIDIEffectBase.h
index a37a7d307..b38f506d6 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/AUMIDIEffectBase.h
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/AUMIDIEffectBase.h
@@ -1,7 +1,48 @@
/*
-
- Part of CoreAudio Utility Classes
-
+ File: AUMIDIEffectBase.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 __AUMIDIEffectBase_h__
#define __AUMIDIEffectBase_h__
@@ -52,15 +93,12 @@ public:
AudioUnitElement inElement,
const void * inData,
UInt32 inDataSize);
-
-#if !CA_USE_AUDIO_PLUGIN_ONLY
#if !TARGET_OS_IPHONE
// component dispatcher
/*! @method ComponentEntryDispatch */
static OSStatus ComponentEntryDispatch( ComponentParameters * params,
AUMIDIEffectBase * This);
#endif
-#endif
};
#endif // __AUMIDIEffectBase_h__
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/MusicDeviceBase.cpp b/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/MusicDeviceBase.cpp
index 778d2d100..28e4d366b 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/MusicDeviceBase.cpp
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/MusicDeviceBase.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: MusicDeviceBase.cpp
+ Abstract: MusicDeviceBase.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 "MusicDeviceBase.h"
// compatibility with older OS SDK releases
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/MusicDeviceBase.h b/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/MusicDeviceBase.h
index b856fde3b..4850b8f0c 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/MusicDeviceBase.h
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/OtherBases/MusicDeviceBase.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: MusicDeviceBase.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 __MusicDeviceBase_h__
#define __MusicDeviceBase_h__
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/Utility/AUBaseHelper.cpp b/src/CoreAudio/CoreAudioComponent/AUPublic/Utility/AUBaseHelper.cpp
index 328b25e50..231680713 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/Utility/AUBaseHelper.cpp
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/Utility/AUBaseHelper.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: AUBaseHelper.cpp
+ Abstract: AUBaseHelper.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 "AUBaseHelper.h"
#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/Utility/AUBaseHelper.h b/src/CoreAudio/CoreAudioComponent/AUPublic/Utility/AUBaseHelper.h
index e27e59e65..310a8df62 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/Utility/AUBaseHelper.h
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/Utility/AUBaseHelper.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: AUBaseHelper.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 __AUBaseHelper_h__
#define __AUBaseHelper_h__
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/Utility/AUBuffer.cpp b/src/CoreAudio/CoreAudioComponent/AUPublic/Utility/AUBuffer.cpp
index 2697e5b31..36bb41fa5 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/Utility/AUBuffer.cpp
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/Utility/AUBuffer.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: AUBuffer.cpp
+ Abstract: AUBuffer.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 "AUBuffer.h"
#include
@@ -40,7 +78,7 @@ void AUBufferList::Allocate(const CAStreamBasicDescription &format, UInt32 nF
if (nStreams > mAllocatedStreams) {
size_t theHeaderSize = sizeof(AudioBufferList) - sizeof(AudioBuffer);
mPtrs = (AudioBufferList *)CA_realloc(mPtrs,
- SafeMultiplyAddUInt32(nStreams, sizeof(AudioBuffer), (UInt32)theHeaderSize));
+ SafeMultiplyAddUInt32(nStreams, sizeof(AudioBuffer), theHeaderSize));
mAllocatedStreams = nStreams;
}
UInt32 bytesPerStream = SafeMultiplyAddUInt32(nFrames, format.mBytesPerFrame, 0xF) & ~0xF;
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/Utility/AUBuffer.h b/src/CoreAudio/CoreAudioComponent/AUPublic/Utility/AUBuffer.h
index a176af07a..64ea4c397 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/Utility/AUBuffer.h
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/Utility/AUBuffer.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: AUBuffer.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 __AUBuffer_h__
#define __AUBuffer_h__
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/Utility/AUMIDIDefs.h b/src/CoreAudio/CoreAudioComponent/AUPublic/Utility/AUMIDIDefs.h
index 38af84ec1..e83c0e7e8 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/Utility/AUMIDIDefs.h
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/Utility/AUMIDIDefs.h
@@ -1,3 +1,49 @@
+/*
+ File: AUMIDIDefs.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 __AUMIDIDefs_h__
#define __AUMIDIDefs_h__
diff --git a/src/CoreAudio/CoreAudioComponent/AUPublic/Utility/AUSilentTimeout.h b/src/CoreAudio/CoreAudioComponent/AUPublic/Utility/AUSilentTimeout.h
index e7da2b0c8..9fbd3e1f2 100644
--- a/src/CoreAudio/CoreAudioComponent/AUPublic/Utility/AUSilentTimeout.h
+++ b/src/CoreAudio/CoreAudioComponent/AUPublic/Utility/AUSilentTimeout.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio AUBase Classes
+ File: AUSilentTimeout.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 __AUSilentTimeout
#define __AUSilentTimeout
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAUMIDIMap.cpp b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAUMIDIMap.cpp
index b5452043d..4e72b2285 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAUMIDIMap.cpp
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAUMIDIMap.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAAUMIDIMap.cpp
+ Abstract: CAAUMIDIMap.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 "CAAUMIDIMap.h"
#include
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAUMIDIMap.h b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAUMIDIMap.h
index 3ae7df5b3..a53fdf70d 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAUMIDIMap.h
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAUMIDIMap.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAAUMIDIMap.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 __CAAUMIDIMap_h_
#define __CAAUMIDIMap_h_
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAUMIDIMapManager.cpp b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAUMIDIMapManager.cpp
index 1c9d8f219..b24ff9945 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAUMIDIMapManager.cpp
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAUMIDIMapManager.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAAUMIDIMapManager.cpp
+ Abstract: CAAUMIDIMapManager.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 "CAAUMIDIMapManager.h"
#include
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAUMIDIMapManager.h b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAUMIDIMapManager.h
index 42bfafa93..8926d8f6e 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAUMIDIMapManager.h
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAUMIDIMapManager.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAAUMIDIMapManager.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 __CAAUMIDIMapManager_h_
#define __CAAUMIDIMapManager_h_
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAtomic.h b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAtomic.h
index f7f3f5df4..c9a611bf7 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAtomic.h
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAtomic.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAAtomic.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.
+
*/
-
/*
This file implements all Atomic operations using Interlocked functions specified in
Winbase.h
@@ -15,14 +53,13 @@ full barrier.
As the Interlocked functions returns the Old value, Extra checks and operations
are made after the atomic operation to return value consistent with OSX counterparts.
*/
-
#ifndef __CAAtomic_h__
#define __CAAtomic_h__
#if TARGET_OS_WIN32
#include
#include
- #pragma intrinsic(_InterlockedOr)
+ #pragma intrinsic(_InterlockedOr)
#pragma intrinsic(_InterlockedAnd)
#else
#include
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAtomicStack.h b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAtomicStack.h
index 6b2093028..8d40fc5d2 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAtomicStack.h
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAtomicStack.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAAtomicStack.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 __CAAtomicStack_h__
#define __CAAtomicStack_h__
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAudioChannelLayout.cpp b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAudioChannelLayout.cpp
index fc9d71305..74753598d 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAudioChannelLayout.cpp
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAudioChannelLayout.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAAudioChannelLayout.cpp
+ Abstract: CAAudioChannelLayout.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
//=============================================================================
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAudioChannelLayout.h b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAudioChannelLayout.h
index 34d0b89ca..4307054ae 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAudioChannelLayout.h
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAudioChannelLayout.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAAudioChannelLayout.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(__CAAudioChannelLayout_h__)
#define __CAAudioChannelLayout_h__
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAudioChannelLayoutObject.cpp b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAudioChannelLayoutObject.cpp
index 382188a55..009d4b3b5 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAudioChannelLayoutObject.cpp
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAudioChannelLayoutObject.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAAudioChannelLayoutObject.cpp
+ Abstract: CAAudioChannelLayoutObject.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 "CAAudioChannelLayout.h"
#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
#include
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAutoDisposer.h b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAutoDisposer.h
index 417bde0e7..2da241506 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAutoDisposer.h
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAAutoDisposer.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAAutoDisposer.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(__CAPtr_h__)
#define __CAPtr_h__
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CABufferList.cpp b/src/CoreAudio/CoreAudioComponent/PublicUtility/CABufferList.cpp
index 9ff292dfa..3249013b5 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CABufferList.cpp
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CABufferList.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CABufferList.cpp
+ Abstract: CABufferList.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 "CABufferList.h"
#include "CAByteOrder.h"
@@ -198,9 +236,7 @@ extern "C" void CAShowAudioBufferList(const AudioBufferList *abl, int framesToPr
show(*abl, framesToPrint, wordSize, NULL);
}
-#pragma mark- CrashIfClientProvidedBogusAudioBufferList Diagostic Function
// if the return result is odd, there was a null buffer.
-/*
extern "C" int CrashIfClientProvidedBogusAudioBufferList(const AudioBufferList *abl, bool nullok)
{
const AudioBuffer *buf = abl->mBuffers, *bufend = buf + abl->mNumberBuffers;
@@ -213,11 +249,11 @@ extern "C" int CrashIfClientProvidedBogusAudioBufferList(const AudioBufferList *
if (nullok) continue;
}
unsigned datasize = buf->mDataByteSize;
- if (datasize >= sizeof(int)) {
+ if (datasize >= sizeof(int) && p != NULL) {
sum += p[0];
sum += p[datasize / sizeof(int) - 1];
}
}
return anyNull | (sum & ~1);
}
-*/
+
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CABufferList.h b/src/CoreAudio/CoreAudioComponent/PublicUtility/CABufferList.h
index 1497ad0e8..72c93f862 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CABufferList.h
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CABufferList.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CABufferList.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 __CABufferList_h__
#define __CABufferList_h__
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAByteOrder.h b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAByteOrder.h
index 04985732c..9a56c6d85 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAByteOrder.h
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAByteOrder.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAByteOrder.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(__CAByteOrder_h__)
#define __CAByteOrder_h__
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CADebugMacros.cpp b/src/CoreAudio/CoreAudioComponent/PublicUtility/CADebugMacros.cpp
index bfa4b0bd7..9739e3753 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CADebugMacros.cpp
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CADebugMacros.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CADebugMacros.cpp
+ Abstract: CADebugMacros.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 "CADebugMacros.h"
#include
#include
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CADebugMacros.h b/src/CoreAudio/CoreAudioComponent/PublicUtility/CADebugMacros.h
index c65cf961f..15af91909 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CADebugMacros.h
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CADebugMacros.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CADebugMacros.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(__CADebugMacros_h__)
#define __CADebugMacros_h__
@@ -68,7 +106,7 @@ Part of Core Audio Public Utility Classes
#else
#include "CADebugPrintf.h"
- #if (CoreAudio_FlushDebugMessages && !CoreAudio_UseSysLog && !CoreAudio_UseCALog) || defined(CoreAudio_UseSideFile)
+ #if (CoreAudio_FlushDebugMessages && !CoreAudio_UseSysLog) || defined(CoreAudio_UseSideFile)
#define FlushRtn ,fflush(DebugPrintfFile)
#else
#define FlushRtn
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CADebugPrintf.cpp b/src/CoreAudio/CoreAudioComponent/PublicUtility/CADebugPrintf.cpp
index ef5677133..d691de3cd 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CADebugPrintf.cpp
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CADebugPrintf.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CADebugPrintf.cpp
+ Abstract: CADebugPrintf.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
//==================================================================================================
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CADebugPrintf.h b/src/CoreAudio/CoreAudioComponent/PublicUtility/CADebugPrintf.h
index 6a626efc5..79aa15daf 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CADebugPrintf.h
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CADebugPrintf.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CADebugPrintf.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(__CADebugPrintf_h__)
#define __CADebugPrintf_h__
@@ -23,6 +61,7 @@ Part of Core Audio Public Utility Classes
// Macros to redirect debugging output to various logging services
//=============================================================================
+//#define CoreAudio_UseSysLog 1
//#define CoreAudio_UseSideFile "/CoreAudio-%d.txt"
#if DEBUG || CoreAudio_Debug
@@ -33,10 +72,9 @@ Part of Core Audio Public Utility Classes
#endif
extern int CAWin32DebugPrintf(char* inFormat, ...);
#define DebugPrintfRtn CAWin32DebugPrintf
- #define DebugPrintfFile
+ #define DebugPrintfFile
#define DebugPrintfLineEnding "\n"
#define DebugPrintfFileComma
- #define DebugPrintf(inFormat, ...) CAWin32DebugPrintf(informat "\n", ## __VA_ARGS__)
#else
#if CoreAudio_UseSysLog
#include
@@ -44,7 +82,6 @@ Part of Core Audio Public Utility Classes
#define DebugPrintfFile LOG_NOTICE
#define DebugPrintfLineEnding ""
#define DebugPrintfFileComma DebugPrintfFile,
- #define DebugPrintf(inFormat, ...) DebugPrintfRtn(DebugPrintfFileComma inFormat DebugPrintfLineEnding, ## __VA_ARGS__)
#elif defined(CoreAudio_UseSideFile)
#include
#if defined(__cplusplus)
@@ -56,27 +93,16 @@ Part of Core Audio Public Utility Classes
#define DebugPrintfFile ((sDebugPrintfSideFile != NULL) ? sDebugPrintfSideFile : stderr)
#define DebugPrintfLineEnding "\n"
#define DebugPrintfFileComma DebugPrintfFile,
- #define DebugPrintf(inFormat, ...) DebugPrintfRtn(DebugPrintfFileComma inFormat DebugPrintfLineEnding, ## __VA_ARGS__)
- #elif CoreAudio_UseCALog
- #include "CALog.h"
- /* We cannot use 'LOG' for 'DebugPrintfRtn' because it is a concatenating macro itself. So we have to use syslog here. */
- #include
- #define DebugPrintfRtn syslog
- #define DebugPrintfFile LOG_NOTICE
- #define DebugPrintfLineEnding ""
- #define DebugPrintfFileComma DebugPrintfFile,
- /* Direct calls to 'DebugPrintf' use the new CALog system */
- #define DebugPrintf(inFormat, ...) LOG(kLogPriority_Notice, 0, inFormat, ## __VA_ARGS__)
#else
#include
#define DebugPrintfRtn fprintf
#define DebugPrintfFile stderr
#define DebugPrintfLineEnding "\n"
#define DebugPrintfFileComma DebugPrintfFile,
- #define DebugPrintf(inFormat, ...) DebugPrintfRtn(DebugPrintfFileComma inFormat DebugPrintfLineEnding, ## __VA_ARGS__)
#endif
#endif
+ #define DebugPrintf(inFormat, ...) DebugPrintfRtn(DebugPrintfFileComma inFormat DebugPrintfLineEnding, ## __VA_ARGS__)
#else
#define DebugPrintfRtn
#define DebugPrintfFile
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CADebugger.cpp b/src/CoreAudio/CoreAudioComponent/PublicUtility/CADebugger.cpp
index 2ba5250ad..7f0141d20 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CADebugger.cpp
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CADebugger.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CADebugger.cpp
+ Abstract: CADebugger.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
//=============================================================================
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CADebugger.h b/src/CoreAudio/CoreAudioComponent/PublicUtility/CADebugger.h
index b194516cf..9391f011a 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CADebugger.h
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CADebugger.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CADebugger.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(__CADebugger_h__)
#define __CADebugger_h__
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAException.h b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAException.h
index 30a5bba30..7217001d7 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAException.h
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAException.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAException.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(__CAException_h__)
#define __CAException_h__
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAGuard.cpp b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAGuard.cpp
index 6d0435b93..a1c83be9d 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAGuard.cpp
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAGuard.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAGuard.cpp
+ Abstract: CAGuard.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
//==================================================================================================
@@ -76,7 +114,7 @@ void CAGuard::Wait()
mOwner = 0;
#if Log_WaitOwnership
- DebugPrintf("%p %.4f: CAGuard::Wait: thread %p is waiting on %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), pthread_self(), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: CAGuard::Wait: thread %p is waiting on %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), pthread_self(), mName, mOwner);
#endif
OSStatus theError = pthread_cond_wait(&mCondVar, &mMutex);
@@ -84,7 +122,7 @@ void CAGuard::Wait()
mOwner = pthread_self();
#if Log_WaitOwnership
- DebugPrintf("%p %.4f: CAGuard::Wait: thread %p waited on %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), pthread_self(), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: CAGuard::Wait: thread %p waited on %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), pthread_self(), mName, mOwner);
#endif
#elif TARGET_OS_WIN32
ThrowIf(GetCurrentThreadId() != mOwner, CAException(1), "CAGuard::Wait: A thread has to have locked a guard before it can wait");
@@ -92,7 +130,7 @@ void CAGuard::Wait()
mOwner = 0;
#if Log_WaitOwnership
- DebugPrintf("%lu %.4f: CAGuard::Wait: thread %lu is waiting on %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%lu %.4f: CAGuard::Wait: thread %lu is waiting on %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
#endif
ReleaseMutex(mMutex);
@@ -103,7 +141,7 @@ void CAGuard::Wait()
ResetEvent(mEvent);
#if Log_WaitOwnership
- DebugPrintf("%lu %.4f: CAGuard::Wait: thread %lu waited on %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%lu %.4f: CAGuard::Wait: thread %lu waited on %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
#endif
#endif
}
@@ -139,7 +177,7 @@ bool CAGuard::WaitFor(UInt64 inNanos)
mOwner = 0;
#if Log_WaitOwnership
- DebugPrintf("%p %.4f: CAGuard::WaitFor: thread %p is waiting on %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), pthread_self(), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: CAGuard::WaitFor: thread %p is waiting on %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), pthread_self(), mName, mOwner);
#endif
OSStatus theError = pthread_cond_timedwait_relative_np(&mCondVar, &mMutex, &theTimeSpec);
@@ -170,7 +208,7 @@ bool CAGuard::WaitFor(UInt64 inNanos)
#endif
#if Log_WaitOwnership
- DebugPrintf("%p %.4f: CAGuard::WaitFor: thread %p waited on %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), pthread_self(), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: CAGuard::WaitFor: thread %p waited on %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), pthread_self(), mName, mOwner);
#endif
theAnswer = theError == ETIMEDOUT;
@@ -191,7 +229,7 @@ bool CAGuard::WaitFor(UInt64 inNanos)
mOwner = 0;
#if Log_WaitOwnership
- DebugPrintf("%lu %.4f: CAGuard::WaitFor: thread %lu is waiting on %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%lu %.4f: CAGuard::WaitFor: thread %lu is waiting on %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
#endif
ReleaseMutex(mMutex);
@@ -229,7 +267,7 @@ bool CAGuard::WaitFor(UInt64 inNanos)
#endif
#if Log_WaitOwnership
- DebugPrintf("%lu %.4f: CAGuard::WaitFor: thread %lu waited on %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%lu %.4f: CAGuard::WaitFor: thread %lu waited on %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
#endif
theAnswer = theError == WAIT_TIMEOUT;
@@ -272,14 +310,14 @@ void CAGuard::Notify()
{
#if TARGET_OS_MAC
#if Log_WaitOwnership
- DebugPrintf("%p %.4f: CAGuard::Notify: thread %p is notifying %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), pthread_self(), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: CAGuard::Notify: thread %p is notifying %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), pthread_self(), mName, mOwner);
#endif
OSStatus theError = pthread_cond_signal(&mCondVar);
ThrowIf(theError != 0, CAException(theError), "CAGuard::Notify: failed");
#elif TARGET_OS_WIN32
#if Log_WaitOwnership
- DebugPrintf("%lu %.4f: CAGuard::Notify: thread %lu is notifying %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%lu %.4f: CAGuard::Notify: thread %lu is notifying %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
#endif
SetEvent(mEvent);
@@ -290,14 +328,14 @@ void CAGuard::NotifyAll()
{
#if TARGET_OS_MAC
#if Log_WaitOwnership
- DebugPrintf("%p %.4f: CAGuard::NotifyAll: thread %p is notifying %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), pthread_self(), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: CAGuard::NotifyAll: thread %p is notifying %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), pthread_self(), mName, mOwner);
#endif
OSStatus theError = pthread_cond_broadcast(&mCondVar);
ThrowIf(theError != 0, CAException(theError), "CAGuard::NotifyAll: failed");
#elif TARGET_OS_WIN32
#if Log_WaitOwnership
- DebugPrintf("%lu %.4f: CAGuard::NotifyAll: thread %lu is notifying %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%lu %.4f: CAGuard::NotifyAll: thread %lu is notifying %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
#endif
SetEvent(mEvent);
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAGuard.h b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAGuard.h
index af35b4a3d..ffcb59da8 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAGuard.h
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAGuard.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAGuard.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(__CAGuard_h__)
#define __CAGuard_h__
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAHostTimeBase.cpp b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAHostTimeBase.cpp
index 974ccd72f..db78a4afe 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAHostTimeBase.cpp
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAHostTimeBase.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAHostTimeBase.cpp
+ Abstract: CAHostTimeBase.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
//=============================================================================
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAHostTimeBase.h b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAHostTimeBase.h
index 83bff4ac7..50e350764 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAHostTimeBase.h
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAHostTimeBase.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAHostTimeBase.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(__CAHostTimeBase_h__)
#define __CAHostTimeBase_h__
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CALogMacros.h b/src/CoreAudio/CoreAudioComponent/PublicUtility/CALogMacros.h
index dd970d5bf..7fd4ac4c2 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CALogMacros.h
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CALogMacros.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CALogMacros.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(__CALogMacros_h__)
#define __CALogMacros_h__
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAMath.h b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAMath.h
index 153225ea9..eb81f26e9 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAMath.h
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAMath.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAMath.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 __CAMath_h__
#define __CAMath_h__
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAMutex.cpp b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAMutex.cpp
index b574fa0af..88cf9b0b0 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAMutex.cpp
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAMutex.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAMutex.cpp
+ Abstract: CAMutex.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
//==================================================================================================
@@ -47,14 +85,14 @@ CAMutex::CAMutex(const char* inName)
ThrowIf(theError != 0, CAException(theError), "CAMutex::CAMutex: Could not init the mutex");
#if Log_Ownership
- DebugPrintf("%p %.4f: CAMutex::CAMutex: creating %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: CAMutex::CAMutex: creating %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), mName, mOwner);
#endif
#elif TARGET_OS_WIN32
mMutex = CreateMutex(NULL, false, NULL);
ThrowIfNULL(mMutex, CAException(GetLastError()), "CAMutex::CAMutex: could not create the mutex.");
#if Log_Ownership
- DebugPrintf("%lu %.4f: CAMutex::CAMutex: creating %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%lu %.4f: CAMutex::CAMutex: creating %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), mName, mOwner);
#endif
#endif
}
@@ -63,12 +101,12 @@ CAMutex::~CAMutex()
{
#if TARGET_OS_MAC
#if Log_Ownership
- DebugPrintf("%p %.4f: CAMutex::~CAMutex: destroying %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: CAMutex::~CAMutex: destroying %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), mName, mOwner);
#endif
pthread_mutex_destroy(&mMutex);
#elif TARGET_OS_WIN32
#if Log_Ownership
- DebugPrintf("%lu %.4f: CAMutex::~CAMutex: destroying %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%lu %.4f: CAMutex::~CAMutex: destroying %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), mName, mOwner);
#endif
if(mMutex != NULL)
{
@@ -86,7 +124,7 @@ bool CAMutex::Lock()
if(!pthread_equal(theCurrentThread, mOwner))
{
#if Log_Ownership
- DebugPrintf("%p %.4f: CAMutex::Lock: thread %p is locking %s, owner: %p\n", theCurrentThread, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), theCurrentThread, mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: CAMutex::Lock: thread %p is locking %s, owner: %p\n", theCurrentThread, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), theCurrentThread, mName, mOwner);
#endif
#if Log_LongLatencies
@@ -101,18 +139,18 @@ bool CAMutex::Lock()
#if Log_LongLatencies
UInt64 lockAcquireTime = CAHostTimeBase::GetCurrentTimeInNanos();
if (lockAcquireTime - lockTryTime >= LongLatencyThresholdNS)
- DebugPrintf("Thread %p took %.6fs to acquire the lock %s\n", theCurrentThread, (lockAcquireTime - lockTryTime) * 1.0e-9 /* nanos to seconds */, mName);
+ DebugPrintfRtn(DebugPrintfFileComma "Thread %p took %.6fs to acquire the lock %s\n", theCurrentThread, (lockAcquireTime - lockTryTime) * 1.0e-9 /* nanos to seconds */, mName);
#endif
#if Log_Ownership
- DebugPrintf("%p %.4f: CAMutex::Lock: thread %p has locked %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), pthread_self(), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: CAMutex::Lock: thread %p has locked %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), pthread_self(), mName, mOwner);
#endif
}
#elif TARGET_OS_WIN32
if(mOwner != GetCurrentThreadId())
{
#if Log_Ownership
- DebugPrintf("%lu %.4f: CAMutex::Lock: thread %lu is locking %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%lu %.4f: CAMutex::Lock: thread %lu is locking %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
#endif
OSStatus theError = WaitForSingleObject(mMutex, INFINITE);
@@ -121,7 +159,7 @@ bool CAMutex::Lock()
theAnswer = true;
#if Log_Ownership
- DebugPrintf("%lu %.4f: CAMutex::Lock: thread %lu has locked %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%lu %.4f: CAMutex::Lock: thread %lu has locked %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
#endif
}
#endif
@@ -135,7 +173,7 @@ void CAMutex::Unlock()
if(pthread_equal(pthread_self(), mOwner))
{
#if Log_Ownership
- DebugPrintf("%p %.4f: CAMutex::Unlock: thread %p is unlocking %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), pthread_self(), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: CAMutex::Unlock: thread %p is unlocking %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), pthread_self(), mName, mOwner);
#endif
mOwner = 0;
@@ -143,7 +181,7 @@ void CAMutex::Unlock()
ThrowIf(theError != 0, CAException(theError), "CAMutex::Unlock: Could not unlock the mutex");
#if Log_Ownership
- DebugPrintf("%p %.4f: CAMutex::Unlock: thread %p has unlocked %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), pthread_self(), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: CAMutex::Unlock: thread %p has unlocked %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), pthread_self(), mName, mOwner);
#endif
}
else
@@ -154,7 +192,7 @@ void CAMutex::Unlock()
if(mOwner == GetCurrentThreadId())
{
#if Log_Ownership
- DebugPrintf("%lu %.4f: CAMutex::Unlock: thread %lu is unlocking %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%lu %.4f: CAMutex::Unlock: thread %lu is unlocking %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
#endif
mOwner = 0;
@@ -162,7 +200,7 @@ void CAMutex::Unlock()
ThrowIf(!wasReleased, CAException(GetLastError()), "CAMutex::Unlock: Could not unlock the mutex");
#if Log_Ownership
- DebugPrintf("%lu %.4f: CAMutex::Unlock: thread %lu has unlocked %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%lu %.4f: CAMutex::Unlock: thread %lu has unlocked %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
#endif
}
else
@@ -183,7 +221,7 @@ bool CAMutex::Try(bool& outWasLocked)
{
// this means the current thread doesn't already own the lock
#if Log_Ownership
- DebugPrintf("%p %.4f: CAMutex::Try: thread %p is try-locking %s, owner: %p\n", theCurrentThread, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), theCurrentThread, mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: CAMutex::Try: thread %p is try-locking %s, owner: %p\n", theCurrentThread, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), theCurrentThread, mName, mOwner);
#endif
// go ahead and call trylock to see if we can lock it.
@@ -196,7 +234,7 @@ bool CAMutex::Try(bool& outWasLocked)
outWasLocked = true;
#if Log_Ownership
- DebugPrintf("%p %.4f: CAMutex::Try: thread %p has locked %s, owner: %p\n", theCurrentThread, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), theCurrentThread, mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: CAMutex::Try: thread %p has locked %s, owner: %p\n", theCurrentThread, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), theCurrentThread, mName, mOwner);
#endif
}
else if(theError == EBUSY)
@@ -206,7 +244,7 @@ bool CAMutex::Try(bool& outWasLocked)
outWasLocked = false;
#if Log_Ownership
- DebugPrintf("%p %.4f: CAMutex::Try: thread %p failed to lock %s, owner: %p\n", theCurrentThread, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), theCurrentThread, mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%p %.4f: CAMutex::Try: thread %p failed to lock %s, owner: %p\n", theCurrentThread, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), theCurrentThread, mName, mOwner);
#endif
}
else
@@ -226,7 +264,7 @@ bool CAMutex::Try(bool& outWasLocked)
{
// this means the current thread doesn't own the lock
#if Log_Ownership
- DebugPrintf("%lu %.4f: CAMutex::Try: thread %lu is try-locking %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%lu %.4f: CAMutex::Try: thread %lu is try-locking %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
#endif
// try to acquire the mutex
@@ -239,7 +277,7 @@ bool CAMutex::Try(bool& outWasLocked)
outWasLocked = true;
#if Log_Ownership
- DebugPrintf("%lu %.4f: CAMutex::Try: thread %lu has locked %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%lu %.4f: CAMutex::Try: thread %lu has locked %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
#endif
}
else if(theError == WAIT_TIMEOUT)
@@ -249,7 +287,7 @@ bool CAMutex::Try(bool& outWasLocked)
outWasLocked = false;
#if Log_Ownership
- DebugPrintf("%lu %.4f: CAMutex::Try: thread %lu failed to lock %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
+ DebugPrintfRtn(DebugPrintfFileComma "%lu %.4f: CAMutex::Try: thread %lu failed to lock %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner);
#endif
}
else
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAMutex.h b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAMutex.h
index b12fb1885..093066b40 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAMutex.h
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAMutex.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAMutex.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 __CAMutex_h__
#define __CAMutex_h__
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAReferenceCounted.h b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAReferenceCounted.h
index ed384267f..f00fc6167 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAReferenceCounted.h
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAReferenceCounted.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAReferenceCounted.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 __CAReferenceCounted_h__
#define __CAReferenceCounted_h__
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAStreamBasicDescription.cpp b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAStreamBasicDescription.cpp
index bf27862fd..d56947ab5 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAStreamBasicDescription.cpp
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAStreamBasicDescription.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAStreamBasicDescription.cpp
+ Abstract: CAStreamBasicDescription.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 "CAStreamBasicDescription.h"
#include "CAMath.h"
@@ -101,9 +139,6 @@ char *CAStreamBasicDescription::AsString(char *buf, size_t _bufsize, bool brief
case kPCMFormatInt16:
desc = "Int16";
break;
- case kPCMFormatInt32:
- desc = "Int32";
- break;
case kPCMFormatFixed824:
desc = "Int8.24";
break;
@@ -237,46 +272,6 @@ void CAStreamBasicDescription::NormalizeLinearPCMFormat(bool inNativeEndian, Aud
}
}
-void CAStreamBasicDescription::VirtualizeLinearPCMFormat(AudioStreamBasicDescription& ioDescription)
-{
- // the only thing that changes is to make mixable linear PCM into the HAL's virtual linear PCM format, which is Float32 currently
- if((ioDescription.mFormatID == kAudioFormatLinearPCM) && ((ioDescription.mFormatFlags & kIsNonMixableFlag) == 0))
- {
- // the virtual linear PCM format
- ioDescription.mFormatFlags = kAudioFormatFlagsNativeFloatPacked;
- ioDescription.mBytesPerPacket = SizeOf32(Float32) * ioDescription.mChannelsPerFrame;
- ioDescription.mFramesPerPacket = 1;
- ioDescription.mBytesPerFrame = SizeOf32(Float32) * ioDescription.mChannelsPerFrame;
- ioDescription.mBitsPerChannel = 8 * SizeOf32(Float32);
- }
-}
-
-void CAStreamBasicDescription::VirtualizeLinearPCMFormat(bool inNativeEndian, AudioStreamBasicDescription& ioDescription)
-{
- // the only thing that changes is to make mixable linear PCM into the HAL's virtual linear PCM format, which is Float32 currently
- if((ioDescription.mFormatID == kAudioFormatLinearPCM) && ((ioDescription.mFormatFlags & kIsNonMixableFlag) == 0))
- {
- // the virtual linear PCM format
- ioDescription.mFormatFlags = kAudioFormatFlagIsFloat | kAudioFormatFlagIsPacked;
- if(inNativeEndian)
- {
-#if TARGET_RT_BIG_ENDIAN
- ioDescription.mFormatFlags |= kAudioFormatFlagIsBigEndian;
-#endif
- }
- else
- {
-#if TARGET_RT_LITTLE_ENDIAN
- ioDescription.mFormatFlags |= kAudioFormatFlagIsBigEndian;
-#endif
- }
- ioDescription.mBytesPerPacket = SizeOf32(Float32) * ioDescription.mChannelsPerFrame;
- ioDescription.mFramesPerPacket = 1;
- ioDescription.mBytesPerFrame = SizeOf32(Float32) * ioDescription.mChannelsPerFrame;
- ioDescription.mBitsPerChannel = 8 * SizeOf32(Float32);
- }
-}
-
void CAStreamBasicDescription::ResetFormat(AudioStreamBasicDescription& ioDescription)
{
ioDescription.mSampleRate = 0;
@@ -565,136 +560,134 @@ bool operator<(const AudioStreamBasicDescription& x, const AudioStreamBasicDescr
return theAnswer;
}
-UInt32 CAStreamBasicDescription::GetRegularizedFormatFlags(bool forHardware) const
+void CAStreamBasicDescription::ModifyFormatFlagsForMatching(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y, UInt32& xFlags, UInt32& yFlags, bool converterOnly )
{
- UInt32 result = mFormatFlags;
-
- if (IsPCM()) {
- // First, if there are bits other than AllClear set, clear it because it's lying.
- if (result & ~kAudioFormatFlagsAreAllClear)
- result &= ~kAudioFormatFlagsAreAllClear;
-
- // If not forHardware, remove the mixability flag.
- if (!forHardware)
- result &= ~kLinearPCMFormatFlagIsNonMixable;
-
- // If the format has no extra bits, then it is packed.
- if (!PackednessIsSignificant())
- result |= kLinearPCMFormatFlagIsPacked;
-
- // Remove the high-aligned flag if alignment is irrelevant.
- if (!AlignmentIsSignificant())
- result &= ~kLinearPCMFormatFlagIsAlignedHigh;
-
- // Remove the signed integer bit if it's float
- if (result & kLinearPCMFormatFlagIsFloat)
- result &= ~kLinearPCMFormatFlagIsSignedInteger;
-
- // If the bit depth is 8 bits or less and the format is packed, we don't care about endianness
- if (mBitsPerChannel <= 8 && (result & kLinearPCMFormatFlagIsPacked))
- result &= kAudioFormatFlagIsBigEndian;
-
- // If there is 1 channel, we don't care about non-interleavedness.
- if (mChannelsPerFrame == 1)
- result &= ~kLinearPCMFormatFlagIsNonInterleaved;
-
- // Finally, if the bits really are all 0, set the AllClear flag.
- if (result == 0)
- result = kAudioFormatFlagsAreAllClear;
- }
- return result;
-}
-
-// private
-bool CAStreamBasicDescription::EquivalentFormatFlags(const AudioStreamBasicDescription &x, const AudioStreamBasicDescription &y, bool forHardware, bool usingWildcards)
-{
- if (usingWildcards)
- {
- // if either of the formats is a wildcard, we don't care about the flags
- // if either of the flags is a wildcard, we have matched
- if (x.mFormatID == 0 || y.mFormatID == 0 || x.mFormatFlags == 0 || y.mFormatFlags == 0)
- {
- return true;
- }
+ // match wildcards
+ if (x.mFormatID == 0 || y.mFormatID == 0 || xFlags == 0 || yFlags == 0)
+ {
+ // Obliterate all flags.
+ xFlags = yFlags = 0;
+ return;
+ }
+
+ if (x.mFormatID == kAudioFormatLinearPCM) {
+ // knock off the all clear flag
+ xFlags = xFlags & ~kAudioFormatFlagsAreAllClear;
+ yFlags = yFlags & ~kAudioFormatFlagsAreAllClear;
+
+ // if both kAudioFormatFlagIsPacked bits are set, then we don't care about the kAudioFormatFlagIsAlignedHigh bit.
+ if (xFlags & yFlags & kAudioFormatFlagIsPacked) {
+ xFlags = xFlags & ~static_cast(kAudioFormatFlagIsAlignedHigh);
+ yFlags = yFlags & ~static_cast(kAudioFormatFlagIsAlignedHigh);
+ }
+
+ // if both kAudioFormatFlagIsFloat bits are set, then we don't care about the kAudioFormatFlagIsSignedInteger bit.
+ if (xFlags & yFlags & kAudioFormatFlagIsFloat) {
+ xFlags = xFlags & ~static_cast(kAudioFormatFlagIsSignedInteger);
+ yFlags = yFlags & ~static_cast(kAudioFormatFlagIsSignedInteger);
+ }
+
+ // if the bit depth is 8 bits or less and the format is packed, we don't care about endianness
+ if((x.mBitsPerChannel <= 8) && ((xFlags & kAudioFormatFlagIsPacked) == kAudioFormatFlagIsPacked))
+ {
+ xFlags = xFlags & ~static_cast(kAudioFormatFlagIsBigEndian);
+ }
+ if((y.mBitsPerChannel <= 8) && ((yFlags & kAudioFormatFlagIsPacked) == kAudioFormatFlagIsPacked))
+ {
+ yFlags = yFlags & ~static_cast(kAudioFormatFlagIsBigEndian);
+ }
+
+ // if the number of channels is 1, we don't care about non-interleavedness
+ if (x.mChannelsPerFrame == 1 && y.mChannelsPerFrame == 1) {
+ xFlags &= ~static_cast(kLinearPCMFormatFlagIsNonInterleaved);
+ yFlags &= ~static_cast(kLinearPCMFormatFlagIsNonInterleaved);
+ }
+
+ if (converterOnly) {
+ CAStreamBasicDescription cas_x = CAStreamBasicDescription(x);
+ CAStreamBasicDescription cas_y = CAStreamBasicDescription(y);
+ if (!cas_x.PackednessIsSignificant() && !cas_y.PackednessIsSignificant()) {
+ xFlags &= ~static_cast(kAudioFormatFlagIsPacked);
+ yFlags &= ~static_cast(kAudioFormatFlagIsPacked);
+ }
+ if (!cas_x.AlignmentIsSignificant() && !cas_y.AlignmentIsSignificant()) {
+ xFlags &= ~static_cast(kAudioFormatFlagIsAlignedHigh);
+ yFlags &= ~static_cast(kAudioFormatFlagIsAlignedHigh);
+ }
+ // We don't care about whether the streams are mixable in this case
+ xFlags &= ~static_cast(kAudioFormatFlagIsNonMixable);
+ yFlags &= ~static_cast(kAudioFormatFlagIsNonMixable);
+ }
}
-
- if (x.mFormatID != kAudioFormatLinearPCM) // we already know the formatID's match and have taken wildcards out of the picture.
- return x.mFormatFlags == y.mFormatFlags;
-
- // It is safe to down-cast from AudioStreamBasicDescription to its C++ wrapper.
- // The cast could be avoided with a copy, but here, efficiency matters.
- const CAStreamBasicDescription &a = *static_cast(&x);
- const CAStreamBasicDescription &b = *static_cast(&y);
-
- return a.GetRegularizedFormatFlags(forHardware) == b.GetRegularizedFormatFlags(forHardware);
}
-bool CAStreamBasicDescription::IsExactlyEqual(const AudioStreamBasicDescription &x, const AudioStreamBasicDescription &y)
+static bool MatchFormatFlags(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y)
{
- // mReserved didn't exist in early versions of OS X; we want to ignore differences there.
- // The structure is properly packed up until that point, so the shortcut of using memcmp()
- // instead of individual field comparisons is safe.
- return memcmp(&x, &y, offsetof(AudioStreamBasicDescription, mReserved)) == 0;
+ UInt32 xFlags = x.mFormatFlags;
+ UInt32 yFlags = y.mFormatFlags;
+
+ CAStreamBasicDescription::ModifyFormatFlagsForMatching(x, y, xFlags, yFlags, false);
+ return xFlags == yFlags;
}
-#define MATCH_WITH_WILDCARD(name) ((x.name) == 0 || (y.name) == 0 || (x.name) == (y.name))
-
-bool CAStreamBasicDescription::IsEquivalent(const AudioStreamBasicDescription &x, const AudioStreamBasicDescription &y, ComparisonOptions options)
+bool operator==(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y)
{
- if (options & kCompareUsingWildcards) {
- return
- // check the sample rate
- (fiszero(x.mSampleRate) || fiszero(y.mSampleRate) || fequal(x.mSampleRate, y.mSampleRate))
-
- // check the format ids
- && MATCH_WITH_WILDCARD(mFormatID)
-
- // check the bytes per packet
- && MATCH_WITH_WILDCARD(mBytesPerPacket)
-
- // check the frames per packet
- && MATCH_WITH_WILDCARD(mFramesPerPacket)
-
- // check the bytes per frame
- && MATCH_WITH_WILDCARD(mBytesPerFrame)
-
- // check the channels per frame
- && MATCH_WITH_WILDCARD(mChannelsPerFrame)
-
- // check the bits per channel
- && MATCH_WITH_WILDCARD(mBitsPerChannel)
-
- // Only if we get this far, do the work of matching the format flags
- && EquivalentFormatFlags(x, y, options & kCompareForHardware, /*usingWildcards=*/true);
- } else {
- return x.mSampleRate == y.mSampleRate
- && x.mFormatID == y.mFormatID
- && x.mBytesPerPacket == y.mBytesPerPacket
- && x.mFramesPerPacket == y.mFramesPerPacket
- && x.mChannelsPerFrame == y.mChannelsPerFrame
- && x.mBitsPerChannel == y.mBitsPerChannel
- && EquivalentFormatFlags(x, y, options & kCompareForHardware, /*usingWildcards=*/false);
- }
+ // the semantics for equality are:
+ // 1) Values must match exactly -- except for PCM format flags, see above.
+ // 2) wildcard's are ignored in the comparison
+
+#define MATCH(name) ((x.name) == 0 || (y.name) == 0 || (x.name) == (y.name))
+
+ return
+ // check all but the format flags
+ CAStreamBasicDescription::FlagIndependentEquivalence(x, y)
+ // check the format flags
+ && MatchFormatFlags(x, y);
}
-// DEPRECATED.
-bool operator==(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y)
+bool CAStreamBasicDescription::FlagIndependentEquivalence(const AudioStreamBasicDescription &x, const AudioStreamBasicDescription &y)
{
- return CAStreamBasicDescription::IsEquivalent(x, y, CAStreamBasicDescription::kCompareUsingWildcards | CAStreamBasicDescription::kCompareForHardware);
+ return
+ // check the sample rate
+ (fiszero(x.mSampleRate) || fiszero(y.mSampleRate) || fequal(x.mSampleRate, y.mSampleRate))
+
+ // check the format ids
+ && MATCH(mFormatID)
+
+ // check the bytes per packet
+ && MATCH(mBytesPerPacket)
+
+ // check the frames per packet
+ && MATCH(mFramesPerPacket)
+
+ // check the bytes per frame
+ && MATCH(mBytesPerFrame)
+
+ // check the channels per frame
+ && MATCH(mChannelsPerFrame)
+
+ // check the channels per frame
+ && MATCH(mBitsPerChannel) ;
}
-// To be deprecated.
bool CAStreamBasicDescription::IsEqual(const AudioStreamBasicDescription &other, bool interpretingWildcards) const
{
if (interpretingWildcards)
- return CAStreamBasicDescription::IsEquivalent(*this, other, CAStreamBasicDescription::kCompareUsingWildcards | CAStreamBasicDescription::kCompareForHardware);
- return IsExactlyEqual(*this, other);
+ return *this == other;
+ return memcmp(this, &other, offsetof(AudioStreamBasicDescription, mReserved)) == 0;
}
-// DEPRECATED.
-bool CAStreamBasicDescription::IsEqual(const AudioStreamBasicDescription &other) const
+bool CAStreamBasicDescription::IsFunctionallyEquivalent(const AudioStreamBasicDescription &x, const AudioStreamBasicDescription &y)
{
- return CAStreamBasicDescription::IsEquivalent(*this, other, CAStreamBasicDescription::kCompareUsingWildcards | CAStreamBasicDescription::kCompareForHardware);
+ UInt32 xFlags = x.mFormatFlags, yFlags = y.mFormatFlags;
+ CAStreamBasicDescription::ModifyFormatFlagsForMatching(x, y, xFlags, yFlags, true);
+
+ return
+ // check all but the format flags
+ CAStreamBasicDescription::FlagIndependentEquivalence(x, y)
+ // check the format flags with converter focus
+ && (xFlags == yFlags);
+
}
bool SanityCheck(const AudioStreamBasicDescription& x)
@@ -709,7 +702,6 @@ bool SanityCheck(const AudioStreamBasicDescription& x)
&& (x.mBytesPerPacket < 1000000)
&& (x.mFramesPerPacket < 1000000)
&& (x.mBytesPerFrame < 1000000)
- && (x.mChannelsPerFrame > 0)
&& (x.mChannelsPerFrame <= 1024)
&& (x.mBitsPerChannel <= 1024)
&& (x.mFormatID != 0)
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAStreamBasicDescription.h b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAStreamBasicDescription.h
index 94d8c4efa..8b81dba69 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAStreamBasicDescription.h
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAStreamBasicDescription.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAStreamBasicDescription.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 __CAStreamBasicDescription_h__
#define __CAStreamBasicDescription_h__
@@ -23,21 +61,6 @@ Part of Core Audio Public Utility Classes
#pragma mark This file needs to compile on more earlier versions of the OS, so please keep that in mind when editing it
-#ifndef ASBD_STRICT_EQUALITY
- #define ASBD_STRICT_EQUALITY 0
-#endif
-
-#if __GNUC__ && ASBD_STRICT_EQUALITY
- // not turning on the deprecation just yet
- #define ASBD_EQUALITY_DEPRECATED __attribute__((deprecated("This method uses a possibly surprising wildcard comparison (i.e. 0 channels == 1 channel)")))
-#else
- #define ASBD_EQUALITY_DEPRECATED
-#endif
-
-#ifndef CA_CANONICAL_DEPRECATED
- #define CA_CANONICAL_DEPRECATED
-#endif
-
extern char *CAStringForOSType (OSType t, char *writeLocation, size_t bufsize);
// define Leopard specific symbols for backward compatibility if applicable
@@ -80,21 +103,9 @@ public:
kPCMFormatFloat32 = 1,
kPCMFormatInt16 = 2,
kPCMFormatFixed824 = 3,
- kPCMFormatFloat64 = 4,
- kPCMFormatInt32 = 5
+ kPCMFormatFloat64 = 4
};
- // options for IsEquivalent
- enum {
- kCompareDefault = 0,
- kCompareUsingWildcards = 1 << 0, // treats fields with values of 0 as wildcards.
- // too liberal if you need to represent 0 channels.
- kCompareForHardware = 1 << 1, // formats are hardware formats (IsNonMixable flag is significant).
-
- kCompareForHardwareUsingWildcards = kCompareForHardware + kCompareUsingWildcards // for convenience
- };
- typedef UInt32 ComparisonOptions;
-
// Construction/Destruction
public:
CAStreamBasicDescription();
@@ -132,10 +143,6 @@ public:
wordsize = 2;
mFormatFlags |= kAudioFormatFlagIsSignedInteger;
break;
- case kPCMFormatInt32:
- wordsize = 4;
- mFormatFlags |= kAudioFormatFlagIsSignedInteger;
- break;
case kPCMFormatFixed824:
wordsize = 4;
mFormatFlags |= kAudioFormatFlagIsSignedInteger | (24 << kLinearPCMFormatFlagsSampleFractionShift);
@@ -251,8 +258,6 @@ public:
unsigned fracbits = (mFormatFlags & kLinearPCMFormatFlagsSampleFractionMask) >> kLinearPCMFormatFlagsSampleFractionShift;
if (wordsize == 4 && fracbits == 24)
outFormat = kPCMFormatFixed824;
- else if (wordsize == 4 && fracbits == 0)
- outFormat = kPCMFormatInt32;
else if (wordsize == 2 && fracbits == 0)
outFormat = kPCMFormatInt16;
}
@@ -281,7 +286,6 @@ public:
//
// manipulation
- CA_CANONICAL_DEPRECATED
void SetCanonical(UInt32 nChannels, bool interleaved)
// note: leaves sample rate untouched
{
@@ -299,7 +303,6 @@ public:
}
}
- CA_CANONICAL_DEPRECATED
bool IsCanonical() const
{
if (mFormatID != kAudioFormatLinearPCM) return false;
@@ -317,7 +320,6 @@ public:
&& mBytesPerPacket == reqFrameSize);
}
- CA_CANONICAL_DEPRECATED
void SetAUCanonical(UInt32 nChannels, bool interleaved)
{
mFormatID = kAudioFormatLinearPCM;
@@ -359,24 +361,10 @@ public:
//
// other
- // IsEqual: Deprecated because of widespread errors due to the default wildcarding behavior.
- ASBD_EQUALITY_DEPRECATED
- bool IsEqual(const AudioStreamBasicDescription &other) const;
- bool IsEqual(const AudioStreamBasicDescription &other, bool interpretingWildcards) const;
-
- // IsExactlyEqual: bit-for-bit. usually unnecessarily strict.
- static bool IsExactlyEqual(const AudioStreamBasicDescription &x, const AudioStreamBasicDescription &y);
-
- // IsEquivalent: Returns whether the two formats are functionally the same, i.e. if one could
- // be correctly passed as the other without an AudioConverter.
- static bool IsEquivalent(const AudioStreamBasicDescription &x, const AudioStreamBasicDescription &y) { return IsEquivalent(x, y, kCompareDefault); }
- static bool IsEquivalent(const AudioStreamBasicDescription &x, const AudioStreamBasicDescription &y, ComparisonOptions comparisonOptions);
-
- // Member versions of IsExactlyEqual and IsEquivalent.
- bool IsExactlyEqual(const AudioStreamBasicDescription &other) const { return IsExactlyEqual(*this, other); }
- bool IsEquivalent(const AudioStreamBasicDescription &other) const { return IsEquivalent(*this, other); }
- bool IsEquivalent(const AudioStreamBasicDescription &other, ComparisonOptions comparisonOptions) const { return IsEquivalent(*this, other, comparisonOptions); }
-
+ bool IsEqual(const AudioStreamBasicDescription &other, bool interpretingWildcards=true) const;
+ static bool FlagIndependentEquivalence(const AudioStreamBasicDescription &x, const AudioStreamBasicDescription &y);
+ static bool IsFunctionallyEquivalent(const AudioStreamBasicDescription &x, const AudioStreamBasicDescription &y);
+
void Print() const {
Print (stdout);
}
@@ -409,37 +397,25 @@ public:
// Operations
static bool IsMixable(const AudioStreamBasicDescription& inDescription) { return (inDescription.mFormatID == kAudioFormatLinearPCM) && ((inDescription.mFormatFlags & kIsNonMixableFlag) == 0); }
- CA_CANONICAL_DEPRECATED
static void NormalizeLinearPCMFormat(AudioStreamBasicDescription& ioDescription);
- CA_CANONICAL_DEPRECATED
static void NormalizeLinearPCMFormat(bool inNativeEndian, AudioStreamBasicDescription& ioDescription);
- static void VirtualizeLinearPCMFormat(AudioStreamBasicDescription& ioDescription);
- static void VirtualizeLinearPCMFormat(bool inNativeEndian, AudioStreamBasicDescription& ioDescription);
static void ResetFormat(AudioStreamBasicDescription& ioDescription);
static void FillOutFormat(AudioStreamBasicDescription& ioDescription, const AudioStreamBasicDescription& inTemplateDescription);
static void GetSimpleName(const AudioStreamBasicDescription& inDescription, char* outName, UInt32 inMaxNameLength, bool inAbbreviate, bool inIncludeSampleRate = false);
+ static void ModifyFormatFlagsForMatching(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y, UInt32& xFlags, UInt32& yFlags, bool converterOnly);
#if CoreAudio_Debug
static void PrintToLog(const AudioStreamBasicDescription& inDesc);
#endif
-
- UInt32 GetRegularizedFormatFlags(bool forHardware) const;
-
-private:
- static bool EquivalentFormatFlags(const AudioStreamBasicDescription &x, const AudioStreamBasicDescription &y, bool forHardware, bool usingWildcards);
};
-#define CAStreamBasicDescription_EmptyInit 0.0, 0, 0, 0, 0, 0, 0, 0, 0
-#define CAStreamBasicDescription_Empty { CAStreamBasicDescription_EmptyInit }
-
-// operator== is deprecated because it uses the deprecated IsEqual(other, true).
bool operator<(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y);
-ASBD_EQUALITY_DEPRECATED bool operator==(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y);
+bool operator==(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y);
#if TARGET_OS_MAC || (TARGET_OS_WIN32 && (_MSC_VER > 600))
-ASBD_EQUALITY_DEPRECATED inline bool operator!=(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y) { return !(x == y); }
-ASBD_EQUALITY_DEPRECATED inline bool operator<=(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y) { return (x < y) || (x == y); }
-ASBD_EQUALITY_DEPRECATED inline bool operator>=(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y) { return !(x < y); }
-ASBD_EQUALITY_DEPRECATED inline bool operator>(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y) { return !((x < y) || (x == y)); }
+inline bool operator!=(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y) { return !(x == y); }
+inline bool operator<=(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y) { return (x < y) || (x == y); }
+inline bool operator>=(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y) { return !(x < y); }
+inline bool operator>(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y) { return !((x < y) || (x == y)); }
#endif
bool SanityCheck(const AudioStreamBasicDescription& x);
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAThreadSafeList.h b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAThreadSafeList.h
index 3a2a97c4b..d0b739147 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAThreadSafeList.h
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAThreadSafeList.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAThreadSafeList.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 __CAThreadSafeList_h__
#define __CAThreadSafeList_h__
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAVectorUnit.cpp b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAVectorUnit.cpp
index b338342a8..83bfb8c88 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAVectorUnit.cpp
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAVectorUnit.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAVectorUnit.cpp
+ Abstract: CAVectorUnit.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 "CAVectorUnit.h"
#if !TARGET_OS_WIN32
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAVectorUnit.h b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAVectorUnit.h
index 2b1cd4c9c..cf3a16c7a 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAVectorUnit.h
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAVectorUnit.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAVectorUnit.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 __CAVectorUnit_h__
#define __CAVectorUnit_h__
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAVectorUnitTypes.h b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAVectorUnitTypes.h
index 9f0aba5ff..85ff837af 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAVectorUnitTypes.h
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAVectorUnitTypes.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAVectorUnitTypes.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 __CAVectorUnitTypes_h__
#define __CAVectorUnitTypes_h__
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAXException.cpp b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAXException.cpp
index a7e381d1a..c2dbac5d6 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAXException.cpp
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAXException.cpp
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAXException.cpp
+ Abstract: CAXException.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 "CAXException.h"
CAXException::WarningHandler CAXException::sWarningHandler = NULL;
diff --git a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAXException.h b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAXException.h
index 0a66e3187..90dabe97d 100644
--- a/src/CoreAudio/CoreAudioComponent/PublicUtility/CAXException.h
+++ b/src/CoreAudio/CoreAudioComponent/PublicUtility/CAXException.h
@@ -1,11 +1,49 @@
/*
-Copyright (C) 2016 Apple Inc. All Rights Reserved.
-See LICENSE.txt for this sample’s licensing information
-
-Abstract:
-Part of Core Audio Public Utility Classes
+ File: CAXException.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 __CAXException_h__
#define __CAXException_h__
@@ -154,7 +192,7 @@ private:
OSStatus __err = error; \
if (__err) { \
DebugMessageN4("%s:%d: error %s: %s", __FILE__, __LINE__, CAX4CCString(__err).get(), #error);\
- __ASSERT_STOP; \
+ STOP; \
} \
} while (0)
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/ACBaseCodec.cpp b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/ACBaseCodec.cpp
new file mode 100644
index 000000000..f1ffdf7f1
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/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
+#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(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(outPropertyData));
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+
+ case kAudioCodecPropertySupportedInputFormats:
+ case kAudioCodecPropertyInputFormatsForOutputFormat:
+ thePacketsToGet = ioPropertyDataSize / SizeOf32(AudioStreamBasicDescription);
+ GetSupportedInputFormats(reinterpret_cast(outPropertyData), thePacketsToGet);
+ ioPropertyDataSize = thePacketsToGet * SizeOf32(AudioStreamBasicDescription);
+ break;
+
+ case kAudioCodecPropertyCurrentOutputFormat:
+ if(ioPropertyDataSize == SizeOf32(AudioStreamBasicDescription))
+ {
+ GetCurrentOutputFormat(*reinterpret_cast(outPropertyData));
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+
+ case kAudioCodecPropertySupportedOutputFormats:
+ case kAudioCodecPropertyOutputFormatsForInputFormat:
+ thePacketsToGet = ioPropertyDataSize / SizeOf32(AudioStreamBasicDescription);
+ GetSupportedOutputFormats(reinterpret_cast(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(outPropertyData) = GetInputBufferByteSize();
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+
+ case kAudioCodecPropertyUsedInputBufferSize:
+ if(ioPropertyDataSize == SizeOf32(UInt32))
+ {
+ *reinterpret_cast(outPropertyData) = GetUsedInputBufferByteSize();
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+
+ case kAudioCodecPropertyIsInitialized:
+ if(ioPropertyDataSize == SizeOf32(UInt32))
+ {
+ *reinterpret_cast(outPropertyData) = IsInitialized() ? 1 : 0;
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+
+ case kAudioCodecPropertyAvailableNumberChannels:
+ if(ioPropertyDataSize == SizeOf32(UInt32) * 2)
+ {
+ (reinterpret_cast(outPropertyData))[0] = 1;
+ (reinterpret_cast(outPropertyData))[1] = 2;
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+
+ case kAudioCodecPropertyPrimeMethod:
+ if(ioPropertyDataSize == SizeOf32(UInt32))
+ {
+ *reinterpret_cast(outPropertyData) = (UInt32)kAudioCodecPrimeMethod_None;
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+
+ case kAudioCodecPropertyPrimeInfo:
+ if(ioPropertyDataSize == SizeOf32(AudioCodecPrimeInfo) )
+ {
+ (reinterpret_cast(outPropertyData))->leadingFrames = 0;
+ (reinterpret_cast(outPropertyData))->trailingFrames = 0;
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+
+ case kAudioCodecPropertyDoesSampleRateConversion:
+ if(ioPropertyDataSize == SizeOf32(UInt32))
+ {
+ *reinterpret_cast(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(inPropertyData));
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+
+ case kAudioCodecPropertyCurrentOutputFormat:
+ if(inPropertyDataSize == SizeOf32(AudioStreamBasicDescription))
+ {
+ SetCurrentOutputFormat(*reinterpret_cast(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/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/ACBaseCodec.h b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/ACBaseCodec.h
new file mode 100644
index 000000000..6689d91fb
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/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
+#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 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/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/ACCodec.cpp b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/ACCodec.cpp
new file mode 100644
index 000000000..512f93842
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/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/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/ACCodec.h b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/ACCodec.h
new file mode 100644
index 000000000..b0d93165a
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/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
+#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(err)
+
+#define CODEC_THROW_IF(cond, err) \
+ if(bool(cond)) CODEC_THROW(err);
+
+
+#endif
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/ACCodecDispatchTypes.h b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/ACCodecDispatchTypes.h
new file mode 100644
index 000000000..42c2bc5ba
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/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/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/ACComponentResources.r b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/ACComponentResources.r
new file mode 100644
index 000000000..a84fd11ad
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/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/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/ACConditionalMacros.h b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/ACConditionalMacros.h
new file mode 100644
index 000000000..2cff483fd
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/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
+#else
+ #include "ConditionalMacros.h"
+#endif
+
+#endif
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/ACPlugInDispatch.cpp b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/ACPlugInDispatch.cpp
new file mode 100644
index 000000000..de9599b18
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/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
+
+#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/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/ACPlugInDispatch.h b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/ACPlugInDispatch.h
new file mode 100644
index 000000000..252a4af0a
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/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 AudioCodecFactory : public APFactory
+{
+};
+
+#if AC_NON_INTERLEAVED_SUPPORT
+struct AudioCodecNonInterleavedEncoderLookup {
+ static AudioComponentMethod Lookup (SInt16 selector);
+};
+template
+class AudioCodecNonInterleavedEncoderFactory : public APFactory
+{
+};
+
+struct AudioCodecNonInterleavedDecoderLookup {
+ static AudioComponentMethod Lookup (SInt16 selector);
+};
+template
+class AudioCodecNonInterleavedDecoderFactory : public APFactory
+{
+};
+#endif
+
+#if TARGET_OS_IPHONE
+struct AudioCodecHWCodecLookup {
+ static AudioComponentMethod Lookup (SInt16 selector);
+};
+template
+class AudioCodecHWCodecFactory : public APFactory
+{
+};
+#endif // TARGET_OS_IPHONE
+
+#endif // __ACPlugInDispatch_h__
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/ACSimpleCodec.cpp b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/ACSimpleCodec.cpp
new file mode 100644
index 000000000..b10add9da
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/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
+
+//=============================================================================
+// 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(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: 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;
+
+ // < 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(inPropertyData));
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+ default:
+ ACBaseCodec::SetProperty(inPropertyID, inPropertyDataSize, inPropertyData);
+ break;
+ }
+}
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/ACSimpleCodec.h b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/ACSimpleCodec.h
new file mode 100644
index 000000000..f41fe54b9
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/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/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/GetCodecBundle.cpp b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/GetCodecBundle.cpp
new file mode 100644
index 000000000..8954c8dd5
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/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/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/GetCodecBundle.h b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioCodecs/ACPublic/GetCodecBundle.h
new file mode 100644
index 000000000..96e3d9e2b
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/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
+
+#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
+ #include
+#else
+ #include "CFBundle.h"
+#endif
+
+CFBundleRef GetCodecBundle();
+
+#endif
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/AudioFileComponentBase.cpp b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/AudioFileComponentBase.cpp
new file mode 100644
index 000000000..053da0a5d
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/AudioFileComponentBase.cpp
@@ -0,0 +1,1040 @@
+/*
+ File: AudioFileComponentBase.cpp
+ Abstract: AudioFileComponentBase.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 !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
+ #include
+#else
+ #include "AudioFileComponent.h"
+#endif
+
+#include "AudioFileComponentBase.h"
+
+#if TARGET_OS_MAC
+ #if __LP64__
+ // comp instance, parameters in forward order
+ #define PARAM(_typ, _name, _index, _nparams) \
+ _typ _name = *(_typ *)¶ms->params[_index + 1];
+ #else
+ // parameters in reverse order, then comp instance
+ #define PARAM(_typ, _name, _index, _nparams) \
+ _typ _name = *(_typ *)¶ms->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 *)¶ms->params[_index];
+#endif
+
+#define ACPI ((AudioComponentPlugInInstance *)self)
+#define AFC ((AudioFileComponentBase *)&ACPI->mInstanceStorage)
+
+//----------------------------------------------------------------------------------------
+
+static OSStatus CreateURL(
+ void * self,
+ CFURLRef inFileRef,
+ const AudioStreamBasicDescription *inFormat,
+ UInt32 inFlags)
+{
+ return AFC->AFAPI_CreateURL(inFileRef, inFormat, inFlags);
+}
+
+static OSStatus OpenURL(
+ void * self,
+ CFURLRef inFileRef,
+ SInt8 inPermissions,
+ int inFileDescriptor)
+{
+ return AFC->AFAPI_OpenURL(inFileRef, inPermissions, inFileDescriptor);
+}
+
+static OSStatus OpenWithCallbacks(
+ void * self,
+ void * inRefCon,
+ AudioFile_ReadProc inReadFunc,
+ AudioFile_WriteProc inWriteFunc,
+ AudioFile_GetSizeProc inGetSizeFunc,
+ AudioFile_SetSizeProc inSetSizeFunc)
+{
+ return AFC->AFAPI_OpenWithCallbacks(inRefCon, inReadFunc, inWriteFunc, inGetSizeFunc, inSetSizeFunc);
+}
+
+static OSStatus InitializeWithCallbacks(
+ void * self,
+ void * inRefCon,
+ AudioFile_ReadProc inReadFunc,
+ AudioFile_WriteProc inWriteFunc,
+ AudioFile_GetSizeProc inGetSizeFunc,
+ AudioFile_SetSizeProc inSetSizeFunc,
+ UInt32 inFileType,
+ const AudioStreamBasicDescription *inFormat,
+ UInt32 inFlags)
+{
+ return AFC->AFAPI_InitializeWithCallbacks(inRefCon, inReadFunc, inWriteFunc, inGetSizeFunc, inSetSizeFunc, inFileType, inFormat, inFlags);
+}
+
+static OSStatus Close(
+ void * self)
+{
+ return AFC->AFAPI_Close();
+}
+
+static OSStatus Optimize(
+ void * self)
+{
+ return AFC->AFAPI_Optimize();
+}
+
+static OSStatus ReadBytes(
+ void * self,
+ Boolean inUseCache,
+ SInt64 inStartingByte,
+ UInt32 *ioNumBytes,
+ void *outBuffer)
+{
+ return AFC->AFAPI_ReadBytes(inUseCache, inStartingByte, ioNumBytes, outBuffer);
+}
+
+
+static OSStatus WriteBytes(
+ void * self,
+ Boolean inUseCache,
+ SInt64 inStartingByte,
+ UInt32 *ioNumBytes,
+ const void *inBuffer)
+{
+ return AFC->AFAPI_WriteBytes(inUseCache, inStartingByte, ioNumBytes, inBuffer);
+}
+
+
+static OSStatus ReadPackets(
+ void * self,
+ Boolean inUseCache,
+ UInt32 *outNumBytes,
+ AudioStreamPacketDescription *outPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ void *outBuffer)
+{
+ return AFC->AFAPI_ReadPackets(inUseCache, outNumBytes, outPacketDescriptions,
+ inStartingPacket, ioNumPackets, outBuffer);
+}
+
+static OSStatus ReadPacketData(
+ void * self,
+ Boolean inUseCache,
+ UInt32 *ioNumBytes,
+ AudioStreamPacketDescription *outPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ void *outBuffer)
+{
+ return AFC->AFAPI_ReadPacketData(inUseCache, ioNumBytes, outPacketDescriptions,
+ inStartingPacket, ioNumPackets, outBuffer);
+}
+
+#if COREAUDIOTYPES_VERSION < 1050
+static OSStatus WritePackets(
+ void * self,
+ Boolean inUseCache,
+ UInt32 inNumBytes,
+ AudioStreamPacketDescription *inPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ const void *inBuffer)
+#else
+static OSStatus WritePackets(
+ void * self,
+ Boolean inUseCache,
+ UInt32 inNumBytes,
+ const AudioStreamPacketDescription *inPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ const void *inBuffer)
+#endif
+{
+ return AFC->AFAPI_WritePackets(inUseCache, inNumBytes,
+ (const AudioStreamPacketDescription *)inPacketDescriptions, // this should be const (and is in 10.5 headers)
+ inStartingPacket, ioNumPackets, inBuffer);
+}
+
+static OSStatus GetPropertyInfo(
+ void * self,
+ AudioFilePropertyID inPropertyID,
+ UInt32 *outDataSize,
+ UInt32 *isWritable)
+{
+ return AFC->AFAPI_GetPropertyInfo(inPropertyID, outDataSize, isWritable);
+}
+
+static OSStatus GetProperty(
+ void * self,
+ AudioFilePropertyID inPropertyID,
+ UInt32 *ioDataSize,
+ void *ioData)
+{
+ return AFC->AFAPI_GetProperty(inPropertyID, ioDataSize, ioData);
+}
+
+
+static OSStatus SetProperty(
+ void * self,
+ AudioFilePropertyID inPropertyID,
+ UInt32 inDataSize,
+ const void *inData)
+{
+ return AFC->AFAPI_SetProperty(inPropertyID, inDataSize, inData);
+}
+
+static OSStatus CountUserData(
+ void * self,
+ UInt32 inUserDataID,
+ UInt32 *outNumberItems)
+{
+ return AFC->AFAPI_CountUserData(inUserDataID, outNumberItems);
+}
+
+static OSStatus GetUserDataSize(
+ void * self,
+ UInt32 inUserDataID,
+ UInt32 inIndex,
+ UInt32 *outDataSize)
+{
+ return AFC->AFAPI_GetUserDataSize(inUserDataID, inIndex, outDataSize);
+}
+
+static OSStatus GetUserData(
+ void * self,
+ UInt32 inUserDataID,
+ UInt32 inIndex,
+ UInt32 *ioUserDataSize,
+ void *outUserData)
+{
+ return AFC->AFAPI_GetUserData(inUserDataID, inIndex, ioUserDataSize, outUserData);
+}
+
+static OSStatus SetUserData(
+ void * self,
+ UInt32 inUserDataID,
+ UInt32 inIndex,
+ UInt32 inUserDataSize,
+ const void *inUserData)
+{
+ return AFC->AFAPI_SetUserData(inUserDataID, inIndex, inUserDataSize, inUserData);
+}
+
+static OSStatus RemoveUserData(
+ void * self,
+ UInt32 inUserDataID,
+ UInt32 inIndex)
+{
+ return AFC->AFAPI_RemoveUserData(inUserDataID, inIndex);
+}
+
+static OSStatus ExtensionIsThisFormat(
+ void * self,
+ CFStringRef inExtension,
+ UInt32 *outResult)
+{
+ AudioFileFormatBase* aff = AFC->GetAudioFileFormatBase();
+ if (!aff) return kAudio_ParamError;
+
+ UInt32 res = aff->ExtensionIsThisFormat(inExtension);
+ if (outResult) *outResult = res;
+ return noErr;
+}
+
+static OSStatus FileDataIsThisFormat(
+ void * self,
+ UInt32 inDataByteSize,
+ const void* inData,
+ UInt32 *outResult)
+{
+ AudioFileFormatBase* aff = AFC->GetAudioFileFormatBase();
+ if (!aff) return kAudio_ParamError;
+
+ UncertainResult res = aff->FileDataIsThisFormat(inDataByteSize, inData);
+ if (outResult) *outResult = res;
+ return noErr;
+}
+
+static OSStatus GetGlobalInfoSize(
+ void * self,
+ AudioFilePropertyID inPropertyID,
+ UInt32 inSpecifierSize,
+ const void* inSpecifier,
+ UInt32 *outPropertySize)
+{
+ return AFC->AFAPI_GetGlobalInfoSize(inPropertyID, inSpecifierSize, inSpecifier, outPropertySize);
+}
+
+static OSStatus GetGlobalInfo(
+ void * self,
+ AudioFilePropertyID inPropertyID,
+ UInt32 inSpecifierSize,
+ const void* inSpecifier,
+ UInt32 *ioPropertySize,
+ void *ioPropertyData)
+{
+ return AFC->AFAPI_GetGlobalInfo(inPropertyID, inSpecifierSize, inSpecifier, ioPropertySize, ioPropertyData);
+}
+
+//----------------------------------------------------------------------------------------
+
+
+AudioFileComponentBase::AudioFileComponentBase(AudioComponentInstance inInstance)
+ : ComponentBase(inInstance)
+{
+}
+
+AudioFileComponentBase::~AudioFileComponentBase()
+{
+}
+
+AudioFileObjectComponentBase::AudioFileObjectComponentBase(AudioComponentInstance inInstance)
+ : AudioFileComponentBase(inInstance), mAudioFileObject(0)
+{
+ // derived class should create an AudioFileObject here and if NULL, the AudioFormat as well.
+}
+
+AudioFileObjectComponentBase::~AudioFileObjectComponentBase()
+{
+ delete mAudioFileObject;
+}
+
+OSStatus AudioFileObjectComponentBase::AFAPI_CreateURL(
+ CFURLRef inFileRef,
+ const AudioStreamBasicDescription *inFormat,
+ UInt32 inFlags)
+{
+ if (!mAudioFileObject) return kAudio_ParamError;
+
+ OSStatus result = mAudioFileObject->DoCreate (inFileRef, inFormat, inFlags);
+ return result;
+}
+
+
+OSStatus AudioFileObjectComponentBase::AFAPI_OpenURL(
+ CFURLRef inFileRef,
+ SInt8 inPermissions,
+ int inFD)
+{
+ if (!mAudioFileObject) return kAudio_ParamError;
+
+ OSStatus result = mAudioFileObject->DoOpen(inFileRef, inPermissions, inFD);
+ return result;
+}
+
+
+OSStatus AudioFileObjectComponentBase::AFAPI_OpenWithCallbacks(
+ void * inRefCon,
+ AudioFile_ReadProc inReadFunc,
+ AudioFile_WriteProc inWriteFunc,
+ AudioFile_GetSizeProc inGetSizeFunc,
+ AudioFile_SetSizeProc inSetSizeFunc)
+{
+ if (!mAudioFileObject) return kAudio_ParamError;
+ return mAudioFileObject->DoOpenWithCallbacks(inRefCon, inReadFunc, inWriteFunc, inGetSizeFunc, inSetSizeFunc);
+}
+
+
+OSStatus AudioFileObjectComponentBase::AFAPI_InitializeWithCallbacks(
+ void * inRefCon,
+ AudioFile_ReadProc inReadFunc,
+ AudioFile_WriteProc inWriteFunc,
+ AudioFile_GetSizeProc inGetSizeFunc,
+ AudioFile_SetSizeProc inSetSizeFunc,
+ UInt32 inFileType,
+ const AudioStreamBasicDescription *inFormat,
+ UInt32 inFlags)
+{
+ if (!mAudioFileObject) return kAudio_ParamError;
+ return mAudioFileObject->DoInitializeWithCallbacks(inRefCon, inReadFunc, inWriteFunc, inGetSizeFunc, inSetSizeFunc,
+ inFileType, inFormat, inFlags);
+}
+
+
+OSStatus AudioFileObjectComponentBase::AFAPI_Close()
+{
+ if (!mAudioFileObject) return kAudio_ParamError;
+ return mAudioFileObject->DoClose();
+}
+
+OSStatus AudioFileObjectComponentBase::AFAPI_Optimize()
+{
+ if (!mAudioFileObject) return kAudio_ParamError;
+ return mAudioFileObject->DoOptimize();
+}
+
+OSStatus AudioFileObjectComponentBase::AFAPI_ReadBytes(
+ Boolean inUseCache,
+ SInt64 inStartingByte,
+ UInt32 *ioNumBytes,
+ void *outBuffer)
+{
+ if (!mAudioFileObject) return kAudio_ParamError;
+ return mAudioFileObject->ReadBytes(inUseCache, inStartingByte, ioNumBytes, outBuffer);
+}
+
+
+OSStatus AudioFileObjectComponentBase::AFAPI_WriteBytes(
+ Boolean inUseCache,
+ SInt64 inStartingByte,
+ UInt32 *ioNumBytes,
+ const void *inBuffer)
+{
+ if (!mAudioFileObject) return kAudio_ParamError;
+ return mAudioFileObject->WriteBytes(inUseCache, inStartingByte, ioNumBytes, inBuffer);
+}
+
+
+
+
+OSStatus AudioFileObjectComponentBase::AFAPI_ReadPackets(
+ Boolean inUseCache,
+ UInt32 *outNumBytes,
+ AudioStreamPacketDescription *outPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ void *outBuffer)
+{
+ if (!mAudioFileObject) return kAudio_ParamError;
+ return mAudioFileObject->ReadPackets(inUseCache, outNumBytes, outPacketDescriptions,
+ inStartingPacket, ioNumPackets, outBuffer);
+}
+
+OSStatus AudioFileObjectComponentBase::AFAPI_ReadPacketData(
+ Boolean inUseCache,
+ UInt32 *ioNumBytes,
+ AudioStreamPacketDescription *outPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ void *outBuffer)
+{
+ if (!mAudioFileObject) return kAudio_ParamError;
+ return mAudioFileObject->ReadPacketData(inUseCache, ioNumBytes, outPacketDescriptions,
+ inStartingPacket, ioNumPackets, outBuffer);
+}
+
+
+OSStatus AudioFileObjectComponentBase::AFAPI_WritePackets(
+ Boolean inUseCache,
+ UInt32 inNumBytes,
+ const AudioStreamPacketDescription *inPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ const void *inBuffer)
+{
+ if (!mAudioFileObject) return kAudio_ParamError;
+ return mAudioFileObject->WritePackets(inUseCache, inNumBytes, inPacketDescriptions,
+ inStartingPacket, ioNumPackets, inBuffer);
+}
+
+
+
+OSStatus AudioFileObjectComponentBase::AFAPI_GetPropertyInfo(
+ AudioFilePropertyID inPropertyID,
+ UInt32 *outDataSize,
+ UInt32 *isWritable)
+{
+ if (!mAudioFileObject) return kAudio_ParamError;
+ return mAudioFileObject->GetPropertyInfo(inPropertyID, outDataSize, isWritable);
+}
+
+
+OSStatus AudioFileObjectComponentBase::AFAPI_GetProperty(
+ AudioFilePropertyID inPropertyID,
+ UInt32 *ioPropertySize,
+ void *ioPropertyData)
+{
+ OSStatus err = noErr;
+
+ if (!ioPropertyData) return kAudio_ParamError;
+
+ if (!mAudioFileObject) return kAudio_ParamError;
+ err = mAudioFileObject->GetProperty(inPropertyID, ioPropertySize, ioPropertyData);
+ return err;
+}
+
+
+OSStatus AudioFileObjectComponentBase::AFAPI_SetProperty(
+ AudioFilePropertyID inPropertyID,
+ UInt32 inPropertySize,
+ const void *inPropertyData)
+{
+ if (!mAudioFileObject) return kAudio_ParamError;
+ return mAudioFileObject->SetProperty(inPropertyID, inPropertySize, inPropertyData);
+}
+
+
+OSStatus AudioFileObjectComponentBase::AFAPI_CountUserData(
+ UInt32 inUserDataID,
+ UInt32 *outNumberItems)
+{
+ if (!mAudioFileObject) return kAudio_ParamError;
+ return mAudioFileObject->CountUserData(inUserDataID, outNumberItems);
+}
+
+OSStatus AudioFileObjectComponentBase::AFAPI_GetUserDataSize(
+ UInt32 inUserDataID,
+ UInt32 inIndex,
+ UInt32 *outUserDataSize)
+{
+ if (!mAudioFileObject) return kAudio_ParamError;
+ return mAudioFileObject->GetUserDataSize(inUserDataID, inIndex, outUserDataSize);
+}
+
+OSStatus AudioFileObjectComponentBase::AFAPI_GetUserData(
+ UInt32 inUserDataID,
+ UInt32 inIndex,
+ UInt32 *ioUserDataSize,
+ void *outUserData)
+{
+ if (!mAudioFileObject) return kAudio_ParamError;
+ return mAudioFileObject->GetUserData(inUserDataID, inIndex, ioUserDataSize, outUserData);
+}
+
+OSStatus AudioFileObjectComponentBase::AFAPI_SetUserData(
+ UInt32 inUserDataID,
+ UInt32 inIndex,
+ UInt32 inUserDataSize,
+ const void *inUserData)
+{
+ if (!mAudioFileObject) return kAudio_ParamError;
+ return mAudioFileObject->SetUserData(inUserDataID, inIndex, inUserDataSize, inUserData);
+}
+
+OSStatus AudioFileObjectComponentBase::AFAPI_RemoveUserData(
+ UInt32 inUserDataID,
+ UInt32 inIndex)
+{
+ if (!mAudioFileObject) return kAudio_ParamError;
+ return mAudioFileObject->RemoveUserData(inUserDataID, inIndex);
+}
+
+
+OSStatus AudioFileComponentBase::AFAPI_GetGlobalInfoSize(
+ AudioFilePropertyID inPropertyID,
+ UInt32 inSpecifierSize,
+ const void* inSpecifier,
+ UInt32 *outPropertySize)
+{
+ OSStatus err = noErr;
+
+ switch (inPropertyID)
+ {
+ case kAudioFileComponent_CanRead :
+ case kAudioFileComponent_CanWrite :
+ *outPropertySize = sizeof(UInt32);
+ break;
+
+ case kAudioFileComponent_FileTypeName :
+ *outPropertySize = sizeof(CFStringRef);
+ break;
+
+ case kAudioFileComponent_ExtensionsForType :
+ *outPropertySize = sizeof(CFArrayRef);
+ break;
+
+ case kAudioFileComponent_UTIsForType :
+ *outPropertySize = sizeof(CFArrayRef);
+ break;
+
+ case kAudioFileComponent_MIMETypesForType :
+ *outPropertySize = sizeof(CFArrayRef);
+ break;
+
+ case kAudioFileComponent_AvailableFormatIDs :
+ {
+ UInt32 size = 0xFFFFFFFF;
+ err = GetAudioFileFormatBase()->GetAvailableFormatIDs(&size, NULL);
+ if (!err) *outPropertySize = size;
+ break;
+ }
+ case kAudioFileComponent_HFSTypeCodesForType :
+ {
+ UInt32 size = 0xFFFFFFFF;
+ err = GetAudioFileFormatBase()->GetHFSCodes(&size, NULL);
+ if (!err) *outPropertySize = size;
+ break;
+ }
+ case kAudioFileComponent_AvailableStreamDescriptionsForFormat :
+ {
+ if (inSpecifierSize != sizeof(UInt32)) return kAudioFileBadPropertySizeError;
+ UInt32 inFormatID = *(UInt32*)inSpecifier;
+ err = GetAudioFileFormatBase()->GetAvailableStreamDescriptions(inFormatID, outPropertySize, NULL);
+ }
+ break;
+
+ default:
+ err = kAudioFileUnsupportedPropertyError;
+ }
+ return err;
+}
+
+
+OSStatus AudioFileComponentBase::AFAPI_GetGlobalInfo(
+ AudioFilePropertyID inPropertyID,
+ UInt32 inSpecifierSize,
+ const void* inSpecifier,
+ UInt32 *ioPropertySize,
+ void *ioPropertyData)
+{
+ OSStatus err = noErr;
+
+ if (!ioPropertyData || !ioPropertySize) return kAudio_ParamError;
+
+ switch (inPropertyID)
+ {
+ case kAudioFileComponent_CanRead :
+ {
+ if (*ioPropertySize != sizeof(UInt32)) return kAudioFileBadPropertySizeError;
+ UInt32* flag = (UInt32*)ioPropertyData;
+ *flag = GetAudioFileFormatBase()->CanRead();
+ }
+ break;
+
+ case kAudioFileComponent_CanWrite :
+ {
+ if (*ioPropertySize != sizeof(UInt32)) return kAudioFileBadPropertySizeError;
+ UInt32* flag = (UInt32*)ioPropertyData;
+ *flag = GetAudioFileFormatBase()->CanWrite();
+ }
+ break;
+
+ case kAudioFileComponent_FileTypeName :
+ {
+ if (*ioPropertySize != sizeof(CFStringRef)) return kAudioFileBadPropertySizeError;
+ CFStringRef* name = (CFStringRef*)ioPropertyData;
+ GetAudioFileFormatBase()->GetFileTypeName(name);
+ }
+ break;
+
+ case kAudioFileComponent_ExtensionsForType :
+ {
+ if (*ioPropertySize != sizeof(CFArrayRef)) return kAudioFileBadPropertySizeError;
+ CFArrayRef* array = (CFArrayRef*)ioPropertyData;
+ GetAudioFileFormatBase()->GetExtensions(array);
+ }
+ break;
+
+ case kAudioFileComponent_UTIsForType :
+ {
+ if (*ioPropertySize != sizeof(CFArrayRef)) return kAudioFileBadPropertySizeError;
+ CFArrayRef* array = (CFArrayRef*)ioPropertyData;
+ GetAudioFileFormatBase()->GetUTIs(array);
+ }
+ break;
+
+ case kAudioFileComponent_MIMETypesForType :
+ {
+ if (*ioPropertySize != sizeof(CFArrayRef)) return kAudioFileBadPropertySizeError;
+ CFArrayRef* array = (CFArrayRef*)ioPropertyData;
+ GetAudioFileFormatBase()->GetMIMETypes(array);
+ }
+ break;
+
+ case kAudioFileComponent_HFSTypeCodesForType :
+ {
+ err = GetAudioFileFormatBase()->GetHFSCodes(ioPropertySize, ioPropertyData);
+ }
+ break;
+
+ case kAudioFileComponent_AvailableFormatIDs :
+ {
+ err = GetAudioFileFormatBase()->GetAvailableFormatIDs(ioPropertySize, ioPropertyData);
+ }
+ break;
+
+ case kAudioFileComponent_AvailableStreamDescriptionsForFormat :
+ {
+ if (inSpecifierSize != sizeof(UInt32)) return kAudioFileBadPropertySizeError;
+ UInt32 inFormatID = *(UInt32*)inSpecifier;
+ err = GetAudioFileFormatBase()->GetAvailableStreamDescriptions(inFormatID, ioPropertySize, ioPropertyData);
+ }
+ break;
+
+ default:
+ err = kAudioFileUnsupportedPropertyError;
+ }
+ return err;
+}
+
+
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+OSStatus AudioFileComponentBase::ComponentEntryDispatch(ComponentParameters* params, AudioFileComponentBase* inThis)
+{
+ OSStatus result = noErr;
+ if (inThis == NULL) return kAudio_ParamError;
+
+ try
+ {
+ switch (params->what)
+ {
+ case kComponentCanDoSelect:
+ switch (GetSelectorForCanDo(params))
+ {
+ case kAudioFileCreateURLSelect:
+ case kAudioFileOpenURLSelect:
+ case kAudioFileOpenWithCallbacksSelect:
+ case kAudioFileInitializeWithCallbacksSelect:
+ case kAudioFileCloseSelect:
+ case kAudioFileOptimizeSelect:
+ case kAudioFileReadBytesSelect:
+ case kAudioFileWriteBytesSelect:
+ case kAudioFileReadPacketsSelect:
+ case kAudioFileWritePacketsSelect:
+ case kAudioFileGetPropertyInfoSelect:
+ case kAudioFileGetPropertySelect:
+ case kAudioFileSetPropertySelect:
+ case kAudioFileExtensionIsThisFormatSelect:
+ case kAudioFileFileDataIsThisFormatSelect:
+ case kAudioFileGetGlobalInfoSizeSelect:
+ case kAudioFileGetGlobalInfoSelect:
+
+ case kAudioFileCountUserDataSelect:
+ case kAudioFileGetUserDataSizeSelect:
+ case kAudioFileGetUserDataSelect:
+ case kAudioFileSetUserDataSelect:
+ case kAudioFileRemoveUserDataSelect:
+ result = 1;
+ break;
+ default:
+ // these are no longer supported
+/* case kAudioFileCreateSelect:
+ case kAudioFileOpenSelect:
+ case kAudioFileInitializeSelect:
+*/ result = ComponentBase::ComponentEntryDispatch(params, inThis);
+ };
+ break;
+
+ case kAudioFileCreateURLSelect:
+ {
+ PARAM(CFURLRef, inFileRef, 0, 3);
+ PARAM(const AudioStreamBasicDescription*, inFormat, 1, 3);
+ PARAM(UInt32, inFlags, 2, 3);
+
+ result = inThis->AFAPI_CreateURL(inFileRef, inFormat, inFlags);
+ }
+ break;
+ case kAudioFileOpenURLSelect:
+ {
+ PARAM(CFURLRef, inFileRef, 0, 3);
+ PARAM(SInt32, inPermissions, 1, 3);
+ PARAM(int, inFileDescriptor, 2, 3);
+
+ result = inThis->AFAPI_OpenURL(inFileRef, inPermissions, inFileDescriptor);
+ }
+ break;
+ case kAudioFileOpenWithCallbacksSelect:
+ {
+ PARAM(void*, inRefCon, 0, 5);
+ PARAM(AudioFile_ReadProc, inReadFunc, 1, 5);
+ PARAM(AudioFile_WriteProc, inWriteFunc, 2, 5);
+ PARAM(AudioFile_GetSizeProc, inGetSizeFunc, 3, 5);
+ PARAM(AudioFile_SetSizeProc, inSetSizeFunc, 4, 5);
+
+ result = inThis->AFAPI_OpenWithCallbacks(inRefCon, inReadFunc, inWriteFunc,
+ inGetSizeFunc, inSetSizeFunc);
+ }
+ break;
+ case kAudioFileInitializeWithCallbacksSelect:
+ {
+ PARAM(void*, inRefCon, 0, 8);
+ PARAM(AudioFile_ReadProc, inReadFunc, 1, 8);
+ PARAM(AudioFile_WriteProc, inWriteFunc, 2, 8);
+ PARAM(AudioFile_GetSizeProc, inGetSizeFunc, 3, 8);
+ PARAM(AudioFile_SetSizeProc, inSetSizeFunc, 4, 8);
+ PARAM(UInt32, inFileType, 5, 8);
+ PARAM(const AudioStreamBasicDescription*, inFormat, 6, 8);
+ PARAM(UInt32, inFlags, 7, 8);
+
+ result = inThis->AFAPI_InitializeWithCallbacks(inRefCon, inReadFunc, inWriteFunc,
+ inGetSizeFunc, inSetSizeFunc,
+ inFileType, inFormat, inFlags);
+ }
+ break;
+ case kAudioFileCloseSelect:
+ {
+ result = inThis->AFAPI_Close();
+ }
+ break;
+ case kAudioFileOptimizeSelect:
+ {
+ result = inThis->AFAPI_Optimize();
+ }
+ break;
+ case kAudioFileReadBytesSelect:
+ {
+ PARAM(UInt32, inUseCache, 0, 4);
+ PARAM(SInt64*, inStartingByte, 1, 4);
+ PARAM(UInt32*, ioNumBytes, 2, 4);
+ PARAM(void*, outBuffer, 3, 4);
+
+ result = inThis->AFAPI_ReadBytes(inUseCache, *inStartingByte, ioNumBytes,
+ outBuffer);
+ }
+ break;
+ case kAudioFileWriteBytesSelect:
+ {
+ PARAM(UInt32, inUseCache, 0, 4);
+ PARAM(SInt64*, inStartingByte, 1, 4);
+ PARAM(UInt32*, ioNumBytes, 2, 4);
+ PARAM(const void*, inBuffer, 3, 4);
+
+ result = inThis->AFAPI_WriteBytes(inUseCache, *inStartingByte, ioNumBytes,
+ inBuffer);
+ }
+ break;
+ case kAudioFileReadPacketsSelect:
+ {
+ PARAM(UInt32, inUseCache, 0, 6);
+ PARAM(UInt32*, outNumBytes, 1, 6);
+ PARAM(AudioStreamPacketDescription*, outPacketDescriptions, 2, 6);
+ PARAM(SInt64*, inStartingPacket, 3, 6);
+ PARAM(UInt32*, ioNumPackets, 4, 6);
+ PARAM(void*, outBuffer, 5, 6);
+
+ result = inThis->AFAPI_ReadPackets(inUseCache, outNumBytes, outPacketDescriptions,
+ *inStartingPacket, ioNumPackets, outBuffer);
+ }
+ break;
+ case kAudioFileWritePacketsSelect:
+ {
+ PARAM(UInt32, inUseCache, 0, 6);
+ PARAM(UInt32, inNumBytes, 1, 6);
+ PARAM(const AudioStreamPacketDescription*, inPacketDescriptions, 2, 6);
+ PARAM(SInt64*, inStartingPacket, 3, 6);
+ PARAM(UInt32*, ioNumPackets, 4, 6);
+ PARAM(const void*, inBuffer, 5, 6);
+
+ result = inThis->AFAPI_WritePackets(inUseCache, inNumBytes, inPacketDescriptions,
+ *inStartingPacket, ioNumPackets, inBuffer);
+ }
+ break;
+
+ case kAudioFileGetPropertyInfoSelect:
+ {
+ PARAM(AudioFileComponentPropertyID, inPropertyID, 0, 3);
+ PARAM(UInt32*, outPropertySize, 1, 3);
+ PARAM(UInt32*, outWritable, 2, 3);
+
+ result = inThis->AFAPI_GetPropertyInfo(inPropertyID, outPropertySize, outWritable);
+ }
+ break;
+
+ case kAudioFileGetPropertySelect:
+ {
+ PARAM(AudioFileComponentPropertyID, inPropertyID, 0, 3);
+ PARAM(UInt32*, ioPropertyDataSize, 1, 3);
+ PARAM(void*, outPropertyData, 2, 3);
+
+ result = inThis->AFAPI_GetProperty(inPropertyID, ioPropertyDataSize, outPropertyData);
+ }
+ break;
+ case kAudioFileSetPropertySelect:
+ {
+ PARAM(AudioFileComponentPropertyID, inPropertyID, 0, 3);
+ PARAM(UInt32, inPropertyDataSize, 1, 3);
+ PARAM(const void*, inPropertyData, 2, 3);
+
+ result = inThis->AFAPI_SetProperty(inPropertyID, inPropertyDataSize, inPropertyData);
+ }
+ break;
+
+ case kAudioFileGetGlobalInfoSizeSelect:
+ {
+ PARAM(AudioFileComponentPropertyID, inPropertyID, 0, 4);
+ PARAM(UInt32, inSpecifierSize, 1, 4);
+ PARAM(const void*, inSpecifier, 2, 4);
+ PARAM(UInt32*, outPropertyDataSize, 3, 4);
+
+ result = inThis->AFAPI_GetGlobalInfoSize(inPropertyID, inSpecifierSize, inSpecifier,
+ outPropertyDataSize);
+ }
+ break;
+ case kAudioFileGetGlobalInfoSelect:
+ {
+ PARAM(AudioFileComponentPropertyID, inPropertyID, 0, 5);
+ PARAM(UInt32, inSpecifierSize, 1, 5);
+ PARAM(const void*, inSpecifier, 2, 5);
+ PARAM(UInt32*, ioPropertyDataSize, 3, 5);
+ PARAM(void*, outPropertyData, 4, 5);
+
+ result = inThis->AFAPI_GetGlobalInfo(inPropertyID, inSpecifierSize, inSpecifier,
+ ioPropertyDataSize, outPropertyData);
+ }
+ break;
+
+ case kAudioFileExtensionIsThisFormatSelect:
+ {
+ PARAM(CFStringRef, inExtension, 0, 2);
+ PARAM(UInt32*, outResult, 1, 2);
+
+ AudioFileFormatBase* aff = inThis->GetAudioFileFormatBase();
+ if (!aff) return kAudio_ParamError;
+
+ UInt32 res = aff->ExtensionIsThisFormat(inExtension);
+ if (outResult) *outResult = res;
+ }
+ break;
+
+ case kAudioFileFileDataIsThisFormatSelect:
+ {
+ PARAM(UInt32, inDataByteSize, 0, 3);
+ PARAM(const void*, inData, 1, 3);
+ PARAM(UInt32*, outResult, 2, 3);
+
+ AudioFileFormatBase* aff = inThis->GetAudioFileFormatBase();
+ if (!aff) return kAudio_ParamError;
+
+ UncertainResult res = aff->FileDataIsThisFormat(inDataByteSize, inData);
+ if (outResult) *outResult = res;
+ }
+ break;
+
+ case kAudioFileCountUserDataSelect:
+ {
+ PARAM(UInt32, inUserDataID, 0, 2);
+ PARAM(UInt32*, outNumberItems, 1, 2);
+
+ result = inThis->AFAPI_CountUserData(inUserDataID, outNumberItems);
+ }
+ break;
+
+ case kAudioFileGetUserDataSizeSelect:
+ {
+ PARAM(UInt32, inUserDataID, 0, 3);
+ PARAM(UInt32, inIndex, 1, 3);
+ PARAM(UInt32*, outUserDataSize, 2, 3);
+
+ result = inThis->AFAPI_GetUserDataSize(inUserDataID, inIndex, outUserDataSize);
+ }
+ break;
+
+ case kAudioFileGetUserDataSelect:
+ {
+ PARAM(UInt32, inUserDataID, 0, 4);
+ PARAM(UInt32, inIndex, 1, 4);
+ PARAM(UInt32*, ioUserDataSize, 2, 4);
+ PARAM(void*, outUserData, 3, 4);
+
+ result = inThis->AFAPI_GetUserData(inUserDataID, inIndex,
+ ioUserDataSize, outUserData);
+ }
+ break;
+
+ case kAudioFileSetUserDataSelect:
+ {
+ PARAM(UInt32, inUserDataID, 0, 4);
+ PARAM(UInt32, inIndex, 1, 4);
+ PARAM(UInt32, inUserDataSize, 2, 4);
+ PARAM(const void*, inUserData, 3, 4);
+
+ result = inThis->AFAPI_SetUserData(inUserDataID, inIndex,
+ inUserDataSize, inUserData);
+ }
+ break;
+
+ case kAudioFileRemoveUserDataSelect:
+ {
+ PARAM(UInt32, inUserDataID, 0, 2);
+ PARAM(UInt32, inIndex, 1, 2);
+
+ result = inThis->AFAPI_RemoveUserData(inUserDataID, inIndex);
+ }
+ break;
+
+
+ default:
+ result = ComponentBase::ComponentEntryDispatch(params, inThis);
+ break;
+ }
+ }
+ COMPONENT_CATCH
+ return result;
+}
+#endif
+
+AudioComponentMethod AudioFileComponentLookup::Lookup (SInt16 selector)
+{
+ switch (selector) {
+
+#define DefCase(NAME) case kAudioFile##NAME##Select: return (AudioComponentMethod)NAME
+
+ DefCase(OpenWithCallbacks);
+ DefCase(InitializeWithCallbacks);
+ DefCase(Close);
+ DefCase(Optimize);
+ DefCase(ReadBytes);
+ DefCase(WriteBytes);
+ DefCase(ReadPackets);
+ DefCase(WritePackets);
+ DefCase(GetPropertyInfo);
+ DefCase(GetProperty);
+ DefCase(SetProperty);
+
+ DefCase(ExtensionIsThisFormat);
+ DefCase(GetGlobalInfoSize);
+ DefCase(GetGlobalInfo);
+
+ DefCase(CountUserData);
+ DefCase(GetUserDataSize);
+ DefCase(GetUserData);
+ DefCase(SetUserData);
+ DefCase(RemoveUserData);
+ DefCase(CreateURL);
+ DefCase(OpenURL);
+ DefCase(FileDataIsThisFormat);
+ DefCase(ReadPacketData);
+
+ // These selectors are deprecated and do not appear: Create, Open, Initialize, FileIsThisFormat, DataIsThisFormat.
+
+ default:
+ break;
+ }
+ return NULL;
+}
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/AudioFileComponentBase.h b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/AudioFileComponentBase.h
new file mode 100644
index 000000000..5a11934e7
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/AudioFileComponentBase.h
@@ -0,0 +1,311 @@
+/*
+ File: AudioFileComponentBase.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 __AudioFileComponentBase_h__
+#define __AudioFileComponentBase_h__
+
+#include "ComponentBase.h"
+#include "AudioFileFormat.h"
+
+struct AudioFileComponentLookup {
+ static AudioComponentMethod Lookup (SInt16 selector);
+};
+template
+class AudioFileComponentFactory : public APFactory
+{
+};
+
+/* subclass, override AudioFileComponentBase() and GetAudioFormat() and that's it. */
+
+class AudioFileComponentBase : public ComponentBase
+{
+public:
+ AudioFileComponentBase(AudioComponentInstance inInstance);
+ virtual ~AudioFileComponentBase();
+
+ virtual AudioFileFormatBase* GetAudioFileFormatBase() const = 0;
+
+ /* Public API Function Support */
+ virtual OSStatus AFAPI_CreateURL(
+ CFURLRef inFileRef,
+ const AudioStreamBasicDescription *inFormat,
+ UInt32 inFlags) { return kAudio_UnimplementedError; }
+
+ virtual OSStatus AFAPI_OpenURL(
+ CFURLRef inFileRef,
+ SInt8 inPermissions,
+ int inFD) { return kAudio_UnimplementedError; }
+
+
+ virtual OSStatus AFAPI_Create(
+ const FSRef *inParentRef,
+ CFStringRef inFileName,
+ const AudioStreamBasicDescription *inFormat,
+ UInt32 inFlags,
+ FSRef *outNewFileRef) { return kAudio_UnimplementedError; }
+
+ virtual OSStatus AFAPI_Initialize(
+ const FSRef *inFileRef,
+ const AudioStreamBasicDescription *inFormat,
+ UInt32 inFlags) { return kAudio_UnimplementedError; }
+
+ virtual OSStatus AFAPI_Open(
+ const FSRef *inFileRef,
+ SInt8 inPermissions,
+ SInt16 inRefNum) { return kAudio_UnimplementedError; }
+
+ virtual OSStatus AFAPI_OpenWithCallbacks(
+ void * inRefCon,
+ AudioFile_ReadProc inReadFunc,
+ AudioFile_WriteProc inWriteFunc,
+ AudioFile_GetSizeProc inGetSizeFunc,
+ AudioFile_SetSizeProc inSetSizeFunc)=0;
+
+ virtual OSStatus AFAPI_InitializeWithCallbacks(
+ void * inRefCon,
+ AudioFile_ReadProc inReadFunc,
+ AudioFile_WriteProc inWriteFunc,
+ AudioFile_GetSizeProc inGetSizeFunc,
+ AudioFile_SetSizeProc inSetSizeFunc,
+ UInt32 inFileType,
+ const AudioStreamBasicDescription *inFormat,
+ UInt32 inFlags)=0;
+
+ virtual OSStatus AFAPI_Close()=0;
+ virtual OSStatus AFAPI_Optimize()=0;
+ virtual OSStatus AFAPI_ReadBytes( Boolean inUseCache,
+ SInt64 inStartingByte,
+ UInt32 *ioNumBytes,
+ void *outBuffer)=0;
+
+ virtual OSStatus AFAPI_WriteBytes( Boolean inUseCache,
+ SInt64 inStartingByte,
+ UInt32 *ioNumBytes,
+ const void *inBuffer)=0;
+
+ virtual OSStatus AFAPI_ReadPackets( Boolean inUseCache,
+ UInt32 *outNumBytes,
+ AudioStreamPacketDescription *outPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ void *outBuffer)=0;
+
+ virtual OSStatus AFAPI_ReadPacketData( Boolean inUseCache,
+ UInt32 *ioNumBytes,
+ AudioStreamPacketDescription *outPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ void *outBuffer)=0;
+
+ virtual OSStatus AFAPI_WritePackets( Boolean inUseCache,
+ UInt32 inNumBytes,
+ const AudioStreamPacketDescription *inPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ const void *inBuffer)=0;
+
+ virtual OSStatus AFAPI_GetPropertyInfo( AudioFilePropertyID inPropertyID,
+ UInt32 *outDataSize,
+ UInt32 *isWritable)=0;
+
+ virtual OSStatus AFAPI_GetProperty( AudioFilePropertyID inPropertyID,
+ UInt32 *ioDataSize,
+ void *ioPropertyData)=0;
+
+ virtual OSStatus AFAPI_SetProperty( AudioFilePropertyID inPropertyID,
+ UInt32 inDataSize,
+ const void *inPropertyData)=0;
+ virtual OSStatus AFAPI_GetGlobalInfoSize(
+ AudioFilePropertyID inPropertyID,
+ UInt32 inSpecifierSize,
+ const void* inSpecifier,
+ UInt32 *outPropertySize);
+
+ virtual OSStatus AFAPI_GetGlobalInfo(
+ AudioFilePropertyID inPropertyID,
+ UInt32 inSpecifierSize,
+ const void* inSpecifier,
+ UInt32 *ioPropertySize,
+ void *ioPropertyData);
+
+ virtual OSStatus AFAPI_CountUserData( UInt32 inUserDataID,
+ UInt32 *outNumberItems)=0;
+
+ virtual OSStatus AFAPI_GetUserDataSize( UInt32 inUserDataID,
+ UInt32 inIndex,
+ UInt32 *outDataSize)=0;
+
+ virtual OSStatus AFAPI_GetUserData( UInt32 inUserDataID,
+ UInt32 inIndex,
+ UInt32 *ioDataSize,
+ void *ioUserData)=0;
+
+ virtual OSStatus AFAPI_SetUserData( UInt32 inUserDataID,
+ UInt32 inIndex,
+ UInt32 inDataSize,
+ const void *inUserData)=0;
+
+ virtual OSStatus AFAPI_RemoveUserData( UInt32 inUserDataID,
+ UInt32 inIndex)=0;
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+ static OSStatus ComponentEntryDispatch(ComponentParameters *p, AudioFileComponentBase *This);
+#endif
+
+protected:
+};
+
+
+
+class AudioFileObjectComponentBase : public AudioFileComponentBase
+{
+public:
+ AudioFileObjectComponentBase(AudioComponentInstance inInstance);
+ virtual ~AudioFileObjectComponentBase();
+
+ virtual AudioFileFormat* GetAudioFormat() const = 0;
+ virtual AudioFileFormatBase* GetAudioFileFormatBase() const { return GetAudioFormat(); }
+
+ void SetAudioFileObject(AudioFileObject* inObject) { mAudioFileObject = inObject; }
+
+ /* Public API Function Support */
+
+ virtual OSStatus AFAPI_CreateURL(
+ CFURLRef inFileRef,
+ const AudioStreamBasicDescription *inFormat,
+ UInt32 inFlags);
+
+ virtual OSStatus AFAPI_OpenURL(
+ CFURLRef inFileRef,
+ SInt8 inPermissions,
+ int inFD);
+
+ virtual OSStatus AFAPI_OpenWithCallbacks(
+ void * inRefCon,
+ AudioFile_ReadProc inReadFunc,
+ AudioFile_WriteProc inWriteFunc,
+ AudioFile_GetSizeProc inGetSizeFunc,
+ AudioFile_SetSizeProc inSetSizeFunc);
+
+ virtual OSStatus AFAPI_InitializeWithCallbacks(
+ void * inRefCon,
+ AudioFile_ReadProc inReadFunc,
+ AudioFile_WriteProc inWriteFunc,
+ AudioFile_GetSizeProc inGetSizeFunc,
+ AudioFile_SetSizeProc inSetSizeFunc,
+ UInt32 inFileType,
+ const AudioStreamBasicDescription *inFormat,
+ UInt32 inFlags);
+
+ virtual OSStatus AFAPI_Close();
+ virtual OSStatus AFAPI_Optimize();
+ virtual OSStatus AFAPI_ReadBytes( Boolean inUseCache,
+ SInt64 inStartingByte,
+ UInt32 *ioNumBytes,
+ void *outBuffer);
+
+ virtual OSStatus AFAPI_WriteBytes( Boolean inUseCache,
+ SInt64 inStartingByte,
+ UInt32 *ioNumBytes,
+ const void *inBuffer);
+
+ virtual OSStatus AFAPI_ReadPackets( Boolean inUseCache,
+ UInt32 *outNumBytes,
+ AudioStreamPacketDescription *outPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ void *outBuffer);
+
+ virtual OSStatus AFAPI_ReadPacketData( Boolean inUseCache,
+ UInt32 *ioNumBytes,
+ AudioStreamPacketDescription *outPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ void *outBuffer);
+
+ virtual OSStatus AFAPI_WritePackets( Boolean inUseCache,
+ UInt32 inNumBytes,
+ const AudioStreamPacketDescription *inPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ const void *inBuffer);
+
+ virtual OSStatus AFAPI_GetPropertyInfo( AudioFilePropertyID inPropertyID,
+ UInt32 *outDataSize,
+ UInt32 *isWritable);
+
+ virtual OSStatus AFAPI_GetProperty( AudioFilePropertyID inPropertyID,
+ UInt32 *ioDataSize,
+ void *ioPropertyData);
+
+ virtual OSStatus AFAPI_SetProperty( AudioFilePropertyID inPropertyID,
+ UInt32 inDataSize,
+ const void *inPropertyData);
+
+ virtual OSStatus AFAPI_CountUserData( UInt32 inUserDataID,
+ UInt32 *outNumberItems);
+
+ virtual OSStatus AFAPI_GetUserDataSize( UInt32 inUserDataID,
+ UInt32 inIndex,
+ UInt32 *outDataSize);
+
+ virtual OSStatus AFAPI_GetUserData( UInt32 inUserDataID,
+ UInt32 inIndex,
+ UInt32 *ioDataSize,
+ void *ioUserData);
+
+ virtual OSStatus AFAPI_SetUserData( UInt32 inUserDataID,
+ UInt32 inIndex,
+ UInt32 inDataSize,
+ const void *inUserData);
+
+ virtual OSStatus AFAPI_RemoveUserData( UInt32 inUserDataID,
+ UInt32 inIndex);
+
+protected:
+ AudioFileObject* mAudioFileObject;
+};
+
+#endif
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/AudioFileFormat.cpp b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/AudioFileFormat.cpp
new file mode 100644
index 000000000..ee6bedd59
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/AudioFileFormat.cpp
@@ -0,0 +1,71 @@
+/*
+ File: AudioFileFormat.cpp
+ Abstract: AudioFileFormat.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 "AudioFileFormat.h"
+#include "DataSource.h"
+
+AudioFileFormatBase::AudioFileFormatBase(UInt32 inFileType)
+ : mFileType(inFileType)
+{
+}
+
+AudioFileFormatBase::~AudioFileFormatBase()
+{
+}
+
+OSStatus AudioFileFormatBase::GetHFSCodes(UInt32* ioDataSize, void* outPropertyData)
+{
+ return kAudioFileUnsupportedPropertyError;
+}
+
+AudioFileFormat::AudioFileFormat(UInt32 inFileType)
+ : AudioFileFormatBase(inFileType)
+{
+}
+
+AudioFileFormat::~AudioFileFormat()
+{
+}
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/AudioFileFormat.h b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/AudioFileFormat.h
new file mode 100644
index 000000000..943619956
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/AudioFileFormat.h
@@ -0,0 +1,125 @@
+/*
+ File: AudioFileFormat.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 _AudioFileFormat_H_
+#define _AudioFileFormat_H_
+
+#include "AudioFileObject.h"
+
+// AudioFileFormat is a factory class for AudioFileObjects.
+
+// UncertainResult is needed for DataIsThisFormat.
+// In the case of SoundDesigner 2 we can't determine if the data is SoundDesigner 2 or not.
+
+typedef int UncertainResult;
+
+enum {
+ kFalse = 0,
+ kTrue = 1,
+ kCantDetermine = -1
+};
+
+class AudioFileHandle;
+class AudioFileFormat;
+class AudioFileFormatComponent;
+
+class AudioFileFormatBase
+{
+public:
+ AudioFileFormatBase(UInt32 inFileType);
+ virtual ~AudioFileFormatBase();
+
+ // return true if extension is of this format type
+ virtual Boolean ExtensionIsThisFormat(CFStringRef inExtension) = 0;
+
+ virtual UncertainResult FileDataIsThisFormat(
+ UInt32 /*inDataByteSize*/,
+ const void* /*inData*/) = 0;
+
+ // support SoundDesigner II files while minimizing opening and closing files.
+ virtual Boolean ResourceIsThisFormat(const FSRef* /*inRef*/) { return false; }
+
+ UInt32 GetFileType() const { return mFileType; }
+
+ virtual UInt32 CanRead() const { return 1; }
+ virtual UInt32 CanWrite() const { return 1; }
+ virtual UInt32 HasResourceFork() const { return 0; }
+
+ virtual void GetExtensions(CFArrayRef *outArray) = 0;
+ virtual void GetUTIs(CFArrayRef *outArray) {}
+ virtual void GetMIMETypes(CFArrayRef *outArray) {}
+ virtual void GetFileTypeName(CFStringRef *outName) = 0;
+ virtual OSStatus GetAvailableFormatIDs(UInt32* ioDataSize, void* outPropertyData) = 0;
+ virtual OSStatus GetAvailableStreamDescriptions(UInt32 inFormatID, UInt32* ioDataSize, void* outPropertyData) = 0;
+ virtual OSStatus GetHFSCodes(UInt32* ioDataSize, void* outPropertyData);
+
+ virtual AudioFileFormat* AsAudioFileFormat() { return NULL; }
+ virtual AudioFileFormatComponent* AsAudioFileFormatComponent() { return NULL; }
+
+private:
+ UInt32 mFileType;
+};
+
+class AudioFileStreamObject;
+
+class AudioFileFormat : public AudioFileFormatBase
+{
+public:
+ AudioFileFormat(UInt32 inFileType);
+ virtual ~AudioFileFormat();
+
+ // create an AudioFileObject for this format type.
+ virtual AudioFileObject* New() = 0;
+ virtual AudioFileStreamObject* NewStream() { return NULL; }
+
+ // return true if file is of this format type
+ virtual UncertainResult FileDataIsThisFormat(UInt32 inDataByteSize, const void* inData) = 0;
+
+ virtual AudioFileFormat* AsAudioFileFormat() { return this; }
+};
+
+
+#endif
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/AudioFileObject.cpp b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/AudioFileObject.cpp
new file mode 100644
index 000000000..1a00f9625
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/AudioFileObject.cpp
@@ -0,0 +1,1966 @@
+/*
+ File: AudioFileObject.cpp
+ Abstract: AudioFileObject.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 "AudioFileObject.h"
+#include "CADebugMacros.h"
+#include
+#include
+
+#define kAudioFileNoCacheMask 0x20
+
+const SInt64 kScanToEnd = 0x7fffFFFFffffFFFFLL;
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+AudioFileObject::~AudioFileObject()
+{
+ delete mDataSource;
+ DeletePacketTable();
+ SetURL(NULL);
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::DoCreate(
+ CFURLRef inFileRef,
+ const AudioStreamBasicDescription *inFormat,
+ UInt32 inFlags)
+{
+ // common prologue
+ if (!IsDataFormatValid(inFormat))
+ return kAudioFileUnsupportedDataFormatError;
+
+ if (!IsDataFormatSupported(inFormat))
+ return kAudioFileUnsupportedDataFormatError;
+
+ SetPermissions(kAudioFileReadWritePermission);
+
+ SetAlignDataWithFillerChunks(!(inFlags & 2 /* kAudioFileFlags_DontPageAlignAudioData */ ));
+
+ // call virtual method for particular format.
+ return Create(inFileRef, inFormat);
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::Create(
+ CFURLRef inFileRef,
+ const AudioStreamBasicDescription *inFormat)
+{
+ int fileD;
+ OSStatus err = CreateDataFile (inFileRef, fileD);
+ FailIf (err != noErr, Bail, "CreateDataFile failed");
+
+ SetURL (inFileRef);
+
+ err = OpenFile(kAudioFileReadWritePermission, fileD);
+ FailIf (err != noErr, Bail, "OpenFile failed");
+
+ err = SetDataFormat(inFormat);
+ FailIf (err != noErr, Bail, "SetDataFormat failed");
+
+ mIsInitialized = false;
+
+Bail:
+ return err;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::DoOpen(
+ CFURLRef inFileRef,
+ SInt8 inPermissions,
+ int inFD)
+{
+ OSStatus err = noErr;
+ SetPermissions(inPermissions);
+
+ err = Open(inFileRef, inPermissions, inFD);
+ FailIf (err != noErr, Bail, "Open failed");
+
+ err = ValidateFormatAndData();
+ FailIf (err != noErr, Bail, "ValidateFormatAndData failed");
+
+Bail:
+ return err;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::Open(
+ CFURLRef inFileRef,
+ SInt8 inPermissions,
+ int inFD)
+{
+ if (!(inPermissions & kAudioFileReadPermission))
+ return kAudioFilePermissionsError; // file must have read permissions
+
+ SetURL(inFileRef);
+
+ OSStatus err = OpenFile(inPermissions, inFD);
+ FailIf (err != noErr, Bail, "OpenFile failed");
+
+ err = OpenFromDataSource();
+ FailIf (err != noErr, Bail, "OpenFromDataSource failed");
+
+Bail:
+ return err;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::ValidateFormatAndData()
+{
+
+
+ AudioStreamBasicDescription asbd = GetDataFormat();
+
+ if (!IsDataFormatValid(&asbd))
+ return kAudioFileInvalidFileError;
+
+ if (asbd.mFormatID == kAudioFormatLinearPCM)
+ {
+ SInt64 maxPackets = GetNumBytes() / asbd.mBytesPerPacket;
+ if (GetNumPackets() > maxPackets)
+ return kAudioFileInvalidFileError;
+ }
+ return noErr;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::DoOpenWithCallbacks(
+ void * inRefCon,
+ AudioFile_ReadProc inReadFunc,
+ AudioFile_WriteProc inWriteFunc,
+ AudioFile_GetSizeProc inGetSizeFunc,
+ AudioFile_SetSizeProc inSetSizeFunc)
+{
+ SInt8 perms = (inSetSizeFunc || inWriteFunc) ? kAudioFileReadWritePermission : kAudioFileReadPermission;
+ SetPermissions(perms);
+
+ DataSource* dataSource = new Seekable_DataSource(inRefCon, inReadFunc, inWriteFunc, inGetSizeFunc, inSetSizeFunc);
+ SetDataSource(dataSource);
+ return OpenFromDataSource();
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::OpenFromDataSource(void)
+{
+ return noErr;
+}
+
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::DoInitializeWithCallbacks(
+ void * inRefCon,
+ AudioFile_ReadProc inReadFunc,
+ AudioFile_WriteProc inWriteFunc,
+ AudioFile_GetSizeProc inGetSizeFunc,
+ AudioFile_SetSizeProc inSetSizeFunc,
+ UInt32 inFileType,
+ const AudioStreamBasicDescription *inFormat,
+ UInt32 inFlags)
+{
+ DataSource* dataSource = new Seekable_DataSource(inRefCon, inReadFunc, inWriteFunc, inGetSizeFunc, inSetSizeFunc);
+ if (!dataSource->CanWrite()) return -54/*permErr*/;
+ dataSource->SetSize(0);
+ SetDataSource(dataSource);
+ SetPermissions(kAudioFileReadWritePermission);
+
+ SetAlignDataWithFillerChunks(!(inFlags & 2 /* kAudioFileFlags_DontPageAlignAudioData */ ));
+
+ OSStatus err = SetDataFormat(inFormat);
+ if (err) return err;
+
+ return InitializeDataSource(inFormat, inFlags);
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::DoInitialize(
+ CFURLRef inFileRef,
+ const AudioStreamBasicDescription *inFormat,
+ UInt32 inFlags)
+{
+ SetURL (inFileRef);
+ SetPermissions(kAudioFileReadWritePermission);
+
+ SetAlignDataWithFillerChunks(!(inFlags & 2 /* kAudioFileFlags_DontPageAlignAudioData */ ));
+
+ return Initialize(inFileRef, inFormat, inFlags);
+}
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::Initialize(
+ CFURLRef inFileRef,
+ const AudioStreamBasicDescription *inFormat,
+ UInt32 inFlags)
+{
+ OSStatus err = noErr;
+
+ UInt8 fPath[FILENAME_MAX];
+ if (!CFURLGetFileSystemRepresentation (inFileRef, true, fPath, FILENAME_MAX))
+ return kAudio_FileNotFoundError;
+
+#if TARGET_OS_WIN32
+ int filePerms = 0;
+ int flags = O_TRUNC | O_RDWR | O_BINARY;
+#else
+ mode_t filePerms = 0;
+ int flags = O_TRUNC | O_RDWR;
+#endif
+
+ int fileD = open((const char*)fPath, flags, filePerms);
+ if (fileD < 0)
+ return AudioFileTranslateErrno(errno);
+
+ err = OpenFile(kAudioFileReadWritePermission, fileD);
+ FailIf (err != noErr, Bail, "OpenFile failed");
+
+ // don't need to do this as open has an option to truncate the file
+// GetDataSource()->SetSize(0);
+
+ err = SetDataFormat(inFormat);
+ FailIf (err != noErr, Bail, "SetDataFormat failed");
+
+ InitializeDataSource(inFormat, inFlags);
+
+Bail:
+ return err;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::InitializeDataSource(const AudioStreamBasicDescription *inFormat, UInt32 /*inFlags*/)
+{
+ return noErr;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::DoClose()
+{
+ OSStatus err = UpdateSizeIfNeeded();
+ if (err) return err;
+
+ return Close();
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::Close()
+{
+ try {
+ delete mDataSource;
+ mDataSource = 0;
+ } catch (OSStatus err) {
+ return err;
+ } catch (...) {
+ return kAudioFileUnspecifiedError;
+ }
+ return noErr;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+OSStatus AudioFileObject::Optimize()
+{
+ // default is that nothing needs to be done. This happens to be true for Raw, SD2 and NeXT/Sun types.
+ SetIsOptimized(true);
+ return noErr;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+OSStatus AudioFileObject::DoOptimize()
+{
+ if (!CanWrite()) return kAudioFilePermissionsError;
+
+ OSStatus err = UpdateSizeIfNeeded();
+ if (err) return err;
+
+ if (IsOptimized()) return noErr;
+
+ err = Optimize();
+ return err;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::UpdateNumBytes(SInt64 inNumBytes)
+{
+ OSStatus err = noErr;
+ if (inNumBytes != GetNumBytes()) {
+ SetNumBytes(inNumBytes);
+
+ // #warning " this will not work for vbr formats"
+ SetNumPackets(GetNumBytes() / mDataFormat.mBytesPerPacket);
+ SizeChanged();
+ }
+ return err;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::UpdateNumPackets(SInt64 inNumPackets)
+{
+ OSStatus err = noErr;
+ if (inNumPackets != GetNumPackets()) {
+ // sync current state.
+ SetNeedsSizeUpdate(true);
+ UpdateSizeIfNeeded();
+ SetNumPackets(inNumPackets);
+
+ // #warning " this will not work for vbr formats"
+ SetNumBytes(GetNumPackets() * mDataFormat.mBytesPerFrame);
+ SizeChanged();
+ }
+ return err;
+}
+
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::PacketToFrame(SInt64 inPacket, SInt64& outFirstFrameInPacket)
+{
+ if (mDataFormat.mFramesPerPacket == 0)
+ {
+ OSStatus err = ScanForPackets(inPacket+1); // the packet count must be one greater than the packet index
+ if (err) return err;
+
+ SInt64 packetTableSize = GetPacketTableSize();
+
+ if (mPacketTable && inPacket >= packetTableSize)
+ return kAudioFileEndOfFileError;
+
+ CompressedPacketTable* packetTable = GetPacketTable();
+ if (!packetTable)
+ return kAudioFileInvalidPacketOffsetError;
+
+ if (inPacket < 0 || inPacket >= packetTableSize)
+ return kAudioFileInvalidPacketOffsetError;
+
+ outFirstFrameInPacket = (*packetTable)[(size_t)inPacket].mFrameOffset;
+ }
+ else
+ {
+ outFirstFrameInPacket = inPacket * mDataFormat.mFramesPerPacket;
+ }
+ return noErr;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::FrameToPacket(SInt64 inFrame, SInt64& outPacket, UInt32& outFrameOffsetInPacket)
+{
+ if (mDataFormat.mFramesPerPacket == 0)
+ {
+ CompressedPacketTable* packetTable = GetPacketTable();
+ if (!packetTable)
+ return kAudioFileInvalidPacketOffsetError;
+
+ // search packet table
+ AudioStreamPacketDescriptionExtended pext;
+ memset(&pext, 0, sizeof(pext));
+ pext.mFrameOffset = inFrame;
+ CompressedPacketTable::iterator iter = std::lower_bound(packetTable->begin(), packetTable->end(), pext);
+
+ if (iter == packetTable->end())
+ return kAudioFileInvalidPacketOffsetError;
+
+ if (iter > packetTable->begin()) --iter;
+
+ outPacket = iter - packetTable->begin();
+ outFrameOffsetInPacket = (UInt32)(inFrame - iter->mFrameOffset);
+ }
+ else
+ {
+ outPacket = inFrame / mDataFormat.mFramesPerPacket;
+ outFrameOffsetInPacket = (UInt32)(inFrame % mDataFormat.mFramesPerPacket);
+ }
+ return noErr;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::PacketToByte(AudioBytePacketTranslation* abpt)
+{
+ if (abpt->mPacket < 0)
+ return kAudioFileInvalidPacketOffsetError;
+
+ if (mDataFormat.mBytesPerPacket == 0)
+ {
+ CompressedPacketTable* packetTable = GetPacketTable();
+ if (!packetTable)
+ return kAudioFileInvalidPacketOffsetError;
+
+ if (abpt->mPacket < GetPacketTableSize()) {
+ abpt->mByte = (*packetTable)[(int)abpt->mPacket].mStartOffset;
+ abpt->mFlags = 0;
+ } else {
+ SInt64 numPackets = packetTable->size();
+ if (numPackets < 8)
+ return 'more' /*kAudioFileStreamError_DataUnavailable*/ ;
+
+ const AudioStreamPacketDescriptionExtended lastPacket = (*packetTable)[numPackets - 1];
+ SInt64 bytesReadSoFar = lastPacket.mStartOffset + lastPacket.mDataByteSize;
+ double averageBytesPerPacket = (double)(bytesReadSoFar - GetDataOffset()) / (double)numPackets;
+ abpt->mByte = (SInt64)floor((double)abpt->mPacket * averageBytesPerPacket);
+ abpt->mFlags = kBytePacketTranslationFlag_IsEstimate;
+ }
+ }
+ else
+ {
+ abpt->mByte = abpt->mPacket * mDataFormat.mBytesPerPacket;
+ abpt->mFlags = 0;
+ }
+ return noErr;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+inline bool byte_less_than (const AudioStreamPacketDescriptionExtended& a, const AudioStreamPacketDescriptionExtended& b)
+{
+ return a.mStartOffset < b.mStartOffset;
+}
+
+OSStatus AudioFileObject::ByteToPacket(AudioBytePacketTranslation* abpt)
+{
+ if (abpt->mByte < 0)
+ return kAudioFileInvalidPacketOffsetError;
+
+ if (mDataFormat.mBytesPerPacket == 0)
+ {
+ CompressedPacketTable* packetTable = GetPacketTable();
+ if (!packetTable)
+ return kAudioFileInvalidPacketOffsetError;
+ // search packet table
+ AudioStreamPacketDescriptionExtended pext;
+ memset(&pext, 0, sizeof(pext));
+ pext.mStartOffset = abpt->mByte;
+ CompressedPacketTable::iterator iter = std::lower_bound(packetTable->begin(), packetTable->end(), pext, byte_less_than);
+
+ if (iter == packetTable->end()) {
+ SInt64 numPackets = packetTable->size();
+ if (numPackets < 8)
+ return 'more' /*kAudioFileStreamError_DataUnavailable*/ ;
+
+ const AudioStreamPacketDescriptionExtended lastPacket = (*packetTable)[numPackets - 1];
+ SInt64 bytesReadSoFar = lastPacket.mStartOffset + lastPacket.mDataByteSize;
+ double averageBytesPerPacket = (double)(bytesReadSoFar - GetDataOffset()) / (double)numPackets;
+
+ double fpacket = (double)abpt->mByte / averageBytesPerPacket;
+ abpt->mPacket = (SInt64)floor(fpacket);
+ abpt->mByteOffsetInPacket = (UInt32)floor((fpacket - (double)abpt->mPacket) * averageBytesPerPacket);
+ abpt->mFlags = kBytePacketTranslationFlag_IsEstimate;
+
+ } else {
+ if (iter > packetTable->begin()) --iter;
+ abpt->mPacket = iter - packetTable->begin();
+ abpt->mByteOffsetInPacket = (UInt32)(abpt->mByte - iter->mStartOffset);
+ abpt->mFlags = 0;
+ }
+ }
+ else
+ {
+ abpt->mPacket = abpt->mByte / mDataFormat.mBytesPerPacket;
+ abpt->mByteOffsetInPacket = (UInt32)(abpt->mByte % mDataFormat.mBytesPerPacket);
+ abpt->mFlags = 0;
+ }
+ return noErr;
+}
+
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::ReadBytes(
+ Boolean inUseCache,
+ SInt64 inStartingByte,
+ UInt32 *ioNumBytes,
+ void *outBuffer)
+{
+ OSStatus err = noErr;
+ UInt16 mode = SEEK_SET;
+ SInt64 fileOffset = mDataOffset + inStartingByte;
+ bool readingPastEnd = false;
+
+ FailWithAction((ioNumBytes == NULL) || (outBuffer == NULL), err = kAudio_ParamError,
+ Bail, "invalid num bytes parameter");
+
+ //printf("inStartingByte %lld GetNumBytes %lld\n", inStartingByte, GetNumBytes());
+
+ if (inStartingByte >= GetNumBytes())
+ {
+ *ioNumBytes = 0;
+ return kAudioFileEndOfFileError;
+ }
+
+ if ((fileOffset + *ioNumBytes) > (GetNumBytes() + mDataOffset))
+ {
+ *ioNumBytes = (UInt32)(GetNumBytes() + mDataOffset - fileOffset);
+ readingPastEnd = true;
+ }
+ //printf("fileOffset %lld mDataOffset %lld readingPastEnd %d\n", fileOffset, mDataOffset, readingPastEnd);
+
+ if (!inUseCache)
+ mode |= kAudioFileNoCacheMask;
+
+ err = GetDataSource()->ReadBytes(mode, fileOffset, *ioNumBytes, outBuffer, ioNumBytes);
+
+ if (readingPastEnd && err == noErr)
+ err = kAudioFileEndOfFileError;
+
+Bail:
+ return err;
+}
+
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::WriteBytes(
+ Boolean inUseCache,
+ SInt64 inStartingByte,
+ UInt32 *ioNumBytes,
+ const void *inBuffer)
+{
+ OSStatus err = noErr;
+ UInt16 mode = SEEK_SET;
+ bool extendingTheAudioData;
+
+ if (!CanWrite()) return kAudioFilePermissionsError;
+
+ FailWithAction((ioNumBytes == NULL) || (inBuffer == NULL), err = kAudioFileUnspecifiedError, Bail, "invalid parameters");
+
+ // Do not try to write to a postion greater than 32 bits for some file types
+ // see if starting byte + ioNumBytes is greater than 32 bits
+ // if so, see if file type supports this and bail if not
+ err = IsValidFilePosition(inStartingByte + *ioNumBytes);
+ FailIf(err != noErr, Bail, "invalid file position");
+
+ extendingTheAudioData = inStartingByte + *ioNumBytes > GetNumBytes();
+
+ // if file is not optimized, then do not write data that would overwrite chunks following the sound data chunk
+ FailWithAction( extendingTheAudioData && !IsOptimized(),
+ err = kAudioFileNotOptimizedError, Bail, "Can't write more data until the file is optimized");
+
+ if (!inUseCache)
+ mode |= kAudioFileNoCacheMask;
+
+ err = GetDataSource()->WriteBytes(mode, mDataOffset + inStartingByte, *ioNumBytes,
+ inBuffer, ioNumBytes);
+
+ FailIf(err != noErr, Bail, "couldn't write new data");
+
+ if (extendingTheAudioData) {
+ SInt64 nuEOF; // Get the total bytes of audio data
+ SInt64 nuByteTotal;
+
+ err = GetDataSource()->GetSize(nuEOF);
+ FailIf(err != noErr, Bail, "GetSize failed");
+
+ nuByteTotal = nuEOF - mDataOffset;
+ err = UpdateNumBytes(nuByteTotal);
+ }
+
+Bail:
+ return err;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::ReadPackets(
+ Boolean inUseCache,
+ UInt32 *outNumBytes,
+ AudioStreamPacketDescription *outPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ void *outBuffer)
+{
+ // This only works with CBR. To suppport VBR you must override.
+ OSStatus err = noErr;
+
+ FailWithAction(outBuffer == NULL, err = kAudio_ParamError, Bail, "NULL buffer");
+
+ FailWithAction((ioNumPackets == NULL) || (*ioNumPackets < 1), err = kAudio_ParamError, Bail, "invalid num packets parameter");
+
+ {
+ UInt32 byteCount = *ioNumPackets * mDataFormat.mBytesPerPacket;
+ SInt64 startingByte = inStartingPacket * mDataFormat.mBytesPerPacket;
+
+ err = ReadBytes (inUseCache, startingByte, &byteCount, outBuffer);
+ if ((err == noErr) || (err == kAudioFileEndOfFileError))
+ {
+ if (byteCount != (*ioNumPackets * mDataFormat.mBytesPerPacket))
+ {
+ *ioNumPackets = byteCount / mDataFormat.mBytesPerPacket;
+ byteCount = *ioNumPackets * mDataFormat.mBytesPerPacket;
+ }
+
+ if (outNumBytes)
+ *outNumBytes = byteCount;
+
+ if (err == kAudioFileEndOfFileError)
+ err = noErr;
+ }
+ }
+Bail:
+ return err;
+}
+
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::ReadPacketData(
+ Boolean inUseCache,
+ UInt32 *ioNumBytes,
+ AudioStreamPacketDescription *outPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ void *outBuffer)
+{
+ OSStatus err = noErr;
+ FailWithAction(ioNumPackets == NULL || *ioNumPackets < 1, err = kAudio_ParamError, Bail, "invalid ioNumPackets parameter");
+ FailWithAction(ioNumBytes == NULL || *ioNumBytes < 1, err = kAudio_ParamError, Bail, "invalid ioNumBytes parameter");
+ if (mDataFormat.mBytesPerPacket) {
+ // CBR
+ FailWithAction(outBuffer == NULL, err = kAudio_ParamError, Bail, "NULL buffer");
+ UInt32 maxPackets = *ioNumBytes / mDataFormat.mBytesPerPacket;
+ if (*ioNumPackets > maxPackets) *ioNumPackets = maxPackets;
+
+ if (outBuffer) {
+ UInt32 byteCount = *ioNumPackets * mDataFormat.mBytesPerPacket;
+ SInt64 startingByte = inStartingPacket * mDataFormat.mBytesPerPacket;
+ err = ReadBytes (inUseCache, startingByte, &byteCount, outBuffer);
+ if (err == noErr || err == kAudioFileEndOfFileError) {
+ if (byteCount != (*ioNumPackets * mDataFormat.mBytesPerPacket)) {
+ *ioNumPackets = byteCount / mDataFormat.mBytesPerPacket;
+ byteCount = *ioNumPackets * mDataFormat.mBytesPerPacket;
+ }
+ *ioNumBytes = byteCount;
+ }
+ }
+ } else {
+ FailWithAction(outPacketDescriptions == NULL, err = kAudio_ParamError, Bail, "invalid outPacketDescriptions parameter");
+ err = ReadPacketDataVBR(inUseCache, ioNumBytes, outPacketDescriptions, inStartingPacket, ioNumPackets, outBuffer);
+ }
+Bail:
+ return err;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::ReadPacketDataVBR(
+ Boolean inUseCache,
+ UInt32 *ioNumBytes,
+ AudioStreamPacketDescription *outPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ void *outBuffer)
+{
+ OSStatus err = ScanForPackets(inStartingPacket+1); // need to scan packets up to start
+ if (err && err != kAudioFileEndOfFileError)
+ return err;
+
+ SInt64 dataOffset = GetDataOffset();
+
+ CompressedPacketTable* packetTable = GetPacketTable();
+ if (!packetTable)
+ return kAudioFileInvalidFileError;
+
+ SInt64 packetTableSize = GetPacketTableSize();
+
+ if (inStartingPacket >= packetTableSize) {
+ *ioNumBytes = 0;
+ *ioNumPackets = 0;
+ return kAudioFileEndOfFileError;
+ }
+
+ if (inStartingPacket + *ioNumPackets <= packetTableSize) {
+ err = ReadPacketDataVBR_InTable(inUseCache, ioNumBytes, outPacketDescriptions, inStartingPacket, ioNumPackets, outBuffer);
+ } else {
+
+ AudioStreamPacketDescription firstPacket = (*packetTable)[inStartingPacket];
+ SInt64 firstPacketOffset = firstPacket.mStartOffset;
+ UInt32 bytesRead = *ioNumBytes;
+ SInt64 fileSize = 0;
+ GetDataSource()->GetSize(fileSize);
+ SInt64 remainingBytesInFile = fileSize - firstPacketOffset - dataOffset;
+ if (bytesRead > remainingBytesInFile)
+ bytesRead = (UInt32)remainingBytesInFile;
+
+ err = ReadBytes (inUseCache, firstPacketOffset, &bytesRead, outBuffer);
+ if (err && err != kAudioFileEndOfFileError) {
+ *ioNumBytes = 0;
+ *ioNumPackets = 0;
+ return err;
+ }
+
+ Buffer_DataSource bufSrc(bytesRead, outBuffer, dataOffset + firstPacketOffset);
+
+ OSStatus scanErr = ScanForPackets(kScanToEnd, &bufSrc, false);
+ if (scanErr && scanErr != kAudioFileEndOfFileError)
+ return scanErr;
+ packetTableSize = packetTable->size();
+
+ UInt32 numPacketsRead = 0;
+ UInt32 endOfData = 0;
+ SInt64 packetNumber = inStartingPacket;
+ for (; numPacketsRead < *ioNumPackets && packetNumber < packetTableSize; ++numPacketsRead, ++packetNumber) {
+ AudioStreamPacketDescription curPacket = (*packetTable)[numPacketsRead + inStartingPacket];
+ SInt64 curPacketOffset = curPacket.mStartOffset - firstPacketOffset;
+ SInt64 endOfPacket = curPacketOffset + curPacket.mDataByteSize;
+ if (endOfPacket > bytesRead) break;
+ endOfData = (UInt32)endOfPacket;
+ outPacketDescriptions[numPacketsRead] = curPacket;
+ outPacketDescriptions[numPacketsRead].mStartOffset = curPacketOffset;
+ }
+
+ *ioNumBytes = endOfData;
+ *ioNumPackets = numPacketsRead;
+ }
+ return err;
+}
+
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+OSStatus AudioFileObject::HowManyPacketsCanBeReadIntoBuffer(UInt32* ioNumBytes, SInt64 inStartingPacket, UInt32 *ioNumPackets)
+{
+ CompressedPacketTable* packetTable = GetPacketTable();
+ SInt64 packetTableSize = GetPacketTableSize();
+
+ if (inStartingPacket + *ioNumPackets > (SInt64)packetTableSize) {
+ *ioNumPackets = (UInt32)(packetTableSize - inStartingPacket);
+ }
+
+ AudioStreamPacketDescription firstPacket = (*packetTable)[inStartingPacket];
+
+ if (*ioNumBytes < firstPacket.mDataByteSize) {
+ *ioNumBytes = 0;
+ *ioNumPackets = 0;
+ return kAudio_ParamError;
+ }
+
+ SInt64 lastPacketIndex = inStartingPacket + *ioNumPackets - 1;
+ if (lastPacketIndex >= packetTableSize)
+ lastPacketIndex = packetTableSize - 1;
+
+ AudioStreamPacketDescription lastPacket = (*packetTable)[lastPacketIndex];
+
+ SInt64 readBytes = lastPacket.mStartOffset + lastPacket.mDataByteSize - firstPacket.mStartOffset;
+ if (readBytes <= *ioNumBytes) {
+ *ioNumBytes = (UInt32)readBytes;
+ return noErr;
+ }
+
+ SInt64 lowBound = inStartingPacket;
+ SInt64 highBound = lastPacketIndex + 1;
+ SInt64 okIndex = lowBound;
+ while (highBound >= lowBound) {
+ SInt64 tryBound = (lowBound + highBound) >> 1;
+ if (tryBound > lastPacketIndex)
+ break;
+ AudioStreamPacketDescription tryPacket = (*packetTable)[tryBound];
+
+ SInt64 readBytes = tryPacket.mStartOffset + tryPacket.mDataByteSize - firstPacket.mStartOffset;
+
+ if (readBytes > (SInt64)*ioNumBytes) {
+ highBound = tryBound - 1;
+ } else if (readBytes < (SInt64)*ioNumBytes) {
+ okIndex = tryBound;
+ lowBound = tryBound + 1;
+ } else {
+ okIndex = tryBound;
+ break;
+ }
+ }
+
+ SInt64 numPackets = okIndex - inStartingPacket + 1;
+ if (numPackets > *ioNumPackets) {
+ numPackets = *ioNumPackets;
+ okIndex = inStartingPacket + numPackets - 1;
+ }
+
+ AudioStreamPacketDescription packet = (*packetTable)[okIndex];
+ *ioNumBytes = (UInt32)(packet.mStartOffset + packet.mDataByteSize - firstPacket.mStartOffset);
+ *ioNumPackets = (UInt32)numPackets;
+ return noErr;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::ReadPacketDataVBR_InTable(
+ Boolean inUseCache,
+ UInt32 *ioNumBytes,
+ AudioStreamPacketDescription *outPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ void *outBuffer)
+{
+ CompressedPacketTable* packetTable = GetPacketTable();
+ if (!packetTable)
+ return kAudioFileInvalidFileError;
+
+ OSStatus err = HowManyPacketsCanBeReadIntoBuffer(ioNumBytes, inStartingPacket, ioNumPackets);
+ if (err) return err;
+
+ AudioStreamPacketDescription firstPacket = (*packetTable)[inStartingPacket];
+ SInt64 firstPacketOffset = firstPacket.mStartOffset;
+ UInt32 bytesRead = *ioNumBytes;
+
+ if (outBuffer) {
+ err = ReadBytes (inUseCache, firstPacketOffset, &bytesRead, outBuffer);
+ if (err && err != kAudioFileEndOfFileError) {
+ *ioNumBytes = 0;
+ *ioNumPackets = 0;
+ return err;
+ }
+ *ioNumBytes = bytesRead;
+ }
+
+ // fill out packet descriptions
+ if (outPacketDescriptions) {
+ for (UInt32 i = 0; i < *ioNumPackets; i++) {
+ AudioStreamPacketDescription curPacket = (*packetTable)[i + inStartingPacket];
+ outPacketDescriptions[i] = curPacket;
+ outPacketDescriptions[i].mStartOffset = curPacket.mStartOffset - firstPacketOffset;
+ }
+ }
+
+ return err;
+}
+
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::WritePackets(
+ Boolean inUseCache,
+ UInt32 inNumBytes,
+ const AudioStreamPacketDescription *inPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ const void *inBuffer)
+{
+ // This only works with CBR. To suppport VBR you must override.
+ OSStatus err = noErr;
+
+ FailWithAction(inStartingPacket > GetNumPackets(), err = kAudioFileInvalidPacketOffsetError, Bail, "write past end");
+ FailWithAction((ioNumPackets == NULL) || (inBuffer == NULL), err = kAudioFileUnspecifiedError, Bail, "invalid parameter");
+
+ {
+ UInt32 byteCount = *ioNumPackets * mDataFormat.mBytesPerPacket;
+ SInt64 startingByte = inStartingPacket * mDataFormat.mBytesPerPacket;
+
+ err = WriteBytes(inUseCache, startingByte, &byteCount, inBuffer);
+ FailIf (err != noErr, Bail, "Write Bytes Failed");
+
+ if (byteCount != (*ioNumPackets * mDataFormat.mBytesPerPacket))
+ *ioNumPackets = byteCount / mDataFormat.mBytesPerPacket;
+ }
+Bail:
+ return (err);
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::GetBitRate( UInt32 *outBitRate)
+{
+
+ if (!outBitRate) return kAudioFileUnspecifiedError;
+
+ UInt32 bytesPerPacket = GetDataFormat().mBytesPerPacket;
+ UInt32 framesPerPacket = GetDataFormat().mFramesPerPacket;
+ Float64 sampleRate = GetDataFormat().mSampleRate;
+ const Float64 bitsPerByte = 8.;
+
+ if (bytesPerPacket && framesPerPacket) {
+ *outBitRate = (UInt32)(bitsPerByte * (Float64)bytesPerPacket * sampleRate / (Float64)framesPerPacket);
+ } else {
+ SInt64 numPackets = GetNumPackets();
+ SInt64 numBytes = GetNumBytes();
+ SInt64 numFrames = 0;
+
+ if (framesPerPacket) {
+ numFrames = numPackets * framesPerPacket;
+ } else {
+ // count frames
+ CompressedPacketTable* packetTable = GetPacketTable();
+ if (packetTable) {
+ if (packetTable->size() != numPackets) {
+ return kAudioFileInvalidFileError;
+ }
+#if !TARGET_OS_WIN32
+ for (ssize_t i = 0; i < numPackets; i++)
+#else
+ for (int i = 0; i < numPackets; i++)
+#endif
+ {
+ numFrames += (*packetTable)[i].mVariableFramesInPacket;
+ }
+ } else {
+ return kAudioFileUnsupportedPropertyError;
+ }
+ }
+
+ if (numFrames == 0 || (sampleRate == 0.)) {
+ *outBitRate = 0;
+ return noErr;
+ }
+ Float64 duration = (Float64)numFrames / sampleRate;
+ *outBitRate = (UInt32)(bitsPerByte * (Float64)numBytes / duration);
+ }
+
+ return noErr;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::GetMagicCookieDataSize(
+ UInt32 *outDataSize,
+ UInt32 *isWritable)
+{
+ if (outDataSize) *outDataSize = 0;
+ if (isWritable) *isWritable = 0;
+ return kAudioFileUnsupportedPropertyError;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::GetMagicCookieData(
+ UInt32 *ioDataSize,
+ void *ioPropertyData)
+{
+ *ioDataSize = 0;
+ return kAudioFileUnsupportedPropertyError;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::SetMagicCookieData( UInt32 /*inDataSize*/,
+ const void *inPropertyData)
+{
+ return kAudioFileInvalidChunkError;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::GetMarkerListSize(
+ UInt32 *outDataSize,
+ UInt32 *isWritable)
+{
+ if (outDataSize) *outDataSize = 0;
+ if (isWritable) *isWritable = 0;
+ return kAudioFileUnsupportedPropertyError;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::GetMarkerList(
+ UInt32 *ioDataSize,
+ AudioFileMarkerList* /*ioPropertyData*/)
+{
+ *ioDataSize = 0;
+ return kAudioFileUnsupportedPropertyError;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::SetMarkerList( UInt32 /*inDataSize*/,
+ const AudioFileMarkerList* /*inPropertyData*/)
+{
+ return kAudioFileUnsupportedPropertyError;
+}
+
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::GetRegionListSize(
+ UInt32 *outDataSize,
+ UInt32 *isWritable)
+{
+ if (outDataSize) *outDataSize = 0;
+ if (isWritable) *isWritable = 0;
+ return kAudioFileUnsupportedPropertyError;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::GetRegionList(
+ UInt32 *ioDataSize,
+ AudioFileRegionList *ioPropertyData)
+{
+ *ioDataSize = 0;
+ return kAudioFileUnsupportedPropertyError;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::SetRegionList( UInt32 /*inDataSize*/,
+ const AudioFileRegionList* /*inPropertyData*/)
+{
+ return kAudioFileUnsupportedPropertyError;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::GetChannelLayoutSize(
+ UInt32 *outDataSize,
+ UInt32 *isWritable)
+{
+ if (outDataSize) *outDataSize = 0;
+ if (isWritable) *isWritable = 0;
+ return kAudioFileUnsupportedPropertyError;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::GetChannelLayout(
+ UInt32 *ioDataSize,
+ AudioChannelLayout* /*ioPropertyData*/)
+{
+ *ioDataSize = 0;
+ return kAudioFileUnsupportedPropertyError;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::SetChannelLayout( UInt32 /*inDataSize*/,
+ const AudioChannelLayout* /*inPropertyData*/)
+{
+ return kAudioFileUnsupportedPropertyError;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::GetInfoDictionarySize( UInt32 *outDataSize,
+ UInt32 *isWritable)
+{
+ if (outDataSize) *outDataSize = sizeof(CFDictionaryRef);
+ if (isWritable) *isWritable = 0;
+ return noErr;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::GetInfoDictionary(CACFDictionary *infoDict)
+{
+ Float64 fl;
+ if (GetEstimatedDuration(&fl) == noErr)
+ return AddDurationToInfoDictionary(infoDict, fl);
+
+ return kAudioFileUnsupportedPropertyError;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::SetInfoDictionary(CACFDictionary *infoDict)
+{
+ return kAudioFileUnsupportedPropertyError;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+OSStatus AudioFileObject::GetEstimatedDuration(Float64* duration)
+{
+ // calculate duration
+ AudioStreamBasicDescription ASBD = GetDataFormat();
+
+ *duration = (ASBD.mFramesPerPacket != 0) ? (GetNumPackets() * ASBD.mFramesPerPacket) / ASBD.mSampleRate : 0.0;
+
+ /*
+ For now, assume that any ASBD that has zero in the frames per packet field has been subclassed for this
+ method. i.e. A CAF file has a frame count in one of it's chunks.
+
+ MP3 has been subclassed because it guesstimates a duration so the entire file does not
+ need to be parsed in order to calculate the total frames.
+ */
+
+ return noErr;
+
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::GetPropertyInfo (
+ AudioFilePropertyID inPropertyID,
+ UInt32 *outDataSize,
+ UInt32 *isWritable)
+{
+ OSStatus err = noErr;
+ UInt32 writable = 0;
+
+ switch (inPropertyID)
+ {
+ case kAudioFilePropertyDeferSizeUpdates :
+ if (outDataSize) *outDataSize = sizeof(UInt32);
+ writable = 1;
+ break;
+
+ case kAudioFilePropertyFileFormat:
+ if (outDataSize) *outDataSize = sizeof(UInt32);
+ writable = 0;
+ break;
+
+ case kAudioFilePropertyDataFormat:
+ if (outDataSize) *outDataSize = sizeof(AudioStreamBasicDescription);
+ writable = 1;
+ break;
+
+ case kAudioFilePropertyFormatList:
+ err = GetFormatListInfo(*outDataSize, writable);
+ break;
+
+ case kAudioFilePropertyPacketSizeUpperBound:
+ case kAudioFilePropertyIsOptimized:
+ case kAudioFilePropertyMaximumPacketSize:
+ if (outDataSize) *outDataSize = sizeof(UInt32);
+ writable = 0;
+ break;
+
+ case kAudioFilePropertyAudioDataByteCount:
+ case kAudioFilePropertyAudioDataPacketCount:
+ writable = 1;
+ if (outDataSize) *outDataSize = sizeof(SInt64);
+ break;
+
+ case kAudioFilePropertyDataOffset:
+ writable = 0;
+ if (outDataSize) *outDataSize = sizeof(SInt64);
+ break;
+
+ case kAudioFilePropertyBitRate:
+ writable = 0;
+ if (outDataSize) *outDataSize = sizeof(UInt32);
+ break;
+
+ case kAudioFilePropertyMagicCookieData:
+ err = GetMagicCookieDataSize(outDataSize, &writable);
+ break;
+
+ case kAudioFilePropertyMarkerList :
+ err = GetMarkerListSize(outDataSize, &writable);
+ break;
+
+ case kAudioFilePropertyRegionList :
+ err = GetRegionListSize(outDataSize, &writable);
+ break;
+
+ case kAudioFilePropertyChannelLayout :
+ err = GetChannelLayoutSize(outDataSize, &writable);
+ break;
+
+ case kAudioFilePropertyPacketToFrame :
+ case kAudioFilePropertyFrameToPacket :
+ if (outDataSize) *outDataSize = sizeof(AudioFramePacketTranslation);
+ writable = 0;
+ break;
+
+ case kAudioFilePropertyPacketToByte :
+ case kAudioFilePropertyByteToPacket :
+ if (outDataSize) *outDataSize = sizeof(AudioBytePacketTranslation);
+ writable = 0;
+ break;
+
+ case kAudioFilePropertyInfoDictionary :
+ err = GetInfoDictionarySize(outDataSize, &writable);
+ break;
+
+ case kTEMPAudioFilePropertySoundCheckDictionary :
+ err = GetSoundCheckDictionarySize(outDataSize, &writable);
+ break;
+
+ case kTEMPAudioFilePropertyGenerateLoudnessInfo :
+ err = GetLoudnessInfoSize(outDataSize, &writable);
+ writable = 0;
+ break;
+
+ case kTEMPAudioFilePropertyLoudnessInfo :
+ err = GetLoudnessInfoSize(outDataSize, &writable);
+ break;
+
+ case kAudioFilePropertyEstimatedDuration :
+ if (outDataSize) *outDataSize = sizeof(Float64);
+ writable = 0;
+ break;
+
+ case 'LYRC':
+ if (outDataSize) *outDataSize = sizeof(CFStringRef);
+ if (isWritable) *isWritable = 0;
+ break;
+
+ case 'eof?':
+ if (outDataSize) *outDataSize = sizeof(UInt32);
+ if (isWritable) *isWritable = 0;
+ break;
+
+ case 'sbtd' /*kAudioFilePropertySourceBitDepth*/ :
+ if (outDataSize) *outDataSize = sizeof(SInt32);
+ if (isWritable) *isWritable = CanWrite();
+ break;
+
+ default:
+ writable = 0;
+ err = kAudioFileUnsupportedPropertyError;
+ break;
+ }
+
+ if (isWritable)
+ *isWritable = writable;
+ return (err);
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::GetProperty(
+ AudioFilePropertyID inPropertyID,
+ UInt32 *ioDataSize,
+ void *ioPropertyData)
+{
+ OSStatus err = noErr;
+ UInt32 neededSize;
+ UInt32 writable;
+
+ switch (inPropertyID)
+ {
+ case kAudioFilePropertyFileFormat:
+ FailWithAction(*ioDataSize != sizeof(UInt32),
+ err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+
+ *(UInt32 *) ioPropertyData = GetFileType();
+ break;
+
+ case kAudioFilePropertyFormatList:
+ err = GetFormatList(*ioDataSize, (AudioFormatListItem*)ioPropertyData);
+ break;
+
+ case kAudioFilePropertyDataFormat:
+ FailWithAction(*ioDataSize != sizeof(AudioStreamBasicDescription),
+ err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+
+ memcpy(ioPropertyData, &mDataFormat, sizeof(AudioStreamBasicDescription));
+ break;
+ case kAudioFilePropertyDataOffset:
+ FailWithAction(*ioDataSize != sizeof(SInt64),
+ err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+ *(SInt64 *) ioPropertyData = mDataOffset;
+ break;
+ case kAudioFilePropertyIsOptimized:
+ FailWithAction(*ioDataSize != sizeof(UInt32),
+ err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+ *(UInt32 *) ioPropertyData = mIsOptimized;
+ break;
+
+ case kAudioFilePropertyAudioDataByteCount:
+ FailWithAction(*ioDataSize != sizeof(SInt64),
+ err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+ *(SInt64 *)ioPropertyData = GetNumBytes();
+ break;
+
+ case kAudioFilePropertyAudioDataPacketCount:
+ FailWithAction(*ioDataSize != sizeof(SInt64),
+ err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+ *(SInt64 *)ioPropertyData = GetNumPackets();
+ break;
+
+ case kAudioFilePropertyPacketSizeUpperBound:
+ FailWithAction(*ioDataSize != sizeof(UInt32),
+ err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+ *(UInt32 *)ioPropertyData = GetPacketSizeUpperBound();
+ break;
+
+ case kAudioFilePropertyMaximumPacketSize:
+ FailWithAction(*ioDataSize != sizeof(UInt32),
+ err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+ *(UInt32 *)ioPropertyData = FindMaximumPacketSize();
+ break;
+
+
+ case kAudioFilePropertyBitRate:
+ FailWithAction(*ioDataSize != sizeof(UInt32),
+ err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+ err = GetBitRate((UInt32*)ioPropertyData);
+ break;
+
+ case kAudioFilePropertyMagicCookieData:
+
+ err = GetMagicCookieData(ioDataSize, ioPropertyData);
+ break;
+
+ case kAudioFilePropertyMarkerList :
+ err = GetMarkerList(ioDataSize, static_cast(ioPropertyData));
+ break;
+
+ case kAudioFilePropertyRegionList :
+ memset(ioPropertyData, 0, *ioDataSize);
+ err = GetRegionList(ioDataSize, static_cast(ioPropertyData));
+ break;
+
+ case kAudioFilePropertyChannelLayout :
+ err = GetChannelLayoutSize(&neededSize, &writable);
+ FailIf(err, Bail, "GetChannelLayoutSize failed");
+ FailWithAction(*ioDataSize != neededSize, err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+
+ err = GetChannelLayout(ioDataSize, static_cast(ioPropertyData));
+ break;
+
+ case kAudioFilePropertyDeferSizeUpdates :
+ FailWithAction(*ioDataSize != sizeof(UInt32),
+ err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+
+ *(UInt32 *) ioPropertyData = DeferSizeUpdates();
+ break;
+
+ case kAudioFilePropertyPacketToFrame :
+ {
+ FailWithAction(*ioDataSize != sizeof(AudioFramePacketTranslation),
+ err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+
+ AudioFramePacketTranslation* afpt = (AudioFramePacketTranslation*)ioPropertyData;
+ err = PacketToFrame(afpt->mPacket, afpt->mFrame);
+ break;
+ }
+ case kAudioFilePropertyFrameToPacket :
+ {
+ FailWithAction(*ioDataSize != sizeof(AudioFramePacketTranslation),
+ err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+
+ AudioFramePacketTranslation* afpt = (AudioFramePacketTranslation*)ioPropertyData;
+ err = FrameToPacket(afpt->mFrame, afpt->mPacket, afpt->mFrameOffsetInPacket);
+ break;
+ }
+
+ case kAudioFilePropertyPacketToByte :
+ {
+ FailWithAction(*ioDataSize != sizeof(AudioBytePacketTranslation),
+ err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+
+ AudioBytePacketTranslation* abpt = (AudioBytePacketTranslation*)ioPropertyData;
+ err = PacketToByte(abpt);
+ break;
+ }
+ case kAudioFilePropertyByteToPacket :
+ {
+ FailWithAction(*ioDataSize != sizeof(AudioBytePacketTranslation),
+ err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+
+ AudioBytePacketTranslation* abpt = (AudioBytePacketTranslation*)ioPropertyData;
+ err = ByteToPacket(abpt);
+ break;
+ }
+
+ case kAudioFilePropertyInfoDictionary :
+ {
+ FailWithAction(*ioDataSize != sizeof(CFDictionaryRef),
+ err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+
+ CACFDictionary afInfoDictionary(true);
+
+ err = GetInfoDictionary(&afInfoDictionary);
+
+ if (!err)
+ {
+ *(CFMutableDictionaryRef *)ioPropertyData = afInfoDictionary.CopyCFMutableDictionary();
+ }
+ break;
+ }
+
+ case kTEMPAudioFilePropertySoundCheckDictionary :
+ {
+ FailWithAction(*ioDataSize != sizeof(CFDictionaryRef),
+ err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+
+ CACFDictionary afInfoDictionary(true);
+
+ err = GetSoundCheckDictionary(&afInfoDictionary);
+ if (err) {
+ OSStatus err2 = GetSoundCheckDictionaryFromLoudnessInfo(&afInfoDictionary);
+ if (err2 == noErr) err = noErr; // else report original error from GetSoundCheckDictionary.
+ }
+
+ if (!err)
+ {
+ *(CFMutableDictionaryRef *)ioPropertyData = afInfoDictionary.CopyCFMutableDictionary();
+ }
+ break;
+ }
+
+ case kTEMPAudioFilePropertyLoudnessInfo :
+ {
+ FailWithAction(*ioDataSize != sizeof(CFDictionaryRef),
+ err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+
+ CACFDictionary afInfoDictionary(true);
+
+ err = GetLoudnessInfo(&afInfoDictionary);
+ if (err) {
+ OSStatus err2 = GetLoudnessInfoFromSoundCheckDictionary(&afInfoDictionary);
+ if (err2 == noErr) err = noErr; // else report original error from GetLoudnessInfo.
+ }
+
+ if (!err)
+ {
+ *(CFMutableDictionaryRef *)ioPropertyData = afInfoDictionary.CopyCFMutableDictionary();
+ }
+ break;
+ }
+
+ case kTEMPAudioFilePropertyGenerateLoudnessInfo :
+ {
+ FailWithAction(*ioDataSize != sizeof(CFDictionaryRef),
+ err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+
+ CACFDictionary afInfoDictionary(true);
+
+ err = GenerateLoudnessInfo(&afInfoDictionary);
+
+ if (!err)
+ {
+ *(CFMutableDictionaryRef *)ioPropertyData = afInfoDictionary.CopyCFMutableDictionary();
+ }
+ break;
+ }
+
+ case kAudioFilePropertyEstimatedDuration :
+ {
+ FailWithAction(*ioDataSize != sizeof(Float64),
+ err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+
+ err = GetEstimatedDuration((Float64*)ioPropertyData);
+ break;
+ }
+
+ case 'LYRC' :
+ if (*ioDataSize < sizeof(CFStringRef))
+ return kAudioFileBadPropertySizeError;
+
+ *ioDataSize = sizeof(CFStringRef);
+ err = GetLyrics((CFStringRef*) ioPropertyData);
+ break;
+
+ case 'eof?' :
+ {
+ if (*ioDataSize != sizeof(UInt32))
+ return kAudioFileBadPropertySizeError;
+
+ SInt64 pos;
+ err = GetDataSource()->GetPos(pos);
+ if (err) break;
+
+ SInt64 endOfData = GetDataOffset() + GetNumBytes();
+ *(UInt32*)ioPropertyData = pos >= endOfData;
+
+ break;
+ }
+ case 'sbtd' /*kAudioFilePropertySourceBitDepth*/ :
+ {
+ if (*ioDataSize != sizeof(SInt32))
+ return kAudioFileBadPropertySizeError;
+
+ SInt32 outValue = 0;
+ err = GetSourceBitDepth(outValue);
+ if ((err || outValue == 0) && GetDataFormat().mFormatID == kAudioFormatLinearPCM) {
+ // if there was no stored source bit depth, and this file is LPCM, then report this file's bit depth.
+ err = noErr;
+ outValue = GetDataFormat().mBitsPerChannel;
+ if (GetDataFormat().mFormatFlags & kAudioFormatFlagIsFloat)
+ outValue = -outValue;
+ } else if (err)
+ break;
+
+ *(SInt32 *) ioPropertyData = outValue;
+
+ break;
+ }
+ default:
+ err = kAudioFileUnsupportedPropertyError;
+ break;
+ }
+
+Bail:
+ return err;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::SetProperty(
+ AudioFilePropertyID inPropertyID,
+ UInt32 inDataSize,
+ const void *inPropertyData)
+{
+ OSStatus err = noErr;
+
+ switch (inPropertyID)
+ {
+ case kAudioFilePropertyDataFormat:
+ FailWithAction(inDataSize != sizeof(AudioStreamBasicDescription),
+ err = kAudioFileBadPropertySizeError, Bail, "Incorrect data size");
+ err = UpdateDataFormat((AudioStreamBasicDescription *) inPropertyData);
+ break;
+ case kAudioFilePropertyFormatList:
+ err = SetFormatList(inDataSize, (AudioFormatListItem*)inPropertyData);
+ break;
+
+ case kAudioFilePropertyAudioDataByteCount: {
+ FailWithAction(inDataSize != sizeof(SInt64), err = kAudioFileBadPropertySizeError, Bail, "Incorrect data size");
+ SInt64 numBytes = *(SInt64 *) inPropertyData;
+ if (numBytes > GetNumBytes()) {
+ // can't use this to increase data size.
+ return kAudioFileOperationNotSupportedError;
+ }
+ UInt32 saveDefer = DeferSizeUpdates();
+ SetDeferSizeUpdates(0); // force an update.
+ err = UpdateNumBytes(numBytes);
+ SetDeferSizeUpdates(saveDefer);
+ } break;
+
+ case kAudioFilePropertyAudioDataPacketCount: {
+ SInt64 numPackets = *(SInt64 *) inPropertyData;
+ if (numPackets > GetNumPackets()) {
+ // can't use this to increase data size.
+ return kAudioFileOperationNotSupportedError;
+ }
+ err = UpdateNumPackets(numPackets);
+ } break;
+
+ case kAudioFilePropertyMagicCookieData:
+ err = SetMagicCookieData(inDataSize, inPropertyData);
+ break;
+
+
+ case kAudioFilePropertyMarkerList :
+ err = SetMarkerList(inDataSize, static_cast(inPropertyData));
+ break;
+
+ case kAudioFilePropertyRegionList :
+ err = SetRegionList(inDataSize, static_cast(inPropertyData));
+ break;
+
+ case kAudioFilePropertyChannelLayout :
+ err = SetChannelLayout(inDataSize, static_cast(inPropertyData));
+ break;
+
+ case kAudioFilePropertyDeferSizeUpdates :
+ FailWithAction(inDataSize != sizeof(UInt32),
+ err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+ SetDeferSizeUpdates(*(UInt32 *) inPropertyData);
+ break;
+
+ case kAudioFilePropertyInfoDictionary :
+ {
+ FailWithAction(inDataSize != sizeof(CFDictionaryRef),
+ err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+
+ // pass the SetInfoDictionary a CACFDictionary object made with the provided CFDictionaryRef
+ // Let the caller release their own CFObject so pass false for th erelease parameter
+ CACFDictionary afInfoDictionary(*(CFDictionaryRef *)inPropertyData, false);
+ err = SetInfoDictionary(&afInfoDictionary);
+
+ break;
+ }
+
+ case kTEMPAudioFilePropertySoundCheckDictionary :
+ {
+ FailWithAction(inDataSize != sizeof(CFDictionaryRef),
+ err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+
+ // pass the SetInfoDictionary a CACFDictionary object made with the provided CFDictionaryRef
+ // Let the caller release their own CFObject so pass false for the release parameter
+ CACFDictionary afInfoDictionary(*(CFDictionaryRef *)inPropertyData, false);
+ err = SetSoundCheckDictionary(&afInfoDictionary);
+
+ break;
+ }
+
+ case kTEMPAudioFilePropertyLoudnessInfo :
+ {
+ FailWithAction(inDataSize != sizeof(CFDictionaryRef),
+ err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+
+ // pass the SetInfoDictionary a CACFDictionary object made with the provided CFDictionaryRef
+ // Let the caller release their own CFObject so pass false for the release parameter
+ CACFDictionary afInfoDictionary(*(CFDictionaryRef *)inPropertyData, false);
+ err = SetLoudnessInfo(&afInfoDictionary);
+
+ break;
+ }
+
+ case 'sbtd' /*kAudioFilePropertySourceBitDepth*/ :
+ {
+ FailWithAction(inDataSize != sizeof(SInt32),
+ err = kAudioFileBadPropertySizeError, Bail, "inDataSize is wrong");
+
+ SInt32 inValue = *(SInt32 *)inPropertyData;
+ err = SetSourceBitDepth(inValue);
+
+ break;
+ }
+
+ default:
+ err = kAudioFileUnsupportedPropertyError;
+ break;
+ }
+
+Bail:
+ return err;
+}
+
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::SetDataFormat(const AudioStreamBasicDescription* inStreamFormat)
+{
+ OSStatus err = noErr;
+
+ if (!IsDataFormatValid(inStreamFormat))
+ return kAudioFileUnsupportedDataFormatError;
+
+ if (!IsDataFormatSupported(inStreamFormat))
+ return kAudioFileUnsupportedDataFormatError;
+
+ UInt32 prevBytesPerPacket = mDataFormat.mBytesPerPacket;
+
+ mDataFormat = *inStreamFormat;
+
+ // if CBR and bytes per packet changes, we need to change the number of packets we think we have.
+ if (mDataFormat.mBytesPerPacket && mDataFormat.mBytesPerPacket != prevBytesPerPacket)
+ {
+ SInt64 numPackets = GetNumBytes() / mDataFormat.mBytesPerPacket;
+ SetNumPackets(numPackets);
+ SetMaximumPacketSize(mDataFormat.mBytesPerPacket);
+
+ if (!mFirstSetFormat)
+ SizeChanged();
+ }
+
+ mFirstSetFormat = false;
+
+ return err;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::GetFormatListInfo( UInt32 &outDataSize,
+ UInt32 &outWritable)
+{
+ // default implementation is to just return the data format
+ outDataSize = sizeof(AudioFormatListItem);
+ outWritable = false;
+ return noErr;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::GetFormatList( UInt32 &ioDataSize,
+ AudioFormatListItem *ioPropertyData)
+{
+ // default implementation is to just return the data format
+ if (ioDataSize < sizeof(AudioFormatListItem))
+ return kAudioFileBadPropertySizeError;
+
+ AudioFormatListItem afli;
+ afli.mASBD = mDataFormat;
+ AudioChannelLayoutTag layoutTag = /*kAudioChannelLayoutTag_Unknown*/ 0xFFFF0000 | mDataFormat.mChannelsPerFrame;
+ UInt32 layoutSize, isWritable;
+ OSStatus err = GetChannelLayoutSize(&layoutSize, &isWritable);
+ if (err == noErr)
+ {
+ CAAutoFree layout;
+ layout.allocBytes(layoutSize);
+ err = GetChannelLayout(&layoutSize, layout());
+ if (err == noErr) {
+ layoutTag = layout->mChannelLayoutTag;
+ }
+ }
+ afli.mChannelLayoutTag = layoutTag;
+
+ memcpy(ioPropertyData, &afli, sizeof(AudioFormatListItem));
+
+ ioDataSize = sizeof(AudioFormatListItem);
+ return noErr;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::SetFormatList( UInt32 inDataSize,
+ const AudioFormatListItem *inPropertyData)
+{
+ return kAudioFileOperationNotSupportedError;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+OSStatus AudioFileObject::UpdateDataFormat(const AudioStreamBasicDescription* inStreamFormat)
+{
+ return SetDataFormat(inStreamFormat);
+}
+
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Boolean AudioFileObject::IsDataFormatValid(AudioStreamBasicDescription const* inDesc)
+{
+ if (inDesc->mSampleRate < 0.)
+ return false;
+
+ if (inDesc->mSampleRate > 3e6)
+ return false;
+
+ if (inDesc->mChannelsPerFrame < 1 || inDesc->mChannelsPerFrame > 0x000FFFFF)
+ return false;
+
+ if (inDesc->mFormatID == kAudioFormatLinearPCM)
+ {
+ if (inDesc->mBitsPerChannel < 1 || inDesc->mBitsPerChannel > 64)
+ return false;
+
+ if (inDesc->mFramesPerPacket != 1)
+ return false;
+
+ if (inDesc->mBytesPerPacket == 0)
+ return false;
+
+ if (inDesc->mBytesPerFrame != inDesc->mBytesPerPacket)
+ return false;
+
+ // [3605260] we assume here that a packet is an integer number of frames.
+ UInt32 minimumBytesPerPacket = (inDesc->mBitsPerChannel * inDesc->mChannelsPerFrame + 7) / 8;
+ if (inDesc->mBytesPerPacket < minimumBytesPerPacket)
+ return false;
+ }
+ return true;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+void AudioFileObject::SetDataSource(DataSource* inDataSource)
+{
+ if (mDataSource != inDataSource) {
+ delete mDataSource;
+ mDataSource = inDataSource;
+ }
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+void AudioFileObject::SetURL (CFURLRef inURL)
+{
+ if (mFileRef == inURL) return;
+ if (inURL) CFRetain (inURL);
+ if (mFileRef) CFRelease(mFileRef);
+ mFileRef = inURL;
+}
+
+OSStatus AudioFileObject::OpenFile(SInt8 inPermissions, int inFD)
+{
+ OSStatus err = noErr;
+
+ SetDataSource(new Cached_DataSource(new UnixFile_DataSource(inFD, inPermissions, true)));
+
+ mFileD = inFD;
+ SetPermissions (inPermissions);
+
+ return err;
+}
+
+OSStatus AudioFileObject::CreateDataFile (CFURLRef inFileRef, int &outFileD)
+{
+ UInt8 fPath[FILENAME_MAX];
+ if (!CFURLGetFileSystemRepresentation (inFileRef, true, fPath, FILENAME_MAX))
+ return kAudio_FileNotFoundError;
+
+ struct stat stbuf;
+ if (stat ((const char*)fPath, &stbuf) == 0)
+ return kAudioFilePermissionsError;
+
+#if TARGET_OS_WIN32
+ int filePerms = S_IREAD | S_IWRITE;
+ int flags = O_CREAT | O_EXCL | O_RDWR | O_BINARY;
+#else
+ mode_t filePerms = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
+ int flags = O_CREAT | O_EXCL | O_RDWR;
+#endif
+ outFileD = open((const char*)fPath, flags, filePerms);
+ if (outFileD < 0)
+ return AudioFileTranslateErrno(errno);
+
+ return noErr;
+}
+
+OSStatus AudioFileObject::AddDurationToInfoDictionary(CACFDictionary *infoDict, Float64 &inDuration)
+{
+#if !TARGET_OS_WIN32
+ CFLocaleRef currentLocale = CFLocaleGetSystem();
+ CFNumberFormatterRef numberFormatter = NULL;
+ numberFormatter = CFNumberFormatterCreate(kCFAllocatorDefault, currentLocale, kCFNumberFormatterDecimalStyle);
+ CFStringRef cfStr = CFNumberFormatterCreateStringWithValue( kCFAllocatorDefault, numberFormatter, kCFNumberFloat64Type, &inDuration);
+ if (cfStr)
+ {
+ if (CFStringGetLength(cfStr) != 0)
+ infoDict->AddString(CFSTR(kAFInfoDictionary_ApproximateDurationInSeconds), cfStr);
+ CFRelease(cfStr);
+ }
+ CFRelease(numberFormatter);
+#endif
+ return noErr;
+}
+
+OSStatus AudioFileObject::SizeChanged()
+{
+ OSStatus err = noErr;
+ if (mPermissions & kAudioFileWritePermission)
+ {
+ if (DeferSizeUpdates())
+ SetNeedsSizeUpdate(true);
+ else
+ err = UpdateSize();
+ }
+ return err;
+}
+
+OSStatus AudioFileObject::UpdateSizeIfNeeded()
+{
+ if (GetNeedsSizeUpdate())
+ {
+ OSStatus err = UpdateSize();
+ if (err) return err;
+ SetNeedsSizeUpdate(false);
+ }
+ return noErr;
+}
+
+OSStatus AudioFileObject::CountUserData( UInt32 /*inUserDataID*/,
+ UInt32* /*outNumberItems*/)
+{
+ return kAudioFileOperationNotSupportedError;
+}
+
+OSStatus AudioFileObject::GetUserDataSize( UInt32 /*inUserDataID*/,
+ UInt32 /*inIndex*/,
+ UInt32* /*outDataSize*/)
+{
+ return kAudioFileOperationNotSupportedError;
+}
+
+OSStatus AudioFileObject::GetUserData( UInt32 /*inUserDataID*/,
+ UInt32 /*inIndex*/,
+ UInt32* /*ioDataSize*/,
+ void* /*ioUserData*/)
+{
+ return kAudioFileOperationNotSupportedError;
+}
+
+OSStatus AudioFileObject::SetUserData( UInt32 /*inUserDataID*/,
+ UInt32 /*inIndex*/,
+ UInt32 /*inDataSize*/,
+ const void* /*inUserData*/)
+{
+ return kAudioFileOperationNotSupportedError;
+}
+
+OSStatus AudioFileObject::RemoveUserData( UInt32 /*inUserDataID*/,
+ UInt32 /*inIndex*/)
+{
+ return kAudioFileOperationNotSupportedError;
+}
+
+OSStatus AudioFileObject::MoveData(SInt64 fromPos, SInt64 toPos, SInt64 size)
+{
+ if (fromPos == toPos)
+ return noErr;
+
+ OSStatus err = noErr;
+ CAAutoFree audioData(kCopySoundDataBufferSize, true);
+
+ SInt64 bytesRemaining = size;
+ if (fromPos < toPos) {
+ while (bytesRemaining > 0)
+ {
+ // read from old file
+ UInt32 byteCount;
+ SInt64 count = (bytesRemaining < kCopySoundDataBufferSize) ? bytesRemaining : kCopySoundDataBufferSize;
+ err = GetDataSource()->ReadBytes(SEEK_SET, fromPos+(bytesRemaining-count), (UInt32)count, audioData(), &byteCount);
+ FailIf (err != noErr, Bail, "MoveData ReadBytes failed");
+
+ err = GetDataSource()->WriteBytes(SEEK_SET, toPos+(bytesRemaining-count), (UInt32)count, audioData(), &byteCount);
+ FailIf (err != noErr, Bail, "WriteBytes failed");
+
+ bytesRemaining -= count;
+ }
+ } else {
+ while (bytesRemaining > 0)
+ {
+ // read from old file
+ UInt32 byteCount;
+ SInt64 count = (bytesRemaining < kCopySoundDataBufferSize) ? bytesRemaining : kCopySoundDataBufferSize;
+ err = GetDataSource()->ReadBytes(SEEK_SET, fromPos+(size - bytesRemaining), (UInt32)count, audioData(), &byteCount);
+ FailIf (err != noErr, Bail, "MoveData ReadBytes failed");
+
+ err = GetDataSource()->WriteBytes(SEEK_SET, toPos+(size - bytesRemaining), (UInt32)count, audioData(), &byteCount);
+ FailIf (err != noErr, Bail, "WriteBytes failed");
+
+ bytesRemaining -= count;
+ }
+ }
+
+Bail:
+ return err;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/AudioFileObject.h b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/AudioFileObject.h
new file mode 100644
index 000000000..6d7c86897
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/AudioFileObject.h
@@ -0,0 +1,667 @@
+/*
+ File: AudioFileObject.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 _AudioFileObject_H_
+#define _AudioFileObject_H_
+
+#include
+
+#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
+ #include
+ #include
+ #include
+#else
+ #include "CoreAudioTypes.h"
+ #include "AudioFile.h"
+ #include "AudioFormat.h"
+#endif
+
+#include "CompressedPacketTable.h"
+#include "CACFDictionary.h"
+#include "DataSource.h"
+#include
+#include
+
+#if TARGET_OS_WIN32
+#include
+#endif
+
+/*
+ These are structs defined in 10.5. They are included here for compatibility with sources
+*/
+#if COREAUDIOTYPES_VERSION < 1050
+
+struct AudioFormatListItem
+{
+ AudioStreamBasicDescription mASBD;
+ AudioChannelLayoutTag mChannelLayoutTag;
+};
+typedef struct AudioFormatListItem AudioFormatListItem;
+
+struct AudioFormatInfo
+{
+ AudioStreamBasicDescription mASBD;
+ const void* mMagicCookie;
+ UInt32 mMagicCookieSize;
+};
+typedef struct AudioFormatInfo AudioFormatInfo;
+
+enum {
+
+ kAudioFormatProperty_FormatList = 'flst',
+ // Returns a list of AudioFormatListItem structs describing the audio formats contained within the compressed bit stream
+ // as described by the magic cookie.
+ // The specifier is an AudioFormatInfo struct. At a minimum formatID member of the ASBD struct must filled in. Other fields
+ // may be filled in.
+
+ kAudioFormatProperty_OutputFormatList = 'ofls',
+ // Returns a list of AudioFormatListItem structs describing the audio formats which may be obtained by decoding the format
+ // described by the specifier.
+ // The specifier is an AudioFormatInfo struct. At a minimum formatID member of the ASBD struct must filled in. Other fields
+ // may be filled in. If there is no magic cookie, then the number of channels and sample rate should be filled in.
+
+};
+
+enum {
+ kAudioFilePropertyPacketSizeUpperBound = 'pkub',
+ kAudioFilePropertyFormatList = 'flst',
+ kAudioFilePropertyEstimatedDuration = 'edur',
+ kAudioFilePropertyBitRate = 'brat'
+};
+
+enum {
+ kAudioFileCreateURLSelect = 0x0019,
+ kAudioFileOpenURLSelect = 0x001A,
+ kAudioFileFileDataIsThisFormatSelect = 0x001B
+};
+#endif
+
+enum {
+ kTEMPAudioFilePropertySoundCheckDictionary = 'scdc',
+ kTEMPAudioFilePropertyLoudnessInfo = 'loud',
+ kTEMPAudioFilePropertyGenerateLoudnessInfo = 'glou'
+};
+
+const UInt32 kCopySoundDataBufferSize = 1024 * 1024;
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+// some files encode these as upper case
+enum {
+ kUpperCase_IMACompression = 'IMA4', /*IMA 4:1*/
+ kUpperCase_ULawCompression = 'ULAW', /*�Law 2:1*/
+ kUpperCase_ALawCompression = 'ALAW', /*aLaw 2:1*/
+
+ kUpperCase_Float32 = 'FL32',
+ kUpperCase_Float64 = 'FL64'
+};
+
+enum
+{
+ // in what header is this defined? what is it?
+ kGSM = 'agsm',
+ kUpperCase_GSM = 'GSM '
+};
+
+#define kPackedBESInt (kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsBigEndian | kLinearPCMFormatFlagIsPacked)
+#define kPackedLESInt (kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked)
+#define kPackedBEFloat (kLinearPCMFormatFlagIsFloat | kLinearPCMFormatFlagIsBigEndian | kLinearPCMFormatFlagIsPacked)
+#define kPackedLEFloat (kLinearPCMFormatFlagIsFloat | kLinearPCMFormatFlagIsPacked)
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+inline int TransformPerm_FS_O (SInt8 inPerm)
+{
+ switch (inPerm) {
+ case kAudioFileReadPermission: return O_RDONLY;
+ case kAudioFileWritePermission: return O_WRONLY;
+ case kAudioFileReadWritePermission: return O_RDWR;
+ }
+ return O_RDONLY;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#pragma mark "File Error Handling"
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+#include
+#include
+
+inline OSErr AudioFileTranslateErrno(int err)
+{
+ switch (err) {
+#if !TARGET_OS_WIN32
+ case ENFILE:
+#endif
+ case EMFILE:
+ return -42 /* kAudio_TooManyFilesOpenError */;
+#if !TARGET_OS_WIN32
+ case EPERM:
+ case EROFS:
+#endif
+ case EACCES:
+ case EEXIST:
+ return -54 /* kAudio_FilePermissionError */;
+#if !TARGET_OS_WIN32
+ case EMLINK:
+ return (OSErr)'!pth' /* kAudio_BadFilePathError */;
+ case ENOTDIR:
+ case ELOOP:
+#endif
+ case ENOENT:
+ default:
+ return (OSErr)kAudioFileUnspecifiedError;
+ }
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+class AudioFileObject
+{
+protected:
+
+private:
+ SInt64 mNumBytes; // total bytes of audio data in the audio file
+ SInt64 mNumPackets; // total frames of audio data in the audio file
+ AudioStreamBasicDescription mDataFormat; // format of the audio data
+ SInt64 mDataOffset; // position if the file where audio data begins
+ UInt32 mIsOptimized; // 1 if there is nothing in the file following the audio data, 0 if there is
+ UInt32 mFileType; // file type of the audio file (i.e. AIFF, WAVE, etc.)
+ CFURLRef mFileRef; // URL of the file passed to AudioFileOpen or AudioFileCreate
+ int mFileD; // Ref num of the file after opening within Audio File
+ SInt8 mPermissions; // file permissions indicated by the caller, passed by AudioFileOpen or set with SetProperty function
+ Boolean mIsInitialized; // has the AudioFileObject for this file been intialized?
+ DataSource *mDataSource;
+ UInt32 mMaximumPacketSize;
+ CompressedPacketTable *mPacketTable;
+ UInt32 mDeferSizeUpdates;
+ Boolean mNeedsSizeUpdate;
+ Boolean mFirstSetFormat;
+ Boolean mAlignDataWithFillerChunks;
+
+public:
+
+ AudioFileObject (UInt32 inFileType)
+ : mNumBytes(0),
+ mNumPackets(0),
+ mDataOffset(0),
+ mIsOptimized(1),
+ mFileType(inFileType),
+ mFileRef(NULL),
+ mFileD(-1),
+ mPermissions(0),
+ mIsInitialized (false),
+ mDataSource(0),
+ mMaximumPacketSize(0),
+ mPacketTable(NULL),
+ mDeferSizeUpdates(1),
+ mNeedsSizeUpdate(false),
+ mFirstSetFormat(true),
+ mAlignDataWithFillerChunks(true)
+ {
+ memset(&mDataFormat, 0, sizeof(mDataFormat));
+ }
+
+ virtual ~AudioFileObject();
+
+
+/* Public API Function Implementation */
+ // The DoSomething() versions of these functions are wrappers that perform a standard prologue.
+ // The Something() methods are those which should be overridden in the subclasses.
+
+ OSStatus DoCreate( CFURLRef inFileRef,
+ const AudioStreamBasicDescription *inFormat,
+ UInt32 inFlags);
+
+ virtual OSStatus Create( CFURLRef inFileRef,
+ const AudioStreamBasicDescription *inFormat);
+
+ OSStatus DoOpen( CFURLRef inFileRef,
+ SInt8 inPermissions,
+ int inFD);
+
+ virtual OSStatus Open( CFURLRef inFileRef,
+ SInt8 inPermissions,
+ int inFD);
+
+ OSStatus DoOpenWithCallbacks(
+ void * inRefCon,
+ AudioFile_ReadProc inReadFunc,
+ AudioFile_WriteProc inWriteFunc,
+ AudioFile_GetSizeProc inGetSizeFunc,
+ AudioFile_SetSizeProc inSetSizeFunc);
+
+
+ OSStatus DoInitialize( CFURLRef inFileRef,
+ const AudioStreamBasicDescription *inFormat,
+ UInt32 inFlags);
+
+ virtual OSStatus Initialize( CFURLRef inFileRef,
+ const AudioStreamBasicDescription *inFormat,
+ UInt32 inFlags);
+
+ OSStatus DoInitializeWithCallbacks(
+ void * inRefCon,
+ AudioFile_ReadProc inReadFunc,
+ AudioFile_WriteProc inWriteFunc,
+ AudioFile_GetSizeProc inGetSizeFunc,
+ AudioFile_SetSizeProc inSetSizeFunc,
+ UInt32 inFileType,
+ const AudioStreamBasicDescription *inFormat,
+ UInt32 inFlags);
+
+ virtual OSStatus OpenFromDataSource(void);
+
+ virtual OSStatus InitializeDataSource(const AudioStreamBasicDescription *inFormat, UInt32 inFlags);
+
+ OSStatus DoClose();
+
+ virtual OSStatus Close();
+
+ OSStatus DoOptimize();
+
+ virtual OSStatus Optimize();
+
+ virtual OSStatus ReadBytes( Boolean inUseCache,
+ SInt64 inStartingByte,
+ UInt32 *ioNumBytes,
+ void *outBuffer);
+
+ virtual OSStatus WriteBytes( Boolean inUseCache,
+ SInt64 inStartingByte,
+ UInt32 *ioNumBytes,
+ const void *inBuffer);
+
+ virtual OSStatus ReadPackets( Boolean inUseCache,
+ UInt32 *outNumBytes,
+ AudioStreamPacketDescription *outPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ void *outBuffer);
+
+ virtual OSStatus ReadPacketData(
+ Boolean inUseCache,
+ UInt32 *ioNumBytes,
+ AudioStreamPacketDescription *outPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ void *outBuffer);
+
+ virtual OSStatus ReadPacketDataVBR(
+ Boolean inUseCache,
+ UInt32 *ioNumBytes,
+ AudioStreamPacketDescription *outPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ void *outBuffer);
+
+ virtual OSStatus HowManyPacketsCanBeReadIntoBuffer(UInt32* ioNumBytes, SInt64 inStartingPacket, UInt32 *ioNumPackets);
+
+ virtual OSStatus ReadPacketDataVBR_InTable(
+ Boolean inUseCache,
+ UInt32 *ioNumBytes,
+ AudioStreamPacketDescription *outPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ void *outBuffer);
+
+ virtual OSStatus WritePackets( Boolean inUseCache,
+ UInt32 inNumBytes,
+ const AudioStreamPacketDescription *inPacketDescriptions,
+ SInt64 inStartingPacket,
+ UInt32 *ioNumPackets,
+ const void *inBuffer);
+/* Property Support */
+
+ virtual OSStatus GetPropertyInfo (
+ AudioFilePropertyID inPropertyID,
+ UInt32 *outDataSize,
+ UInt32 *isWritable);
+
+ virtual OSStatus GetProperty ( AudioFilePropertyID inPropertyID,
+ UInt32 *ioDataSize,
+ void *ioPropertyData);
+
+ virtual OSStatus SetProperty ( AudioFilePropertyID inPropertyID,
+ UInt32 inDataSize,
+ const void *inPropertyData);
+
+ UInt32 GetFileType() const { return mFileType; }
+ void SetFileType(UInt32 inFileType) { mFileType = inFileType; }
+
+ // this will set the format in memory only.
+ virtual OSStatus SetDataFormat(const AudioStreamBasicDescription* inStreamFormat);
+
+ // this will update the format info on disk and in memory.
+ virtual OSStatus UpdateDataFormat(const AudioStreamBasicDescription* inStreamFormat);
+
+ const UInt32 GetBytesPerPacket() const { return mDataFormat.mBytesPerPacket; }
+
+ const AudioStreamBasicDescription &GetDataFormat() const { return mDataFormat; }
+
+ virtual OSStatus GetFormatListInfo( UInt32 &outDataSize,
+ UInt32 &outWritable);
+
+ virtual OSStatus GetFormatList( UInt32 &ioDataSize,
+ AudioFormatListItem *ioPropertyData);
+
+ virtual OSStatus SetFormatList( UInt32 inDataSize,
+ const AudioFormatListItem *inPropertyData);
+
+ virtual OSStatus UpdateSize() { return noErr; }
+ UInt32 DeferSizeUpdates() { return mDeferSizeUpdates; }
+ void SetDeferSizeUpdates(UInt32 inFlag) { mDeferSizeUpdates = inFlag; }
+ OSStatus UpdateSizeIfNeeded();
+ OSStatus SizeChanged();
+
+ Boolean IsOptimized() const { return mIsOptimized != 0; }
+ void SetIsOptimized(Boolean inIsOptimized) { mIsOptimized = inIsOptimized ? 1 : 0; }
+
+ Boolean AlignDataWithFillerChunks() const { return mAlignDataWithFillerChunks; }
+
+ virtual SInt64 GetNumBytes() { return mNumBytes; }
+ virtual void SetNumBytes(SInt64 inNumBytes) { mNumBytes = inNumBytes; }
+
+ // this will update the header size info on disk
+ OSStatus UpdateNumBytes(SInt64 inNumBytes);
+
+ virtual SInt64 GetNumPackets(){ return mNumPackets; }
+ virtual void SetNumPackets(SInt64 inNumPackets) { mNumPackets = inNumPackets; }
+
+ // this will update the header size info on disk
+ OSStatus UpdateNumPackets(SInt64 inNumPackets);
+
+ virtual OSStatus PacketToFrame(SInt64 inPacket, SInt64& outFirstFrameInPacket);
+ virtual OSStatus FrameToPacket(SInt64 inFrame, SInt64& outPacket, UInt32& outFrameOffsetInPacket);
+
+ virtual OSStatus PacketToByte(AudioBytePacketTranslation* abpt);
+
+ virtual OSStatus ByteToPacket(AudioBytePacketTranslation* abpt);
+
+ virtual OSStatus GetBitRate( UInt32 *outBitRate);
+
+ virtual OSStatus GetMagicCookieDataSize( UInt32 *outDataSize,
+ UInt32 *isWritable);
+
+ virtual OSStatus GetMagicCookieData( UInt32 *ioDataSize,
+ void *ioPropertyData);
+
+ virtual OSStatus SetMagicCookieData( UInt32 inDataSize,
+ const void *inPropertyData);
+
+ virtual OSStatus GetMarkerListSize( UInt32 *outDataSize,
+ UInt32 *isWritable);
+
+ virtual OSStatus GetMarkerList( UInt32 *ioDataSize,
+ AudioFileMarkerList *ioMarkerList);
+
+ virtual OSStatus SetMarkerList( UInt32 inDataSize,
+ const AudioFileMarkerList *inMarkerList);
+
+
+ virtual OSStatus GetRegionListSize( UInt32 *outDataSize,
+ UInt32 *isWritable);
+
+ virtual OSStatus GetRegionList( UInt32 *ioDataSize,
+ AudioFileRegionList *ioRegionList);
+
+ virtual OSStatus SetRegionList( UInt32 inDataSize,
+ const AudioFileRegionList *inRegionList);
+
+ virtual OSStatus GetChannelLayoutSize( UInt32 *outDataSize,
+ UInt32 *isWritable);
+
+ virtual OSStatus GetChannelLayout( UInt32 *ioDataSize,
+ AudioChannelLayout *ioChannelLayout);
+
+ virtual OSStatus SetChannelLayout( UInt32 inDataSize,
+ const AudioChannelLayout *inChannelLayout);
+
+
+ virtual OSStatus GetInfoDictionarySize( UInt32 *outDataSize,
+ UInt32 *isWritable);
+
+ virtual OSStatus GetInfoDictionary( CACFDictionary *infoDict);
+
+ virtual OSStatus SetInfoDictionary( CACFDictionary *infoDict);
+
+ virtual OSStatus GetSoundCheckDictionarySize( UInt32 *outDataSize,
+ UInt32 *isWritable) { return kAudioFileUnsupportedPropertyError; }
+
+ virtual OSStatus GetSoundCheckDictionary( CACFDictionary *infoDict) { return kAudioFileUnsupportedPropertyError; }
+
+ virtual OSStatus SetSoundCheckDictionary( CACFDictionary *infoDict) { return kAudioFileUnsupportedPropertyError; }
+
+ virtual OSStatus GetLoudnessInfo( CACFDictionary *infoDict) { return kAudioFileUnsupportedPropertyError; }
+
+ virtual OSStatus GetSoundCheckDictionaryFromLoudnessInfo(CACFDictionary* outInfoDict) { return kAudioFileUnsupportedPropertyError; }
+ virtual OSStatus GetLoudnessInfoFromSoundCheckDictionary(CACFDictionary* outInfoDict) { return kAudioFileUnsupportedPropertyError; }
+
+ virtual OSStatus SetLoudnessInfo( CACFDictionary *infoDict) { return kAudioFileUnsupportedPropertyError; }
+
+ virtual OSStatus GetLoudnessInfoSize( UInt32 *outDataSize,
+ UInt32 *isWritable) { return kAudioFileUnsupportedPropertyError; }
+
+ virtual OSStatus GenerateLoudnessInfo( CACFDictionary *infoDict) { return kAudioFileUnsupportedPropertyError; }
+
+ virtual OSStatus GetEstimatedDuration( Float64* duration);
+
+ virtual OSStatus CountUserData( UInt32 inUserDataID,
+ UInt32 *outNumberItems);
+
+ virtual OSStatus GetUserDataSize( UInt32 inUserDataID,
+ UInt32 inIndex,
+ UInt32 *outDataSize);
+
+ virtual OSStatus GetUserData( UInt32 inUserDataID,
+ UInt32 inIndex,
+ UInt32 *ioDataSize,
+ void *ioUserData);
+
+ virtual OSStatus SetUserData( UInt32 inUserDataID,
+ UInt32 inIndex,
+ UInt32 inDataSize,
+ const void *inUserData);
+
+ virtual OSStatus RemoveUserData( UInt32 inUserDataID,
+ UInt32 inIndex);
+
+ virtual OSStatus GetLyrics(CFStringRef *outLyrics) { return kAudioFileUnsupportedPropertyError; }
+
+
+ Boolean CanRead() const { return mPermissions & kAudioFileReadPermission; }
+ Boolean CanWrite() const { return mPermissions & kAudioFileWritePermission; }
+
+ void SetPermissions(SInt8 inPermissions) { mPermissions = inPermissions; }
+
+/* Other Helper Methods: (some may not be necessary depending on how things are refactored) */
+
+ OSStatus OpenFile(SInt8 inPermissions, int inFD);
+
+ OSStatus CreateDataFile (CFURLRef inFileRef, int &outFileD);
+
+ OSStatus AddDurationToInfoDictionary(CACFDictionary *infoDict, Float64 &inDuration);
+
+ virtual Boolean IsDataFormatSupported(const AudioStreamBasicDescription *inFormat) = 0;
+ virtual Boolean IsDataFormatValid(const AudioStreamBasicDescription *inFormat);
+
+ virtual OSStatus IsValidFilePosition(SInt64 /*position*/) { return noErr; }
+
+ OSStatus MoveData(SInt64 fromPos, SInt64 toPos, SInt64 size);
+
+/* Accessors: */
+ Boolean IsInitialized() const { return mIsInitialized; }
+ void SetInitialized(Boolean inFlag) { mIsInitialized = inFlag; }
+
+ DataSource* GetDataSource() const { return mDataSource; }
+ void SetDataSource(DataSource *inDataSource);
+
+ void SetURL (CFURLRef inURL);
+
+ virtual UInt32 GetMaximumPacketSize() { return mMaximumPacketSize; }
+ virtual UInt32 FindMaximumPacketSize() { return mMaximumPacketSize; }
+ virtual void SetMaximumPacketSize(const UInt32 inPacketSize) { mMaximumPacketSize = inPacketSize; }
+
+ virtual UInt32 GetPacketSizeUpperBound() { return GetMaximumPacketSize (); }
+
+ SInt64 GetDataOffset() const { return mDataOffset; }
+ void SetDataOffset(SInt64 inOffset) { mDataOffset = inOffset; }
+
+ // I like this idiom better than DoesPacketTableExist+NewPacketTable:
+ CompressedPacketTable* GetPacketTable(Boolean inCreateIt = false)
+ {
+ if (!mPacketTable && inCreateIt)
+ mPacketTable = new CompressedPacketTable(mDataFormat.mFramesPerPacket);
+ return mPacketTable;
+ }
+ void ClearPacketTable()
+ {
+ DeletePacketTable();
+ GetPacketTable(true);
+ }
+
+ virtual OSStatus ScanForPackets(SInt64 inToPacketCount, DataSource* inDataSrc = NULL, bool fullyParsedIfEndOfDataReached = true)
+ {
+ // In formats that read packets lazily, this will be overridden to scan for packets up to the index.
+ if (inToPacketCount > GetNumPackets())
+ return kAudioFileEndOfFileError;
+
+ return noErr;
+ }
+
+ void AppendPacket(const AudioStreamPacketDescription &inPacket)
+ {
+ CompressedPacketTable* packetTable = GetPacketTable(true);
+ UInt32 numFramesInPacket = mDataFormat.mFramesPerPacket ? mDataFormat.mFramesPerPacket : inPacket.mVariableFramesInPacket;
+
+ AudioStreamPacketDescriptionExtended pext;
+ memset(&pext, 0, sizeof(pext));
+ pext.mStartOffset = inPacket.mStartOffset;
+ pext.mDataByteSize = inPacket.mDataByteSize;
+ pext.mVariableFramesInPacket = inPacket.mVariableFramesInPacket;
+ pext.mFrameOffset = numFramesInPacket + (packetTable->size() ? packetTable->back().mFrameOffset : 0);
+
+ packetTable->push_back(pext);
+ if (inPacket.mDataByteSize > mMaximumPacketSize)
+ mMaximumPacketSize = inPacket.mDataByteSize;
+ }
+ void DeletePacketTable() { delete mPacketTable; mPacketTable = NULL;}
+ SInt64 GetPacketTableSize() { return mPacketTable ? mPacketTable->size() : 0; }
+ OSStatus GetPacketDescriptions(UInt32 inStartingPacket, UInt32 *ioDataSize, AudioStreamPacketDescription *outPacketDescriptions)
+ {
+ if (outPacketDescriptions == NULL) return kAudioFileUnspecifiedError;
+ if (mPacketTable)
+ {
+ // only get as many packet descriptions as can fit in outPacketDescriptions
+ UInt32 count = *ioDataSize / sizeof(AudioStreamPacketDescription);
+ if (count + inStartingPacket > GetPacketTableSize())
+ count = (UInt32)(GetPacketTableSize() - inStartingPacket);
+
+ *ioDataSize = 0;
+ for (UInt32 i = inStartingPacket; i < (count + inStartingPacket); i++)
+ {
+ AudioStreamPacketDescription curPacket = (*mPacketTable)[i];
+ outPacketDescriptions[i].mStartOffset = curPacket.mStartOffset - GetDataOffset();
+ outPacketDescriptions[i].mVariableFramesInPacket = curPacket.mVariableFramesInPacket;
+ outPacketDescriptions[i].mDataByteSize = curPacket.mDataByteSize;
+ *ioDataSize += sizeof(AudioStreamPacketDescription);
+ }
+ }
+ else
+ *ioDataSize = 0;
+
+ return noErr;
+ }
+
+#if DEBUG
+ void DumpPacketTable()
+ {
+ if (mPacketTable) {
+ SInt64 size = mPacketTable->size();
+ printf("PacketTable size %d\n", (int)size);
+ for (SInt64 i = 0; i < size; i++) {
+ AudioStreamPacketDescription curPacket = (*mPacketTable)[i];
+ printf("dpkt %5qd %8qd %5d %5d\n", i, curPacket.mStartOffset, (int)curPacket.mDataByteSize, (int)curPacket.mVariableFramesInPacket);
+ }
+ }
+ }
+#endif
+
+ Boolean GetNeedsSizeUpdate() const { return mNeedsSizeUpdate; }
+ void SetNeedsSizeUpdate(Boolean inNeedsSizeUpdate) { mNeedsSizeUpdate = inNeedsSizeUpdate; }
+
+ CFURLRef GetURL () const { return mFileRef; }
+
+ virtual OSStatus GetSourceBitDepth(SInt32& outValue) { outValue = 0; return kAudioFileUnsupportedPropertyError; }
+ virtual OSStatus SetSourceBitDepth(SInt32 inValue) { return kAudioFileUnsupportedPropertyError; }
+
+ virtual OSStatus GetAlbumArtwork(CFDataRef& outValue) { outValue = NULL; return kAudioFileUnsupportedPropertyError; }
+ virtual OSStatus SetAlbumArtwork(CFDataRef inValue){ return kAudioFileUnsupportedPropertyError; }
+
+private:
+
+ void SetAlignDataWithFillerChunks(Boolean inFlag) { mAlignDataWithFillerChunks = inFlag; }
+
+ OSStatus ValidateFormatAndData();
+
+/* debug */
+// virtual void PrintFile (FILE* inFile, const char *indent) = 0;
+};
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+inline Boolean cfstrcmpi(CFStringRef a, CFStringRef b)
+{
+ // case insensitive CFString compare
+ return CFStringCompare(a, b, kCFCompareCaseInsensitive) == kCFCompareEqualTo;
+}
+
+CFBundleRef GetAudioToolboxBundle();
+
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+#endif
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/CompressedPacketTable.cpp b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/CompressedPacketTable.cpp
new file mode 100644
index 000000000..ba07580bb
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/CompressedPacketTable.cpp
@@ -0,0 +1,216 @@
+/*
+ File: CompressedPacketTable.cpp
+ Abstract: CompressedPacketTable.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 "CompressedPacketTable.h"
+#include "CAAutoDisposer.h"
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+const UInt32 CompressedPacketTable::kShift = 5;
+const UInt32 CompressedPacketTable::kMask = 31;
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+CompressedPacketTable::~CompressedPacketTable()
+{
+ size_t size = mBases.size();
+ for (size_t i = 0; i < size; ++i) {
+ free(mBases[i].mDescs);
+ }
+}
+
+void CompressedPacketTable::push_back(const AudioStreamPacketDescriptionExtended& inDesc)
+{
+ SInt64 baseIndex = mSize >> kShift;
+ UInt32 packetIndex = (UInt32)(mSize & kMask);
+
+ if (packetIndex == 0) {
+ // first packet in a new sequence. create a new PacketBase.
+ PacketBase newBase;
+ newBase.mBaseOffset = 0;
+ newBase.mDescs = CA_malloc((kMask+1) * sizeof(AudioStreamPacketDescriptionExtended));
+ newBase.mDescType = kExtendedPacketDescription;
+ mBases.push_back(newBase);
+ }
+
+ PacketBase& base = mBases[(size_t)baseIndex];
+ AudioStreamPacketDescriptionExtended* descs = (AudioStreamPacketDescriptionExtended*)base.mDescs;
+ descs[packetIndex] = inDesc;
+
+ if (packetIndex == kMask) {
+ // last packet in a sequence. compress the sequence.
+ Compress(base);
+ }
+
+ mSize++;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+#define ACCESS_TYPE(TYPE) \
+ case k##TYPE##ContiguousPacketDescription : { \
+ TYPE##ContiguousPacketDescription* descs = (TYPE##ContiguousPacketDescription*)base.mDescs; \
+ packetOffset = packetIndex ? descs[packetIndex-1].mNextOffset : 0; \
+ packetSize = (UInt32)(descs[packetIndex].mNextOffset - packetOffset); \
+ } break; \
+ case k##TYPE##DiscontiguousPacketDescription : { \
+ TYPE##DiscontiguousPacketDescription* descs = (TYPE##DiscontiguousPacketDescription*)base.mDescs; \
+ packetOffset = packetIndex ? descs[packetIndex-1].mNextOffset : 0; \
+ packetSize = descs[packetIndex].mDataByteSize; \
+ } break;
+
+const AudioStreamPacketDescriptionExtended CompressedPacketTable::operator[](SInt64 inPacketIndex) const
+{
+ SInt64 baseIndex = inPacketIndex >> kShift;
+ UInt32 packetIndex = (UInt32)(inPacketIndex & kMask);
+
+ if ((size_t)baseIndex >= mBases.size())
+ throw -1;
+
+ const PacketBase& base = mBases[(size_t)baseIndex];
+
+ SInt64 packetOffset = 0;
+ UInt32 packetSize = 0;
+
+ switch (base.mDescType)
+ {
+ ACCESS_TYPE(Tiny)
+ ACCESS_TYPE(Small)
+ ACCESS_TYPE(Big)
+ case kExtendedPacketDescription :
+ return ((AudioStreamPacketDescriptionExtended*)base.mDescs)[packetIndex];
+ }
+
+ AudioStreamPacketDescriptionExtended outDesc;
+ outDesc.mStartOffset = base.mBaseOffset + packetOffset;
+ outDesc.mDataByteSize = packetSize;
+ outDesc.mVariableFramesInPacket = 0;
+ outDesc.mFrameOffset = mFramesPerPacket * inPacketIndex;
+
+ //printf("get %d %10qd %10qd %2d %10qd %6d %10qd\n", base.mDescType, inPacketIndex, baseIndex, packetIndex, outDesc.mStartOffset, outDesc.mDataByteSize, outDesc.mFrameOffset);
+
+ return outDesc;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+bool CompressedPacketTable::isContiguous(PacketBase& base)
+{
+ AudioStreamPacketDescriptionExtended* descs = (AudioStreamPacketDescriptionExtended*)base.mDescs;
+ SInt64 expectedOffset = descs[0].mStartOffset + descs[0].mDataByteSize;
+ for (UInt32 i = 1; i <= kMask; ++i) {
+ if (expectedOffset != descs[i].mStartOffset) return false;
+ expectedOffset += descs[i].mDataByteSize;
+ }
+ return true;
+}
+
+bool CompressedPacketTable::hasVariableFrames(PacketBase& base)
+{
+ AudioStreamPacketDescriptionExtended* descs = (AudioStreamPacketDescriptionExtended*)base.mDescs;
+ for (UInt32 i = 0; i <= kMask; ++i) {
+ if (descs[i].mVariableFramesInPacket) return true;
+ }
+ return false;
+}
+
+UInt32 CompressedPacketTable::largestPacket(PacketBase& base)
+{
+ UInt32 maxPacketSize = 0;
+ AudioStreamPacketDescriptionExtended* descs = (AudioStreamPacketDescriptionExtended*)base.mDescs;
+ for (UInt32 i = 0; i <= kMask; ++i) {
+ UInt32 packetSize = descs[i].mDataByteSize;
+ if (packetSize > maxPacketSize) maxPacketSize = packetSize;
+ }
+ return maxPacketSize;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+#define COMPRESS_TYPE(TYPE, BITS) \
+ if (contiguous) { \
+ TYPE##ContiguousPacketDescription* newDescs = (TYPE##ContiguousPacketDescription*)CA_malloc((kMask+1) * sizeof(TYPE##ContiguousPacketDescription)); \
+ base.mDescs = newDescs; \
+ base.mDescType = k##TYPE##ContiguousPacketDescription; \
+ for (UInt32 i = 0; i <= kMask; ++i) { \
+ newDescs[i].mNextOffset = (BITS)(descs[i].mStartOffset + descs[i].mDataByteSize - baseOffset); \
+ } \
+ free(descs); \
+ } else { \
+ TYPE##DiscontiguousPacketDescription* newDescs = (TYPE##DiscontiguousPacketDescription*)CA_malloc((kMask+1) * sizeof(TYPE##DiscontiguousPacketDescription)); \
+ base.mDescs = newDescs; \
+ base.mDescType = k##TYPE##DiscontiguousPacketDescription; \
+ for (UInt32 i = 0; i <= kMask; ++i) { \
+ newDescs[i].mNextOffset = i == kMask ? 0 : (BITS)(descs[i+1].mStartOffset - baseOffset); \
+ newDescs[i].mDataByteSize = descs[i].mDataByteSize; \
+ } \
+ free(descs); \
+ } \
+ return;
+
+void CompressedPacketTable::Compress(PacketBase& base)
+{
+ if (hasVariableFrames(base))
+ return;
+
+ bool contiguous = isContiguous(base);
+
+ AudioStreamPacketDescriptionExtended* descs = (AudioStreamPacketDescriptionExtended*)base.mDescs;
+ SInt64 delta = descs[kMask].mStartOffset + descs[kMask].mDataByteSize - descs[0].mStartOffset;
+
+ SInt64 baseOffset = descs[0].mStartOffset;
+ base.mBaseOffset = baseOffset;
+
+ if (delta <= 65535LL) {
+ COMPRESS_TYPE(Tiny, UInt16)
+ } else if (delta <= 4294967295LL && largestPacket(base) <= 65535) {
+ COMPRESS_TYPE(Small, UInt32)
+ } else {
+ COMPRESS_TYPE(Big, SInt64)
+ }
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/CompressedPacketTable.h b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/CompressedPacketTable.h
new file mode 100644
index 000000000..47e28ca49
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/CompressedPacketTable.h
@@ -0,0 +1,186 @@
+/*
+ File: CompressedPacketTable.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.
+
+*/
+#include
+#include
+#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
+ #include
+#else
+ #include "CoreAudioTypes.h"
+#endif
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+struct AudioStreamPacketDescriptionExtended : AudioStreamPacketDescription
+{
+ SInt64 mFrameOffset; // this is the sum of the mVariableFramesInPacket up to this point so we can binary search.
+};
+typedef struct AudioStreamPacketDescriptionExtended AudioStreamPacketDescriptionExtended;
+
+inline bool operator < (const AudioStreamPacketDescriptionExtended& a, const AudioStreamPacketDescriptionExtended& b)
+{
+ return a.mFrameOffset < b.mFrameOffset;
+}
+
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+class CompressedPacketTable
+{
+public:
+ CompressedPacketTable(UInt32 inFramesPerPacket) : mSize(0), mFramesPerPacket(inFramesPerPacket) {}
+ ~CompressedPacketTable();
+
+ SInt64 size() const { return mSize; }
+ void push_back(const AudioStreamPacketDescriptionExtended& inDesc);
+
+ const AudioStreamPacketDescriptionExtended operator[](SInt64 inPacketIndex) const;
+ const AudioStreamPacketDescriptionExtended front() const { return (*this)[0]; }
+ const AudioStreamPacketDescriptionExtended back() const { return (*this)[mSize-1]; }
+
+ //SInt64 PacketForByte(SInt64 inByteOffset) const;
+ SInt64 ByteForPacket(SInt64 inPacketIndex) const { return (*this)[inPacketIndex].mStartOffset; }
+
+ class iterator {
+ public:
+ typedef std::input_iterator_tag iterator_category;
+ typedef iterator pointer;
+ typedef SInt64 difference_type;
+ typedef AudioStreamPacketDescriptionExtended value_type;
+ typedef value_type& reference;
+
+ iterator() : mTable(NULL), mIndex(0) {}
+ iterator(const CompressedPacketTable* table, SInt64 index) : mTable(table), mIndex(index) {}
+ iterator(const iterator& that) : mTable(that.mTable), mIndex(that.mIndex) {}
+
+ iterator& operator=(const iterator& that) { mTable = that.mTable; mIndex = that.mIndex; return *this; }
+
+ const AudioStreamPacketDescriptionExtended operator*() const { return (*mTable)[mIndex]; }
+ const AudioStreamPacketDescriptionExtended* const operator->() { mValue = (*mTable)[mIndex]; return &mValue; }
+ iterator& operator++() { ++mIndex; return *this; }
+ iterator& operator--() { --mIndex; return *this; }
+
+ SInt64 operator-(const iterator& that) { return mIndex - that.mIndex; }
+ const iterator operator-(SInt64 index) { return iterator(mTable, mIndex - index); }
+ const iterator operator+(SInt64 index) { return iterator(mTable, mIndex + index); }
+ bool operator==(const iterator& that) { return mIndex == that.mIndex; }
+ bool operator!=(const iterator& that) { return mIndex != that.mIndex; }
+ bool operator>(const iterator& that) { return mIndex > that.mIndex; }
+ bool operator<(const iterator& that) { return mIndex < that.mIndex; }
+ private:
+ const CompressedPacketTable* mTable;
+ SInt64 mIndex;
+ AudioStreamPacketDescriptionExtended mValue; // in order to support operator-> .
+ };
+
+ iterator begin() const { return iterator(this, 0); }
+ iterator end() const { return iterator(this, mSize); }
+
+private:
+ struct TinyContiguousPacketDescription
+ {
+ UInt16 mNextOffset;
+ };
+
+ struct TinyDiscontiguousPacketDescription : TinyContiguousPacketDescription
+ {
+ UInt16 mDataByteSize;
+ };
+
+ // There could be a 24 bit packet description. But ALAC is who usually needs SmallContiguousPacketDescription and
+ // it already uses 8x fewer packet descriptions than AAC due to the mFramesPerPacket being 8x greater.
+ // So there isn't as great a need for saving space. 4 bytes per packet is OK for ALAC.
+
+ struct SmallContiguousPacketDescription
+ {
+ UInt32 mNextOffset;
+ };
+
+ struct SmallDiscontiguousPacketDescription : SmallContiguousPacketDescription
+ {
+ UInt16 mDataByteSize;
+ };
+
+ struct BigContiguousPacketDescription
+ {
+ UInt64 mNextOffset;
+ };
+
+ struct BigDiscontiguousPacketDescription : BigContiguousPacketDescription
+ {
+ UInt32 mDataByteSize;
+ };
+
+ struct PacketBase
+ {
+ SInt64 mBaseOffset;
+ UInt8 mDescType;
+ void* mDescs;
+ };
+
+ enum {
+ kTinyContiguousPacketDescription,
+ kTinyDiscontiguousPacketDescription,
+ kSmallContiguousPacketDescription,
+ kSmallDiscontiguousPacketDescription,
+ kBigContiguousPacketDescription,
+ kBigDiscontiguousPacketDescription,
+ kExtendedPacketDescription
+ };
+ static const UInt32 kShift;
+ static const UInt32 kMask;
+
+ bool isContiguous(PacketBase& base);
+ bool hasVariableFrames(PacketBase& base);
+ UInt32 largestPacket(PacketBase& base);
+
+ void Compress(PacketBase& base);
+
+private:
+ std::vector mBases;
+ UInt64 mSize;
+ UInt32 mFramesPerPacket;
+};
+
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/DataSource.cpp b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/DataSource.cpp
new file mode 100644
index 000000000..4249c2724
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/DataSource.cpp
@@ -0,0 +1,690 @@
+/*
+ File: DataSource.cpp
+ Abstract: DataSource.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 "DataSource.h"
+#if TARGET_OS_WIN32
+ #include
+#else
+ #include
+ #include
+#endif
+#include
+#include
+#include
+
+#define VERBOSE 0
+
+//////////////////////////////////////////////////////////////////////////////////////////
+
+
+const UInt16 kPositionModeMask = 3;
+
+DataSource::DataSource(Boolean inCloseOnDelete)
+ : mCloseOnDelete(inCloseOnDelete)
+{
+}
+
+DataSource::~DataSource()
+{
+}
+
+SInt64 DataSource::CalcOffset( UInt16 positionMode,
+ SInt64 positionOffset,
+ SInt64 currentOffset,
+ SInt64 size)
+{
+ SInt64 newOffset = 0;
+ switch (positionMode & kPositionModeMask) {
+ //case fsAtMark : newOffset = currentOffset; break;
+ case SEEK_SET : newOffset = positionOffset; break;
+ case SEEK_END : newOffset = size + positionOffset; break;
+ case SEEK_CUR : newOffset = positionOffset + currentOffset; break;
+ }
+ return newOffset;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////
+
+#if 0
+
+MacFile_DataSource::MacFile_DataSource( FSIORefNum inForkRefNum, SInt8 inPermissions, Boolean inCloseOnDelete)
+ : DataSource(inCloseOnDelete), mFileNum(inForkRefNum), mPermissions(inPermissions)
+{
+}
+
+MacFile_DataSource::~MacFile_DataSource()
+{
+ if (mCloseOnDelete) FSCloseFork(mFileNum);
+}
+
+
+OSStatus MacFile_DataSource::GetSize(SInt64& outSize)
+{
+ outSize = -1; // in case of error
+ OSStatus err = FSGetForkSize(mFileNum, &outSize);
+ return err;
+}
+
+OSStatus MacFile_DataSource::GetPos(SInt64& outPos) const
+{
+ return FSGetForkPosition(mFileNum, &outPos);
+}
+
+OSStatus MacFile_DataSource::SetSize(SInt64 inSize)
+{
+ return FSSetForkSize(mFileNum, SEEK_SET, inSize);
+}
+
+
+OSStatus MacFile_DataSource::ReadBytes(
+ UInt16 positionMode,
+ SInt64 positionOffset,
+ UInt32 requestCount,
+ void *buffer,
+ UInt32* actualCount)
+{
+ if (actualCount) *actualCount = 0;
+ if (!buffer) return kAudio_ParamError;
+ ByteCount bc_actualCount = 0;
+ OSStatus err = FSReadFork(mFileNum, positionMode, positionOffset, requestCount, buffer, &bc_actualCount);
+ if (actualCount) *actualCount = (UInt32)bc_actualCount;
+ return err;
+}
+
+OSStatus MacFile_DataSource::WriteBytes(
+ UInt16 positionMode,
+ SInt64 positionOffset,
+ UInt32 requestCount,
+ const void *buffer,
+ UInt32* actualCount)
+{
+ if (!buffer) return kAudio_ParamError;
+ ByteCount bc_actualCount = 0;
+ OSStatus err = FSWriteFork(mFileNum, positionMode, positionOffset, requestCount, buffer, &bc_actualCount);
+ if (actualCount) *actualCount = (UInt32)bc_actualCount;
+ return err;
+}
+#endif
+
+//////////////////////////////////////////////////////////////////////////////////////////
+
+#define kAudioFileNoCacheMask 0x20
+
+UnixFile_DataSource::UnixFile_DataSource( int inFD, SInt8 inPermissions, Boolean inCloseOnDelete)
+ : DataSource(inCloseOnDelete), mFileD(inFD), mPermissions(inPermissions), mNoCache(0), mCachedSize(-1), mFilePointer(0)
+{
+}
+
+UnixFile_DataSource::~UnixFile_DataSource()
+{
+ if (mCloseOnDelete) close(mFileD);
+}
+
+OSStatus UnixFile_DataSource::GetSize(SInt64& outSize)
+{
+#if 0 // 6764274 using the cached file size causes a regression for apps that play a file while writing to it.
+ if (mCachedSize >= 0) {
+ outSize = mCachedSize;
+ return noErr;
+ }
+#endif
+ outSize = -1; // in case of error
+ struct stat stbuf;
+ if (fstat (mFileD, &stbuf) == -1) return kAudio_FileNotFoundError;
+ outSize = mCachedSize = stbuf.st_size;
+ return noErr;
+}
+
+OSStatus UnixFile_DataSource::SetSize(SInt64 inSize)
+{
+ mCachedSize = -1;
+#if TARGET_OS_WIN32
+ if (chsize (mFileD, inSize)) return kAudioFilePermissionsError;
+#else
+ if (ftruncate (mFileD, inSize) == -1) return kAudioFilePermissionsError;
+#endif
+ mCachedSize = inSize;
+ return noErr;
+}
+
+
+OSStatus UnixFile_DataSource::GetPos(SInt64& outPos) const
+{
+ outPos = mFilePointer;
+ return noErr;
+}
+
+SInt64 UnixFile_DataSource::UFCurrentOffset (UInt16 positionMode,
+ SInt64 positionOffset)
+{
+ SInt64 offset = -1;
+ switch (positionMode & kPositionModeMask)
+ {
+ /*case fsAtMark :
+ {
+ SInt64 pos;
+ OSStatus result = GetPos (pos);
+ if (result) return result;
+ offset = pos;
+ break;
+ }*/
+ case SEEK_SET :
+ {
+ offset = positionOffset;
+ break;
+ }
+ case SEEK_END :
+ {
+ SInt64 size;
+ OSStatus result = GetSize (size);
+ if (result) return result;
+ offset = size + positionOffset;
+ break;
+ }
+ case SEEK_CUR :
+ {
+ SInt64 pos;
+ OSStatus result = GetPos (pos);
+ if (result) return result;
+ offset = positionOffset + pos;
+ break;
+ }
+ }
+ return offset;
+}
+
+OSStatus UnixFile_DataSource::ReadBytes( UInt16 positionMode,
+ SInt64 positionOffset,
+ UInt32 requestCount,
+ void *buffer,
+ UInt32* actualCount)
+{
+ if (actualCount) *actualCount = 0;
+ if (!buffer) return kAudio_ParamError;
+
+ // can't use current offset as we need to go to the disk too much
+ SInt64 offset = UFCurrentOffset (positionMode, positionOffset);
+ if (offset < 0) return kAudioFilePositionError;
+
+#if 0 // 6571050 fstat-ing the file every read causes a performance regression
+ // 5931571 check that read may exceed eof and curtail it.
+ do {
+ SInt64 size;
+ OSStatus serr = GetSize(size);
+ if (serr) break;
+ SInt64 remain = size - offset;
+ if (remain < 0) requestCount = 0;
+ else if (requestCount > remain) requestCount = remain;
+ } while (false);
+#endif
+
+ if (requestCount <= 0) {
+ if (actualCount) *actualCount = 0;
+ return noErr;
+ }
+
+#if !TARGET_OS_WIN32
+ UInt32 noCache = positionMode & kAudioFileNoCacheMask ? 1 : 0;
+ if (noCache != mNoCache) {
+ mNoCache = noCache;
+ fcntl(mFileD, F_NOCACHE, mNoCache);
+ }
+#endif
+
+ size_t readBytes = requestCount;
+#if TARGET_OS_WIN32
+ lseek(mFileD, offset, SEEK_SET);
+ int numBytes = read (mFileD, buffer, readBytes);
+#else
+ ssize_t numBytes = pread (mFileD, buffer, readBytes, offset);
+#endif
+ if (numBytes == -1) return kAudioFilePositionError;
+ mFilePointer = offset + numBytes;
+
+ if (actualCount) *actualCount = (UInt32)numBytes;
+ return noErr;
+}
+
+OSStatus UnixFile_DataSource::WriteBytes(UInt16 positionMode,
+ SInt64 positionOffset,
+ UInt32 requestCount,
+ const void *buffer,
+ UInt32* actualCount)
+{
+ if (!buffer) return kAudio_ParamError;
+
+ // can't use current offset as we need to go to the disk too much
+ SInt64 offset = UFCurrentOffset (positionMode, positionOffset);
+ if (offset < 0) return kAudioFilePositionError;
+
+ mCachedSize = -1;
+
+ size_t writeBytes = requestCount;
+
+#if !TARGET_OS_WIN32
+ UInt32 noCache = positionMode & kAudioFileNoCacheMask ? 1 : 0;
+ if (noCache != mNoCache) {
+ mNoCache = noCache;
+ fcntl(mFileD, F_NOCACHE, mNoCache);
+ }
+#endif
+
+#if TARGET_OS_WIN32
+ lseek(mFileD, offset, SEEK_SET);
+ int numBytes = write (mFileD, buffer, writeBytes);
+#else
+ ssize_t numBytes = pwrite (mFileD, buffer, writeBytes, offset);
+#endif
+ if (numBytes == -1) return kAudioFilePositionError;
+ mFilePointer = offset + numBytes;
+
+ if (actualCount) *actualCount = (UInt32)numBytes;
+ return noErr;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+
+#define NO_CACHE 0
+
+OSStatus Cached_DataSource::ReadFromHeaderCache(
+ SInt64 offset,
+ UInt32 requestCount,
+ void *buffer,
+ UInt32* actualCount)
+{
+ if (actualCount) *actualCount = 0;
+ OSStatus err = noErr;
+ ByteCount theActualCount = 0;
+
+#if VERBOSE
+ printf("read from header %lld %lu %lld %lu\n", offset, requestCount, 0LL, mHeaderCacheSize);
+#endif
+
+ if (!mHeaderCache())
+ {
+ mHeaderCache.allocBytes(mHeaderCacheSize, true);
+ err = mDataSource->ReadBytes(SEEK_SET, 0, mHeaderCacheSize, mHeaderCache(), &mHeaderCacheSize);
+ if (err == kAudioFileEndOfFileError) err = noErr;
+ if (err) return err;
+ }
+
+ ByteCount firstPart = std::min((ByteCount)requestCount, (ByteCount)(mHeaderCacheSize - offset));
+ ByteCount secondPart = requestCount - firstPart;
+
+ memcpy(buffer, mHeaderCache + (ByteCount)offset, firstPart);
+ theActualCount = firstPart;
+
+ if (secondPart) {
+ UInt32 secondPartActualCount = 0;
+ err = mDataSource->ReadBytes(SEEK_SET, mHeaderCacheSize, static_cast(secondPart), (char*)buffer + firstPart, &secondPartActualCount);
+ theActualCount += secondPartActualCount;
+ }
+
+ if (actualCount) *actualCount = (UInt32)theActualCount;
+ mOffset = offset + theActualCount;
+
+ return err;
+}
+
+OSStatus Cached_DataSource::ReadBytes(
+ UInt16 positionMode,
+ SInt64 positionOffset,
+ UInt32 requestCount,
+ void *buffer,
+ UInt32* actualCount)
+{
+ if (actualCount) *actualCount = 0;
+ OSStatus err = noErr;
+ SInt64 size;
+ UInt32 theActualCount = 0;
+
+ if (!buffer) return kAudio_ParamError;
+
+ if ((positionMode & kPositionModeMask) != SEEK_END) size = 0; // not used in this case
+ else
+ {
+ err = GetSize(size);
+ if (err) return err;
+ }
+
+ SInt64 offset = CalcOffset(positionMode, positionOffset, mOffset, size);
+ if (offset < 0) return kAudioFilePositionError;
+
+ if (offset < mHeaderCacheSize) {
+ return ReadFromHeaderCache(offset, requestCount, buffer, actualCount);
+ }
+
+#if NO_CACHE
+ err = mDataSource->ReadBytes(positionMode, positionOffset, requestCount, buffer, &theActualCount);
+ mOffset = offset + theActualCount;
+#else
+
+ SInt64 cacheEnd = mBodyCacheOffset + mBodyCacheCurSize;
+ if (mBodyCache() && requestCount < mBodyCacheSize && offset >= mBodyCacheOffset && offset < cacheEnd)
+ {
+ if (offset + requestCount <= cacheEnd)
+ {
+ // request is entirely within cache
+#if VERBOSE
+ printf("request is entirely within cache %lld %lu %lld %lu\n", offset, requestCount, mBodyCacheOffset, mBodyCacheCurSize);
+#endif
+ memcpy(buffer, mBodyCache + (size_t)(offset - mBodyCacheOffset), requestCount);
+ theActualCount = requestCount;
+ }
+ else
+ {
+ // part of request is within cache. copy, read next cache block, copy.
+#if VERBOSE
+ printf("part of request is within cache %lld %lu %lld %lu\n", offset, requestCount, mBodyCacheOffset, mBodyCacheCurSize);
+#endif
+
+ // copy first part.
+ ByteCount firstPart = (ByteCount)(cacheEnd - offset);
+ ByteCount secondPart = requestCount - firstPart;
+#if VERBOSE
+ printf("memcpy offset %lld mBodyCacheOffset %lld offset - mBodyCacheOffset %lld firstPart %lu requestCount %lu\n",
+ offset, mBodyCacheOffset, offset - mBodyCacheOffset, firstPart, requestCount);
+#endif
+ memcpy(buffer, mBodyCache + (size_t)(offset - mBodyCacheOffset), firstPart);
+
+ theActualCount = static_cast(firstPart);
+
+ // read new block
+ SInt64 nextOffset = mBodyCacheOffset + mBodyCacheCurSize;
+ err = mDataSource->ReadBytes(SEEK_SET, nextOffset, mBodyCacheSize, mBodyCache(), &mBodyCacheCurSize);
+
+ if (err == kAudioFileEndOfFileError) err = noErr;
+ if (err) goto leave;
+
+ mBodyCacheOffset = nextOffset;
+
+ // copy second part
+ secondPart = std::min(secondPart, (ByteCount)mBodyCacheCurSize);
+ if (secondPart) memcpy((char*)buffer + firstPart, mBodyCache(), secondPart);
+ theActualCount = static_cast(firstPart + secondPart);
+ }
+ }
+ else
+ {
+ if (requestCount > mBodyCacheSize)
+ {
+#if VERBOSE
+ printf("large request %lld %lu %lld %lu\n", offset, requestCount, mBodyCacheOffset, mBodyCacheCurSize);
+#endif
+ // the request is larger than we normally cache, just do a read and don't cache.
+ err = mDataSource->ReadBytes(positionMode, positionOffset, requestCount, buffer, &theActualCount);
+ mOffset = offset + theActualCount;
+ }
+ else
+ {
+ // request is outside cache. read new block.
+#if VERBOSE
+ printf("request is outside cache %lld %lu %lld %lu\n", offset, requestCount, mBodyCacheOffset, mBodyCacheCurSize);
+#endif
+ if (!mBodyCache())
+ {
+ mBodyCache.allocBytes(mBodyCacheSize, true);
+#if VERBOSE
+ printf("alloc mBodyCache %08X\n", mBodyCache());
+#endif
+ }
+ mBodyCacheOffset = offset;
+ err = mDataSource->ReadBytes(SEEK_SET, mBodyCacheOffset, mBodyCacheSize, mBodyCache(), &mBodyCacheCurSize);
+#if VERBOSE
+ printf("read %08X %d mBodyCacheOffset %lld %lu %lu\n", err, err, mBodyCacheOffset, mBodyCacheSize, mBodyCacheCurSize);
+#endif
+ if (err == kAudioFileEndOfFileError) err = noErr;
+ if (err) return err;
+
+ theActualCount = std::min(requestCount, mBodyCacheCurSize);
+ memcpy(buffer, mBodyCache(), theActualCount);
+ }
+
+ }
+
+leave:
+#endif
+ if (actualCount) *actualCount = (UInt32)theActualCount;
+#if VERBOSE
+ printf("<= mBodyCacheOffset && offset < cacheEnd)
+ {
+ // body cache write through
+ ByteCount firstPart = std::min((SInt64)requestCount, cacheEnd - offset);
+#if VERBOSE
+ printf("body cache write through %lld %lu %lld %lu\n", mBodyCacheOffset, mBodyCacheCurSize, offset, firstPart);
+#endif
+ memcpy(mBodyCache + (offset - mBodyCacheOffset), buffer, firstPart);
+ }
+
+ UInt32 theActualCount;
+ err = mDataSource->WriteBytes(positionMode, positionOffset, requestCount, buffer, &theActualCount);
+
+ mOffset = offset + theActualCount;
+ if (actualCount) *actualCount = (UInt32)theActualCount;
+
+ return err;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////
+
+Seekable_DataSource::Seekable_DataSource( void * inClientData,
+ AudioFile_ReadProc inReadFunc,
+ AudioFile_WriteProc inWriteFunc,
+ AudioFile_GetSizeProc inGetSizeFunc,
+ AudioFile_SetSizeProc inSetSizeFunc)
+ : DataSource(false), mClientData(inClientData), mReadFunc(inReadFunc), mWriteFunc(inWriteFunc),
+ mSizeFunc(inGetSizeFunc), mSetSizeFunc(inSetSizeFunc)
+{
+}
+
+Seekable_DataSource::~Seekable_DataSource()
+{
+}
+
+
+OSStatus Seekable_DataSource::GetSize(SInt64& outSize)
+{
+ if (!mSizeFunc) {
+ outSize = LLONG_MAX;
+ } else {
+ outSize = (*mSizeFunc)(mClientData);
+ }
+ return noErr;
+}
+
+OSStatus Seekable_DataSource::SetSize(SInt64 inSize)
+{
+ if (!mSetSizeFunc) return kAudioFileOperationNotSupportedError;
+ return (*mSetSizeFunc)(mClientData, inSize);
+}
+
+OSStatus Seekable_DataSource::ReadBytes(
+ UInt16 positionMode,
+ SInt64 positionOffset,
+ UInt32 requestCount,
+ void *buffer,
+ UInt32* actualCount)
+{
+ OSStatus err;
+
+ if (actualCount) *actualCount = 0;
+ if (!mReadFunc) return kAudioFileOperationNotSupportedError;
+ if (!buffer) return kAudio_ParamError;
+
+ positionMode &= kPositionModeMask;
+
+ SInt64 size;
+ err = GetSize(size);
+ if (err) return err;
+
+ SInt64 offset = CalcOffset(positionMode, positionOffset, mOffset, size);
+
+ // request is outside bounds of file
+ if (offset < 0)
+ return kAudioFilePositionError;
+ if (offset >= size)
+ return kAudioFileEndOfFileError;
+
+ // reduce request if it exceeds the amount available
+ requestCount = static_cast(std::min((SInt64)requestCount, size - offset));
+
+ UInt32 theActualCount = 0;
+ err = (*mReadFunc)(mClientData, offset, requestCount, buffer, &theActualCount);
+ if (actualCount) *actualCount = theActualCount;
+ mOffset = offset + theActualCount;
+ return err;
+}
+
+
+OSStatus Seekable_DataSource::WriteBytes(
+ UInt16 positionMode,
+ SInt64 positionOffset,
+ UInt32 requestCount,
+ const void *buffer,
+ UInt32* actualCount)
+{
+ OSStatus err;
+
+ if (!mWriteFunc) return kAudioFileOperationNotSupportedError;
+ if (!buffer) return kAudio_ParamError;
+
+ SInt64 size;
+ positionMode &= kPositionModeMask;
+ if (positionMode != SEEK_END) size = 0; // not used in this case
+ else
+ {
+ err = GetSize(size);
+ if (err) return err;
+ }
+
+ SInt64 offset = CalcOffset(positionMode, positionOffset, mOffset, size);
+ if (offset < 0) return kAudioFilePositionError;
+
+ UInt32 theActualCount;
+ err = (*mWriteFunc)(mClientData, offset, requestCount, buffer, &theActualCount);
+ if (err) return err;
+ if (actualCount) *actualCount = theActualCount;
+ mOffset = offset + theActualCount;
+ return noErr;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+
+OSStatus Buffer_DataSource::ReadBytes(
+ UInt16 positionMode,
+ SInt64 positionOffset,
+ UInt32 requestCount,
+ void *buffer,
+ UInt32* actualCount)
+{
+ if (actualCount) *actualCount = 0;
+ SInt64 offsetWithinBuffer = CalcOffset(positionMode, positionOffset, mOffset, mDataByteSize + mStartOffset) - mStartOffset;
+ if (offsetWithinBuffer < 0 || offsetWithinBuffer >= mDataByteSize) return kAudioFilePositionError;
+
+ SInt64 bytesAfterOffset = mDataByteSize - offsetWithinBuffer;
+ SInt64 theActualCount = std::min(bytesAfterOffset, (SInt64)requestCount);
+
+ if (theActualCount <= 0) {
+ if (actualCount) *actualCount = 0;
+ return kAudio_ParamError;
+ }
+
+ memcpy(buffer, mData + offsetWithinBuffer, theActualCount);
+
+ if (actualCount) *actualCount = static_cast(theActualCount);
+ mOffset = offsetWithinBuffer + theActualCount;
+
+ return noErr;
+}
+
+
+
+//////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/DataSource.h b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/DataSource.h
new file mode 100644
index 000000000..6c79c94df
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioFile/AFPublic/DataSource.h
@@ -0,0 +1,372 @@
+/*
+ File: DataSource.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 __DataSource_h__
+#define __DataSource_h__
+
+#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
+ #include
+#else
+ #include
+ #include "AudioFile.h"
+#endif
+#include
+#include
+#include
+#include "CAAutoDisposer.h"
+
+//////////////////////////////////////////////////////////////////////////////////////////
+
+class DataSource
+{
+public:
+
+ DataSource(Boolean inCloseOnDelete);
+ virtual ~DataSource();
+
+ virtual OSStatus GetSize32(UInt32& outSize)
+ {
+ SInt64 size64;
+ OSStatus err = GetSize(size64);
+ if (err) return err;
+ if (size64 > 0x00000000FFFFffffLL) return kAudioFileDoesNotAllow64BitDataSizeError;
+ outSize = (UInt32)size64;
+ return noErr;
+ }
+
+ virtual OSStatus GetSize(SInt64& outSize) =0;
+
+ virtual OSStatus SetSize(SInt64 inSize)=0;
+
+ virtual OSStatus GetPos(SInt64& outPos) const=0;
+
+ /* non seekable data sources should use fsAtMark for the positionMode (or SEEK_CUR with offset zero,
+ or SEEK_SET with offset equal to the current position in the stream, in other words no seeking from the
+ current position is allowed.)
+ */
+
+ virtual OSStatus ReadBytes( UInt16 positionMode,
+ SInt64 positionOffset,
+ UInt32 requestCount,
+ void *buffer,
+ UInt32* actualCount)=0;
+
+ virtual OSStatus WriteBytes(UInt16 positionMode,
+ SInt64 positionOffset,
+ UInt32 requestCount,
+ const void *buffer,
+ UInt32* actualCount)=0;
+
+ virtual void SetCloseOnDelete(Boolean inFlag) { mCloseOnDelete = inFlag; }
+
+ virtual Boolean CanSeek() const=0;
+ virtual Boolean CanGetSize() const=0;
+ virtual Boolean CanSetSize() const=0;
+ virtual Boolean CanRead() const=0;
+ virtual Boolean CanWrite() const=0;
+
+protected:
+ Boolean mCloseOnDelete;
+
+ /* utility method */
+ SInt64 CalcOffset( UInt16 positionMode,
+ SInt64 positionOffset,
+ SInt64 currentOffset,
+ SInt64 size);
+};
+
+//////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////
+
+/*
+ Initialize with a Macintosh file fork ref num as obtained from FSOpenFork.
+*/
+
+#if 0
+
+class MacFile_DataSource : public DataSource
+{
+ FSIORefNum mFileNum;
+ SInt8 mPermissions;
+
+public:
+
+ MacFile_DataSource( FSIORefNum inForkRefNum, SInt8 inPermissions, Boolean inCloseOnDelete);
+ virtual ~MacFile_DataSource();
+
+ virtual OSStatus GetSize(SInt64& outSize);
+ virtual OSStatus GetPos(SInt64& outPos) const;
+
+ virtual OSStatus SetSize(SInt64 inSize);
+
+ virtual OSStatus ReadBytes( UInt16 positionMode,
+ SInt64 positionOffset,
+ UInt32 requestCount,
+ void *buffer,
+ UInt32* actualCount);
+
+ virtual OSStatus WriteBytes(UInt16 positionMode,
+ SInt64 positionOffset,
+ UInt32 requestCount,
+ const void *buffer,
+ UInt32* actualCount);
+
+ virtual Boolean CanSeek() const { return true; }
+ virtual Boolean CanGetSize() const { return true; }
+ virtual Boolean CanSetSize() const { return true; }
+
+ virtual Boolean CanRead() const { return mPermissions & kAudioFileReadPermission; }
+ virtual Boolean CanWrite() const { return mPermissions & kAudioFileWritePermission; }
+};
+#endif
+
+
+class UnixFile_DataSource : public DataSource
+{
+ int mFileD;
+ SInt8 mPermissions;
+ UInt32 mNoCache;
+ SInt64 mCachedSize;
+ SInt64 mFilePointer;
+
+public:
+
+ UnixFile_DataSource( int inFD, SInt8 inPermissions, Boolean inCloseOnDelete);
+ virtual ~UnixFile_DataSource();
+
+ virtual OSStatus GetSize(SInt64& outSize);
+ virtual OSStatus GetPos(SInt64& outPos) const;
+
+ virtual OSStatus SetSize(SInt64 inSize);
+
+ virtual OSStatus ReadBytes( UInt16 positionMode,
+ SInt64 positionOffset,
+ UInt32 requestCount,
+ void *buffer,
+ UInt32* actualCount);
+
+ virtual OSStatus WriteBytes(UInt16 positionMode,
+ SInt64 positionOffset,
+ UInt32 requestCount,
+ const void *buffer,
+ UInt32* actualCount);
+
+ virtual Boolean CanSeek() const { return true; }
+ virtual Boolean CanGetSize() const { return true; }
+ virtual Boolean CanSetSize() const { return true; }
+
+ virtual Boolean CanRead() const { return mPermissions & kAudioFileReadPermission; }
+ virtual Boolean CanWrite() const { return mPermissions & kAudioFileWritePermission; }
+
+private:
+
+ SInt64 UFCurrentOffset (UInt16 positionMode,
+ SInt64 positionOffset);
+};
+
+//////////////////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////////////////
+
+/*
+ A wrapper that caches the wrapped source's header.
+*/
+class Cached_DataSource : public DataSource
+{
+ DataSource* mDataSource;
+ CAAutoFree mHeaderCache;
+ UInt32 mHeaderCacheSize;
+ CAAutoFree mBodyCache;
+ UInt32 mBodyCacheSize;
+ UInt32 mBodyCacheCurSize;
+ SInt64 mBodyCacheOffset;
+ SInt64 mOffset;
+ Boolean mOwnDataSource;
+
+public:
+
+ Cached_DataSource(DataSource* inDataSource, UInt32 inHeaderCacheSize = 4096, UInt32 inBodyCacheSize = 32768, Boolean inOwnDataSource = true)
+ : DataSource(false),
+ mDataSource(inDataSource), mHeaderCacheSize(inHeaderCacheSize),
+ mBodyCacheSize(inBodyCacheSize), mBodyCacheCurSize(0), mBodyCacheOffset(-1),
+ mOffset(0),
+ mOwnDataSource(inOwnDataSource)
+ {
+ }
+
+ virtual ~Cached_DataSource()
+ {
+ if (mOwnDataSource) delete mDataSource;
+ }
+
+
+ virtual OSStatus GetSize(SInt64& outSize) { return mDataSource->GetSize(outSize); }
+ virtual OSStatus GetPos(SInt64& outPos) const { return mDataSource->GetPos(outPos); }
+
+ virtual OSStatus SetSize(SInt64 inSize) { return mDataSource->SetSize(inSize); }
+
+ virtual OSStatus ReadBytes( UInt16 positionMode,
+ SInt64 positionOffset,
+ UInt32 requestCount,
+ void *buffer,
+ UInt32* actualCount);
+
+ virtual OSStatus WriteBytes( UInt16 positionMode,
+ SInt64 positionOffset,
+ UInt32 requestCount,
+ const void *buffer,
+ UInt32* actualCount);
+
+ OSStatus ReadFromHeaderCache( SInt64 offset,
+ UInt32 requestCount,
+ void *buffer,
+ UInt32* actualCount);
+
+ virtual Boolean CanSeek() const { return mDataSource->CanSeek(); }
+ virtual Boolean CanGetSize() const { return mDataSource->CanGetSize(); }
+ virtual Boolean CanSetSize() const { return mDataSource->CanSetSize(); }
+
+ virtual Boolean CanRead() const { return mDataSource->CanRead(); }
+ virtual Boolean CanWrite() const { return mDataSource->CanWrite(); }
+};
+
+//////////////////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////////////////
+
+
+/* This class calls user supplied routines on demand. */
+
+class Seekable_DataSource : public DataSource
+{
+ void * mClientData;
+ SInt64 mOffset;
+
+ AudioFile_ReadProc mReadFunc;
+ AudioFile_WriteProc mWriteFunc;
+ AudioFile_GetSizeProc mSizeFunc;
+ AudioFile_SetSizeProc mSetSizeFunc;
+
+public:
+ Seekable_DataSource( void * inClientData,
+ AudioFile_ReadProc inReadFunc,
+ AudioFile_WriteProc inWriteFunc,
+ AudioFile_GetSizeProc inGetSizeFunc,
+ AudioFile_SetSizeProc inSetSizeFunc
+ );
+
+ virtual ~Seekable_DataSource();
+
+ virtual OSStatus GetSize(SInt64& outSize);
+ virtual OSStatus GetPos(SInt64& outPos) const { outPos = mOffset; return noErr; };
+
+ virtual OSStatus SetSize(SInt64 inSize);
+
+ virtual OSStatus ReadBytes( UInt16 positionMode,
+ SInt64 positionOffset,
+ UInt32 requestCount,
+ void *buffer,
+ UInt32* actualCount);
+
+ virtual OSStatus WriteBytes(UInt16 positionMode,
+ SInt64 positionOffset,
+ UInt32 requestCount,
+ const void *buffer,
+ UInt32* actualCount);
+
+ virtual Boolean CanSeek() const { return true; }
+ virtual Boolean CanGetSize() const { return mSizeFunc != 0; }
+ virtual Boolean CanSetSize() const { return mSetSizeFunc != 0; }
+ virtual Boolean CanRead() const { return mReadFunc != 0; }
+ virtual Boolean CanWrite() const { return mWriteFunc != 0; }
+};
+
+//////////////////////////////////////////////////////////////////////////////////////////
+
+class Buffer_DataSource : public DataSource
+{
+ UInt32 mDataByteSize;
+ const char * mData;
+
+ SInt64 mStartOffset;
+ SInt64 mOffset;
+public:
+ Buffer_DataSource( UInt32 inDataByteSize,
+ const void * inData,
+ SInt64 inStartOffset = 0
+ ) : DataSource(false), mDataByteSize(inDataByteSize), mData((const char*)inData), mStartOffset(inStartOffset), mOffset(mStartOffset) {}
+
+ virtual ~Buffer_DataSource() {}
+
+ virtual OSStatus GetSize(SInt64& outSize) { outSize = mDataByteSize + mStartOffset; return noErr; }
+ virtual OSStatus GetPos(SInt64& outPos) const { outPos = mOffset; return noErr; };
+
+ virtual OSStatus SetSize(SInt64 inSize) { throw std::runtime_error("not writable"); }
+
+ virtual OSStatus ReadBytes( UInt16 positionMode,
+ SInt64 positionOffset,
+ UInt32 requestCount,
+ void *buffer,
+ UInt32* actualCount);
+
+ virtual OSStatus WriteBytes(UInt16 positionMode,
+ SInt64 positionOffset,
+ UInt32 requestCount,
+ const void *buffer,
+ UInt32* actualCount) { throw std::runtime_error("not writable"); }
+
+ virtual Boolean CanSeek() const { return true; }
+ virtual Boolean CanGetSize() const { return true; }
+ virtual Boolean CanSetSize() const { return false; }
+ virtual Boolean CanRead() const { return true; }
+ virtual Boolean CanWrite() const { return false; }
+};
+
+//////////////////////////////////////////////////////////////////////////////////////////
+
+#endif
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUBase.cpp b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUBase.cpp
new file mode 100644
index 000000000..612bc4d30
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUBase.cpp
@@ -0,0 +1,2393 @@
+/*
+ File: AUBase.cpp
+ Abstract: AUBase.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 "AUBase.h"
+#include "AUDispatch.h"
+#include "AUInputElement.h"
+#include "AUOutputElement.h"
+#include
+#include
+#include "CAAudioChannelLayout.h"
+#include "CAHostTimeBase.h"
+#include "CAVectorUnit.h"
+#include "CAXException.h"
+
+
+
+#if TARGET_OS_MAC && (TARGET_CPU_X86 || TARGET_CPU_X86_64)
+ // our compiler does ALL floating point with SSE
+ inline int GETCSR () { int _result; asm volatile ("stmxcsr %0" : "=m" (*&_result) ); return _result; }
+ inline void SETCSR (int a) { int _temp = a; asm volatile( "ldmxcsr %0" : : "m" (*&_temp ) ); }
+
+ #define DISABLE_DENORMALS int _savemxcsr = GETCSR(); SETCSR(_savemxcsr | 0x8040);
+ #define RESTORE_DENORMALS SETCSR(_savemxcsr);
+#else
+ #define DISABLE_DENORMALS
+ #define RESTORE_DENORMALS
+#endif
+
+static bool sAUBaseCFStringsInitialized = false;
+// this is used for the presets
+static CFStringRef kUntitledString = NULL;
+//these are the current keys for the class info document
+static CFStringRef kVersionString = NULL;
+static CFStringRef kTypeString = NULL;
+static CFStringRef kSubtypeString = NULL;
+static CFStringRef kManufacturerString = NULL;
+static CFStringRef kDataString = NULL;
+static CFStringRef kNameString = NULL;
+static CFStringRef kRenderQualityString = NULL;
+static CFStringRef kCPULoadString = NULL;
+static CFStringRef kElementNameString = NULL;
+static CFStringRef kPartString = NULL;
+
+SInt32 AUBase::sVectorUnitType = kVecUninitialized;
+
+//_____________________________________________________________________________
+//
+AUBase::AUBase( AudioComponentInstance inInstance,
+ UInt32 numInputElements,
+ UInt32 numOutputElements,
+ UInt32 numGroupElements) :
+ ComponentBase(inInstance),
+ mElementsCreated(false),
+ mInitialized(false),
+ mHasBegunInitializing(false),
+ mInitNumInputEls(numInputElements), mInitNumOutputEls(numOutputElements),
+#if !CA_BASIC_AU_FEATURES
+ mInitNumGroupEls(numGroupElements),
+#endif
+ mRenderCallbacksTouched(false),
+ mRenderThreadID (NULL),
+ mWantsRenderThreadID (false),
+ mLastRenderError(0),
+ mUsesFixedBlockSize(false),
+ mBuffersAllocated(false),
+ mLogString (NULL),
+ mNickName (NULL),
+ mAUMutex(NULL)
+ #if !CA_NO_AU_UI_FEATURES
+ ,
+ mContextName(NULL)
+ #endif
+{
+ ResetRenderTime ();
+
+ if(!sAUBaseCFStringsInitialized)
+ {
+ kUntitledString = CFSTR("Untitled");
+ kVersionString = CFSTR(kAUPresetVersionKey);
+ kTypeString = CFSTR(kAUPresetTypeKey);
+ kSubtypeString = CFSTR(kAUPresetSubtypeKey);
+ kManufacturerString = CFSTR(kAUPresetManufacturerKey);
+ kDataString = CFSTR(kAUPresetDataKey);
+ kNameString = CFSTR(kAUPresetNameKey);
+ kRenderQualityString = CFSTR(kAUPresetRenderQualityKey);
+ kCPULoadString = CFSTR(kAUPresetCPULoadKey);
+ kElementNameString = CFSTR(kAUPresetElementNameKey);
+ kPartString = CFSTR(kAUPresetPartKey);
+ sAUBaseCFStringsInitialized = true;
+ }
+
+ if (sVectorUnitType == kVecUninitialized) {
+ sVectorUnitType = CAVectorUnit::GetVectorUnitType() ;
+ }
+
+ mAudioUnitAPIVersion = 2;
+
+ SetMaxFramesPerSlice(kAUDefaultMaxFramesPerSlice);
+
+ GlobalScope().Initialize(this, kAudioUnitScope_Global, 1);
+
+#if !CA_NO_AU_UI_FEATURES
+ memset (&mHostCallbackInfo, 0, sizeof (mHostCallbackInfo));
+#endif
+
+
+ mCurrentPreset.presetNumber = -1;
+ mCurrentPreset.presetName = kUntitledString;
+ CFRetain (mCurrentPreset.presetName);
+}
+
+//_____________________________________________________________________________
+//
+AUBase::~AUBase()
+{
+ if (mCurrentPreset.presetName) CFRelease (mCurrentPreset.presetName);
+#if !CA_NO_AU_UI_FEATURES
+ if (mContextName) CFRelease (mContextName);
+#endif
+ if (mLogString) delete [] mLogString;
+ if (mNickName) CFRelease(mNickName);
+}
+
+//_____________________________________________________________________________
+//
+void AUBase::CreateElements()
+{
+ if (!mElementsCreated) {
+ Inputs().Initialize(this, kAudioUnitScope_Input, mInitNumInputEls);
+ Outputs().Initialize(this, kAudioUnitScope_Output, mInitNumOutputEls);
+#if !CA_BASIC_AU_FEATURES
+ Groups().Initialize(this, kAudioUnitScope_Group, mInitNumGroupEls);
+#endif
+ CreateExtendedElements();
+
+ mElementsCreated = true;
+ }
+}
+
+//_____________________________________________________________________________
+//
+void AUBase::SetMaxFramesPerSlice(UInt32 nFrames)
+{
+ mMaxFramesPerSlice = nFrames;
+ if (mBuffersAllocated)
+ ReallocateBuffers();
+ PropertyChanged(kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Global, 0);
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::CanSetMaxFrames() const
+{
+ return IsInitialized() ? kAudioUnitErr_Initialized : OSStatus(noErr);
+}
+
+//_____________________________________________________________________________
+//
+void AUBase::ReallocateBuffers()
+{
+ CreateElements();
+
+ UInt32 nOutputs = Outputs().GetNumberOfElements();
+ for (UInt32 i = 0; i < nOutputs; ++i) {
+ AUOutputElement *output = GetOutput(i);
+ output->AllocateBuffer(); // does no work if already allocated
+ }
+ UInt32 nInputs = Inputs().GetNumberOfElements();
+ for (UInt32 i = 0; i < nInputs; ++i) {
+ AUInputElement *input = GetInput(i);
+ input->AllocateBuffer(); // does no work if already allocated
+ }
+ mBuffersAllocated = true;
+}
+
+//_____________________________________________________________________________
+//
+void AUBase::DeallocateIOBuffers()
+{
+ if (!mBuffersAllocated)
+ return;
+
+ UInt32 nOutputs = Outputs().GetNumberOfElements();
+ for (UInt32 i = 0; i < nOutputs; ++i) {
+ AUOutputElement *output = GetOutput(i);
+ output->DeallocateBuffer();
+ }
+ UInt32 nInputs = Inputs().GetNumberOfElements();
+ for (UInt32 i = 0; i < nInputs; ++i) {
+ AUInputElement *input = GetInput(i);
+ input->DeallocateBuffer();
+ }
+ mBuffersAllocated = false;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::DoInitialize()
+{
+ OSStatus result = noErr;
+
+ if (!mInitialized) {
+ result = Initialize();
+ if (result == noErr) {
+ if (CanScheduleParameters())
+ mParamList.reserve(24);
+ mHasBegunInitializing = true;
+ ReallocateBuffers(); // calls CreateElements()
+ mInitialized = true; // signal that it's okay to render
+ CAMemoryBarrier();
+ }
+ }
+
+ return result;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::Initialize()
+{
+ return noErr;
+}
+
+//_____________________________________________________________________________
+//
+void AUBase::PreDestructor()
+{
+ // this is called from the ComponentBase dispatcher, which doesn't know anything about our (optional) lock
+ CAMutex::Locker lock(mAUMutex);
+ DoCleanup();
+}
+
+//_____________________________________________________________________________
+//
+void AUBase::DoCleanup()
+{
+ if (mInitialized)
+ Cleanup();
+
+ DeallocateIOBuffers();
+ ResetRenderTime ();
+
+ mInitialized = false;
+ mHasBegunInitializing = false;
+}
+
+//_____________________________________________________________________________
+//
+void AUBase::Cleanup()
+{
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::Reset( AudioUnitScope inScope,
+ AudioUnitElement inElement)
+{
+ ResetRenderTime ();
+ return noErr;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::DispatchGetPropertyInfo(AudioUnitPropertyID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ UInt32 & outDataSize,
+ Boolean & outWritable)
+{
+ OSStatus result = noErr;
+ bool validateElement = true;
+
+ switch (inID) {
+ case kAudioUnitProperty_MakeConnection:
+ ca_require(inScope == kAudioUnitScope_Input || inScope == kAudioUnitScope_Global, InvalidScope);
+ outDataSize = sizeof(AudioUnitConnection);
+ outWritable = true;
+ break;
+
+
+ case kAudioUnitProperty_SetRenderCallback:
+ ca_require(AudioUnitAPIVersion() > 1, InvalidProperty);
+ ca_require(inScope == kAudioUnitScope_Input || inScope == kAudioUnitScope_Global, InvalidScope);
+ outDataSize = sizeof(AURenderCallbackStruct);
+ outWritable = true;
+ break;
+
+ case kAudioUnitProperty_StreamFormat:
+ outDataSize = sizeof(CAStreamBasicDescription);
+ outWritable = IsStreamFormatWritable(inScope, inElement);
+ break;
+
+ case kAudioUnitProperty_SampleRate:
+ outDataSize = sizeof(Float64);
+ outWritable = IsStreamFormatWritable(inScope, inElement);
+ break;
+
+ case kAudioUnitProperty_ClassInfo:
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+ outDataSize = sizeof(CFPropertyListRef);
+ outWritable = true;
+ break;
+
+ case kAudioUnitProperty_FactoryPresets:
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+ result = GetPresets(NULL);
+ if (!result) {
+ outDataSize = sizeof(CFArrayRef);
+ outWritable = false;
+ }
+ break;
+
+ case kAudioUnitProperty_PresentPreset:
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+#ifndef __LP64__
+ case kAudioUnitProperty_CurrentPreset:
+#endif
+#endif
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+ outDataSize = sizeof(AUPreset);
+ outWritable = true;
+ break;
+
+ case kAudioUnitProperty_ElementName:
+ outDataSize = sizeof (CFStringRef);
+ outWritable = true;
+ break;
+
+ case kAudioUnitProperty_ParameterList:
+ {
+ UInt32 nparams = 0;
+ result = GetParameterList(inScope, NULL, nparams);
+
+ outDataSize = sizeof(AudioUnitParameterID) * nparams;
+ outWritable = false;
+ validateElement = false;
+ }
+ break;
+
+ case kAudioUnitProperty_ParameterInfo:
+ outDataSize = sizeof(AudioUnitParameterInfo);
+ outWritable = false;
+ validateElement = false;
+ break;
+
+ case kAudioUnitProperty_ParameterHistoryInfo:
+ outDataSize = sizeof(AudioUnitParameterHistoryInfo);
+ outWritable = false;
+ validateElement = false;
+ break;
+
+ case kAudioUnitProperty_ElementCount:
+ outDataSize = sizeof(UInt32);
+ outWritable = BusCountWritable(inScope);
+ validateElement = false;
+ break;
+
+ case kAudioUnitProperty_Latency:
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+ outDataSize = sizeof(Float64);
+ outWritable = false;
+ break;
+
+ case kAudioUnitProperty_TailTime:
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+ if (SupportsTail()) {
+ outDataSize = sizeof(Float64);
+ outWritable = false;
+ } else
+ goto InvalidProperty;
+ break;
+
+ case kAudioUnitProperty_MaximumFramesPerSlice:
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+ outDataSize = sizeof(UInt32);
+ outWritable = true;
+ break;
+
+ case kAudioUnitProperty_LastRenderError:
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+ outDataSize = sizeof(OSStatus);
+ outWritable = false;
+ break;
+
+ case kAudioUnitProperty_SupportedNumChannels:
+ {
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+ UInt32 num = SupportedNumChannels (NULL);
+ if (num) {
+ outDataSize = sizeof (AUChannelInfo) * num;
+ result = noErr;
+ } else
+ goto InvalidProperty;
+ outWritable = false;
+ break;
+ }
+
+ case kAudioUnitProperty_SupportedChannelLayoutTags:
+ {
+ UInt32 numLayouts = GetChannelLayoutTags(inScope, inElement, NULL);
+ if (numLayouts) {
+ outDataSize = numLayouts * sizeof(AudioChannelLayoutTag);
+ result = noErr;
+ } else
+ goto InvalidProperty;
+ outWritable = false;
+ validateElement = false; //already done it
+ break;
+ }
+
+ case kAudioUnitProperty_AudioChannelLayout:
+ {
+ outWritable = false;
+ outDataSize = GetAudioChannelLayout(inScope, inElement, NULL, outWritable);
+ if (outDataSize) {
+ result = noErr;
+ } else {
+ if (GetChannelLayoutTags(inScope, inElement, NULL) == 0)
+ goto InvalidProperty;
+ else
+ result = kAudioUnitErr_InvalidPropertyValue;
+ }
+ validateElement = false; //already done it
+ break;
+ }
+
+#if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5) || TARGET_OS_IPHONE
+ case kAudioUnitProperty_ShouldAllocateBuffer:
+ ca_require((inScope == kAudioUnitScope_Input || inScope == kAudioUnitScope_Output), InvalidScope);
+ outWritable = true;
+ outDataSize = sizeof(UInt32);
+ break;
+#endif
+
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+ case kAudioUnitProperty_FastDispatch:
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+ if (!IsCMgrObject()) goto InvalidProperty;
+ outDataSize = sizeof(void *);
+ outWritable = false;
+ validateElement = false;
+ break;
+
+ case kAudioUnitProperty_GetUIComponentList:
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+ outDataSize = GetNumCustomUIComponents();
+ if (outDataSize == 0)
+ goto InvalidProperty;
+ outDataSize *= sizeof (AudioComponentDescription);
+
+ outWritable = false;
+ break;
+#endif
+
+ case kAudioUnitProperty_ParameterValueStrings:
+ result = GetParameterValueStrings(inScope, inElement, NULL);
+ if (result == noErr) {
+ outDataSize = sizeof(CFArrayRef);
+ outWritable = false;
+ validateElement = false;
+ }
+ break;
+
+#if !CA_NO_AU_HOST_CALLBACKS
+ case kAudioUnitProperty_HostCallbacks:
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+ outDataSize = sizeof(mHostCallbackInfo);
+ outWritable = true;
+ break;
+#endif
+#if !CA_NO_AU_UI_FEATURES
+ case kAudioUnitProperty_ContextName:
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+ outDataSize = sizeof(CFStringRef);
+ outWritable = true;
+ break;
+
+ case kAudioUnitProperty_IconLocation:
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+ outWritable = false;
+ if (!HasIcon())
+ goto InvalidProperty;
+ outDataSize = sizeof(CFURLRef);
+ break;
+
+ case kAudioUnitProperty_ParameterClumpName:
+ outDataSize = sizeof(AudioUnitParameterNameInfo );
+ outWritable = false;
+ break;
+
+#endif // !CA_NO_AU_UI_FEATURES
+
+ case 'lrst' : // kAudioUnitProperty_LastRenderedSampleTime
+ outDataSize = sizeof(Float64);
+ outWritable = false;
+ break;
+
+ case kAudioUnitProperty_NickName:
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+ outDataSize = sizeof(CFStringRef);
+ outWritable = true;
+ break;
+
+ default:
+ result = GetPropertyInfo(inID, inScope, inElement, outDataSize, outWritable);
+ validateElement = false;
+ break;
+ }
+
+ if (result == noErr && validateElement) {
+ ca_require(GetElement(inScope, inElement) != NULL, InvalidElement);
+ }
+
+ return result;
+InvalidProperty:
+ return kAudioUnitErr_InvalidProperty;
+InvalidScope:
+ return kAudioUnitErr_InvalidScope;
+InvalidElement:
+ return kAudioUnitErr_InvalidElement;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::DispatchGetProperty( AudioUnitPropertyID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ void * outData)
+{
+ // NOTE: We're currently only called from AUBase::ComponentEntryDispatch, which
+ // calls DispatchGetPropertyInfo first, which performs validation of the scope/element,
+ // and ensures that the outData buffer is non-null and large enough.
+ OSStatus result = noErr;
+
+ switch (inID) {
+ case kAudioUnitProperty_StreamFormat:
+ *(CAStreamBasicDescription *)outData = GetStreamFormat(inScope, inElement);
+ break;
+
+ case kAudioUnitProperty_SampleRate:
+ *(Float64 *)outData = GetStreamFormat(inScope, inElement).mSampleRate;
+ break;
+
+ case kAudioUnitProperty_ParameterList:
+ {
+ UInt32 nparams = 0;
+ result = GetParameterList(inScope, (AudioUnitParameterID *)outData, nparams);
+ }
+ break;
+
+ case kAudioUnitProperty_ParameterInfo:
+ result = GetParameterInfo(inScope, inElement, *(AudioUnitParameterInfo *)outData);
+ break;
+
+ case kAudioUnitProperty_ParameterHistoryInfo:
+ {
+ AudioUnitParameterHistoryInfo* info = (AudioUnitParameterHistoryInfo*)outData;
+ result = GetParameterHistoryInfo(inScope, inElement, info->updatesPerSecond, info->historyDurationInSeconds);
+ }
+ break;
+
+ case kAudioUnitProperty_ClassInfo:
+ {
+ *(CFPropertyListRef *)outData = NULL;
+ result = SaveState((CFPropertyListRef *)outData);
+ }
+ break;
+
+ case kAudioUnitProperty_FactoryPresets:
+ {
+ *(CFArrayRef *)outData = NULL;
+ result = GetPresets ((CFArrayRef *)outData);
+ }
+ break;
+
+ case kAudioUnitProperty_PresentPreset:
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+#ifndef __LP64__
+ case kAudioUnitProperty_CurrentPreset:
+#endif
+#endif
+ {
+ *(AUPreset *)outData = mCurrentPreset;
+
+ // retain current string (as client owns a reference to it and will release it)
+ if (inID == kAudioUnitProperty_PresentPreset && mCurrentPreset.presetName)
+ CFRetain (mCurrentPreset.presetName);
+
+ result = noErr;
+ }
+ break;
+
+ case kAudioUnitProperty_ElementName:
+ {
+ AUElement * element = GetElement(inScope, inElement);
+ if (element->HasName()) {
+ *(CFStringRef *)outData = element->GetName();
+ CFRetain (element->GetName());
+ result = noErr;
+ } else
+ result = kAudioUnitErr_InvalidPropertyValue;
+ }
+ break;
+
+ case kAudioUnitProperty_ElementCount:
+ *(UInt32 *)outData = GetScope(inScope).GetNumberOfElements();
+ break;
+
+ case kAudioUnitProperty_Latency:
+ *(Float64 *)outData = GetLatency();
+ break;
+
+ case kAudioUnitProperty_TailTime:
+ if (SupportsTail())
+ *(Float64 *)outData = GetTailTime();
+ else
+ result = kAudioUnitErr_InvalidProperty;
+ break;
+
+ case kAudioUnitProperty_MaximumFramesPerSlice:
+ *(UInt32 *)outData = mMaxFramesPerSlice;
+ break;
+
+ case kAudioUnitProperty_LastRenderError:
+ *(OSStatus *)outData = mLastRenderError;
+ mLastRenderError = 0;
+ break;
+
+ case kAudioUnitProperty_SupportedNumChannels:
+ {
+ const AUChannelInfo* infoPtr = NULL;
+ UInt32 num = SupportedNumChannels (&infoPtr);
+ if(num != 0 && infoPtr != NULL)
+ memcpy (outData, infoPtr, num * sizeof (AUChannelInfo));
+ }
+ break;
+
+ case kAudioUnitProperty_SupportedChannelLayoutTags:
+ {
+ AudioChannelLayoutTag* ptr = outData ? static_cast(outData) : NULL;
+ UInt32 numLayouts = GetChannelLayoutTags (inScope, inElement, ptr);
+ if (numLayouts == 0)
+ result = kAudioUnitErr_InvalidProperty;
+ }
+ break;
+
+ case kAudioUnitProperty_AudioChannelLayout:
+ {
+ AudioChannelLayout* ptr = outData ? static_cast(outData) : NULL;
+ Boolean writable;
+ UInt32 dataSize = GetAudioChannelLayout(inScope, inElement, ptr, writable);
+ if (!dataSize) {
+ result = kAudioUnitErr_InvalidProperty;
+ }
+ break;
+ }
+
+#if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5) || TARGET_OS_IPHONE
+ case kAudioUnitProperty_ShouldAllocateBuffer:
+ {
+ AUIOElement * element = GetIOElement(inScope, inElement);
+ *(UInt32*)outData = element->WillAllocateBuffer();
+ break;
+ }
+#endif
+
+ case kAudioUnitProperty_ParameterValueStrings:
+ result = GetParameterValueStrings(inScope, inElement, (CFArrayRef *)outData);
+ break;
+
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+ case kAudioUnitProperty_FastDispatch:
+ if (!IsCMgrObject()) result = kAudioUnitErr_InvalidProperty;
+ else {
+ switch (inElement) {
+ case kAudioUnitGetParameterSelect:
+ *(AudioUnitGetParameterProc *)outData = (AudioUnitGetParameterProc)CMgr_AudioUnitBaseGetParameter;
+ break;
+ case kAudioUnitSetParameterSelect:
+ *(AudioUnitSetParameterProc *)outData = (AudioUnitSetParameterProc)CMgr_AudioUnitBaseSetParameter;
+ break;
+ case kAudioUnitRenderSelect:
+ if (AudioUnitAPIVersion() > 1)
+ *(AudioUnitRenderProc *)outData = (AudioUnitRenderProc)CMgr_AudioUnitBaseRender;
+ else result = kAudioUnitErr_InvalidElement;
+ break;
+ default:
+ result = GetProperty(inID, inScope, inElement, outData);
+ break;
+ }
+ }
+ break;
+
+ case kAudioUnitProperty_GetUIComponentList:
+ GetUIComponentDescs ((ComponentDescription*)outData);
+ break;
+#endif
+
+#if !CA_NO_AU_HOST_CALLBACKS
+ case kAudioUnitProperty_HostCallbacks:
+ memcpy(outData, &mHostCallbackInfo, sizeof(mHostCallbackInfo));
+ break;
+#endif
+#if !CA_NO_AU_UI_FEATURES
+ case kAudioUnitProperty_IconLocation:
+ {
+ CFURLRef iconLocation = CopyIconLocation();
+ if (iconLocation) {
+ *(CFURLRef*)outData = iconLocation;
+ } else
+ result = kAudioUnitErr_InvalidProperty;
+ }
+ break;
+
+ case kAudioUnitProperty_ContextName:
+ *(CFStringRef *)outData = mContextName;
+ if (mContextName) {
+ CFRetain(mContextName);
+ // retain CFString (if exists) since client will be responsible for its release
+ result = noErr;
+ } else {
+ result = kAudioUnitErr_InvalidPropertyValue;
+ }
+ break;
+
+ case kAudioUnitProperty_ParameterClumpName:
+ {
+ AudioUnitParameterNameInfo * ioClumpInfo = (AudioUnitParameterNameInfo*) outData;
+ if (ioClumpInfo->inID == kAudioUnitClumpID_System) // this ID value is reserved
+ result = kAudioUnitErr_InvalidPropertyValue;
+ else
+ {
+ result = CopyClumpName(inScope, ioClumpInfo->inID, ioClumpInfo->inDesiredLength, &ioClumpInfo->outName);
+
+ // this is provided for compatbility with existing implementations that don't know
+ // about this new mechanism
+ if (result == kAudioUnitErr_InvalidProperty)
+ result = GetProperty (inID, inScope, inElement, outData);
+ }
+ }
+ break;
+
+#endif // !CA_NO_AU_UI_FEATURES
+
+ case 'lrst' : // kAudioUnitProperty_LastRenderedSampleTime
+ *(Float64*)outData = mCurrentRenderTime.mSampleTime;
+ break;
+
+ case kAudioUnitProperty_NickName:
+ // Ownership follows Core Foundation's 'Copy Rule'
+ if (mNickName) CFRetain(mNickName);
+ *(CFStringRef*)outData = mNickName;
+ break;
+
+ default:
+ result = GetProperty(inID, inScope, inElement, outData);
+ break;
+ }
+ return result;
+}
+
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::DispatchSetProperty( AudioUnitPropertyID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ const void * inData,
+ UInt32 inDataSize)
+{
+ OSStatus result = noErr;
+
+ switch (inID) {
+ case kAudioUnitProperty_MakeConnection:
+ ca_require(inDataSize >= sizeof(AudioUnitConnection), InvalidPropertyValue);
+ {
+ AudioUnitConnection &connection = *(AudioUnitConnection *)inData;
+ result = SetConnection(connection);
+ }
+ break;
+
+
+ case kAudioUnitProperty_SetRenderCallback:
+ {
+ ca_require(inDataSize >= sizeof(AURenderCallbackStruct), InvalidPropertyValue);
+ ca_require(AudioUnitAPIVersion() > 1, InvalidProperty);
+ AURenderCallbackStruct &callback = *(AURenderCallbackStruct*)inData;
+ result = SetInputCallback(kAudioUnitProperty_SetRenderCallback, inElement, callback.inputProc, callback.inputProcRefCon);
+ }
+ break;
+
+ case kAudioUnitProperty_ElementCount:
+ ca_require(inDataSize == sizeof(UInt32), InvalidPropertyValue);
+ ca_require(BusCountWritable(inScope), NotWritable);
+ result = SetBusCount(inScope, *(UInt32*)inData);
+ if (result == noErr) {
+ PropertyChanged(inID, inScope, inElement);
+ }
+ break;
+
+ case kAudioUnitProperty_MaximumFramesPerSlice:
+ ca_require(inDataSize == sizeof(UInt32), InvalidPropertyValue);
+ result = CanSetMaxFrames();
+ if (result) return result;
+ SetMaxFramesPerSlice(*(UInt32 *)inData);
+ break;
+
+ case kAudioUnitProperty_StreamFormat:
+ {
+ if (inDataSize < 36) goto InvalidPropertyValue;
+ ca_require(GetElement(inScope, inElement) != NULL, InvalidElement);
+
+ CAStreamBasicDescription newDesc;
+ // now we're going to be ultra conservative! because of discrepancies between
+ // sizes of this struct based on aligment padding inconsistencies
+ memset (&newDesc, 0, sizeof(newDesc));
+ memcpy (&newDesc, inData, 36);
+
+ ca_require(ValidFormat(inScope, inElement, newDesc), InvalidFormat);
+
+ const CAStreamBasicDescription curDesc = GetStreamFormat(inScope, inElement);
+
+ if ( !curDesc.IsEqual(newDesc, false) ) {
+ ca_require(IsStreamFormatWritable(inScope, inElement), NotWritable);
+ result = ChangeStreamFormat(inScope, inElement, curDesc, newDesc);
+ }
+ }
+ break;
+
+ case kAudioUnitProperty_SampleRate:
+ {
+ ca_require(inDataSize == sizeof(Float64), InvalidPropertyValue);
+ ca_require(GetElement(inScope, inElement) != NULL, InvalidElement);
+
+ const CAStreamBasicDescription curDesc = GetStreamFormat(inScope, inElement);
+ CAStreamBasicDescription newDesc = curDesc;
+ newDesc.mSampleRate = *(Float64 *)inData;
+
+ ca_require(ValidFormat(inScope, inElement, newDesc), InvalidFormat);
+
+ if ( !curDesc.IsEqual(newDesc, false) ) {
+ ca_require(IsStreamFormatWritable(inScope, inElement), NotWritable);
+ result = ChangeStreamFormat(inScope, inElement, curDesc, newDesc);
+ }
+ }
+ break;
+
+ case kAudioUnitProperty_AudioChannelLayout:
+ {
+ const AudioChannelLayout *layout = static_cast(inData);
+ size_t headerSize = sizeof(AudioChannelLayout) - sizeof(AudioChannelDescription);
+
+ ca_require(inDataSize >= headerSize + layout->mNumberChannelDescriptions * sizeof(AudioChannelDescription), InvalidPropertyValue);
+ result = SetAudioChannelLayout(inScope, inElement, layout);
+ if (result == noErr)
+ PropertyChanged(inID, inScope, inElement);
+ break;
+ }
+
+ case kAudioUnitProperty_ClassInfo:
+ ca_require(inDataSize == sizeof(CFPropertyListRef *), InvalidPropertyValue);
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+ result = RestoreState(*(CFPropertyListRef *)inData);
+ break;
+
+ case kAudioUnitProperty_PresentPreset:
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+#ifndef __LP64__
+ case kAudioUnitProperty_CurrentPreset:
+#endif
+#endif
+ {
+ ca_require(inDataSize == sizeof(AUPreset), InvalidPropertyValue);
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+ AUPreset & newPreset = *(AUPreset *)inData;
+
+ if (newPreset.presetNumber >= 0)
+ {
+ result = NewFactoryPresetSet(newPreset);
+ // NewFactoryPresetSet SHOULD call SetAFactoryPreset if the preset is valid
+ // from its own list of preset number->name
+ if (!result)
+ PropertyChanged(inID, inScope, inElement);
+ }
+ else if (newPreset.presetName)
+ {
+ result = NewCustomPresetSet(newPreset);
+ if (!result)
+ PropertyChanged(inID, inScope, inElement);
+ }
+ else
+ result = kAudioUnitErr_InvalidPropertyValue;
+ }
+ break;
+
+ case kAudioUnitProperty_ElementName:
+ {
+ ca_require(GetElement(inScope, inElement) != NULL, InvalidElement);
+ ca_require(inDataSize == sizeof(CFStringRef), InvalidPropertyValue);
+ AUElement * element = GetScope(inScope).GetElement (inElement);
+ element->SetName (*(CFStringRef *)inData);
+ PropertyChanged(inID, inScope, inElement);
+ }
+ break;
+
+#if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5) || TARGET_OS_IPHONE
+ case kAudioUnitProperty_ShouldAllocateBuffer:
+ {
+ ca_require((inScope == kAudioUnitScope_Input || inScope == kAudioUnitScope_Output), InvalidScope);
+ ca_require(GetElement(inScope, inElement) != NULL, InvalidElement);
+ ca_require(inDataSize == sizeof(UInt32), InvalidPropertyValue);
+ ca_require(!IsInitialized(), Initialized);
+
+ AUIOElement * element = GetIOElement(inScope, inElement);
+ element->SetWillAllocateBuffer(*(UInt32 *)inData != 0);
+ }
+ break;
+#endif
+
+#if !CA_NO_AU_HOST_CALLBACKS
+ case kAudioUnitProperty_HostCallbacks:
+ {
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+ UInt32 availSize = std::min(inDataSize, (UInt32)sizeof(HostCallbackInfo));
+ bool hasChanged = !memcmp (&mHostCallbackInfo, inData, availSize);
+ memset (&mHostCallbackInfo, 0, sizeof (mHostCallbackInfo));
+ memcpy (&mHostCallbackInfo, inData, availSize);
+ if (hasChanged)
+ PropertyChanged(inID, inScope, inElement);
+ break;
+ }
+#endif
+#if !CA_NO_AU_UI_FEATURES
+ case kAudioUnitProperty_SetExternalBuffer:
+ ca_require(inDataSize >= sizeof(AudioUnitExternalBuffer), InvalidPropertyValue);
+ ca_require(IsInitialized(), Uninitialized);
+ {
+ AudioUnitExternalBuffer &buf = *(AudioUnitExternalBuffer*)inData;
+ if (intptr_t(buf.buffer) & 0x0F) result = kAudio_ParamError;
+ else if (inScope == kAudioUnitScope_Input) {
+ AUInputElement *input = GetInput(inElement);
+ input->UseExternalBuffer(buf);
+ } else {
+ AUOutputElement *output = GetOutput(inElement);
+ output->UseExternalBuffer(buf);
+ }
+ }
+ break;
+
+ case kAudioUnitProperty_ContextName:
+ {
+ ca_require(inDataSize == sizeof(CFStringRef), InvalidPropertyValue);
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+ CFStringRef inStr = *(CFStringRef *)inData;
+ if (mContextName) CFRelease(mContextName);
+ if (inStr) CFRetain(inStr);
+ mContextName = inStr;
+ PropertyChanged(inID, inScope, inElement);
+ }
+ break;
+
+#endif // !CA_NO_AU_UI_FEATURES
+
+ case kAudioUnitProperty_NickName:
+ {
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+ ca_require(inDataSize == sizeof(CFStringRef), InvalidPropertyValue);
+ CFStringRef inStr = *(CFStringRef *)inData;
+ if (mNickName) CFRelease(mNickName);
+ if (inStr) CFRetain(inStr);
+ mNickName = inStr;
+ PropertyChanged(inID, inScope, inElement);
+ break;
+ }
+
+ default:
+ result = SetProperty(inID, inScope, inElement, inData, inDataSize);
+ if (result == noErr)
+ PropertyChanged(inID, inScope, inElement);
+
+ break;
+ }
+ return result;
+NotWritable:
+ return kAudioUnitErr_PropertyNotWritable;
+InvalidFormat:
+ return kAudioUnitErr_FormatNotSupported;
+#if !CA_NO_AU_UI_FEATURES
+Uninitialized:
+ return kAudioUnitErr_Uninitialized;
+#endif
+#if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5) || CA_USE_AUDIO_PLUGIN_ONLY
+Initialized:
+ return kAudioUnitErr_Initialized;
+#endif
+InvalidScope:
+ return kAudioUnitErr_InvalidScope;
+InvalidProperty:
+ return kAudioUnitErr_InvalidProperty;
+InvalidPropertyValue:
+ return kAudioUnitErr_InvalidPropertyValue;
+InvalidElement:
+ return kAudioUnitErr_InvalidElement;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::DispatchRemovePropertyValue (AudioUnitPropertyID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement)
+{
+ OSStatus result = noErr;
+ switch (inID)
+ {
+ case kAudioUnitProperty_AudioChannelLayout:
+ {
+ result = RemoveAudioChannelLayout(inScope, inElement);
+ if (result == noErr)
+ PropertyChanged(inID, inScope, inElement);
+ break;
+ }
+
+#if !CA_NO_AU_HOST_CALLBACKS
+ case kAudioUnitProperty_HostCallbacks:
+ {
+ ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+ bool hasValue = false;
+ void* ptr = &mHostCallbackInfo;
+ for (unsigned int i = 0; i < sizeof (HostCallbackInfo); ++i) {
+ if (static_cast(ptr)[i]) {
+ hasValue = true;
+ break;
+ }
+ }
+ if (hasValue) {
+ memset (&mHostCallbackInfo, 0, sizeof (HostCallbackInfo));
+ PropertyChanged(inID, inScope, inElement);
+ }
+ break;
+ }
+#endif
+#if !CA_NO_AU_UI_FEATURES
+ case kAudioUnitProperty_ContextName:
+ if (mContextName) CFRelease(mContextName);
+ mContextName = NULL;
+ result = noErr;
+ break;
+
+#endif // !CA_NO_AU_UI_FEATURES
+
+ case kAudioUnitProperty_NickName:
+ {
+ if(inScope == kAudioUnitScope_Global) {
+ if (mNickName) CFRelease(mNickName);
+ mNickName = NULL;
+ PropertyChanged(inID, inScope, inElement);
+ } else {
+ result = kAudioUnitErr_InvalidScope;
+ }
+ break;
+ }
+
+ default:
+ result = RemovePropertyValue (inID, inScope, inElement);
+ break;
+ }
+
+ return result;
+#if !CA_NO_AU_UI_FEATURES || !CA_NO_AU_HOST_CALLBACKS
+InvalidScope:
+ return kAudioUnitErr_InvalidScope;
+#endif
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::GetPropertyInfo( AudioUnitPropertyID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ UInt32 & outDataSize,
+ Boolean & outWritable)
+{
+ return kAudioUnitErr_InvalidProperty;
+}
+
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::GetProperty( AudioUnitPropertyID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ void * outData)
+{
+ return kAudioUnitErr_InvalidProperty;
+}
+
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::SetProperty( AudioUnitPropertyID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ const void * inData,
+ UInt32 inDataSize)
+{
+ return kAudioUnitErr_InvalidProperty;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::RemovePropertyValue ( AudioUnitPropertyID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement)
+{
+ return kAudioUnitErr_InvalidPropertyValue;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::AddPropertyListener( AudioUnitPropertyID inID,
+ AudioUnitPropertyListenerProc inProc,
+ void * inProcRefCon)
+{
+ PropertyListener pl;
+
+ pl.propertyID = inID;
+ pl.listenerProc = inProc;
+ pl.listenerRefCon = inProcRefCon;
+
+ if (mPropertyListeners.empty())
+ mPropertyListeners.reserve(32);
+ mPropertyListeners.push_back(pl);
+
+ return noErr;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::RemovePropertyListener( AudioUnitPropertyID inID,
+ AudioUnitPropertyListenerProc inProc,
+ void * inProcRefCon,
+ bool refConSpecified)
+{
+ // iterate in reverse so that it's safe to erase in the middle of the vector
+ for (int i = (int)mPropertyListeners.size(); --i >=0; ) {
+ PropertyListeners::iterator it = mPropertyListeners.begin() + i;
+ if ((*it).propertyID == inID && (*it).listenerProc == inProc && (!refConSpecified || (*it).listenerRefCon == inProcRefCon))
+ mPropertyListeners.erase(it);
+ }
+ return noErr;
+}
+
+//_____________________________________________________________________________
+//
+void AUBase::PropertyChanged( AudioUnitPropertyID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement)
+{
+ for (PropertyListeners::iterator it = mPropertyListeners.begin(); it != mPropertyListeners.end(); ++it)
+ if ((*it).propertyID == inID)
+ ((*it).listenerProc)((*it).listenerRefCon, mComponentInstance, inID, inScope, inElement);
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::SetRenderNotification( AURenderCallback inProc,
+ void * inRefCon)
+{
+ if (inProc == NULL)
+ return kAudio_ParamError;
+
+ mRenderCallbacksTouched = true;
+ mRenderCallbacks.deferred_add(RenderCallback(inProc, inRefCon));
+ // this will do nothing if it's already in the list
+ return noErr;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::RemoveRenderNotification( AURenderCallback inProc,
+ void * inRefCon)
+{
+ mRenderCallbacks.deferred_remove(RenderCallback(inProc, inRefCon));
+ return noErr; // error?
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::GetParameter( AudioUnitParameterID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ AudioUnitParameterValue & outValue)
+{
+ AUElement *elem = SafeGetElement(inScope, inElement);
+ outValue = elem->GetParameter(inID);
+ return noErr;
+}
+
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::SetParameter( AudioUnitParameterID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ AudioUnitParameterValue inValue,
+ UInt32 inBufferOffsetInFrames)
+{
+ AUElement *elem = SafeGetElement(inScope, inElement);
+ elem->SetParameter(inID, inValue);
+ return noErr;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::ScheduleParameter ( const AudioUnitParameterEvent *inParameterEvent,
+ UInt32 inNumEvents)
+{
+ bool canScheduleParameters = CanScheduleParameters();
+
+ for (UInt32 i = 0; i < inNumEvents; ++i)
+ {
+ if (inParameterEvent[i].eventType == kParameterEvent_Immediate)
+ {
+ SetParameter (inParameterEvent[i].parameter,
+ inParameterEvent[i].scope,
+ inParameterEvent[i].element,
+ inParameterEvent[i].eventValues.immediate.value,
+ inParameterEvent[i].eventValues.immediate.bufferOffset);
+ }
+ if (canScheduleParameters) {
+ mParamList.push_back (inParameterEvent[i]);
+ }
+ }
+
+ return noErr;
+}
+
+// ____________________________________________________________________________
+//
+static bool SortParameterEventList(const AudioUnitParameterEvent &ev1, const AudioUnitParameterEvent &ev2 )
+{
+ int offset1 = ev1.eventType == kParameterEvent_Immediate ? ev1.eventValues.immediate.bufferOffset : ev1.eventValues.ramp.startBufferOffset;
+ int offset2 = ev2.eventType == kParameterEvent_Immediate ? ev2.eventValues.immediate.bufferOffset : ev2.eventValues.ramp.startBufferOffset;
+
+ if(offset1 < offset2) return true;
+ return false;
+}
+
+
+// ____________________________________________________________________________
+//
+OSStatus AUBase::ProcessForScheduledParams( ParameterEventList &inParamList,
+ UInt32 inFramesToProcess,
+ void *inUserData )
+{
+ OSStatus result = noErr;
+
+ int totalFramesToProcess = inFramesToProcess;
+
+ int framesRemaining = totalFramesToProcess;
+
+ unsigned int currentStartFrame = 0; // start of the whole buffer
+
+
+
+ // sort the ParameterEventList by startBufferOffset
+ std::sort(inParamList.begin(), inParamList.end(), SortParameterEventList);
+
+ ParameterEventList::iterator iter = inParamList.begin();
+
+
+ while(framesRemaining > 0 )
+ {
+ // first of all, go through the ramped automation events and find out where the next
+ // division of our whole buffer will be
+
+ int currentEndFrame = totalFramesToProcess; // start out assuming we'll process all the way to
+ // the end of the buffer
+
+ iter = inParamList.begin();
+
+ // find the next break point
+ while(iter != inParamList.end() )
+ {
+ AudioUnitParameterEvent &event = *iter;
+
+ int offset = event.eventType == kParameterEvent_Immediate ? event.eventValues.immediate.bufferOffset : event.eventValues.ramp.startBufferOffset;
+
+ if(offset > (int)currentStartFrame && offset < currentEndFrame )
+ {
+ currentEndFrame = offset;
+ break;
+ }
+
+ // consider ramp end to be a possible choice (there may be gaps in the supplied ramp events)
+ if(event.eventType == kParameterEvent_Ramped )
+ {
+ offset = event.eventValues.ramp.startBufferOffset + event.eventValues.ramp.durationInFrames;
+
+ if(offset > (int)currentStartFrame && offset < currentEndFrame )
+ {
+ currentEndFrame = offset;
+ }
+ }
+
+ iter++;
+ }
+
+ int framesThisTime = currentEndFrame - currentStartFrame;
+
+ // next, setup the parameter maps to be current for the ramp parameters active during
+ // this time segment...
+
+ for(ParameterEventList::iterator iter2 = inParamList.begin(); iter2 != inParamList.end(); iter2++ )
+ {
+ AudioUnitParameterEvent &event = *iter2;
+
+ bool eventFallsInSlice;
+
+
+ if(event.eventType == kParameterEvent_Ramped)
+ eventFallsInSlice = event.eventValues.ramp.startBufferOffset < currentEndFrame
+ && event.eventValues.ramp.startBufferOffset + event.eventValues.ramp.durationInFrames > currentStartFrame;
+ else /* kParameterEvent_Immediate */
+ // actually, for the same parameter, there may be future immediate events which override this one,
+ // but it's OK since the event list is sorted in time order, we're guaranteed to end up with the current one
+ eventFallsInSlice = event.eventValues.immediate.bufferOffset <= currentStartFrame;
+
+ if(eventFallsInSlice)
+ {
+ AUElement *element = GetElement(event.scope, event.element );
+
+ if(element) element->SetScheduledEvent( event.parameter,
+ event,
+ currentStartFrame,
+ currentEndFrame - currentStartFrame );
+ }
+ }
+
+
+
+ // Finally, actually do the processing for this slice.....
+
+ result = ProcessScheduledSlice( inUserData,
+ currentStartFrame,
+ framesThisTime,
+ inFramesToProcess );
+
+ if(result != noErr) break;
+
+ framesRemaining -= framesThisTime;
+ currentStartFrame = currentEndFrame; // now start from where we left off last time
+ }
+
+ return result;
+}
+
+//_____________________________________________________________________________
+//
+void AUBase::SetWantsRenderThreadID (bool inFlag)
+{
+ if (inFlag == mWantsRenderThreadID)
+ return;
+
+ mWantsRenderThreadID = inFlag;
+ if (!mWantsRenderThreadID)
+ mRenderThreadID = NULL;
+}
+
+//_____________________________________________________________________________
+//
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::DoRender( AudioUnitRenderActionFlags & ioActionFlags,
+ const AudioTimeStamp & inTimeStamp,
+ UInt32 inBusNumber,
+ UInt32 inFramesToProcess,
+ AudioBufferList & ioData)
+{
+ OSStatus theError;
+ RenderCallbackList::iterator rcit;
+
+ AUTRACE(kCATrace_AUBaseRenderStart, mComponentInstance, (uintptr_t)this, inBusNumber, inFramesToProcess, (uintptr_t)ioData.mBuffers[0].mData);
+ DISABLE_DENORMALS
+
+ try {
+ ca_require(IsInitialized(), Uninitialized);
+ ca_require(mAudioUnitAPIVersion >= 2, ParamErr);
+ if (inFramesToProcess > mMaxFramesPerSlice) {
+ static time_t lastTimeMessagePrinted = 0;
+ time_t now = time(NULL);
+ if (now != lastTimeMessagePrinted) {
+ lastTimeMessagePrinted = now;
+ syslog(LOG_ERR, "kAudioUnitErr_TooManyFramesToProcess : inFramesToProcess=%u, mMaxFramesPerSlice=%u", (unsigned)inFramesToProcess, (unsigned)mMaxFramesPerSlice);
+ DebugMessageN4("%s:%d inFramesToProcess=%u, mMaxFramesPerSlice=%u; TooManyFrames", __FILE__, __LINE__, (unsigned)inFramesToProcess, (unsigned)mMaxFramesPerSlice);
+ }
+ goto TooManyFrames;
+ }
+ ca_require (!UsesFixedBlockSize() || inFramesToProcess == GetMaxFramesPerSlice(), ParamErr);
+
+ AUOutputElement *output = GetOutput(inBusNumber); // will throw if non-existant
+ if (output->GetStreamFormat().NumberChannelStreams() != ioData.mNumberBuffers) {
+ DebugMessageN4("%s:%d ioData.mNumberBuffers=%u, output->GetStreamFormat().NumberChannelStreams()=%u; kAudio_ParamError",
+ __FILE__, __LINE__, (unsigned)ioData.mNumberBuffers, (unsigned)output->GetStreamFormat().NumberChannelStreams());
+ goto ParamErr;
+ }
+
+ unsigned expectedBufferByteSize = inFramesToProcess * output->GetStreamFormat().mBytesPerFrame;
+ for (unsigned ibuf = 0; ibuf < ioData.mNumberBuffers; ++ibuf) {
+ AudioBuffer &buf = ioData.mBuffers[ibuf];
+ if (buf.mData != NULL) {
+ // only care about the size if the buffer is non-null
+ if (buf.mDataByteSize < expectedBufferByteSize) {
+ // if the buffer is too small, we cannot render safely. kAudio_ParamError.
+ DebugMessageN7("%s:%d %u frames, %u bytes/frame, expected %u-byte buffer; ioData.mBuffers[%u].mDataByteSize=%u; kAudio_ParamError",
+ __FILE__, __LINE__, (unsigned)inFramesToProcess, (unsigned)output->GetStreamFormat().mBytesPerFrame, expectedBufferByteSize, ibuf, (unsigned)buf.mDataByteSize);
+ goto ParamErr;
+ }
+ // Some clients incorrectly pass bigger buffers than expectedBufferByteSize.
+ // We will generally set the buffer size at the end of rendering, before we return.
+ // However we should ensure that no one, DURING rendering, READS a
+ // potentially incorrect size. This can lead to doing too much work, or
+ // reading past the end of an input buffer into unmapped memory.
+ buf.mDataByteSize = expectedBufferByteSize;
+ }
+ }
+
+ if (WantsRenderThreadID())
+ {
+ #if TARGET_OS_MAC
+ mRenderThreadID = pthread_self();
+ #elif TARGET_OS_WIN32
+ mRenderThreadID = GetCurrentThreadId();
+ #endif
+ }
+
+ AudioUnitRenderActionFlags flags;
+ if (mRenderCallbacksTouched) {
+ mRenderCallbacks.update();
+ flags = ioActionFlags | kAudioUnitRenderAction_PreRender;
+ for (rcit = mRenderCallbacks.begin(); rcit != mRenderCallbacks.end(); ++rcit) {
+ RenderCallback &rc = *rcit;
+ AUTRACE(kCATrace_AUBaseRenderCallbackStart, mComponentInstance, (intptr_t)this, (intptr_t)rc.mRenderNotify, 1, 0);
+ (*(AURenderCallback)rc.mRenderNotify)(rc.mRenderNotifyRefCon,
+ &flags,
+ &inTimeStamp, inBusNumber, inFramesToProcess, &ioData);
+ AUTRACE(kCATrace_AUBaseRenderCallbackEnd, mComponentInstance, (intptr_t)this, (intptr_t)rc.mRenderNotify, 1, 0);
+ }
+ }
+
+ theError = DoRenderBus(ioActionFlags, inTimeStamp, inBusNumber, output, inFramesToProcess, ioData);
+
+ if (mRenderCallbacksTouched) {
+ flags = ioActionFlags | kAudioUnitRenderAction_PostRender;
+
+ if (SetRenderError (theError)) {
+ flags |= kAudioUnitRenderAction_PostRenderError;
+ }
+
+ for (rcit = mRenderCallbacks.begin(); rcit != mRenderCallbacks.end(); ++rcit) {
+ RenderCallback &rc = *rcit;
+ AUTRACE(kCATrace_AUBaseRenderCallbackStart, mComponentInstance, (intptr_t)this, (intptr_t)rc.mRenderNotify, 2, 0);
+ (*(AURenderCallback)rc.mRenderNotify)(rc.mRenderNotifyRefCon,
+ &flags,
+ &inTimeStamp, inBusNumber, inFramesToProcess, &ioData);
+ AUTRACE(kCATrace_AUBaseRenderCallbackEnd, mComponentInstance, (intptr_t)this, (intptr_t)rc.mRenderNotify, 2, 0);
+ }
+ }
+
+ // The vector's being emptied
+ // because these events should only apply to this Render cycle, so anything
+ // left over is from a preceding cycle and should be dumped. New scheduled
+ // parameters must be scheduled from the next pre-render callback.
+ if (!mParamList.empty())
+ mParamList.clear();
+
+ }
+ catch (OSStatus err) {
+ theError = err;
+ goto errexit;
+ }
+ catch (...) {
+ theError = -1;
+ goto errexit;
+ }
+done:
+ RESTORE_DENORMALS
+ AUTRACE(kCATrace_AUBaseRenderEnd, mComponentInstance, (intptr_t)this, theError, ioActionFlags, CATrace::ablData(ioData));
+
+ return theError;
+
+Uninitialized: theError = kAudioUnitErr_Uninitialized; goto errexit;
+ParamErr: theError = kAudio_ParamError; goto errexit;
+TooManyFrames: theError = kAudioUnitErr_TooManyFramesToProcess; goto errexit;
+errexit:
+ DebugMessageN2 (" from %s, render err: %d", GetLoggingString(), (int)theError);
+ SetRenderError(theError);
+ goto done;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::DoProcess ( AudioUnitRenderActionFlags & ioActionFlags,
+ const AudioTimeStamp & inTimeStamp,
+ UInt32 inFramesToProcess,
+ AudioBufferList & ioData)
+{
+ OSStatus theError;
+ AUTRACE(kCATrace_AUBaseRenderStart, mComponentInstance, (intptr_t)this, -1, inFramesToProcess, 0);
+ DISABLE_DENORMALS
+
+ try {
+
+ if (!(ioActionFlags & (1 << 9)/*kAudioUnitRenderAction_DoNotCheckRenderArgs*/)) {
+ ca_require(IsInitialized(), Uninitialized);
+ ca_require(inFramesToProcess <= mMaxFramesPerSlice, TooManyFrames);
+ ca_require(!UsesFixedBlockSize() || inFramesToProcess == GetMaxFramesPerSlice(), ParamErr);
+
+ AUInputElement *input = GetInput(0); // will throw if non-existant
+ if (input->GetStreamFormat().NumberChannelStreams() != ioData.mNumberBuffers) {
+ DebugMessageN4("%s:%d ioData.mNumberBuffers=%u, input->GetStreamFormat().NumberChannelStreams()=%u; kAudio_ParamError",
+ __FILE__, __LINE__, (unsigned)ioData.mNumberBuffers, (unsigned)input->GetStreamFormat().NumberChannelStreams());
+ goto ParamErr;
+ }
+
+ unsigned expectedBufferByteSize = inFramesToProcess * input->GetStreamFormat().mBytesPerFrame;
+ for (unsigned ibuf = 0; ibuf < ioData.mNumberBuffers; ++ibuf) {
+ AudioBuffer &buf = ioData.mBuffers[ibuf];
+ if (buf.mData != NULL) {
+ // only care about the size if the buffer is non-null
+ if (buf.mDataByteSize < expectedBufferByteSize) {
+ // if the buffer is too small, we cannot render safely. kAudio_ParamError.
+ DebugMessageN7("%s:%d %u frames, %u bytes/frame, expected %u-byte buffer; ioData.mBuffers[%u].mDataByteSize=%u; kAudio_ParamError",
+ __FILE__, __LINE__, (unsigned)inFramesToProcess, (unsigned)input->GetStreamFormat().mBytesPerFrame, expectedBufferByteSize, ibuf, (unsigned)buf.mDataByteSize);
+ goto ParamErr;
+ }
+ // Some clients incorrectly pass bigger buffers than expectedBufferByteSize.
+ // We will generally set the buffer size at the end of rendering, before we return.
+ // However we should ensure that no one, DURING rendering, READS a
+ // potentially incorrect size. This can lead to doing too much work, or
+ // reading past the end of an input buffer into unmapped memory.
+ buf.mDataByteSize = expectedBufferByteSize;
+ }
+ }
+ }
+
+ if (WantsRenderThreadID())
+ {
+ #if TARGET_OS_MAC
+ mRenderThreadID = pthread_self();
+ #elif TARGET_OS_WIN32
+ mRenderThreadID = GetCurrentThreadId();
+ #endif
+ }
+
+ if (NeedsToRender (inTimeStamp)) {
+ theError = ProcessBufferLists (ioActionFlags, ioData, ioData, inFramesToProcess);
+ } else
+ theError = noErr;
+
+ }
+ catch (OSStatus err) {
+ theError = err;
+ goto errexit;
+ }
+ catch (...) {
+ theError = -1;
+ goto errexit;
+ }
+done:
+ RESTORE_DENORMALS
+ AUTRACE(kCATrace_AUBaseRenderEnd, mComponentInstance, (intptr_t)this, theError, ioActionFlags, CATrace::ablData(ioData));
+
+ return theError;
+
+Uninitialized: theError = kAudioUnitErr_Uninitialized; goto errexit;
+ParamErr: theError = kAudio_ParamError; goto errexit;
+TooManyFrames: theError = kAudioUnitErr_TooManyFramesToProcess; goto errexit;
+errexit:
+ DebugMessageN2 (" from %s, process err: %d", GetLoggingString(), (int)theError);
+ SetRenderError(theError);
+ goto done;
+}
+
+OSStatus AUBase::DoProcessMultiple ( AudioUnitRenderActionFlags & ioActionFlags,
+ const AudioTimeStamp & inTimeStamp,
+ UInt32 inFramesToProcess,
+ UInt32 inNumberInputBufferLists,
+ const AudioBufferList ** inInputBufferLists,
+ UInt32 inNumberOutputBufferLists,
+ AudioBufferList ** ioOutputBufferLists)
+{
+ OSStatus theError;
+ DISABLE_DENORMALS
+
+ try {
+
+ if (!(ioActionFlags & (1 << 9)/*kAudioUnitRenderAction_DoNotCheckRenderArgs*/)) {
+ ca_require(IsInitialized(), Uninitialized);
+ ca_require(inFramesToProcess <= mMaxFramesPerSlice, TooManyFrames);
+ ca_require (!UsesFixedBlockSize() || inFramesToProcess == GetMaxFramesPerSlice(), ParamErr);
+
+ for (unsigned ibl = 0; ibl < inNumberInputBufferLists; ++ibl) {
+ if (inInputBufferLists[ibl] != NULL) {
+ AUInputElement *input = GetInput(ibl); // will throw if non-existant
+ unsigned expectedBufferByteSize = inFramesToProcess * input->GetStreamFormat().mBytesPerFrame;
+
+ if (input->GetStreamFormat().NumberChannelStreams() != inInputBufferLists[ibl]->mNumberBuffers) {
+ DebugMessageN5("%s:%d inInputBufferLists[%u]->mNumberBuffers=%u, input->GetStreamFormat().NumberChannelStreams()=%u; kAudio_ParamError",
+ __FILE__, __LINE__, ibl, (unsigned)inInputBufferLists[ibl]->mNumberBuffers, (unsigned)input->GetStreamFormat().NumberChannelStreams());
+ goto ParamErr;
+ }
+
+ for (unsigned ibuf = 0; ibuf < inInputBufferLists[ibl]->mNumberBuffers; ++ibuf) {
+ const AudioBuffer &buf = inInputBufferLists[ibl]->mBuffers[ibuf];
+ if (buf.mData != NULL) {
+ if (buf.mDataByteSize < expectedBufferByteSize) {
+ // the buffer is too small
+ DebugMessageN8("%s:%d %u frames, %u bytes/frame, expected %u-byte buffer; inInputBufferLists[%u].mBuffers[%u].mDataByteSize=%u; kAudio_ParamError",
+ __FILE__, __LINE__, (unsigned)inFramesToProcess, (unsigned)input->GetStreamFormat().mBytesPerFrame, expectedBufferByteSize, ibl, ibuf, (unsigned)buf.mDataByteSize);
+ goto ParamErr;
+ }
+ } else {
+ // the buffer must exist
+ goto ParamErr;
+ }
+ }
+ } else {
+ // skip NULL input audio buffer list
+ }
+ }
+
+ for (unsigned obl = 0; obl < inNumberOutputBufferLists; ++obl) {
+ if (ioOutputBufferLists[obl] != NULL) {
+ AUOutputElement *output = GetOutput(obl); // will throw if non-existant
+ unsigned expectedBufferByteSize = inFramesToProcess * output->GetStreamFormat().mBytesPerFrame;
+
+ if (output->GetStreamFormat().NumberChannelStreams() != ioOutputBufferLists[obl]->mNumberBuffers) {
+ DebugMessageN5("%s:%d ioOutputBufferLists[%u]->mNumberBuffers=%u, output->GetStreamFormat().NumberChannelStreams()=%u; kAudio_ParamError",
+ __FILE__, __LINE__, obl, (unsigned)ioOutputBufferLists[obl]->mNumberBuffers, (unsigned)output->GetStreamFormat().NumberChannelStreams());
+ goto ParamErr;
+ }
+
+ for (unsigned obuf = 0; obuf < ioOutputBufferLists[obl]->mNumberBuffers; ++obuf) {
+ AudioBuffer &buf = ioOutputBufferLists[obl]->mBuffers[obuf];
+ if (buf.mData != NULL) {
+ // only care about the size if the buffer is non-null
+ if (buf.mDataByteSize < expectedBufferByteSize) {
+ // if the buffer is too small, we cannot render safely. kAudio_ParamError.
+ DebugMessageN8("%s:%d %u frames, %u bytes/frame, expected %u-byte buffer; ioOutputBufferLists[%u]->mBuffers[%u].mDataByteSize=%u; kAudio_ParamError",
+ __FILE__, __LINE__, (unsigned)inFramesToProcess, (unsigned)output->GetStreamFormat().mBytesPerFrame, expectedBufferByteSize, obl, obuf, (unsigned)buf.mDataByteSize);
+ goto ParamErr;
+ }
+ // Some clients incorrectly pass bigger buffers than expectedBufferByteSize.
+ // We will generally set the buffer size at the end of rendering, before we return.
+ // However we should ensure that no one, DURING rendering, READS a
+ // potentially incorrect size. This can lead to doing too much work, or
+ // reading past the end of an input buffer into unmapped memory.
+ buf.mDataByteSize = expectedBufferByteSize;
+ }
+ }
+ } else {
+ // skip NULL output audio buffer list
+ }
+ }
+ }
+
+ if (WantsRenderThreadID())
+ {
+#if TARGET_OS_MAC
+ mRenderThreadID = pthread_self();
+#elif TARGET_OS_WIN32
+ mRenderThreadID = GetCurrentThreadId();
+#endif
+ }
+
+ if (NeedsToRender (inTimeStamp)) {
+ theError = ProcessMultipleBufferLists (ioActionFlags, inFramesToProcess, inNumberInputBufferLists, inInputBufferLists, inNumberOutputBufferLists, ioOutputBufferLists);
+ } else
+ theError = noErr;
+ }
+ catch (OSStatus err) {
+ theError = err;
+ goto errexit;
+ }
+ catch (...) {
+ theError = -1;
+ goto errexit;
+ }
+done:
+ RESTORE_DENORMALS
+
+ return theError;
+
+Uninitialized: theError = kAudioUnitErr_Uninitialized; goto errexit;
+ParamErr: theError = kAudio_ParamError; goto errexit;
+TooManyFrames: theError = kAudioUnitErr_TooManyFramesToProcess; goto errexit;
+errexit:
+ DebugMessageN2 (" from %s, processmultiple err: %d", GetLoggingString(), (int)theError);
+ SetRenderError(theError);
+ goto done;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::SetInputCallback( UInt32 inPropertyID,
+ AudioUnitElement inElement,
+ AURenderCallback inProc,
+ void * inRefCon)
+{
+ AUInputElement *input = GetInput(inElement); // may throw
+
+ input->SetInputCallback(inProc, inRefCon);
+ PropertyChanged(inPropertyID, kAudioUnitScope_Input, inElement);
+
+ return noErr;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::SetConnection( const AudioUnitConnection & inConnection)
+{
+
+ OSStatus err;
+ AUInputElement *input = GetInput(inConnection.destInputNumber); // may throw
+
+ if (inConnection.sourceAudioUnit) {
+ // connecting, not disconnecting
+ CAStreamBasicDescription sourceDesc;
+ UInt32 size = sizeof(CAStreamBasicDescription);
+ ca_require_noerr(err = AudioUnitGetProperty(
+ inConnection.sourceAudioUnit,
+ kAudioUnitProperty_StreamFormat,
+ kAudioUnitScope_Output,
+ inConnection.sourceOutputNumber,
+ &sourceDesc,
+ &size), errexit);
+ ca_require_noerr(err = DispatchSetProperty (kAudioUnitProperty_StreamFormat,
+ kAudioUnitScope_Input, inConnection.destInputNumber,
+ &sourceDesc, sizeof(CAStreamBasicDescription)), errexit);
+ }
+ input->SetConnection(inConnection);
+
+ PropertyChanged(kAudioUnitProperty_MakeConnection, kAudioUnitScope_Input, inConnection.destInputNumber);
+ return noErr;
+
+errexit:
+ return err;
+}
+
+//_____________________________________________________________________________
+//
+UInt32 AUBase::SupportedNumChannels ( const AUChannelInfo** outInfo)
+{
+ return 0;
+}
+
+//_____________________________________________________________________________
+//
+bool AUBase::ValidFormat( AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ const CAStreamBasicDescription & inNewFormat)
+{
+ return FormatIsCanonical(inNewFormat);
+}
+
+//_____________________________________________________________________________
+//
+bool AUBase::IsStreamFormatWritable( AudioUnitScope scope,
+ AudioUnitElement element)
+{
+ switch (scope) {
+ case kAudioUnitScope_Input:
+ {
+ AUInputElement *input = GetInput(element);
+ if (input->HasConnection()) return false; // can't write format when input comes from connection
+ }
+ // ... fall ...
+ case kAudioUnitScope_Output:
+ return StreamFormatWritable(scope, element);
+
+//#warning "aliasing of global scope format should be pushed to subclasses"
+ case kAudioUnitScope_Global:
+ return StreamFormatWritable(kAudioUnitScope_Output, 0);
+ }
+ return false;
+}
+
+//_____________________________________________________________________________
+//
+const CAStreamBasicDescription &
+ AUBase::GetStreamFormat( AudioUnitScope inScope,
+ AudioUnitElement inElement)
+{
+//#warning "aliasing of global scope format should be pushed to subclasses"
+ AUIOElement *element;
+
+ switch (inScope) {
+ case kAudioUnitScope_Input:
+ element = Inputs().GetIOElement(inElement);
+ break;
+ case kAudioUnitScope_Output:
+ element = Outputs().GetIOElement(inElement);
+ break;
+ case kAudioUnitScope_Global: // global stream description is an alias for that of output 0
+ element = Outputs().GetIOElement(0);
+ break;
+ default:
+ COMPONENT_THROW(kAudioUnitErr_InvalidScope);
+ }
+ return element->GetStreamFormat();
+}
+
+OSStatus AUBase::SetBusCount( AudioUnitScope inScope,
+ UInt32 inCount)
+{
+ if (IsInitialized())
+ return kAudioUnitErr_Initialized;
+
+ GetScope(inScope).SetNumberOfElements(inCount);
+ return noErr;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::ChangeStreamFormat( AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ const CAStreamBasicDescription & inPrevFormat,
+ const CAStreamBasicDescription & inNewFormat)
+{
+//#warning "aliasing of global scope format should be pushed to subclasses"
+ AUIOElement *element;
+
+ switch (inScope) {
+ case kAudioUnitScope_Input:
+ element = Inputs().GetIOElement(inElement);
+ break;
+ case kAudioUnitScope_Output:
+ element = Outputs().GetIOElement(inElement);
+ break;
+ case kAudioUnitScope_Global:
+ element = Outputs().GetIOElement(0);
+ break;
+ default:
+ COMPONENT_THROW(kAudioUnitErr_InvalidScope);
+ }
+ element->SetStreamFormat(inNewFormat);
+ PropertyChanged(kAudioUnitProperty_StreamFormat, inScope, inElement);
+ return noErr;
+}
+
+UInt32 AUBase::GetChannelLayoutTags( AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ AudioChannelLayoutTag * outLayoutTags)
+{
+ return GetIOElement(inScope, inElement)->GetChannelLayoutTags(outLayoutTags);
+}
+
+UInt32 AUBase::GetAudioChannelLayout( AudioUnitScope scope,
+ AudioUnitElement element,
+ AudioChannelLayout * outLayoutPtr,
+ Boolean & outWritable)
+{
+ AUIOElement * el = GetIOElement(scope, element);
+ return el->GetAudioChannelLayout(outLayoutPtr, outWritable);
+}
+
+OSStatus AUBase::RemoveAudioChannelLayout( AudioUnitScope inScope,
+ AudioUnitElement inElement)
+{
+ OSStatus result = noErr;
+ AUIOElement * el = GetIOElement(inScope, inElement);
+ Boolean writable;
+ if (el->GetAudioChannelLayout(NULL, writable)) {
+ result = el->RemoveAudioChannelLayout();
+ }
+ return result;
+}
+
+OSStatus AUBase::SetAudioChannelLayout( AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ const AudioChannelLayout * inLayout)
+{
+ AUIOElement* ioEl = GetIOElement (inScope, inElement);
+
+ // the num channels of the layout HAS TO MATCH the current channels of the Element's stream format
+ UInt32 currentChannels = ioEl->GetStreamFormat().NumberChannels();
+ UInt32 numChannelsInLayout = CAAudioChannelLayout::NumberChannels(*inLayout);
+ if (currentChannels != numChannelsInLayout)
+ return kAudioUnitErr_InvalidPropertyValue;
+
+ UInt32 numLayouts = GetChannelLayoutTags (inScope, inElement, NULL);
+ if (numLayouts == 0)
+ return kAudioUnitErr_InvalidProperty;
+ AudioChannelLayoutTag *tags = (AudioChannelLayoutTag *)CA_malloc (numLayouts * sizeof (AudioChannelLayoutTag));
+ GetChannelLayoutTags (inScope, inElement, tags);
+ bool foundTag = false;
+ for (unsigned int i = 0; i < numLayouts; ++i) {
+ if (tags[i] == inLayout->mChannelLayoutTag || tags[i] == kAudioChannelLayoutTag_UseChannelDescriptions) {
+ foundTag = true;
+ break;
+ }
+ }
+ free(tags);
+
+ if (foundTag == false)
+ return kAudioUnitErr_InvalidPropertyValue;
+
+ return ioEl->SetAudioChannelLayout(*inLayout);
+}
+
+static void AddNumToDictionary (CFMutableDictionaryRef dict, CFStringRef key, SInt32 value)
+{
+ CFNumberRef num = CFNumberCreate (NULL, kCFNumberSInt32Type, &value);
+ CFDictionarySetValue (dict, key, num);
+ CFRelease (num);
+}
+
+#define kCurrentSavedStateVersion 0
+
+OSStatus AUBase::SaveState( CFPropertyListRef * outData)
+{
+ AudioComponentDescription desc = GetComponentDescription();
+
+ CFMutableDictionaryRef dict = CFDictionaryCreateMutable (NULL, 0,
+ &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+
+// first step -> save the version to the data ref
+ SInt32 value = kCurrentSavedStateVersion;
+ AddNumToDictionary (dict, kVersionString, value);
+
+// second step -> save the component type, subtype, manu to the data ref
+ value = desc.componentType;
+ AddNumToDictionary (dict, kTypeString, value);
+
+ value = desc.componentSubType;
+ AddNumToDictionary (dict, kSubtypeString, value);
+
+ value = desc.componentManufacturer;
+ AddNumToDictionary (dict, kManufacturerString, value);
+
+// fourth step -> save the state of all parameters on all scopes and elements
+ CFMutableDataRef data = CFDataCreateMutable(NULL, 0);
+ for (AudioUnitScope iscope = 0; iscope < 3; ++iscope) {
+ AUScope &scope = GetScope(iscope);
+ scope.SaveState (data);
+ }
+
+ SaveExtendedScopes(data);
+
+// save all this in the data section of the dictionary
+ CFDictionarySetValue(dict, kDataString, data);
+ CFRelease (data);
+
+//OK - now we're going to do some properties
+//save the preset name...
+ CFDictionarySetValue (dict, kNameString, mCurrentPreset.presetName);
+
+// Does the unit support the RenderQuality property - if so, save it...
+ value = 0;
+ OSStatus result = DispatchGetProperty (kAudioUnitProperty_RenderQuality,
+ kAudioUnitScope_Global,
+ 0,
+ &value);
+
+ if (result == noErr) {
+ AddNumToDictionary (dict, kRenderQualityString, value);
+ }
+
+// Does the unit support the CPULoad Quality property - if so, save it...
+ Float32 cpuLoad;
+ result = DispatchGetProperty (6/*kAudioUnitProperty_CPULoad*/,
+ kAudioUnitScope_Global,
+ 0,
+ &cpuLoad);
+
+ if (result == noErr) {
+ CFNumberRef num = CFNumberCreate (NULL, kCFNumberFloatType, &cpuLoad);
+ CFDictionarySetValue (dict, kCPULoadString, num);
+ CFRelease (num);
+ }
+
+// Do we have any element names for any of our scopes?
+ // first check to see if we have any names...
+ bool foundName = false;
+ for (AudioUnitScope i = 0; i < kNumScopes; ++i) {
+ foundName = GetScope (i).HasElementWithName();
+ if (foundName)
+ break;
+ }
+ // OK - we found a name away we go...
+ if (foundName) {
+ CFMutableDictionaryRef nameDict = CFDictionaryCreateMutable (NULL, 0,
+ &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ for (AudioUnitScope i = 0; i < kNumScopes; ++i) {
+ GetScope (i).AddElementNamesToDict (nameDict);
+ }
+
+ CFDictionarySetValue (dict, kElementNameString, nameDict);
+ CFRelease (nameDict);
+ }
+
+// we're done!!!
+ *outData = dict;
+
+ return noErr;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::RestoreState( CFPropertyListRef plist)
+{
+ if (CFGetTypeID(plist) != CFDictionaryGetTypeID()) return kAudioUnitErr_InvalidPropertyValue;
+
+ AudioComponentDescription desc = GetComponentDescription();
+
+ CFDictionaryRef dict = static_cast(plist);
+
+// zeroeth step - make sure the Part key is NOT present, as this method is used
+// to restore the GLOBAL state of the dictionary
+ if (CFDictionaryContainsKey (dict, kPartString))
+ return kAudioUnitErr_InvalidPropertyValue;
+
+// first step -> check the saved version in the data ref
+// at this point we're only dealing with version==0
+ CFNumberRef cfnum = reinterpret_cast(CFDictionaryGetValue (dict, kVersionString));
+ if (cfnum == NULL) return kAudioUnitErr_InvalidPropertyValue;
+ SInt32 value;
+ CFNumberGetValue (cfnum, kCFNumberSInt32Type, &value);
+ if (value != kCurrentSavedStateVersion) return kAudioUnitErr_InvalidPropertyValue;
+
+// second step -> check that this data belongs to this kind of audio unit
+// by checking the component subtype and manuID
+// We're not checking the type, since there may be different versions (effect, format-converter, offline)
+// of essentially the same AU
+ cfnum = reinterpret_cast(CFDictionaryGetValue (dict, kSubtypeString));
+ if (cfnum == NULL) return kAudioUnitErr_InvalidPropertyValue;
+ CFNumberGetValue (cfnum, kCFNumberSInt32Type, &value);
+ if (UInt32(value) != desc.componentSubType) return kAudioUnitErr_InvalidPropertyValue;
+
+ cfnum = reinterpret_cast(CFDictionaryGetValue (dict, kManufacturerString));
+ if (cfnum == NULL) return kAudioUnitErr_InvalidPropertyValue;
+ CFNumberGetValue (cfnum, kCFNumberSInt32Type, &value);
+ if (UInt32(value) != desc.componentManufacturer) return kAudioUnitErr_InvalidPropertyValue;
+
+// fourth step -> restore the state of all of the parameters for each scope and element
+ CFDataRef data = reinterpret_cast(CFDictionaryGetValue (dict, kDataString));
+ if (data != NULL)
+ {
+ const UInt8 *p, *pend;
+
+ p = CFDataGetBytePtr(data);
+ pend = p + CFDataGetLength(data);
+
+ // we have a zero length data, which may just mean there were no parameters to save!
+ // if (p >= pend) return noErr;
+
+ while (p < pend) {
+ UInt32 scopeIdx = CFSwapInt32BigToHost(*(UInt32 *)p);
+ p += sizeof(UInt32);
+
+ AUScope &scope = GetScope(scopeIdx);
+ p = scope.RestoreState(p);
+ }
+ }
+
+//OK - now we're going to do some properties
+//restore the preset name...
+ CFStringRef name = reinterpret_cast(CFDictionaryGetValue (dict, kNameString));
+ if (mCurrentPreset.presetName) CFRelease (mCurrentPreset.presetName);
+ if (name)
+ {
+ mCurrentPreset.presetName = name;
+ mCurrentPreset.presetNumber = -1;
+ }
+ else { // no name entry make the default one
+ mCurrentPreset.presetName = kUntitledString;
+ mCurrentPreset.presetNumber = -1;
+ }
+
+ CFRetain (mCurrentPreset.presetName);
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+#ifndef __LP64__
+ PropertyChanged(kAudioUnitProperty_CurrentPreset, kAudioUnitScope_Global, 0);
+#endif
+#endif
+ PropertyChanged(kAudioUnitProperty_PresentPreset, kAudioUnitScope_Global, 0);
+
+// Does the dict contain render quality information?
+ if (CFDictionaryGetValueIfPresent (dict, kRenderQualityString, reinterpret_cast(&cfnum)))
+ {
+ CFNumberGetValue (cfnum, kCFNumberSInt32Type, &value);
+ DispatchSetProperty (kAudioUnitProperty_RenderQuality,
+ kAudioUnitScope_Global,
+ 0,
+ &value,
+ sizeof(value));
+ }
+
+// Does the unit support the CPULoad Quality property - if so, save it...
+ if (CFDictionaryGetValueIfPresent (dict, kCPULoadString, reinterpret_cast(&cfnum)))
+ {
+ Float32 floatValue;
+ CFNumberGetValue (cfnum, kCFNumberFloatType, &floatValue);
+ DispatchSetProperty (6/*kAudioUnitProperty_CPULoad*/,
+ kAudioUnitScope_Global,
+ 0,
+ &floatValue,
+ sizeof(floatValue));
+ }
+
+// Do we have any element names for any of our scopes?
+ CFDictionaryRef nameDict;
+ if (CFDictionaryGetValueIfPresent (dict, kElementNameString, reinterpret_cast(&nameDict)))
+ {
+ char string[64];
+ for (int i = 0; i < kNumScopes; ++i)
+ {
+ snprintf (string, sizeof(string), "%d", i);
+ CFStringRef key = CFStringCreateWithCString (NULL, string, kCFStringEncodingASCII);
+ CFDictionaryRef elementDict;
+ if (CFDictionaryGetValueIfPresent (nameDict, key, reinterpret_cast(&elementDict)))
+ {
+ bool didAddElements = GetScope (i).RestoreElementNames (elementDict);
+ if (didAddElements)
+ PropertyChanged (kAudioUnitProperty_ElementCount, i, 0);
+ }
+ CFRelease (key);
+ }
+ }
+
+ return noErr;
+}
+
+OSStatus AUBase::GetPresets ( CFArrayRef * outData) const
+{
+ return kAudioUnitErr_InvalidProperty;
+}
+
+OSStatus AUBase::NewFactoryPresetSet (const AUPreset & inNewFactoryPreset)
+{
+ return kAudioUnitErr_InvalidProperty;
+}
+
+OSStatus AUBase::NewCustomPresetSet (const AUPreset & inNewCustomPreset)
+{
+ CFRelease (mCurrentPreset.presetName);
+ mCurrentPreset = inNewCustomPreset;
+ CFRetain (mCurrentPreset.presetName);
+ return noErr;
+}
+
+ // set the default preset for the unit -> the number of the preset MUST be >= 0
+ // and the name should be valid, or the preset WON'T take
+bool AUBase::SetAFactoryPresetAsCurrent (const AUPreset & inPreset)
+{
+ if (inPreset.presetNumber < 0 || inPreset.presetName == NULL) return false;
+ CFRelease (mCurrentPreset.presetName);
+ mCurrentPreset = inPreset;
+ CFRetain (mCurrentPreset.presetName);
+ return true;
+}
+
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+int AUBase::GetNumCustomUIComponents ()
+{
+ return 0;
+}
+
+void AUBase::GetUIComponentDescs (ComponentDescription* inDescArray) {}
+#endif
+
+bool AUBase::HasIcon ()
+{
+#if !CA_NO_AU_UI_FEATURES
+ CFURLRef url = CopyIconLocation();
+ if (url) {
+ CFRelease (url);
+ return true;
+ }
+#endif
+ return false;
+}
+
+CFURLRef AUBase::CopyIconLocation ()
+{
+ return NULL;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::GetParameterList( AudioUnitScope inScope,
+ AudioUnitParameterID * outParameterList,
+ UInt32 & outNumParameters)
+{
+ AUScope &scope = GetScope(inScope);
+ AUElement *elementWithMostParameters = NULL;
+ UInt32 maxNumParams = 0;
+
+ int nElems = scope.GetNumberOfElements();
+ for (int ielem = 0; ielem < nElems; ++ielem) {
+ AUElement *element = scope.GetElement(ielem);
+ UInt32 nParams = element->GetNumberOfParameters();
+ if (nParams > maxNumParams) {
+ maxNumParams = nParams;
+ elementWithMostParameters = element;
+ }
+ }
+
+ if (outParameterList != NULL && elementWithMostParameters != NULL)
+ elementWithMostParameters->GetParameterList(outParameterList);
+
+ outNumParameters = maxNumParams;
+ return noErr;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::GetParameterInfo( AudioUnitScope inScope,
+ AudioUnitParameterID inParameterID,
+ AudioUnitParameterInfo &outParameterInfo )
+{
+ return kAudioUnitErr_InvalidParameter;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::GetParameterValueStrings(AudioUnitScope inScope,
+ AudioUnitParameterID inParameterID,
+ CFArrayRef * outStrings)
+{
+ return kAudioUnitErr_InvalidProperty;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::GetParameterHistoryInfo( AudioUnitScope inScope,
+ AudioUnitParameterID inParameterID,
+ Float32 & outUpdatesPerSecond,
+ Float32 & outHistoryDurationInSeconds)
+{
+ return kAudioUnitErr_InvalidProperty;
+}
+
+
+//_____________________________________________________________________________
+//
+OSStatus AUBase::CopyClumpName( AudioUnitScope inScope,
+ UInt32 inClumpID,
+ UInt32 inDesiredNameLength,
+ CFStringRef * outClumpName)
+{
+ return kAudioUnitErr_InvalidProperty;
+}
+
+//_____________________________________________________________________________
+//
+void AUBase::SetNumberOfElements( AudioUnitScope inScope,
+ UInt32 numElements)
+{
+ if (inScope == kAudioUnitScope_Global && numElements != 1)
+ COMPONENT_THROW(kAudioUnitErr_InvalidScope);
+
+ GetScope(inScope).SetNumberOfElements(numElements);
+}
+
+//_____________________________________________________________________________
+//
+AUElement * AUBase::CreateElement( AudioUnitScope scope,
+ AudioUnitElement element)
+{
+ switch (scope) {
+ case kAudioUnitScope_Global:
+ return new AUElement(this);
+ case kAudioUnitScope_Input:
+ return new AUInputElement(this);
+ case kAudioUnitScope_Output:
+ return new AUOutputElement(this);
+#if !CA_BASIC_AU_FEATURES
+ case kAudioUnitScope_Group:
+ return new AUElement(this);
+ case kAudioUnitScope_Part:
+ return new AUElement(this);
+#endif
+ }
+ COMPONENT_THROW(kAudioUnitErr_InvalidScope);
+
+ return NULL; // get rid of compiler warning
+}
+
+//_____________________________________________________________________________
+//
+bool AUBase::FormatIsCanonical( const CAStreamBasicDescription &f)
+{
+ return (f.mFormatID == kAudioFormatLinearPCM
+ && f.mFramesPerPacket == 1
+ && f.mBytesPerPacket == f.mBytesPerFrame
+// && f.mChannelsPerFrame >= 0 -- this is always true since it's unsigned
+ // so far, it's a valid PCM format
+#if CA_PREFER_FIXED_POINT
+ && (f.mFormatFlags & kLinearPCMFormatFlagIsFloat) == 0
+ && (((f.mFormatFlags & kLinearPCMFormatFlagsSampleFractionMask) >> kLinearPCMFormatFlagsSampleFractionShift) == kAudioUnitSampleFractionBits)
+#else
+ && (f.mFormatFlags & kLinearPCMFormatFlagIsFloat) != 0
+#endif
+ && ((f.mChannelsPerFrame == 1) || ((f.mFormatFlags & kAudioFormatFlagIsNonInterleaved) == 0) == (mAudioUnitAPIVersion == 1))
+#if TARGET_RT_BIG_ENDIAN
+ && (f.mFormatFlags & kLinearPCMFormatFlagIsBigEndian) != 0
+#else
+ && (f.mFormatFlags & kLinearPCMFormatFlagIsBigEndian) == 0
+#endif
+ && f.mBitsPerChannel == 8 * sizeof(AudioUnitSampleType)
+ && f.mBytesPerFrame == f.NumberInterleavedChannels() * sizeof(AudioUnitSampleType)
+ );
+}
+
+//_____________________________________________________________________________
+//
+void AUBase::MakeCanonicalFormat( CAStreamBasicDescription & f,
+ int nChannels)
+{
+ f.SetAUCanonical(nChannels, mAudioUnitAPIVersion < 2); // interleaved for v1, non for v2
+ f.mSampleRate = 0.0;
+}
+
+const Float64 AUBase::kNoLastRenderedSampleTime = -1.;
+
+#include "AUBaseHelper.h"
+
+char* AUBase::GetLoggingString () const
+{
+ if (mLogString) return mLogString;
+
+ AudioComponentDescription desc = GetComponentDescription();
+
+ const size_t logStringSize = 256;
+ const_cast(this)->mLogString = new char[logStringSize];
+ char str[24];
+ char str1[24];
+ char str2[24];
+ snprintf (const_cast(this)->mLogString, logStringSize, "AU (%p): %s %s %s",
+ GetComponentInstance(),
+ CAStringForOSType(desc.componentType, str, sizeof(str)),
+ CAStringForOSType(desc.componentSubType, str1, sizeof(str1)),
+ CAStringForOSType(desc.componentManufacturer, str2, sizeof(str2)));
+
+ return mLogString;
+}
+
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUBase.h b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUBase.h
new file mode 100644
index 000000000..0c78221cc
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUBase.h
@@ -0,0 +1,1048 @@
+/*
+ File: AUBase.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 __AUBase_h__
+#define __AUBase_h__
+
+#include
+
+#if TARGET_OS_MAC
+ #include
+#elif TARGET_OS_WIN32
+ #include
+#else
+ #error Unsupported Operating System
+#endif
+
+#include
+
+#include "AUScopeElement.h"
+#include "AUInputElement.h"
+#include "AUOutputElement.h"
+#include "AUBuffer.h"
+#include "CAMath.h"
+#include "CAThreadSafeList.h"
+#include "CAVectorUnit.h"
+#include "CAMutex.h"
+#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
+ #include
+ #if !CA_BASIC_AU_FEATURES
+ #include
+ #endif
+#else
+ #include "AudioUnit.h"
+ #if !CA_BASIC_AU_FEATURES
+ #include "MusicDevice.h"
+ #endif
+#endif
+
+#ifndef AUTRACE
+ #define AUTRACE(code, obj, a, b, c, d)
+#endif
+
+#include "AUPlugInDispatch.h"
+
+
+
+// ________________________________________________________________________
+// These are to be moved to the public AudioUnit headers
+
+#define kAUDefaultSampleRate 44100.0
+#if !TARGET_OS_WIN32
+#define kAUDefaultMaxFramesPerSlice 1156
+//this allows enough default frames for a 512 dest 44K and SRC from 96K
+// add a padding of 4 frames for any altivec rounding
+#else
+#define kAUDefaultMaxFramesPerSlice 2048
+#endif
+
+// ________________________________________________________________________
+
+/*! @class AUBase */
+class AUBase : public ComponentBase {
+public:
+
+ /*! @ctor AUBase */
+ AUBase( AudioComponentInstance inInstance,
+ UInt32 numInputElements,
+ UInt32 numOutputElements,
+ UInt32 numGroupElements = 0);
+ /*! @dtor AUBase */
+ virtual ~AUBase();
+
+ /*! @method PostConstructor */
+ virtual void PostConstructor() { CreateElements(); }
+
+ /*! @method PreDestructor */
+ virtual void PreDestructor();
+
+ /*! @method CreateElements */
+ void CreateElements();
+ // Called immediately after construction, when virtual methods work.
+ // Or, a subclass may call this in order to have access to elements
+ // in its constructor.
+
+ /*! @method CreateExtendedElements */
+ virtual void CreateExtendedElements() {}
+
+#pragma mark -
+#pragma mark AU dispatch
+ // ________________________________________________________________________
+ // Virtual methods (mostly) directly corresponding to the entry points. Many of these
+ // have useful implementations here and will not need overriding.
+
+ /*! @method DoInitialize */
+ OSStatus DoInitialize();
+ // this implements the entry point and makes sure that initialization
+ // is only attempted exactly once...
+
+ /*! @method Initialize */
+ virtual OSStatus Initialize();
+ // ... so that overrides to this method can assume that they will only
+ // be called exactly once.
+
+ /*! @method IsInitialized */
+ bool IsInitialized() const { return mInitialized; }
+ /*! @method HasBegunInitializing */
+ bool HasBegunInitializing() const { return mHasBegunInitializing; }
+
+ /*! @method DoCleanup */
+ void DoCleanup();
+ // same pattern as with Initialize
+
+ /*! @method Cleanup */
+ virtual void Cleanup();
+
+ /*! @method Reset */
+ virtual OSStatus Reset( AudioUnitScope inScope,
+ AudioUnitElement inElement);
+
+ // Note about GetPropertyInfo, GetProperty, SetProperty:
+ // Certain properties are trapped out in these dispatch functions and handled with different virtual
+ // methods. (To discourage hacks and keep vtable size down, these are non-virtual)
+
+ /*! @method DispatchGetPropertyInfo */
+ OSStatus DispatchGetPropertyInfo(AudioUnitPropertyID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ UInt32 & outDataSize,
+ Boolean & outWritable);
+
+ /*! @method DispatchGetProperty */
+ OSStatus DispatchGetProperty( AudioUnitPropertyID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ void * outData);
+
+ /*! @method DispatchSetProperty */
+ OSStatus DispatchSetProperty( AudioUnitPropertyID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ const void * inData,
+ UInt32 inDataSize);
+
+ OSStatus DispatchRemovePropertyValue( AudioUnitPropertyID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement);
+
+ /*! @method GetPropertyInfo */
+ virtual OSStatus GetPropertyInfo( AudioUnitPropertyID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ UInt32 & outDataSize,
+ Boolean & outWritable);
+
+ /*! @method GetProperty */
+ virtual OSStatus GetProperty( AudioUnitPropertyID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ void * outData);
+
+ /*! @method SetProperty */
+ virtual OSStatus SetProperty( AudioUnitPropertyID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ const void * inData,
+ UInt32 inDataSize);
+
+ /*! @method ClearPropertyUsage */
+ virtual OSStatus RemovePropertyValue ( AudioUnitPropertyID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement);
+
+ /*! @method AddPropertyListener */
+ virtual OSStatus AddPropertyListener( AudioUnitPropertyID inID,
+ AudioUnitPropertyListenerProc inProc,
+ void * inProcRefCon);
+
+ /*! @method RemovePropertyListener */
+ virtual OSStatus RemovePropertyListener( AudioUnitPropertyID inID,
+ AudioUnitPropertyListenerProc inProc,
+ void * inProcRefCon,
+ bool refConSpecified);
+
+ /*! @method SetRenderNotification */
+ virtual OSStatus SetRenderNotification( AURenderCallback inProc,
+ void * inRefCon);
+
+ /*! @method RemoveRenderNotification */
+ virtual OSStatus RemoveRenderNotification(
+ AURenderCallback inProc,
+ void * inRefCon);
+
+ /*! @method GetParameter */
+ virtual OSStatus GetParameter( AudioUnitParameterID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ AudioUnitParameterValue & outValue);
+
+ /*! @method SetParameter */
+ virtual OSStatus SetParameter( AudioUnitParameterID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ AudioUnitParameterValue inValue,
+ UInt32 inBufferOffsetInFrames);
+
+ /*! @method CanScheduleParams */
+ virtual bool CanScheduleParameters() const = 0;
+
+ /*! @method ScheduleParameter */
+ virtual OSStatus ScheduleParameter ( const AudioUnitParameterEvent *inParameterEvent,
+ UInt32 inNumEvents);
+
+
+ /*! @method DoRender */
+ OSStatus DoRender( AudioUnitRenderActionFlags & ioActionFlags,
+ const AudioTimeStamp & inTimeStamp,
+ UInt32 inBusNumber,
+ UInt32 inNumberFrames,
+ AudioBufferList & ioData);
+
+
+ /*! @method Process */
+ OSStatus DoProcess ( AudioUnitRenderActionFlags & ioActionFlags,
+ const AudioTimeStamp & inTimeStamp,
+ UInt32 inFramesToProcess,
+ AudioBufferList & ioData);
+
+ /*! @method ProcessMultiple */
+ OSStatus DoProcessMultiple ( AudioUnitRenderActionFlags & ioActionFlags,
+ const AudioTimeStamp & inTimeStamp,
+ UInt32 inFramesToProcess,
+ UInt32 inNumberInputBufferLists,
+ const AudioBufferList ** inInputBufferLists,
+ UInt32 inNumberOutputBufferLists,
+ AudioBufferList ** ioOutputBufferLists);
+
+ /*! @method ProcessBufferLists */
+ virtual OSStatus ProcessBufferLists( AudioUnitRenderActionFlags & ioActionFlags,
+ const AudioBufferList & inBuffer,
+ AudioBufferList & outBuffer,
+ UInt32 inFramesToProcess )
+ {
+ return kAudio_UnimplementedError;
+ }
+
+ /*! @method ProcessMultipleBufferLists */
+ virtual OSStatus ProcessMultipleBufferLists( AudioUnitRenderActionFlags & ioActionFlags,
+ UInt32 inFramesToProcess,
+ UInt32 inNumberInputBufferLists,
+ const AudioBufferList ** inInputBufferLists,
+ UInt32 inNumberOutputBufferLists,
+ AudioBufferList ** ioOutputBufferLists)
+ {
+ return kAudio_UnimplementedError;
+ }
+
+ /*! @method ComplexRender */
+ virtual OSStatus ComplexRender( AudioUnitRenderActionFlags & ioActionFlags,
+ const AudioTimeStamp & inTimeStamp,
+ UInt32 inOutputBusNumber,
+ UInt32 inNumberOfPackets,
+ UInt32 * outNumberOfPackets,
+ AudioStreamPacketDescription * outPacketDescriptions,
+ AudioBufferList & ioData,
+ void * outMetadata,
+ UInt32 * outMetadataByteSize)
+ {
+ return kAudio_UnimplementedError;
+ }
+
+ // Override this method if your AU processes multiple output busses completely independently --
+ // you'll want to just call Render without the NeedsToRender check.
+ // Otherwise, override Render().
+ //
+ // N.B. Implementations of this method can assume that the output's buffer list has already been
+ // prepared and access it with GetOutput(inBusNumber)->GetBufferList() instead of
+ // GetOutput(inBusNumber)->PrepareBuffer(nFrames) -- if PrepareBuffer is called, a
+ // copy may occur after rendering.
+ /*! @method RenderBus */
+ virtual OSStatus RenderBus( AudioUnitRenderActionFlags & ioActionFlags,
+ const AudioTimeStamp & inTimeStamp,
+ UInt32 inBusNumber,
+ UInt32 inNumberFrames)
+ {
+ if (NeedsToRender(inTimeStamp))
+ return Render(ioActionFlags, inTimeStamp, inNumberFrames);
+ return noErr; // was presumably already rendered via another bus
+ }
+
+ // N.B. For a unit with only one output bus, it can assume in its implementation of this
+ // method that the output's buffer list has already been prepared and access it with
+ // GetOutput(0)->GetBufferList() instead of GetOutput(0)->PrepareBuffer(nFrames)
+ // -- if PrepareBuffer is called, a copy may occur after rendering.
+ /*! @method Render */
+ virtual OSStatus Render( AudioUnitRenderActionFlags & ioActionFlags,
+ const AudioTimeStamp & inTimeStamp,
+ UInt32 inNumberFrames)
+ {
+ return noErr;
+ }
+
+
+#pragma mark -
+#pragma mark Property Dispatch
+
+ static const Float64 kNoLastRenderedSampleTime;
+
+ // ________________________________________________________________________
+ // These are generated from DispatchGetProperty/DispatchGetPropertyInfo/DispatchSetProperty
+
+ /*! @method BusCountWritable */
+ virtual bool BusCountWritable( AudioUnitScope inScope)
+ {
+ return false;
+ }
+ virtual OSStatus SetBusCount( AudioUnitScope inScope,
+ UInt32 inCount);
+
+ /*! @method SetConnection */
+ virtual OSStatus SetConnection( const AudioUnitConnection & inConnection);
+
+ /*! @method SetInputCallback */
+ virtual OSStatus SetInputCallback( UInt32 inPropertyID,
+ AudioUnitElement inElement,
+ AURenderCallback inProc,
+ void * inRefCon);
+
+ /*! @method GetParameterList */
+ virtual OSStatus GetParameterList( AudioUnitScope inScope,
+ AudioUnitParameterID * outParameterList,
+ UInt32 & outNumParameters);
+ // outParameterList may be a null pointer
+
+ /*! @method GetParameterInfo */
+ virtual OSStatus GetParameterInfo( AudioUnitScope inScope,
+ AudioUnitParameterID inParameterID,
+ AudioUnitParameterInfo & outParameterInfo);
+
+ virtual OSStatus GetParameterHistoryInfo(AudioUnitScope inScope,
+ AudioUnitParameterID inParameterID,
+ Float32 & outUpdatesPerSecond,
+ Float32 & outHistoryDurationInSeconds);
+
+ /*! @method SaveState */
+ virtual OSStatus SaveState( CFPropertyListRef * outData);
+
+ /*! @method SaveExtendedScopes */
+ virtual void SaveExtendedScopes( CFMutableDataRef outData) {};
+
+ /*! @method RestoreState */
+ virtual OSStatus RestoreState( CFPropertyListRef inData);
+
+ /*! @method GetParameterValueStrings */
+ virtual OSStatus GetParameterValueStrings(AudioUnitScope inScope,
+ AudioUnitParameterID inParameterID,
+ CFArrayRef * outStrings);
+
+ /*! @method CopyClumpName */
+ virtual OSStatus CopyClumpName( AudioUnitScope inScope,
+ UInt32 inClumpID,
+ UInt32 inDesiredNameLength,
+ CFStringRef * outClumpName);
+
+ /*! @method GetPresets */
+ virtual OSStatus GetPresets ( CFArrayRef * outData) const;
+
+ // set the default preset for the unit -> the number of the preset MUST be >= 0
+ // and the name should be valid, or the preset WON'T take
+ /*! @method SetAFactoryPresetAsCurrent */
+ bool SetAFactoryPresetAsCurrent (const AUPreset & inPreset);
+
+ // Called when someone sets a new, valid preset
+ // If this is a valid preset, then the subclass sets its state to that preset
+ // and returns noErr.
+ // If not a valid preset, return an error, and the pre-existing preset is restored
+ /*! @method NewFactoryPresetSet */
+ virtual OSStatus NewFactoryPresetSet (const AUPreset & inNewFactoryPreset);
+
+ /*! @method NewCustomPresetSet */
+ virtual OSStatus NewCustomPresetSet (const AUPreset & inNewCustomPreset);
+
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+ /*! @method GetNumCustomUIComponents */
+ virtual int GetNumCustomUIComponents ();
+
+ /*! @method GetUIComponentDescs */
+ virtual void GetUIComponentDescs (ComponentDescription* inDescArray);
+#endif
+
+ /*! @method CopyIconLocation */
+ virtual CFURLRef CopyIconLocation ();
+
+ // default is no latency, and unimplemented tail time
+ /*! @method GetLatency */
+ virtual Float64 GetLatency() {return 0.0;}
+ /*! @method GetTailTime */
+ virtual Float64 GetTailTime() {return 0;}
+ /*! @method SupportsRampAndTail */
+ virtual bool SupportsTail () { return false; }
+
+ /*! @method IsStreamFormatWritable */
+ bool IsStreamFormatWritable( AudioUnitScope scope,
+ AudioUnitElement element);
+
+ /*! @method StreamFormatWritable */
+ virtual bool StreamFormatWritable( AudioUnitScope scope,
+ AudioUnitElement element) = 0;
+ // scope will always be input or output
+
+ // pass in a pointer to get the struct, and num channel infos
+ // you can pass in NULL to just get the number
+ // a return value of 0 (the default in AUBase) means the property is not supported...
+ /*! @method SupportedNumChannels */
+ virtual UInt32 SupportedNumChannels ( const AUChannelInfo** outInfo);
+
+ /*! @method ValidFormat */
+ virtual bool ValidFormat( AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ const CAStreamBasicDescription & inNewFormat);
+ // Will only be called after StreamFormatWritable
+ // has succeeded.
+ // Default implementation requires canonical format:
+ // native-endian 32-bit float, any sample rate,
+ // any number of channels; override when other
+ // formats are supported. A subclass's override can
+ // choose to always return true and trap invalid
+ // formats in ChangeStreamFormat.
+
+
+ /*! @method FormatIsCanonical */
+ bool FormatIsCanonical( const CAStreamBasicDescription &format);
+
+ /*! @method MakeCanonicalFormat */
+ void MakeCanonicalFormat( CAStreamBasicDescription & outDesc,
+ int numChannels = 2);
+
+ /*! @method GetStreamFormat */
+ virtual const CAStreamBasicDescription &
+ GetStreamFormat( AudioUnitScope inScope,
+ AudioUnitElement inElement);
+
+ /*! @method ChangeStreamFormat */
+ virtual OSStatus ChangeStreamFormat( AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ const CAStreamBasicDescription & inPrevFormat,
+ const CAStreamBasicDescription & inNewFormat);
+ // Will only be called after StreamFormatWritable
+ // and ValidFormat have succeeded.
+
+ // ________________________________________________________________________
+
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+ /*! @method ComponentEntryDispatch */
+ static OSStatus ComponentEntryDispatch( ComponentParameters * params,
+ AUBase * This);
+#endif
+
+ // ________________________________________________________________________
+ // Methods useful for subclasses
+
+ /*! @method GetScope */
+ AUScope & GetScope( AudioUnitScope inScope)
+ {
+ if (inScope >= kNumScopes) {
+ AUScope * scope = GetScopeExtended(inScope);
+ if (!scope) COMPONENT_THROW(kAudioUnitErr_InvalidScope);
+ return *scope;
+ }
+ return mScopes[inScope];
+ }
+
+ /*! @method GetScopeExtended */
+ virtual AUScope * GetScopeExtended (AudioUnitScope inScope) { return NULL; }
+
+ /*! @method GlobalScope */
+ AUScope & GlobalScope() { return mScopes[kAudioUnitScope_Global]; }
+ /*! @method Inputs */
+ AUScope & Inputs() { return mScopes[kAudioUnitScope_Input]; }
+ /*! @method Outputs */
+ AUScope & Outputs() { return mScopes[kAudioUnitScope_Output]; }
+#if !CA_BASIC_AU_FEATURES
+ /*! @method Groups */
+ AUScope & Groups() { return mScopes[kAudioUnitScope_Group]; }
+#endif
+ /*! @method Globals */
+ AUElement * Globals() { return mScopes[kAudioUnitScope_Global].GetElement(0); }
+
+ /*! @method SetNumberOfElements */
+ void SetNumberOfElements( AudioUnitScope inScope,
+ UInt32 numElements);
+
+ /*! @method GetElement */
+ AUElement * GetElement( AudioUnitScope inScope,
+ AudioUnitElement inElement)
+ {
+ return GetScope(inScope).GetElement(inElement);
+ }
+
+ /*! @method GetIOElement */
+ AUIOElement * GetIOElement( AudioUnitScope inScope,
+ AudioUnitElement inElement)
+ {
+ return GetScope(inScope).GetIOElement(inElement);
+ }
+
+ /*! @method SafeGetElement */
+ AUElement * SafeGetElement( AudioUnitScope inScope,
+ AudioUnitElement inElement)
+ {
+ return GetScope(inScope).SafeGetElement(inElement);
+ }
+
+ /*! @method GetInput */
+ AUInputElement * GetInput( AudioUnitElement inElement)
+ {
+ return static_cast(Inputs().SafeGetElement(inElement));
+ }
+
+ /*! @method GetOutput */
+ AUOutputElement * GetOutput( AudioUnitElement inElement)
+ {
+ return static_cast(Outputs().SafeGetElement(inElement));
+ }
+
+#if !CA_BASIC_AU_FEATURES
+ /*! @method GetGroup */
+ AUElement * GetGroup( AudioUnitElement inElement)
+ {
+ return Groups().SafeGetElement(inElement);
+ }
+#endif
+
+ /*! @method PullInput */
+ OSStatus PullInput( UInt32 inBusNumber,
+ AudioUnitRenderActionFlags &ioActionFlags,
+ const AudioTimeStamp & inTimeStamp,
+ UInt32 inNumberFrames)
+ {
+ AUInputElement *input = GetInput(inBusNumber); // throws if error
+ return input->PullInput(ioActionFlags, inTimeStamp, inBusNumber, inNumberFrames);
+ }
+
+ /*! @method GetMaxFramesPerSlice */
+ UInt32 GetMaxFramesPerSlice() const { return mMaxFramesPerSlice; }
+ /*! @method UsesFixedBlockSize */
+ bool UsesFixedBlockSize() const { return mUsesFixedBlockSize; }
+ /*! @method SetUsesFixedBlockSize */
+ void SetUsesFixedBlockSize(bool inUsesFixedBlockSize) { mUsesFixedBlockSize = inUsesFixedBlockSize; }
+
+ /*! @method GetVectorUnitType */
+ static SInt32 GetVectorUnitType() { return sVectorUnitType; }
+ /*! @method HasVectorUnit */
+ static bool HasVectorUnit() { return sVectorUnitType > 0; }
+ /*! @method HasAltivec */
+ static bool HasAltivec() { return sVectorUnitType == kVecAltivec; }
+ /*! @method HasSSE2 */
+ static bool HasSSE2() { return sVectorUnitType >= kVecSSE2; }
+ /*! @method HasSSE3 */
+ static bool HasSSE3() { return sVectorUnitType >= kVecSSE3; }
+
+ /*! @method AudioUnitAPIVersion */
+ UInt8 AudioUnitAPIVersion() const { return mAudioUnitAPIVersion; }
+
+ /*! @method IsRenderThread */
+ bool InRenderThread () const
+ {
+#if TARGET_OS_MAC
+ return (mRenderThreadID ? pthread_equal (mRenderThreadID, pthread_self()) : false);
+#elif TARGET_OS_WIN32
+ return (mRenderThreadID ? mRenderThreadID == GetCurrentThreadId() : false);
+#endif
+ }
+
+ /*! @method HasInput */
+ bool HasInput( AudioUnitElement inElement) {
+ AUInputElement *in = static_cast(Inputs().GetElement(inElement));
+ return in != NULL && in->IsActive();
+ }
+ // says whether an input is connected or has a callback
+
+ /*! @method PropertyChanged */
+ virtual void PropertyChanged( AudioUnitPropertyID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement);
+
+#if !CA_NO_AU_UI_FEATURES
+ // These calls can be used to call a Host's Callbacks. The method returns -1 if the host
+ // hasn't supplied the callback. Any other result is returned by the host.
+ // As in the API contract, for a parameter's value, you specify a pointer
+ // to that data type. Specify NULL for a parameter that you are not interested
+ // as this can save work in the host.
+
+ /*! @method CallHostBeatAndTempo */
+ OSStatus CallHostBeatAndTempo (Float64 *outCurrentBeat,
+ Float64 *outCurrentTempo)
+ {
+ return (mHostCallbackInfo.beatAndTempoProc
+ ? (*mHostCallbackInfo.beatAndTempoProc) (mHostCallbackInfo.hostUserData,
+ outCurrentBeat,
+ outCurrentTempo)
+ : -1);
+ }
+
+ /*! @method CallHostMusicalTimeLocation */
+ OSStatus CallHostMusicalTimeLocation (UInt32 *outDeltaSampleOffsetToNextBeat,
+ Float32 *outTimeSig_Numerator,
+ UInt32 *outTimeSig_Denominator,
+ Float64 *outCurrentMeasureDownBeat)
+ {
+ return (mHostCallbackInfo.musicalTimeLocationProc
+ ? (*mHostCallbackInfo.musicalTimeLocationProc) (mHostCallbackInfo.hostUserData,
+ outDeltaSampleOffsetToNextBeat,
+ outTimeSig_Numerator,
+ outTimeSig_Denominator,
+ outCurrentMeasureDownBeat)
+ : -1);
+ }
+
+ /*! @method CallHostTransportState */
+ OSStatus CallHostTransportState (Boolean *outIsPlaying,
+ Boolean *outTransportStateChanged,
+ Float64 *outCurrentSampleInTimeLine,
+ Boolean *outIsCycling,
+ Float64 *outCycleStartBeat,
+ Float64 *outCycleEndBeat)
+ {
+ return (mHostCallbackInfo.transportStateProc
+ ? (*mHostCallbackInfo.transportStateProc) (mHostCallbackInfo.hostUserData,
+ outIsPlaying,
+ outTransportStateChanged,
+ outCurrentSampleInTimeLine,
+ outIsCycling,
+ outCycleStartBeat,
+ outCycleEndBeat)
+ : -1);
+ }
+#endif
+
+ char* GetLoggingString () const;
+
+ CAMutex* GetMutex() { return mAUMutex; }
+
+ // ________________________________________________________________________
+ /*! @method CreateElement */
+ virtual AUElement * CreateElement( AudioUnitScope scope,
+ AudioUnitElement element);
+
+#pragma mark -
+#pragma mark AU Output Base Dispatch
+ // ________________________________________________________________________
+ // ________________________________________________________________________
+ // ________________________________________________________________________
+ // output unit methods
+ /*! @method Start */
+ virtual OSStatus Start() { return kAudio_UnimplementedError; }
+ /*! @method Stop */
+ virtual OSStatus Stop() { return kAudio_UnimplementedError; }
+
+#if !CA_BASIC_AU_FEATURES
+#pragma mark -
+#pragma mark AU Music Base Dispatch
+
+#if !TARGET_OS_IPHONE
+// these methods are deprecated, so we don't include them except for compatability
+ /*! @method PrepareInstrument */
+ virtual OSStatus PrepareInstrument(MusicDeviceInstrumentID inInstrument) { return kAudio_UnimplementedError; }
+
+ /*! @method PrepareInstrument */
+ virtual OSStatus ReleaseInstrument(MusicDeviceInstrumentID inInstrument) { return kAudio_UnimplementedError; }
+#endif
+
+ // ________________________________________________________________________
+ // ________________________________________________________________________
+ // ________________________________________________________________________
+ // music device/music effect methods -- incomplete
+ /*! @method MIDIEvent */
+ virtual OSStatus MIDIEvent( UInt32 inStatus,
+ UInt32 inData1,
+ UInt32 inData2,
+ UInt32 inOffsetSampleFrame) { return kAudio_UnimplementedError; }
+
+ /*! @method SysEx */
+ virtual OSStatus SysEx( const UInt8 * inData,
+ UInt32 inLength) { return kAudio_UnimplementedError;}
+
+ /*! @method StartNote */
+ virtual OSStatus StartNote( MusicDeviceInstrumentID inInstrument,
+ MusicDeviceGroupID inGroupID,
+ NoteInstanceID * outNoteInstanceID,
+ UInt32 inOffsetSampleFrame,
+ const MusicDeviceNoteParams &inParams) { return kAudio_UnimplementedError; }
+
+ /*! @method StopNote */
+ virtual OSStatus StopNote( MusicDeviceGroupID inGroupID,
+ NoteInstanceID inNoteInstanceID,
+ UInt32 inOffsetSampleFrame) { return kAudio_UnimplementedError; }
+#endif
+
+ // ________________________________________________________________________
+ // ________________________________________________________________________
+ // ________________________________________________________________________
+
+protected:
+#pragma mark -
+#pragma mark Implementation methods
+
+ /*! @method ReallocateBuffers */
+ virtual void ReallocateBuffers();
+ // needs to be called when mMaxFramesPerSlice changes
+ virtual void DeallocateIOBuffers();
+
+ /*! @method FillInParameterName */
+ static void FillInParameterName (AudioUnitParameterInfo& ioInfo, CFStringRef inName, bool inShouldRelease)
+ {
+ ioInfo.cfNameString = inName;
+ ioInfo.flags |= kAudioUnitParameterFlag_HasCFNameString;
+ if (inShouldRelease)
+ ioInfo.flags |= kAudioUnitParameterFlag_CFNameRelease;
+ CFStringGetCString (inName, ioInfo.name, offsetof (AudioUnitParameterInfo, clumpID), kCFStringEncodingUTF8);
+ }
+
+ static void HasClump (AudioUnitParameterInfo& ioInfo, UInt32 inClumpID)
+ {
+ ioInfo.clumpID = inClumpID;
+ ioInfo.flags |= kAudioUnitParameterFlag_HasClump;
+ }
+
+ /*! @method SetMaxFramesPerSlice */
+ virtual void SetMaxFramesPerSlice(UInt32 nFrames);
+
+ /*! @method CanSetMaxFrames */
+ virtual OSStatus CanSetMaxFrames() const;
+
+ /*! @method WantsRenderThreadID */
+ bool WantsRenderThreadID () const { return mWantsRenderThreadID; }
+
+ /*! @method SetWantsRenderThreadID */
+ void SetWantsRenderThreadID (bool inFlag);
+
+ /*! @method SetRenderError */
+ OSStatus SetRenderError (OSStatus inErr)
+ {
+ if (inErr && mLastRenderError == 0) {
+ mLastRenderError = inErr;
+ PropertyChanged(kAudioUnitProperty_LastRenderError, kAudioUnitScope_Global, 0);
+ }
+ return inErr;
+ }
+
+private:
+ /*! @method DoRenderBus */
+ // shared between Render and RenderSlice, inlined to minimize function call overhead
+ OSStatus DoRenderBus( AudioUnitRenderActionFlags & ioActionFlags,
+ const AudioTimeStamp & inTimeStamp,
+ UInt32 inBusNumber,
+ AUOutputElement * theOutput,
+ UInt32 inNumberFrames,
+ AudioBufferList & ioData)
+ {
+ if (ioData.mBuffers[0].mData == NULL || (theOutput->WillAllocateBuffer() && Outputs().GetNumberOfElements() > 1))
+ // will render into cache buffer
+ theOutput->PrepareBuffer(inNumberFrames);
+ else
+ // will render into caller's buffer
+ theOutput->SetBufferList(ioData);
+ OSStatus result = RenderBus(ioActionFlags, inTimeStamp, inBusNumber, inNumberFrames);
+ if (result == noErr) {
+ if (ioData.mBuffers[0].mData == NULL) {
+ theOutput->CopyBufferListTo(ioData);
+ AUTRACE(kCATrace_AUBaseDoRenderBus, mComponentInstance, inNumberFrames, (intptr_t)theOutput->GetBufferList().mBuffers[0].mData, 0, *(UInt32 *)ioData.mBuffers[0].mData);
+ } else {
+ theOutput->CopyBufferContentsTo(ioData);
+ AUTRACE(kCATrace_AUBaseDoRenderBus, mComponentInstance, inNumberFrames, (intptr_t)theOutput->GetBufferList().mBuffers[0].mData, (intptr_t)ioData.mBuffers[0].mData, *(UInt32 *)ioData.mBuffers[0].mData);
+ theOutput->InvalidateBufferList();
+ }
+ }
+ return result;
+ }
+
+ /*! @method HasIcon */
+ bool HasIcon ();
+
+ /*! @method ResetRenderTime */
+ void ResetRenderTime ()
+ {
+ memset (&mCurrentRenderTime, 0, sizeof(mCurrentRenderTime));
+ mCurrentRenderTime.mSampleTime = kNoLastRenderedSampleTime;
+ }
+
+protected:
+ /*! @method GetAudioChannelLayout */
+ virtual UInt32 GetChannelLayoutTags( AudioUnitScope scope,
+ AudioUnitElement element,
+ AudioChannelLayoutTag * outLayoutTags);
+
+ /*! @method GetAudioChannelLayout */
+ virtual UInt32 GetAudioChannelLayout( AudioUnitScope scope,
+ AudioUnitElement element,
+ AudioChannelLayout * outLayoutPtr,
+ Boolean & outWritable);
+
+ /*! @method SetAudioChannelLayout */
+ virtual OSStatus SetAudioChannelLayout( AudioUnitScope scope,
+ AudioUnitElement element,
+ const AudioChannelLayout * inLayout);
+
+ /*! @method RemoveAudioChannelLayout */
+ virtual OSStatus RemoveAudioChannelLayout(AudioUnitScope scope, AudioUnitElement element);
+
+ /*! @method NeedsToRender */
+ bool NeedsToRender( const AudioTimeStamp & inTimeStamp)
+ {
+ bool needsToRender = fnotequal(inTimeStamp.mSampleTime, mCurrentRenderTime.mSampleTime);
+ if (needsToRender) // only copy this if we need to render
+ mCurrentRenderTime = inTimeStamp;
+ return needsToRender;
+ }
+
+ // Scheduled parameter implementation:
+
+ typedef std::vector ParameterEventList;
+
+ // Usually, you won't override this method. You only need to call this if your DSP code
+ // is prepared to handle scheduled immediate and ramped parameter changes.
+ // Before calling this method, it is assumed you have already called PullInput() on the input busses
+ // for which the DSP code depends. ProcessForScheduledParams() will call (potentially repeatedly)
+ // virtual method ProcessScheduledSlice() to perform the actual DSP for a given sub-division of
+ // the buffer. The job of ProcessForScheduledParams() is to sub-divide the buffer into smaller
+ // pieces according to the scheduled times found in the ParameterEventList (usually coming
+ // directly from a previous call to ScheduleParameter() ), setting the appropriate immediate or
+ // ramped parameter values for the corresponding scopes and elements, then calling ProcessScheduledSlice()
+ // to do the actual DSP for each of these divisions.
+ virtual OSStatus ProcessForScheduledParams( ParameterEventList &inParamList,
+ UInt32 inFramesToProcess,
+ void *inUserData );
+
+ // This method is called (potentially repeatedly) by ProcessForScheduledParams()
+ // in order to perform the actual DSP required for this portion of the entire buffer
+ // being processed. The entire buffer can be divided up into smaller "slices"
+ // according to the timestamps on the scheduled parameters...
+ //
+ // sub-classes wishing to handle scheduled parameter changes should override this method
+ // in order to do the appropriate DSP. AUEffectBase already overrides this for standard
+ // effect AudioUnits.
+ virtual OSStatus ProcessScheduledSlice( void *inUserData,
+ UInt32 inStartFrameInBuffer,
+ UInt32 inSliceFramesToProcess,
+ UInt32 inTotalBufferFrames ) {return noErr;}; // default impl does nothing...
+
+
+ /*! @method CurrentRenderTime */
+ const AudioTimeStamp & CurrentRenderTime () const { return mCurrentRenderTime; }
+
+ // ________________________________________________________________________
+ // Private data members to discourage hacking in subclasses
+private:
+ struct RenderCallback {
+ RenderCallback(AURenderCallback proc, void *ref) :
+ mRenderNotify(proc),
+ mRenderNotifyRefCon(ref)
+ { }
+
+ AURenderCallback mRenderNotify;
+ void * mRenderNotifyRefCon;
+
+ bool operator == (const RenderCallback &other) {
+ return this->mRenderNotify == other.mRenderNotify &&
+ this->mRenderNotifyRefCon == other.mRenderNotifyRefCon;
+ }
+ };
+ typedef TThreadSafeList RenderCallbackList;
+
+#if !CA_BASIC_AU_FEATURES
+ enum { kNumScopes = 4 };
+#else
+ enum { kNumScopes = 3 };
+#endif
+
+ /*! @var mElementsCreated */
+ bool mElementsCreated;
+protected:
+ /*! @var mInitialized */
+ bool mInitialized;
+ /*! @var mHasBegunInitializing */
+ bool mHasBegunInitializing;
+private:
+ /*! @var mAudioUnitAPIVersion */
+ UInt8 mAudioUnitAPIVersion;
+
+ /*! @var mInitNumInputEls */
+ const UInt32 mInitNumInputEls;
+ /*! @var mInitNumOutputEls */
+ const UInt32 mInitNumOutputEls;
+#if !CA_BASIC_AU_FEATURES
+ /*! @var mInitNumGroupEls */
+ const UInt32 mInitNumGroupEls;
+#endif
+ /*! @var mScopes */
+ AUScope mScopes[kNumScopes];
+
+ /*! @var mRenderCallbacks */
+ RenderCallbackList mRenderCallbacks;
+ bool mRenderCallbacksTouched;
+
+ /*! @var mRenderThreadID */
+#if TARGET_OS_MAC
+ pthread_t mRenderThreadID;
+#elif TARGET_OS_WIN32
+ UInt32 mRenderThreadID;
+#endif
+
+ /*! @var mWantsRenderThreadID */
+ bool mWantsRenderThreadID;
+
+ /*! @var mCurrentRenderTime */
+ AudioTimeStamp mCurrentRenderTime;
+
+ /*! @var mMaxFramesPerSlice */
+ UInt32 mMaxFramesPerSlice;
+
+ /*! @var mLastRenderError */
+ OSStatus mLastRenderError;
+ /*! @var mCurrentPreset */
+ AUPreset mCurrentPreset;
+
+protected:
+ /*! @var mUsesFixedBlockSize */
+ bool mUsesFixedBlockSize;
+
+ struct PropertyListener {
+ AudioUnitPropertyID propertyID;
+ AudioUnitPropertyListenerProc listenerProc;
+ void * listenerRefCon;
+ };
+ typedef std::vector PropertyListeners;
+
+ /*! @var mParamList */
+ ParameterEventList mParamList;
+ /*! @var mPropertyListeners */
+ PropertyListeners mPropertyListeners;
+
+ /*! @var mBuffersAllocated */
+ bool mBuffersAllocated;
+
+ /*! @var mLogString */
+ // if this is NOT null, it will contain identifying info about this AU.
+ char* mLogString;
+
+ /*! @var mNickName */
+ CFStringRef mNickName;
+
+ /*! @var mAUMutex */
+ CAMutex * mAUMutex;
+
+private:
+ /*! @var sVectorUnitType */
+ static SInt32 sVectorUnitType;
+
+#if !CA_NO_AU_HOST_CALLBACKS
+protected:
+ /*! @var mHostCallbackInfo */
+ HostCallbackInfo mHostCallbackInfo;
+
+#endif
+#if !CA_NO_AU_UI_FEATURES
+protected:
+ /*! @var mContextInfo */
+ CFStringRef mContextName;
+#endif
+};
+
+inline OSStatus AUInputElement::PullInputWithBufferList(
+ AudioUnitRenderActionFlags & ioActionFlags,
+ const AudioTimeStamp & inTimeStamp,
+ AudioUnitElement inElement,
+ UInt32 nFrames,
+ AudioBufferList * inBufferList)
+{
+ OSStatus theResult;
+
+ if (HasConnection()) {
+ // only support connections for V2 audio units
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+ if (mConnRenderProc != NULL)
+ theResult = reinterpret_cast(mConnRenderProc)(
+ mConnInstanceStorage, &ioActionFlags, &inTimeStamp, mConnection.sourceOutputNumber, nFrames, inBufferList);
+ else
+#endif
+ theResult = AudioUnitRender(
+ mConnection.sourceAudioUnit, &ioActionFlags, &inTimeStamp, mConnection.sourceOutputNumber, nFrames, inBufferList);
+ } else {
+ // kFromCallback:
+ theResult = (mInputProc)(
+ mInputProcRefCon, &ioActionFlags, &inTimeStamp, inElement, nFrames, inBufferList);
+ }
+
+ if (mInputType == kNoInput) // defense: the guy upstream could have disconnected
+ // it's a horrible thing to do, but may happen!
+ return kAudioUnitErr_NoConnection;
+
+
+ return theResult;
+}
+
+#endif // __AUBase_h__
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUDispatch.cpp b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUDispatch.cpp
new file mode 100644
index 000000000..1f0f01c7d
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUDispatch.cpp
@@ -0,0 +1,438 @@
+/*
+ File: AUDispatch.cpp
+ Abstract: AUDispatch.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 "AUBase.h"
+#include "CAXException.h"
+#include "AUDispatch.h"
+
+
+
+#if TARGET_OS_MAC
+ #if __LP64__
+ // comp instance, parameters in forward order
+ #define PARAM(_typ, _name, _index, _nparams) \
+ _typ _name = *(_typ *)¶ms->params[_index + 1];
+ #else
+ // parameters in reverse order, then comp instance
+ #define PARAM(_typ, _name, _index, _nparams) \
+ _typ _name = *(_typ *)¶ms->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 *)¶ms->params[_index];
+#endif
+
+
+OSStatus AUBase::ComponentEntryDispatch(ComponentParameters *params, AUBase *This)
+{
+ if (This == NULL) return kAudio_ParamError;
+
+ OSStatus result = noErr;
+
+ switch (params->what) {
+ case kComponentCanDoSelect:
+ switch (GetSelectorForCanDo(params)) {
+ // any selectors
+ case kAudioUnitInitializeSelect:
+ case kAudioUnitUninitializeSelect:
+ case kAudioUnitGetPropertyInfoSelect:
+ case kAudioUnitGetPropertySelect:
+ case kAudioUnitSetPropertySelect:
+ case kAudioUnitAddPropertyListenerSelect:
+#if (!__LP64__)
+ case kAudioUnitRemovePropertyListenerSelect:
+#endif
+ case kAudioUnitGetParameterSelect:
+ case kAudioUnitSetParameterSelect:
+ case kAudioUnitResetSelect:
+ result = 1;
+ break;
+ // v1 selectors
+
+ // v2 selectors
+ case kAudioUnitRemovePropertyListenerWithUserDataSelect:
+ case kAudioUnitAddRenderNotifySelect:
+ case kAudioUnitRemoveRenderNotifySelect:
+ case kAudioUnitScheduleParametersSelect:
+ case kAudioUnitRenderSelect:
+ result = (This->AudioUnitAPIVersion() > 1);
+ break;
+
+ default:
+ return ComponentBase::ComponentEntryDispatch(params, This);
+ }
+ break;
+
+ case kAudioUnitInitializeSelect:
+ {
+ CAMutex::Locker lock2(This->GetMutex());
+ result = This->DoInitialize();
+ }
+ break;
+
+ case kAudioUnitUninitializeSelect:
+ {
+ CAMutex::Locker lock2(This->GetMutex());
+ This->DoCleanup();
+ result = noErr;
+ }
+ break;
+
+ case kAudioUnitGetPropertyInfoSelect:
+ {
+ CAMutex::Locker lock(This->GetMutex());
+ PARAM(AudioUnitPropertyID, pinID, 0, 5);
+ PARAM(AudioUnitScope, pinScope, 1, 5);
+ PARAM(AudioUnitElement, pinElement, 2, 5);
+ PARAM(UInt32 *, poutDataSize, 3, 5);
+ PARAM(Boolean *, poutWritable, 4, 5);
+
+ // pass our own copies so that we assume responsibility for testing
+ // the caller's pointers against null and our C++ classes can
+ // always assume they're non-null
+ UInt32 dataSize;
+ Boolean writable;
+
+ result = This->DispatchGetPropertyInfo(pinID, pinScope, pinElement, dataSize, writable);
+ if (poutDataSize != NULL)
+ *poutDataSize = dataSize;
+ if (poutWritable != NULL)
+ *poutWritable = writable;
+ }
+ break;
+
+ case kAudioUnitGetPropertySelect:
+ {
+ CAMutex::Locker lock(This->GetMutex());
+ PARAM(AudioUnitPropertyID, pinID, 0, 5);
+ PARAM(AudioUnitScope, pinScope, 1, 5);
+ PARAM(AudioUnitElement, pinElement, 2, 5);
+ PARAM(void *, poutData, 3, 5);
+ PARAM(UInt32 *, pioDataSize, 4, 5);
+
+ UInt32 actualPropertySize, clientBufferSize;
+ Boolean writable;
+ char *tempBuffer;
+ void *destBuffer;
+
+ if (pioDataSize == NULL) {
+ ca_debug_string("AudioUnitGetProperty: null size pointer");
+ result = kAudio_ParamError;
+ goto finishGetProperty;
+ }
+ if (poutData == NULL) {
+ UInt32 dataSize;
+
+ result = This->DispatchGetPropertyInfo(pinID, pinScope, pinElement, dataSize, writable);
+ *pioDataSize = dataSize;
+ goto finishGetProperty;
+ }
+
+ clientBufferSize = *pioDataSize;
+ if (clientBufferSize == 0)
+ {
+ ca_debug_string("AudioUnitGetProperty: *ioDataSize == 0 on entry");
+ // $$$ or should we allow this as a shortcut for finding the size?
+ result = kAudio_ParamError;
+ goto finishGetProperty;
+ }
+
+ result = This->DispatchGetPropertyInfo(pinID, pinScope, pinElement,
+ actualPropertySize, writable);
+ if (result)
+ goto finishGetProperty;
+
+ if (clientBufferSize < actualPropertySize)
+ {
+ tempBuffer = new char[actualPropertySize];
+ destBuffer = tempBuffer;
+ } else {
+ tempBuffer = NULL;
+ destBuffer = poutData;
+ }
+
+ result = This->DispatchGetProperty(pinID, pinScope, pinElement, destBuffer);
+
+ if (result == noErr) {
+ if (clientBufferSize < actualPropertySize && tempBuffer != NULL)
+ {
+ memcpy(poutData, tempBuffer, clientBufferSize);
+ delete[] tempBuffer;
+ // pioDataSize remains correct, the number of bytes we wrote
+ } else
+ *pioDataSize = actualPropertySize;
+ } else
+ *pioDataSize = 0;
+
+ finishGetProperty:
+ ;
+
+ }
+ break;
+
+ case kAudioUnitSetPropertySelect:
+ {
+ CAMutex::Locker lock(This->GetMutex());
+ PARAM(AudioUnitPropertyID, pinID, 0, 5);
+ PARAM(AudioUnitScope, pinScope, 1, 5);
+ PARAM(AudioUnitElement, pinElement, 2, 5);
+ PARAM(const void *, pinData, 3, 5);
+ PARAM(UInt32, pinDataSize, 4, 5);
+
+ if (pinData && pinDataSize)
+ result = This->DispatchSetProperty(pinID, pinScope, pinElement, pinData, pinDataSize);
+ else {
+ if (pinData == NULL && pinDataSize == 0) {
+ result = This->DispatchRemovePropertyValue (pinID, pinScope, pinElement);
+ } else {
+ if (pinData == NULL) {
+ ca_debug_string("AudioUnitSetProperty: inData == NULL");
+ result = kAudio_ParamError;
+ goto finishSetProperty;
+ }
+
+ if (pinDataSize == 0) {
+ ca_debug_string("AudioUnitSetProperty: inDataSize == 0");
+ result = kAudio_ParamError;
+ goto finishSetProperty;
+ }
+ }
+ }
+ finishSetProperty:
+ ;
+
+ }
+ break;
+
+ case kAudioUnitAddPropertyListenerSelect:
+ {
+ CAMutex::Locker lock(This->GetMutex());
+ PARAM(AudioUnitPropertyID, pinID, 0, 3);
+ PARAM(AudioUnitPropertyListenerProc, pinProc, 1, 3);
+ PARAM(void *, pinProcRefCon, 2, 3);
+ result = This->AddPropertyListener(pinID, pinProc, pinProcRefCon);
+ }
+ break;
+
+#if (!__LP64__)
+ case kAudioUnitRemovePropertyListenerSelect:
+ {
+ CAMutex::Locker lock(This->GetMutex());
+ PARAM(AudioUnitPropertyID, pinID, 0, 2);
+ PARAM(AudioUnitPropertyListenerProc, pinProc, 1, 2);
+ result = This->RemovePropertyListener(pinID, pinProc, NULL, false);
+ }
+ break;
+#endif
+
+ case kAudioUnitRemovePropertyListenerWithUserDataSelect:
+ {
+ CAMutex::Locker lock(This->GetMutex());
+ PARAM(AudioUnitPropertyID, pinID, 0, 3);
+ PARAM(AudioUnitPropertyListenerProc, pinProc, 1, 3);
+ PARAM(void *, pinProcRefCon, 2, 3);
+ result = This->RemovePropertyListener(pinID, pinProc, pinProcRefCon, true);
+ }
+ break;
+
+ case kAudioUnitAddRenderNotifySelect:
+ {
+ CAMutex::Locker lock(This->GetMutex());
+ PARAM(AURenderCallback, pinProc, 0, 2);
+ PARAM(void *, pinProcRefCon, 1, 2);
+ result = This->SetRenderNotification (pinProc, pinProcRefCon);
+ }
+ break;
+
+ case kAudioUnitRemoveRenderNotifySelect:
+ {
+ CAMutex::Locker lock(This->GetMutex());
+ PARAM(AURenderCallback, pinProc, 0, 2);
+ PARAM(void *, pinProcRefCon, 1, 2);
+ result = This->RemoveRenderNotification (pinProc, pinProcRefCon);
+ }
+ break;
+
+ case kAudioUnitGetParameterSelect:
+ {
+ CAMutex::Locker lock(This->GetMutex());
+ PARAM(AudioUnitParameterID, pinID, 0, 4);
+ PARAM(AudioUnitScope, pinScope, 1, 4);
+ PARAM(AudioUnitElement, pinElement, 2, 4);
+ PARAM(AudioUnitParameterValue *, poutValue, 3, 4);
+ result = (poutValue == NULL ? kAudio_ParamError : This->GetParameter(pinID, pinScope, pinElement, *poutValue));
+ }
+ break;
+
+ case kAudioUnitSetParameterSelect:
+ {
+ CAMutex::Locker lock(This->GetMutex()); // is this realtime or no???
+ PARAM(AudioUnitParameterID, pinID, 0, 5);
+ PARAM(AudioUnitScope, pinScope, 1, 5);
+ PARAM(AudioUnitElement, pinElement, 2, 5);
+ PARAM(AudioUnitParameterValue, pinValue, 3, 5);
+ PARAM(UInt32, pinBufferOffsetInFrames, 4, 5);
+ result = This->SetParameter(pinID, pinScope, pinElement, pinValue, pinBufferOffsetInFrames);
+ }
+ break;
+
+ case kAudioUnitScheduleParametersSelect:
+ {
+ CAMutex::Locker lock(This->GetMutex()); // is this realtime or no???
+ if (This->AudioUnitAPIVersion() > 1)
+ {
+ PARAM(AudioUnitParameterEvent *, pinParameterEvent, 0, 2);
+ PARAM(UInt32, pinNumParamEvents, 1, 2);
+ result = This->ScheduleParameter (pinParameterEvent, pinNumParamEvents);
+ } else
+ result = badComponentSelector;
+ }
+ break;
+
+
+ case kAudioUnitRenderSelect:
+ {
+ // realtime; no lock
+ {
+ PARAM(AudioUnitRenderActionFlags *, pinActionFlags, 0, 5);
+ PARAM(const AudioTimeStamp *, pinTimeStamp, 1, 5);
+ PARAM(UInt32, pinOutputBusNumber, 2, 5);
+ PARAM(UInt32, pinNumberFrames, 3, 5);
+ PARAM(AudioBufferList *, pioData, 4, 5);
+ AudioUnitRenderActionFlags tempFlags;
+
+ if (pinTimeStamp == NULL || pioData == NULL)
+ result = kAudio_ParamError;
+ else {
+ if (pinActionFlags == NULL) {
+ tempFlags = 0;
+ pinActionFlags = &tempFlags;
+ }
+ result = This->DoRender(*pinActionFlags, *pinTimeStamp, pinOutputBusNumber, pinNumberFrames, *pioData);
+ }
+ }
+ }
+ break;
+
+ case kAudioUnitResetSelect:
+ {
+ CAMutex::Locker lock(This->GetMutex());
+ PARAM(AudioUnitScope, pinScope, 0, 2);
+ PARAM(AudioUnitElement, pinElement, 1, 2);
+ This->ResetRenderTime();
+ result = This->Reset(pinScope, pinElement);
+ }
+ break;
+
+ default:
+ result = ComponentBase::ComponentEntryDispatch(params, This);
+ break;
+ }
+
+ return result;
+}
+
+// Fast dispatch entry points -- these need to replicate all error-checking logic from above
+
+OSStatus CMgr_AudioUnitBaseGetParameter( AUBase * This,
+ AudioUnitParameterID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ float *outValue)
+{
+ OSStatus result = AUBase::noErr;
+
+ try {
+ if (This == NULL || outValue == NULL) return kAudio_ParamError;
+ result = This->GetParameter(inID, inScope, inElement, *outValue);
+ }
+ COMPONENT_CATCH
+
+ return result;
+}
+
+OSStatus CMgr_AudioUnitBaseSetParameter( AUBase * This,
+ AudioUnitParameterID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ float inValue,
+ UInt32 inBufferOffset)
+{
+ OSStatus result = AUBase::noErr;
+
+ try {
+ if (This == NULL) return kAudio_ParamError;
+ result = This->SetParameter(inID, inScope, inElement, inValue, inBufferOffset);
+ }
+ COMPONENT_CATCH
+
+ return result;
+}
+
+OSStatus CMgr_AudioUnitBaseRender( AUBase * This,
+ AudioUnitRenderActionFlags *ioActionFlags,
+ const AudioTimeStamp * inTimeStamp,
+ UInt32 inBusNumber,
+ UInt32 inNumberFrames,
+ AudioBufferList * ioData)
+{
+ if (inTimeStamp == NULL || ioData == NULL) return kAudio_ParamError;
+
+ OSStatus result = AUBase::noErr;
+ AudioUnitRenderActionFlags tempFlags;
+
+ try {
+ if (ioActionFlags == NULL) {
+ tempFlags = 0;
+ ioActionFlags = &tempFlags;
+ }
+ result = This->DoRender(*ioActionFlags, *inTimeStamp, inBusNumber, inNumberFrames, *ioData);
+ }
+ COMPONENT_CATCH
+
+ return result;
+}
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUDispatch.h b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUDispatch.h
new file mode 100644
index 000000000..5acd96250
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUDispatch.h
@@ -0,0 +1,82 @@
+/*
+ File: AUDispatch.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 __AUDispatch_h__
+#define __AUDispatch_h__
+
+
+#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
+ #include
+#else
+ #include "AudioUnit.h"
+#endif
+
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+/*! @function AudioUnitBaseGetParameter */
+OSStatus CMgr_AudioUnitBaseGetParameter( AUBase * This,
+ AudioUnitParameterID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ float * outValue);
+
+/*! @function AudioUnitBaseSetParameter */
+OSStatus CMgr_AudioUnitBaseSetParameter( AUBase * This,
+ AudioUnitParameterID inID,
+ AudioUnitScope inScope,
+ AudioUnitElement inElement,
+ float inValue,
+ UInt32 inBufferOffset);
+
+/*! @function AudioUnitBaseRender */
+OSStatus CMgr_AudioUnitBaseRender( AUBase * This,
+ AudioUnitRenderActionFlags *ioActionFlags,
+ const AudioTimeStamp * inTimeStamp,
+ UInt32 inBusNumber,
+ UInt32 inNumberFrames,
+ AudioBufferList * ioData);
+#endif
+
+#endif // __AUDispatch_h__
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUInputElement.cpp b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUInputElement.cpp
new file mode 100644
index 000000000..2e148e8ba
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUInputElement.cpp
@@ -0,0 +1,151 @@
+/*
+ File: AUInputElement.cpp
+ Abstract: AUInputElement.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 "AUBase.h"
+
+inline bool HasGoodBufferPointers(const AudioBufferList &abl, UInt32 nBytes)
+{
+ const AudioBuffer *buf = abl.mBuffers;
+ for (UInt32 i = abl.mNumberBuffers; i--;++buf) {
+ if (buf->mData == NULL || buf->mDataByteSize < nBytes)
+ return false;
+ }
+ return true;
+}
+
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// AUInputElement::AUInputElement
+//
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+AUInputElement::AUInputElement(AUBase *audioUnit) :
+ AUIOElement(audioUnit),
+ mInputType(kNoInput)
+{
+}
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// AUInputElement::SetConnection
+//
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+void AUInputElement::SetConnection(const AudioUnitConnection &conn)
+{
+ if (conn.sourceAudioUnit == 0) {
+ Disconnect();
+ return;
+ }
+
+ mInputType = kFromConnection;
+ mConnection = conn;
+ AllocateBuffer();
+
+ mConnInstanceStorage = NULL;
+
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+ mConnRenderProc = NULL;
+ UInt32 size = sizeof(AudioUnitRenderProc);
+ OSStatus result = AudioUnitGetProperty( conn.sourceAudioUnit,
+ kAudioUnitProperty_FastDispatch,
+ kAudioUnitScope_Global,
+ kAudioUnitRenderSelect,
+ &mConnRenderProc,
+ &size);
+ if (result == noErr)
+ mConnInstanceStorage = CMgr_GetComponentInstanceStorage (conn.sourceAudioUnit);
+ else
+ mConnRenderProc = NULL;
+#endif
+}
+
+void AUInputElement::Disconnect()
+{
+ mInputType = kNoInput;
+ mIOBuffer.Deallocate();
+}
+
+
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// AUInputElement::SetInputCallback
+//
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+void AUInputElement::SetInputCallback(AURenderCallback proc, void *refCon)
+{
+ if (proc == NULL)
+ Disconnect();
+ else {
+ mInputType = kFromCallback;
+ mInputProc = proc;
+ mInputProcRefCon = refCon;
+ AllocateBuffer();
+ }
+}
+
+OSStatus AUInputElement::SetStreamFormat(const CAStreamBasicDescription &fmt)
+{
+ OSStatus err = AUIOElement::SetStreamFormat(fmt);
+ if (err == AUBase::noErr)
+ AllocateBuffer();
+ return err;
+}
+
+OSStatus AUInputElement::PullInput( AudioUnitRenderActionFlags & ioActionFlags,
+ const AudioTimeStamp & inTimeStamp,
+ AudioUnitElement inElement,
+ UInt32 nFrames)
+{
+ if (!IsActive())
+ return kAudioUnitErr_NoConnection;
+
+ AudioBufferList *pullBuffer;
+
+ if (HasConnection() || !WillAllocateBuffer())
+ pullBuffer = &mIOBuffer.PrepareNullBuffer(mStreamFormat, nFrames);
+ else
+ pullBuffer = &mIOBuffer.PrepareBuffer(mStreamFormat, nFrames);
+
+ return PullInputWithBufferList (ioActionFlags, inTimeStamp, inElement, nFrames, pullBuffer);
+}
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUInputElement.h b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUInputElement.h
new file mode 100644
index 000000000..891e4c60b
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUInputElement.h
@@ -0,0 +1,119 @@
+/*
+ File: AUInputElement.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 __AUInput_h__
+#define __AUInput_h__
+
+#include "AUScopeElement.h"
+#include "AUBuffer.h"
+
+/*! @class AUInputElement */
+class AUInputElement : public AUIOElement {
+public:
+
+ /*! @ctor AUInputElement */
+ AUInputElement(AUBase *audioUnit);
+ /*! @dtor ~AUInputElement */
+ virtual ~AUInputElement() { }
+
+ // AUElement override
+ /*! @method SetStreamFormat */
+ virtual OSStatus SetStreamFormat(const CAStreamBasicDescription &desc);
+ /*! @method NeedsBufferSpace */
+ virtual bool NeedsBufferSpace() const { return IsCallback(); }
+
+ /*! @method SetConnection */
+ void SetConnection(const AudioUnitConnection &conn);
+ /*! @method SetInputCallback */
+ void SetInputCallback(AURenderCallback proc, void *refCon);
+
+ /*! @method IsActive */
+ bool IsActive() const { return mInputType != kNoInput; }
+ /*! @method IsCallback */
+ bool IsCallback() const { return mInputType == kFromCallback; }
+ /*! @method HasConnection */
+ bool HasConnection() const { return mInputType == kFromConnection; }
+
+ /*! @method PullInput */
+ OSStatus PullInput( AudioUnitRenderActionFlags & ioActionFlags,
+ const AudioTimeStamp & inTimeStamp,
+ AudioUnitElement inElement,
+ UInt32 inNumberFrames);
+
+ /*! @method PullInputWithBufferList */
+ OSStatus PullInputWithBufferList( AudioUnitRenderActionFlags & ioActionFlags,
+ const AudioTimeStamp & inTimeStamp,
+ AudioUnitElement inElement,
+ UInt32 nFrames,
+ AudioBufferList * inBufferList);
+protected:
+ /*! @method Disconnect */
+ void Disconnect();
+
+ enum EInputType { kNoInput, kFromConnection, kFromCallback };
+
+ /*! @var mInputType */
+ EInputType mInputType;
+
+ // if from callback:
+ /*! @var mInputProc */
+ AURenderCallback mInputProc;
+ /*! @var mInputProcRefCon */
+ void * mInputProcRefCon;
+
+ // if from connection:
+ /*! @var mConnection */
+ AudioUnitConnection mConnection;
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+ /*! @var mConnRenderProc */
+ AudioUnitRenderProc mConnRenderProc;
+#endif
+ /*! @var mConnInstanceStorage */
+ void * mConnInstanceStorage; // for the input component
+};
+
+
+#endif // __AUInput_h__
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUOutputElement.cpp b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUOutputElement.cpp
new file mode 100644
index 000000000..5eb34a1c2
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUOutputElement.cpp
@@ -0,0 +1,62 @@
+/*
+ File: AUOutputElement.cpp
+ Abstract: AUOutputElement.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 "AUOutputElement.h"
+#include "AUBase.h"
+
+AUOutputElement::AUOutputElement(AUBase *audioUnit) :
+ AUIOElement(audioUnit)
+{
+ AllocateBuffer();
+}
+
+OSStatus AUOutputElement::SetStreamFormat(const CAStreamBasicDescription &desc)
+{
+ OSStatus result = AUIOElement::SetStreamFormat(desc); // inherited
+ if (result == AUBase::noErr)
+ AllocateBuffer();
+ return result;
+}
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUOutputElement.h b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUOutputElement.h
new file mode 100644
index 000000000..3e6a938ff
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUOutputElement.h
@@ -0,0 +1,66 @@
+/*
+ File: AUOutputElement.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 __AUOutput_h__
+#define __AUOutput_h__
+
+#include "AUScopeElement.h"
+#include "AUBuffer.h"
+
+ /*! @class AUOutputElement */
+class AUOutputElement : public AUIOElement {
+public:
+ /*! @ctor AUOutputElement */
+ AUOutputElement(AUBase *audioUnit);
+
+ // AUElement override
+ /*! @method SetStreamFormat */
+ virtual OSStatus SetStreamFormat(const CAStreamBasicDescription &desc);
+ /*! @method NeedsBufferSpace */
+ virtual bool NeedsBufferSpace() const { return true; }
+};
+
+#endif // __AUOutput_h__
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUPlugInDispatch.cpp b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUPlugInDispatch.cpp
new file mode 100644
index 000000000..3bab19836
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUPlugInDispatch.cpp
@@ -0,0 +1,669 @@
+/*
+ File: AUPlugInDispatch.cpp
+ Abstract: AUPlugInDispatch.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 "AUPlugInDispatch.h"
+#include "CAXException.h"
+#include "ComponentBase.h"
+#include "AUBase.h"
+
+#define ACPI ((AudioComponentPlugInInstance *)self)
+#define AUI ((AUBase *)&ACPI->mInstanceStorage)
+
+#define AUI_LOCK CAMutex::Locker auLock(AUI->GetMutex());
+
+// ------------------------------------------------------------------------------------------------
+static OSStatus AUMethodInitialize(void *self)
+{
+ OSStatus result = noErr;
+ try {
+ AUI_LOCK
+ result = AUI->DoInitialize();
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus AUMethodUninitialize(void *self)
+{
+ OSStatus result = noErr;
+ try {
+ AUI_LOCK
+ AUI->DoCleanup();
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus AUMethodGetPropertyInfo(void *self, AudioUnitPropertyID prop, AudioUnitScope scope, AudioUnitElement elem, UInt32 *outDataSize, Boolean *outWritable)
+{
+ OSStatus result = noErr;
+ try {
+ UInt32 dataSize = 0; // 13517289 GetPropetyInfo was returning an uninitialized value when there is an error. This is a problem for auval.
+ Boolean writable = false;
+
+ AUI_LOCK
+ result = AUI->DispatchGetPropertyInfo(prop, scope, elem, dataSize, writable);
+ if (outDataSize != NULL)
+ *outDataSize = dataSize;
+ if (outWritable != NULL)
+ *outWritable = writable;
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus AUMethodGetProperty(void *self, AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, void *outData, UInt32 *ioDataSize)
+{
+ OSStatus result = noErr;
+ try {
+ UInt32 actualPropertySize, clientBufferSize;
+ Boolean writable;
+ char *tempBuffer;
+ void *destBuffer;
+
+ AUI_LOCK
+ if (ioDataSize == NULL) {
+ ca_debug_string("AudioUnitGetProperty: null size pointer");
+ result = kAudio_ParamError;
+ goto finishGetProperty;
+ }
+ if (outData == NULL) {
+ UInt32 dataSize;
+
+ result = AUI->DispatchGetPropertyInfo(inID, inScope, inElement, dataSize, writable);
+ *ioDataSize = dataSize;
+ goto finishGetProperty;
+ }
+
+ clientBufferSize = *ioDataSize;
+ if (clientBufferSize == 0)
+ {
+ ca_debug_string("AudioUnitGetProperty: *ioDataSize == 0 on entry");
+ // $$$ or should we allow this as a shortcut for finding the size?
+ result = kAudio_ParamError;
+ goto finishGetProperty;
+ }
+
+ result = AUI->DispatchGetPropertyInfo(inID, inScope, inElement, actualPropertySize, writable);
+ if (result != noErr)
+ goto finishGetProperty;
+
+ if (clientBufferSize < actualPropertySize)
+ {
+ tempBuffer = new char[actualPropertySize];
+ destBuffer = tempBuffer;
+ } else {
+ tempBuffer = NULL;
+ destBuffer = outData;
+ }
+
+ result = AUI->DispatchGetProperty(inID, inScope, inElement, destBuffer);
+
+ if (result == noErr) {
+ if (clientBufferSize < actualPropertySize && tempBuffer != NULL)
+ {
+ memcpy(outData, tempBuffer, clientBufferSize);
+ delete[] tempBuffer;
+ // ioDataSize remains correct, the number of bytes we wrote
+ } else
+ *ioDataSize = actualPropertySize;
+ } else
+ *ioDataSize = 0;
+ }
+ COMPONENT_CATCH
+finishGetProperty:
+ return result;
+}
+
+static OSStatus AUMethodSetProperty(void *self, AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, const void *inData, UInt32 inDataSize)
+{
+ OSStatus result = noErr;
+ try {
+ AUI_LOCK
+ if (inData && inDataSize)
+ result = AUI->DispatchSetProperty(inID, inScope, inElement, inData, inDataSize);
+ else {
+ if (inData == NULL && inDataSize == 0) {
+ result = AUI->DispatchRemovePropertyValue(inID, inScope, inElement);
+ } else {
+ if (inData == NULL) {
+ ca_debug_string("AudioUnitSetProperty: inData == NULL");
+ result = kAudio_ParamError;
+ goto finishSetProperty;
+ }
+
+ if (inDataSize == 0) {
+ ca_debug_string("AudioUnitSetProperty: inDataSize == 0");
+ result = kAudio_ParamError;
+ goto finishSetProperty;
+ }
+ }
+ }
+ }
+ COMPONENT_CATCH
+finishSetProperty:
+ return result;
+}
+
+static OSStatus AUMethodAddPropertyListener(void *self, AudioUnitPropertyID prop, AudioUnitPropertyListenerProc proc, void *userData)
+{
+ OSStatus result = noErr;
+ try {
+ AUI_LOCK
+ result = AUI->AddPropertyListener(prop, proc, userData);
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus AUMethodRemovePropertyListener(void *self, AudioUnitPropertyID prop, AudioUnitPropertyListenerProc proc)
+{
+ OSStatus result = noErr;
+ try {
+ AUI_LOCK
+ result = AUI->RemovePropertyListener(prop, proc, NULL, false);
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus AUMethodRemovePropertyListenerWithUserData(void *self, AudioUnitPropertyID prop, AudioUnitPropertyListenerProc proc, void *userData)
+{
+ OSStatus result = noErr;
+ try {
+ AUI_LOCK
+ result = AUI->RemovePropertyListener(prop, proc, userData, true);
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus AUMethodAddRenderNotify(void *self, AURenderCallback proc, void *userData)
+{
+ OSStatus result = noErr;
+ try {
+ AUI_LOCK
+ result = AUI->SetRenderNotification(proc, userData);
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus AUMethodRemoveRenderNotify(void *self, AURenderCallback proc, void *userData)
+{
+ OSStatus result = noErr;
+ try {
+ AUI_LOCK
+ result = AUI->RemoveRenderNotification(proc, userData);
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus AUMethodGetParameter(void *self, AudioUnitParameterID param, AudioUnitScope scope, AudioUnitElement elem, AudioUnitParameterValue *value)
+{
+ OSStatus result = noErr;
+ try {
+ AUI_LOCK
+ result = (value == NULL ? kAudio_ParamError : AUI->GetParameter(param, scope, elem, *value));
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus AUMethodSetParameter(void *self, AudioUnitParameterID param, AudioUnitScope scope, AudioUnitElement elem, AudioUnitParameterValue value, UInt32 bufferOffset)
+{
+ OSStatus result = noErr;
+ try {
+ // this is a (potentially) realtime method; no lock
+ result = AUI->SetParameter(param, scope, elem, value, bufferOffset);
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus AUMethodScheduleParameters(void *self, const AudioUnitParameterEvent *events, UInt32 numEvents)
+{
+ OSStatus result = noErr;
+ try {
+ // this is a (potentially) realtime method; no lock
+ result = AUI->ScheduleParameter(events, numEvents);
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus AUMethodRender(void *self, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inOutputBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData)
+{
+ OSStatus result = noErr;
+
+#if !TARGET_OS_IPHONE
+ try {
+#endif
+ // this is a processing method; no lock
+ AudioUnitRenderActionFlags tempFlags;
+
+ if (inTimeStamp == NULL || ioData == NULL)
+ result = kAudio_ParamError;
+ else {
+ if (ioActionFlags == NULL) {
+ tempFlags = 0;
+ ioActionFlags = &tempFlags;
+ }
+ result = AUI->DoRender(*ioActionFlags, *inTimeStamp, inOutputBusNumber, inNumberFrames, *ioData);
+ }
+
+#if !TARGET_OS_IPHONE
+ }
+ COMPONENT_CATCH
+#endif
+
+ return result;
+}
+
+static OSStatus AUMethodComplexRender(void *self, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inOutputBusNumber, UInt32 inNumberOfPackets, UInt32 *outNumberOfPackets, AudioStreamPacketDescription *outPacketDescriptions, AudioBufferList *ioData, void *outMetadata, UInt32 *outMetadataByteSize)
+{
+ OSStatus result = noErr;
+
+#if !TARGET_OS_IPHONE
+ try {
+#endif
+ // this is a processing method; no lock
+ AudioUnitRenderActionFlags tempFlags;
+
+ if (inTimeStamp == NULL || ioData == NULL)
+ result = kAudio_ParamError;
+ else {
+ if (ioActionFlags == NULL) {
+ tempFlags = 0;
+ ioActionFlags = &tempFlags;
+ }
+ result = AUI->ComplexRender(*ioActionFlags, *inTimeStamp, inOutputBusNumber, inNumberOfPackets, outNumberOfPackets, outPacketDescriptions, *ioData, outMetadata, outMetadataByteSize);
+ }
+
+#if !TARGET_OS_IPHONE
+ }
+ COMPONENT_CATCH
+#endif
+
+ return result;
+}
+
+static OSStatus AUMethodReset(void *self, AudioUnitScope scope, AudioUnitElement elem)
+{
+ OSStatus result = noErr;
+ try {
+ AUI_LOCK
+ result = AUI->Reset(scope, elem);
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus AUMethodProcess (void *self, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inNumberFrames, AudioBufferList *ioData)
+{
+ OSStatus result = noErr;
+
+#if !TARGET_OS_IPHONE
+ try {
+#endif
+ // this is a processing method; no lock
+ bool doParamCheck = true;
+
+ AudioUnitRenderActionFlags tempFlags;
+
+ if (ioActionFlags == NULL) {
+ tempFlags = 0;
+ ioActionFlags = &tempFlags;
+ } else {
+ if (*ioActionFlags & (1 << 9)/*kAudioUnitRenderAction_DoNotCheckRenderArgs*/)
+ doParamCheck = false;
+ }
+
+ if (doParamCheck && (inTimeStamp == NULL || ioData == NULL))
+ result = kAudio_ParamError;
+ else {
+ result = AUI->DoProcess(*ioActionFlags, *inTimeStamp, inNumberFrames, *ioData);
+ }
+
+#if !TARGET_OS_IPHONE
+ }
+ COMPONENT_CATCH
+#endif
+
+ return result;
+}
+
+static OSStatus AUMethodProcessMultiple (void *self, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inNumberFrames, UInt32 inNumberInputBufferLists, const AudioBufferList **inInputBufferLists, UInt32 inNumberOutputBufferLists, AudioBufferList **ioOutputBufferLists)
+{
+ OSStatus result = noErr;
+
+#if !TARGET_OS_IPHONE
+ try {
+#endif
+ // this is a processing method; no lock
+ bool doParamCheck = true;
+
+ AudioUnitRenderActionFlags tempFlags;
+
+ if (ioActionFlags == NULL) {
+ tempFlags = 0;
+ ioActionFlags = &tempFlags;
+ } else {
+ if (*ioActionFlags & (1 << 9)/*kAudioUnitRenderAction_DoNotCheckRenderArgs*/)
+ doParamCheck = false;
+ }
+
+ if (doParamCheck && (inTimeStamp == NULL || inInputBufferLists == NULL || ioOutputBufferLists == NULL))
+ result = kAudio_ParamError;
+ else {
+ result = AUI->DoProcessMultiple(*ioActionFlags, *inTimeStamp, inNumberFrames, inNumberInputBufferLists, inInputBufferLists, inNumberOutputBufferLists, ioOutputBufferLists);
+ }
+
+#if !TARGET_OS_IPHONE
+ }
+ COMPONENT_CATCH
+#endif
+
+ return result;
+}
+// ------------------------------------------------------------------------------------------------
+
+static OSStatus AUMethodStart(void *self)
+{
+ OSStatus result = noErr;
+ try {
+ AUI_LOCK
+ result = AUI->Start();
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus AUMethodStop(void *self)
+{
+ OSStatus result = noErr;
+ try {
+ AUI_LOCK
+ result = AUI->Stop();
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+// ------------------------------------------------------------------------------------------------
+
+#if !CA_BASIC_AU_FEATURES
+// I don't know what I'm doing here; conflicts with the multiple inheritence in MusicDeviceBase.
+static OSStatus AUMethodMIDIEvent(void *self, UInt32 inStatus, UInt32 inData1, UInt32 inData2, UInt32 inOffsetSampleFrame)
+{
+ OSStatus result = noErr;
+ try {
+ // this is a potential render-time method; no lock
+ result = AUI->MIDIEvent(inStatus, inData1, inData2, inOffsetSampleFrame);
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus AUMethodSysEx(void *self, const UInt8 *inData, UInt32 inLength)
+{
+ OSStatus result = noErr;
+ try {
+ // this is a potential render-time method; no lock
+ result = AUI->SysEx(inData, inLength);
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus AUMethodStartNote(void *self, MusicDeviceInstrumentID inInstrument, MusicDeviceGroupID inGroupID, NoteInstanceID *outNoteInstanceID, UInt32 inOffsetSampleFrame, const MusicDeviceNoteParams *inParams)
+{
+ OSStatus result = noErr;
+ try {
+ // this is a potential render-time method; no lock
+ if (inParams == NULL || outNoteInstanceID == NULL)
+ result = kAudio_ParamError;
+ else
+ result = AUI->StartNote(inInstrument, inGroupID, outNoteInstanceID, inOffsetSampleFrame, *inParams);
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus AUMethodStopNote(void *self, MusicDeviceGroupID inGroupID, NoteInstanceID inNoteInstanceID, UInt32 inOffsetSampleFrame)
+{
+ OSStatus result = noErr;
+ try {
+ // this is a potential render-time method; no lock
+ result = AUI->StopNote(inGroupID, inNoteInstanceID, inOffsetSampleFrame);
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+#if !TARGET_OS_IPHONE
+static OSStatus AUMethodPrepareInstrument (void *self, MusicDeviceInstrumentID inInstrument)
+{
+ OSStatus result = noErr;
+ try {
+ // this is a potential render-time method; no lock
+ result = AUI->PrepareInstrument(inInstrument);
+ }
+ COMPONENT_CATCH
+ return result;
+}
+
+static OSStatus AUMethodReleaseInstrument (void *self, MusicDeviceInstrumentID inInstrument)
+{
+ OSStatus result = noErr;
+ try {
+ // this is a potential render-time method; no lock
+ result = AUI->ReleaseInstrument(inInstrument);
+ }
+ COMPONENT_CATCH
+ return result;
+}
+#endif // TARGET_OS_IPHONE
+#endif // CA_BASIC_AU_FEATURES
+
+
+//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+#pragma mark -
+#pragma mark Lookup Methods
+
+AudioComponentMethod AUBaseLookup::Lookup (SInt16 selector)
+{
+ switch (selector) {
+ case kAudioUnitInitializeSelect: return (AudioComponentMethod)AUMethodInitialize;
+ case kAudioUnitUninitializeSelect: return (AudioComponentMethod)AUMethodUninitialize;
+ case kAudioUnitGetPropertyInfoSelect: return (AudioComponentMethod)AUMethodGetPropertyInfo;
+ case kAudioUnitGetPropertySelect: return (AudioComponentMethod)AUMethodGetProperty;
+ case kAudioUnitSetPropertySelect: return (AudioComponentMethod)AUMethodSetProperty;
+ case kAudioUnitAddPropertyListenerSelect:return (AudioComponentMethod)AUMethodAddPropertyListener;
+ case kAudioUnitRemovePropertyListenerSelect:
+ return (AudioComponentMethod)AUMethodRemovePropertyListener;
+ case kAudioUnitRemovePropertyListenerWithUserDataSelect:
+ return (AudioComponentMethod)AUMethodRemovePropertyListenerWithUserData;
+ case kAudioUnitAddRenderNotifySelect: return (AudioComponentMethod)AUMethodAddRenderNotify;
+ case kAudioUnitRemoveRenderNotifySelect:return (AudioComponentMethod)AUMethodRemoveRenderNotify;
+ case kAudioUnitGetParameterSelect: return (AudioComponentMethod)AUMethodGetParameter;
+ case kAudioUnitSetParameterSelect: return (AudioComponentMethod)AUMethodSetParameter;
+ case kAudioUnitScheduleParametersSelect:return (AudioComponentMethod)AUMethodScheduleParameters;
+ case kAudioUnitRenderSelect: return (AudioComponentMethod)AUMethodRender;
+ case kAudioUnitResetSelect: return (AudioComponentMethod)AUMethodReset;
+ default:
+ break;
+ }
+ return NULL;
+}
+
+AudioComponentMethod AUOutputLookup::Lookup (SInt16 selector)
+{
+ AudioComponentMethod method = AUBaseLookup::Lookup(selector);
+ if (method) return method;
+
+ switch (selector) {
+ case kAudioOutputUnitStartSelect: return (AudioComponentMethod)AUMethodStart;
+ case kAudioOutputUnitStopSelect: return (AudioComponentMethod)AUMethodStop;
+ default:
+ break;
+ }
+ return NULL;
+}
+
+AudioComponentMethod AUComplexOutputLookup::Lookup (SInt16 selector)
+{
+ AudioComponentMethod method = AUBaseLookup::Lookup(selector);
+ if (method) return method;
+
+ method = AUOutputLookup::Lookup(selector);
+ if (method) return method;
+
+ if (selector == kAudioUnitComplexRenderSelect)
+ return (AudioComponentMethod)AUMethodComplexRender;
+ return NULL;
+}
+
+AudioComponentMethod AUBaseProcessLookup::Lookup (SInt16 selector)
+{
+ AudioComponentMethod method = AUBaseLookup::Lookup(selector);
+ if (method) return method;
+
+ if (selector == kAudioUnitProcessSelect)
+ return (AudioComponentMethod)AUMethodProcess;
+
+ return NULL;
+}
+
+AudioComponentMethod AUBaseProcessMultipleLookup::Lookup (SInt16 selector)
+{
+ AudioComponentMethod method = AUBaseLookup::Lookup(selector);
+ if (method) return method;
+
+ if (selector == kAudioUnitProcessMultipleSelect)
+ return (AudioComponentMethod)AUMethodProcessMultiple;
+
+ return NULL;
+}
+
+AudioComponentMethod AUBaseProcessAndMultipleLookup::Lookup (SInt16 selector)
+{
+ AudioComponentMethod method = AUBaseLookup::Lookup(selector);
+ if (method) return method;
+
+ method = AUBaseProcessMultipleLookup::Lookup(selector);
+ if (method) return method;
+
+ method = AUBaseProcessLookup::Lookup(selector);
+ if (method) return method;
+
+ return NULL;
+}
+
+#if !CA_BASIC_AU_FEATURES
+inline AudioComponentMethod MIDI_Lookup (SInt16 selector)
+{
+ switch (selector) {
+ case kMusicDeviceMIDIEventSelect: return (AudioComponentMethod)AUMethodMIDIEvent;
+ case kMusicDeviceSysExSelect: return (AudioComponentMethod)AUMethodSysEx;
+ default:
+ break;
+ }
+ return NULL;
+}
+
+AudioComponentMethod AUMIDILookup::Lookup (SInt16 selector)
+{
+ AudioComponentMethod method = AUBaseLookup::Lookup(selector);
+ if (method) return method;
+
+ return MIDI_Lookup(selector);
+}
+
+AudioComponentMethod AUMIDIProcessLookup::Lookup (SInt16 selector)
+{
+ AudioComponentMethod method = AUBaseProcessLookup::Lookup(selector);
+ if (method) return method;
+
+ return MIDI_Lookup(selector);
+}
+
+AudioComponentMethod AUMusicLookup::Lookup (SInt16 selector)
+{
+ AudioComponentMethod method = AUBaseLookup::Lookup(selector);
+ if (method) return method;
+
+ switch (selector) {
+ case kMusicDeviceStartNoteSelect: return (AudioComponentMethod)AUMethodStartNote;
+ case kMusicDeviceStopNoteSelect: return (AudioComponentMethod)AUMethodStopNote;
+#if !TARGET_OS_IPHONE
+ case kMusicDevicePrepareInstrumentSelect: return (AudioComponentMethod)AUMethodPrepareInstrument;
+ case kMusicDeviceReleaseInstrumentSelect: return (AudioComponentMethod)AUMethodReleaseInstrument;
+#endif
+ default:
+ break;
+ }
+ return MIDI_Lookup (selector);
+}
+
+AudioComponentMethod AUAuxBaseLookup::Lookup (SInt16 selector)
+{
+ switch (selector) {
+ case kAudioUnitGetPropertyInfoSelect: return (AudioComponentMethod)AUMethodGetPropertyInfo;
+ case kAudioUnitGetPropertySelect: return (AudioComponentMethod)AUMethodGetProperty;
+ case kAudioUnitSetPropertySelect: return (AudioComponentMethod)AUMethodSetProperty;
+
+ case kAudioUnitGetParameterSelect: return (AudioComponentMethod)AUMethodGetParameter;
+ case kAudioUnitSetParameterSelect: return (AudioComponentMethod)AUMethodSetParameter;
+
+ default:
+ break;
+ }
+ return NULL;
+}
+#endif
+
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUPlugInDispatch.h b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUPlugInDispatch.h
new file mode 100644
index 000000000..6ebea75fd
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUPlugInDispatch.h
@@ -0,0 +1,144 @@
+/*
+ File: AUPlugInDispatch.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 __AUPlugInBase_h__
+#define __AUPlugInBase_h__
+
+#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
+ #include
+ #if !CA_BASIC_AU_FEATURES
+ #include
+ #endif
+#else
+ #include "AudioComponent.h"
+ #include "MusicDevice.h"
+#endif
+
+#include "ComponentBase.h"
+
+struct AUBaseLookup {
+ static AudioComponentMethod Lookup (SInt16 selector);
+};
+template
+class AUBaseFactory : public APFactory
+{
+};
+
+struct AUOutputLookup {
+ static AudioComponentMethod Lookup (SInt16 selector);
+};
+template
+class AUOutputBaseFactory : public APFactory
+{
+};
+
+struct AUComplexOutputLookup {
+ static AudioComponentMethod Lookup (SInt16 selector);
+};
+template
+class AUOutputComplexBaseFactory : public APFactory
+{
+};
+
+struct AUBaseProcessLookup {
+ static AudioComponentMethod Lookup (SInt16 selector);
+};
+template
+class AUBaseProcessFactory : public APFactory
+{
+};
+
+struct AUBaseProcessMultipleLookup {
+ static AudioComponentMethod Lookup (SInt16 selector);
+};
+template
+class AUBaseProcessMultipleFactory : public APFactory
+{
+};
+
+struct AUBaseProcessAndMultipleLookup {
+ static AudioComponentMethod Lookup (SInt16 selector);
+};
+template
+class AUBaseProcessAndMultipleFactory : public APFactory
+{
+};
+
+#if !CA_BASIC_AU_FEATURES
+struct AUMIDILookup {
+ static AudioComponentMethod Lookup (SInt16 selector);
+};
+template
+class AUMIDIEffectFactory : public APFactory
+{
+};
+
+struct AUMIDIProcessLookup {
+ static AudioComponentMethod Lookup (SInt16 selector);
+};
+template
+class AUMIDIProcessFactory : public APFactory
+{
+};
+
+struct AUMusicLookup {
+ static AudioComponentMethod Lookup (SInt16 selector);
+};
+template
+class AUMusicDeviceFactory : public APFactory
+{
+};
+
+struct AUAuxBaseLookup {
+ static AudioComponentMethod Lookup (SInt16 selector);
+};
+template
+class AUAuxBaseFactory : public APFactory
+{
+};
+#endif // CA_BASIC_AU_FEATURES
+
+#endif // __AUPlugInBase_h__
diff --git a/src/CoreAudio/CoreAudioComponent/AUResources.r b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUResources.r
similarity index 100%
rename from src/CoreAudio/CoreAudioComponent/AUResources.r
rename to src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUResources.r
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUScopeElement.cpp b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUScopeElement.cpp
new file mode 100644
index 000000000..24bd18e43
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUScopeElement.cpp
@@ -0,0 +1,565 @@
+/*
+ File: AUScopeElement.cpp
+ Abstract: AUScopeElement.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 "AUScopeElement.h"
+#include "AUBase.h"
+
+//_____________________________________________________________________________
+//
+// By default, parameterIDs may be arbitrarily spaced, and an STL map
+// will be used for access. Calling UseIndexedParameters() will
+// instead use an STL vector for faster indexed access.
+// This assumes the paramIDs are numbered 0.....inNumberOfParameters-1
+// Call this before defining/adding any parameters with SetParameter()
+//
+void AUElement::UseIndexedParameters(int inNumberOfParameters)
+{
+ mIndexedParameters.resize (inNumberOfParameters);
+ mUseIndexedParameters = true;
+}
+
+//_____________________________________________________________________________
+//
+// Helper method.
+// returns the ParameterMapEvent object associated with the paramID
+//
+inline ParameterMapEvent& AUElement::GetParamEvent(AudioUnitParameterID paramID)
+{
+ ParameterMapEvent *event;
+
+ if(mUseIndexedParameters)
+ {
+ if(paramID >= mIndexedParameters.size() )
+ COMPONENT_THROW(kAudioUnitErr_InvalidParameter);
+
+ event = &mIndexedParameters[paramID];
+ }
+ else
+ {
+ ParameterMap::iterator i = mParameters.find(paramID);
+ if (i == mParameters.end())
+ COMPONENT_THROW(kAudioUnitErr_InvalidParameter);
+
+ event = &(*i).second;
+ }
+
+ return *event;
+}
+
+//_____________________________________________________________________________
+//
+// Helper method.
+// returns whether the specified paramID is known to the element
+//
+bool AUElement::HasParameterID (AudioUnitParameterID paramID) const
+{
+ if(mUseIndexedParameters)
+ {
+ if(paramID >= mIndexedParameters.size() )
+ return false;
+
+ return true;
+ }
+
+ ParameterMap::const_iterator i = mParameters.find(paramID);
+ if (i == mParameters.end())
+ return false;
+
+ return true;
+}
+
+//_____________________________________________________________________________
+//
+// caller assumes that this is actually an immediate parameter
+//
+AudioUnitParameterValue AUElement::GetParameter(AudioUnitParameterID paramID)
+{
+ ParameterMapEvent &event = GetParamEvent(paramID);
+
+ return event.GetValue();
+}
+
+
+//_____________________________________________________________________________
+//
+void AUElement::GetRampSliceStartEnd( AudioUnitParameterID paramID,
+ AudioUnitParameterValue & outStartValue,
+ AudioUnitParameterValue & outEndValue,
+ AudioUnitParameterValue & outValuePerFrameDelta )
+
+{
+ ParameterMapEvent &event = GetParamEvent(paramID);
+
+ // works even if the value is constant (immediate parameter value)
+ event.GetRampSliceStartEnd(outStartValue, outEndValue, outValuePerFrameDelta );
+}
+
+//_____________________________________________________________________________
+//
+AudioUnitParameterValue AUElement::GetEndValue( AudioUnitParameterID paramID)
+
+{
+ ParameterMapEvent &event = GetParamEvent(paramID);
+
+ // works even if the value is constant (immediate parameter value)
+ return event.GetEndValue();
+}
+
+//_____________________________________________________________________________
+//
+void AUElement::SetParameter(AudioUnitParameterID paramID, AudioUnitParameterValue inValue, bool okWhenInitialized)
+{
+ if(mUseIndexedParameters)
+ {
+ ParameterMapEvent &event = GetParamEvent(paramID);
+ event.SetValue(inValue);
+ }
+ else
+ {
+ ParameterMap::iterator i = mParameters.find(paramID);
+
+ if (i == mParameters.end())
+ {
+ if (mAudioUnit->IsInitialized() && !okWhenInitialized) {
+ // The AU should not be creating new parameters once initialized.
+ // If a client tries to set an undefined parameter, we could throw as follows,
+ // but this might cause a regression. So it is better to just fail silently.
+ // COMPONENT_THROW(kAudioUnitErr_InvalidParameter);
+#if DEBUG
+ fprintf(stderr, "WARNING: %s SetParameter for undefined param ID %d while initialized. Ignoring..\n",
+ mAudioUnit->GetLoggingString(), (int)paramID);
+#endif
+ } else {
+ // create new entry in map for the paramID (only happens first time)
+ ParameterMapEvent event(inValue);
+ mParameters[paramID] = event;
+ }
+ }
+ else
+ {
+ // paramID already exists in map so simply change its value
+ ParameterMapEvent &event = (*i).second;
+ event.SetValue(inValue);
+ }
+ }
+}
+
+//_____________________________________________________________________________
+//
+void AUElement::SetScheduledEvent( AudioUnitParameterID paramID,
+ const AudioUnitParameterEvent &inEvent,
+ UInt32 inSliceOffsetInBuffer,
+ UInt32 inSliceDurationFrames,
+ bool okWhenInitialized )
+{
+ if(mUseIndexedParameters)
+ {
+ ParameterMapEvent &event = GetParamEvent(paramID);
+ event.SetScheduledEvent(inEvent, inSliceOffsetInBuffer, inSliceDurationFrames );
+ }
+ else
+ {
+ ParameterMap::iterator i = mParameters.find(paramID);
+
+ if (i == mParameters.end())
+ {
+ if (mAudioUnit->IsInitialized() && !okWhenInitialized) {
+ // The AU should not be creating new parameters once initialized.
+ // If a client tries to set an undefined parameter, we could throw as follows,
+ // but this might cause a regression. So it is better to just fail silently.
+ // COMPONENT_THROW(kAudioUnitErr_InvalidParameter);
+#if DEBUG
+ fprintf(stderr, "WARNING: %s SetScheduledEvent for undefined param ID %d while initialized. Ignoring..\n",
+ mAudioUnit->GetLoggingString(), (int)paramID);
+#endif
+ } else {
+ // create new entry in map for the paramID (only happens first time)
+ ParameterMapEvent event(inEvent, inSliceOffsetInBuffer, inSliceDurationFrames);
+ mParameters[paramID] = event;
+ }
+ }
+ else
+ {
+ // paramID already exists in map so simply change its value
+ ParameterMapEvent &event = (*i).second;
+
+ event.SetScheduledEvent(inEvent, inSliceOffsetInBuffer, inSliceDurationFrames );
+ }
+ }
+}
+
+
+
+//_____________________________________________________________________________
+//
+void AUElement::GetParameterList(AudioUnitParameterID *outList)
+{
+ if(mUseIndexedParameters)
+ {
+ UInt32 nparams = static_cast(mIndexedParameters.size());
+ for (UInt32 i = 0; i < nparams; i++ )
+ *outList++ = (AudioUnitParameterID)i;
+ }
+ else
+ {
+ for (ParameterMap::iterator i = mParameters.begin(); i != mParameters.end(); ++i)
+ *outList++ = (*i).first;
+ }
+}
+
+//_____________________________________________________________________________
+//
+void AUElement::SaveState(CFMutableDataRef data)
+{
+ if(mUseIndexedParameters)
+ {
+ UInt32 nparams = static_cast(mIndexedParameters.size());
+ UInt32 theData = CFSwapInt32HostToBig(nparams);
+ CFDataAppendBytes(data, (UInt8 *)&theData, sizeof(nparams));
+
+ for (UInt32 i = 0; i < nparams; i++)
+ {
+ struct {
+ UInt32 paramID;
+ //CFSwappedFloat32 value; crashes gcc3 PFE
+ UInt32 value; // really a big-endian float
+ } entry;
+
+ entry.paramID = CFSwapInt32HostToBig(i);
+
+ AudioUnitParameterValue v = mIndexedParameters[i].GetValue();
+ entry.value = CFSwapInt32HostToBig(*(UInt32 *)&v );
+
+ CFDataAppendBytes(data, (UInt8 *)&entry, sizeof(entry));
+ }
+ }
+ else
+ {
+ UInt32 nparams = CFSwapInt32HostToBig(static_cast(mParameters.size()));
+ CFDataAppendBytes(data, (UInt8 *)&nparams, sizeof(nparams));
+
+ for (ParameterMap::iterator i = mParameters.begin(); i != mParameters.end(); ++i) {
+ struct {
+ UInt32 paramID;
+ //CFSwappedFloat32 value; crashes gcc3 PFE
+ UInt32 value; // really a big-endian float
+ } entry;
+
+ entry.paramID = CFSwapInt32HostToBig((*i).first);
+
+ AudioUnitParameterValue v = (*i).second.GetValue();
+ entry.value = CFSwapInt32HostToBig(*(UInt32 *)&v );
+
+ CFDataAppendBytes(data, (UInt8 *)&entry, sizeof(entry));
+ }
+ }
+}
+
+//_____________________________________________________________________________
+//
+const UInt8 * AUElement::RestoreState(const UInt8 *state)
+{
+ union FloatInt32 { UInt32 i; AudioUnitParameterValue f; };
+ const UInt8 *p = state;
+ UInt32 nparams = CFSwapInt32BigToHost(*(UInt32 *)p);
+ p += sizeof(UInt32);
+
+ for (UInt32 i = 0; i < nparams; ++i) {
+ struct {
+ AudioUnitParameterID paramID;
+ AudioUnitParameterValue value;
+ } entry;
+
+ entry.paramID = CFSwapInt32BigToHost(*(UInt32 *)p);
+ p += sizeof(UInt32);
+ FloatInt32 temp;
+ temp.i = CFSwapInt32BigToHost(*(UInt32 *)p);
+ entry.value = temp.f;
+ p += sizeof(AudioUnitParameterValue);
+
+ SetParameter(entry.paramID, entry.value);
+ }
+ return p;
+}
+
+//_____________________________________________________________________________
+//
+void AUElement::SetName (CFStringRef inName)
+{
+ if (mElementName) CFRelease (mElementName);
+ mElementName = inName;
+ if (mElementName) CFRetain (mElementName);
+}
+
+
+//_____________________________________________________________________________
+//
+AUIOElement::AUIOElement(AUBase *audioUnit) :
+ AUElement(audioUnit),
+ mWillAllocate (true)
+{
+ mStreamFormat.SetAUCanonical(2, // stereo
+ audioUnit->AudioUnitAPIVersion() == 1);
+ // interleaved if API version 1, deinterleaved if version 2
+ mStreamFormat.mSampleRate = kAUDefaultSampleRate;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus AUIOElement::SetStreamFormat(const CAStreamBasicDescription &desc)
+{
+ mStreamFormat = desc;
+ return AUBase::noErr;
+}
+
+//_____________________________________________________________________________
+// inFramesToAllocate == 0 implies the AudioUnit's max-frames-per-slice will be used
+void AUIOElement::AllocateBuffer(UInt32 inFramesToAllocate)
+{
+ if (GetAudioUnit()->HasBegunInitializing())
+ {
+ UInt32 framesToAllocate = inFramesToAllocate > 0 ? inFramesToAllocate : GetAudioUnit()->GetMaxFramesPerSlice();
+
+// printf ("will allocate: %d\n", (int)((mWillAllocate && NeedsBufferSpace()) ? framesToAllocate : 0));
+
+ mIOBuffer.Allocate(mStreamFormat, (mWillAllocate && NeedsBufferSpace()) ? framesToAllocate : 0);
+ }
+}
+
+//_____________________________________________________________________________
+//
+void AUIOElement::DeallocateBuffer()
+{
+ mIOBuffer.Deallocate();
+}
+
+//_____________________________________________________________________________
+//
+// AudioChannelLayout support
+
+// outLayoutTagsPtr WILL be NULL if called to find out how many
+// layouts that Audio Unit will report
+// return 0 (ie. NO channel layouts) if the AU doesn't require channel layout knowledge
+UInt32 AUIOElement::GetChannelLayoutTags (AudioChannelLayoutTag *outLayoutTagsPtr)
+{
+ return 0;
+}
+
+// As the AudioChannelLayout can be a variable length structure
+// (though in most cases it won't be!!!)
+// The size of the ACL is always returned by the method
+// if outMapPtr is NOT-NULL, then AU should copy into this pointer (outMapPtr) the current ACL that it has in use.
+// the AU should also return whether the property is writable (that is the client can provide any arbitrary ACL that the audio unit will then honour)
+// or if the property is read only - which is the generally preferred mode.
+// If the AU doesn't require an AudioChannelLayout, then just return 0.
+UInt32 AUIOElement::GetAudioChannelLayout (AudioChannelLayout *outMapPtr,
+ Boolean &outWritable)
+{
+ return 0;
+}
+
+// the incoming channel map will be at least as big as a basic AudioChannelLayout
+// but its contents will determine its actual size
+// Subclass should overide if channel map is writable
+OSStatus AUIOElement::SetAudioChannelLayout (const AudioChannelLayout &inData)
+{
+ return kAudioUnitErr_InvalidProperty;
+}
+
+// Some units support optional usage of channel maps - typically converter units
+// that can do channel remapping between different maps. In that optional case
+// the user should be able to remove a channel map if that is possible.
+// Typically this is NOT the case (e.g., the 3DMixer even in the stereo case
+// needs to know if it is rendering to speakers or headphones)
+OSStatus AUIOElement::RemoveAudioChannelLayout ()
+{
+ return kAudioUnitErr_InvalidPropertyValue;
+}
+
+
+//_____________________________________________________________________________
+//
+AUScope::~AUScope()
+{
+ for (ElementVector::iterator it = mElements.begin(); it != mElements.end(); ++it)
+ delete *it;
+}
+
+//_____________________________________________________________________________
+//
+void AUScope::SetNumberOfElements(UInt32 numElements)
+{
+ if (mDelegate)
+ return mDelegate->SetNumberOfElements(numElements);
+
+ if (numElements > mElements.size()) {
+ mElements.reserve(numElements);
+ while (numElements > mElements.size()) {
+ AUElement *elem = mCreator->CreateElement(GetScope(), static_cast(mElements.size()));
+ mElements.push_back(elem);
+ }
+ } else
+ while (numElements < mElements.size()) {
+ AUElement *elem = mElements.back();
+ mElements.pop_back();
+ delete elem;
+ }
+}
+
+//_____________________________________________________________________________
+//
+bool AUScope::HasElementWithName () const
+{
+ for (UInt32 i = 0; i < GetNumberOfElements(); ++i) {
+ AUElement * el = const_cast(this)->GetElement (i);
+ if (el && el->HasName()) {
+ return true;
+ }
+ }
+ return false;
+}
+
+//_____________________________________________________________________________
+//
+
+void AUScope::AddElementNamesToDict (CFMutableDictionaryRef & inNameDict)
+{
+ if (HasElementWithName())
+ {
+ static char string[32];
+ CFMutableDictionaryRef elementDict = CFDictionaryCreateMutable (NULL, 0,
+ &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ CFStringRef str;
+ for (UInt32 i = 0; i < GetNumberOfElements(); ++i) {
+ AUElement * el = GetElement (i);
+ if (el && el->HasName()) {
+ snprintf (string, sizeof(string), "%d", int(i));
+ str = CFStringCreateWithCString (NULL, string, kCFStringEncodingASCII);
+ CFDictionarySetValue (elementDict, str, el->GetName());
+ CFRelease (str);
+ }
+ }
+
+ snprintf (string, sizeof(string), "%d", int(mScope));
+ str = CFStringCreateWithCString (NULL, string, kCFStringEncodingASCII);
+ CFDictionarySetValue (inNameDict, str, elementDict);
+ CFRelease (str);
+ CFRelease (elementDict);
+ }
+}
+
+//_____________________________________________________________________________
+//
+bool AUScope::RestoreElementNames (CFDictionaryRef& inNameDict)
+{
+ static char string[32];
+
+ //first we have to see if we have enough elements
+ bool didAddElements = false;
+ unsigned int maxElNum = GetNumberOfElements();
+
+ int dictSize = static_cast(CFDictionaryGetCount(inNameDict));
+ CFStringRef * keys = (CFStringRef*)CA_malloc (dictSize * sizeof (CFStringRef));
+ CFDictionaryGetKeysAndValues (inNameDict, reinterpret_cast(keys), NULL);
+ for (int i = 0; i < dictSize; i++)
+ {
+ unsigned int intKey = 0;
+ CFStringGetCString (keys[i], string, 32, kCFStringEncodingASCII);
+ int result = sscanf (string, "%u", &intKey);
+ // check if sscanf succeeded and element index is less than max elements.
+ if (result && UInt32(intKey) < maxElNum)
+ {
+ CFStringRef elName = reinterpret_cast(CFDictionaryGetValue (inNameDict, keys[i]));
+ AUElement* element = GetElement (intKey);
+ if (element)
+ element->SetName (elName);
+ }
+ }
+ free (keys);
+
+ return didAddElements;
+}
+
+void AUScope::SaveState(CFMutableDataRef data)
+{
+ AudioUnitElement nElems = GetNumberOfElements();
+ for (AudioUnitElement ielem = 0; ielem < nElems; ++ielem) {
+ AUElement *element = GetElement(ielem);
+ UInt32 nparams = element->GetNumberOfParameters();
+ if (nparams > 0) {
+ struct {
+ UInt32 scope;
+ UInt32 element;
+ } hdr;
+
+ hdr.scope = CFSwapInt32HostToBig(GetScope());
+ hdr.element = CFSwapInt32HostToBig(ielem);
+ CFDataAppendBytes(data, (UInt8 *)&hdr, sizeof(hdr));
+
+ element->SaveState(data);
+ }
+ }
+}
+
+const UInt8 * AUScope::RestoreState(const UInt8 *state)
+{
+ const UInt8 *p = state;
+ UInt32 elementIdx = CFSwapInt32BigToHost(*(UInt32 *)p); p += sizeof(UInt32);
+ AUElement *element = GetElement(elementIdx);
+ if (!element) {
+ struct {
+ AudioUnitParameterID paramID;
+ AudioUnitParameterValue value;
+ } entry;
+ UInt32 nparams = CFSwapInt32BigToHost(*(UInt32 *)p);
+ p += sizeof(UInt32);
+
+ p += nparams * sizeof(entry);
+ } else
+ p = element->RestoreState(p);
+
+ return p;
+}
diff --git a/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUScopeElement.h b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUScopeElement.h
new file mode 100644
index 000000000..47ebe2f33
--- /dev/null
+++ b/src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUScopeElement.h
@@ -0,0 +1,553 @@
+/*
+ File: AUScopeElement.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 __AUScopeElement_h__
+#define __AUScopeElement_h__
+
+#include