├── .gitattributes ├── .gitignore ├── Apple-SampleCode-ReadMe.txt ├── BuildSystem └── XcodeProjects │ ├── Sample.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ ├── Sample Assistant.xcscheme │ │ ├── Sample Kernel Extension.xcscheme │ │ ├── Sample Plugin.xcscheme │ │ ├── Sample User Client.xcscheme │ │ ├── Sample.xcscheme │ │ ├── SampleVCam Assistant.xcscheme │ │ ├── SampleVCam Plugin.xcscheme │ │ └── SampleVCam.xcscheme │ └── xcconfigs │ ├── CMIOSampleCommon.xcconfig │ ├── CMIOSampleDebug.xcconfig │ └── CMIOSampleRelease.xcconfig ├── Documentation ├── Core Media IO DAL Example.pdf └── DAL Sample Explained.pdf ├── LICENSE.txt ├── Prebuilts ├── Prebuilts ReadMe.txt ├── Sample-Debug.tar.gz └── Sample-Release.tar.gz ├── README.md └── Sources └── Extras ├── CoreAudio └── PublicUtility │ ├── AUOutputBL.cpp │ ├── AUOutputBL.h │ ├── AUParamInfo.cpp │ ├── AUParamInfo.h │ ├── CAAUMIDIMap.cpp │ ├── CAAUMIDIMap.h │ ├── CAAUMIDIMapManager.cpp │ ├── CAAUMIDIMapManager.h │ ├── CAAUParameter.cpp │ ├── CAAUParameter.h │ ├── CAAUProcessor.cpp │ ├── CAAUProcessor.h │ ├── CAAtomic.h │ ├── CAAtomicStack.h │ ├── CAAudioBufferList.cpp │ ├── CAAudioBufferList.h │ ├── CAAudioChannelLayout.cpp │ ├── CAAudioChannelLayout.h │ ├── CAAudioChannelLayoutObject.cpp │ ├── CAAudioFileFormats.cpp │ ├── CAAudioFileFormats.h │ ├── CAAudioTimeStamp.cpp │ ├── CAAudioTimeStamp.h │ ├── CAAudioUnit.cpp │ ├── CAAudioUnit.h │ ├── CAAudioUnitOutputCapturer.h │ ├── CAAudioValueRange.cpp │ ├── CAAudioValueRange.h │ ├── CAAutoDisposer.h │ ├── CABitOperations.h │ ├── CABool.h │ ├── CABufferList.cpp │ ├── CABufferList.h │ ├── CABundleLocker.cpp │ ├── CABundleLocker.h │ ├── CAByteOrder.h │ ├── CACFArray.cpp │ ├── CACFArray.h │ ├── CACFData.h │ ├── CACFDictionary.cpp │ ├── CACFDictionary.h │ ├── CACFDistributedNotification.cpp │ ├── CACFDistributedNotification.h │ ├── CACFMachPort.cpp │ ├── CACFMachPort.h │ ├── CACFMessagePort.cpp │ ├── CACFMessagePort.h │ ├── CACFNumber.cpp │ ├── CACFNumber.h │ ├── CACFObject.h │ ├── CACFPlugIn.h │ ├── CACFPreferences.cpp │ ├── CACFPreferences.h │ ├── CACFString.cpp │ ├── CACFString.h │ ├── CAComponent.cpp │ ├── CAComponent.h │ ├── CAComponentDescription.cpp │ ├── CAComponentDescription.h │ ├── CADebugMacros.cpp │ ├── CADebugMacros.h │ ├── CADebugPrintf.cpp │ ├── CADebugPrintf.h │ ├── CADebugger.cpp │ ├── CADebugger.h │ ├── CAException.h │ ├── CAExtAudioFile.h │ ├── CAFilePathUtils.cpp │ ├── CAFilePathUtils.h │ ├── CAGuard.cpp │ ├── CAGuard.h │ ├── CAHALAudioDevice.cpp │ ├── CAHALAudioDevice.h │ ├── CAHALAudioObject.cpp │ ├── CAHALAudioObject.h │ ├── CAHALAudioStream.cpp │ ├── CAHALAudioStream.h │ ├── CAHALAudioSystemObject.cpp │ ├── CAHALAudioSystemObject.h │ ├── CAHostTimeBase.cpp │ ├── CAHostTimeBase.h │ ├── CALogMacros.h │ ├── CAMath.h │ ├── CAMixMap.h │ ├── CAMutex.cpp │ ├── CAMutex.h │ ├── CAPThread.cpp │ ├── CAPThread.h │ ├── CAPersistence.cpp │ ├── CAProcess.cpp │ ├── CAProcess.h │ ├── CAPropertyAddress.h │ ├── CAReferenceCounted.h │ ├── CARingBuffer.cpp │ ├── CARingBuffer.h │ ├── CASettingsStorage.cpp │ ├── CASettingsStorage.h │ ├── CASharedLibrary.cpp │ ├── CASharedLibrary.h │ ├── CASpectralProcessor.cpp │ ├── CASpectralProcessor.h │ ├── CAStreamBasicDescription.cpp │ ├── CAStreamBasicDescription.h │ ├── CAStreamRangedDescription.cpp │ ├── CAStreamRangedDescription.h │ ├── CAThreadSafeList.h │ ├── CATink.h │ ├── CATokenMap.h │ ├── CAVectorUnit.cpp │ ├── CAVectorUnit.h │ ├── CAVectorUnitTypes.h │ ├── CAVolumeCurve.cpp │ ├── CAVolumeCurve.h │ ├── CAXException.cpp │ ├── CAXException.h │ ├── MatrixMixerVolumes.cpp │ └── MatrixMixerVolumes.h ├── CoreMediaIO ├── DeviceAbstractionLayer │ └── Devices │ │ ├── DP │ │ ├── Base │ │ │ ├── CMIO_DP_Command.cpp │ │ │ ├── CMIO_DP_Command.h │ │ │ ├── CMIO_DP_Control.cpp │ │ │ ├── CMIO_DP_Control.h │ │ │ ├── CMIO_DP_ControlDictionary.cpp │ │ │ ├── CMIO_DP_ControlDictionary.h │ │ │ ├── CMIO_DP_Device.cpp │ │ │ ├── CMIO_DP_Device.h │ │ │ ├── CMIO_DP_DeviceCommands.cpp │ │ │ ├── CMIO_DP_DeviceCommands.h │ │ │ ├── CMIO_DP_DeviceSettings.cpp │ │ │ ├── CMIO_DP_DeviceSettings.h │ │ │ ├── CMIO_DP_HardwarePlugInInterface.cpp │ │ │ ├── CMIO_DP_HogMode.cpp │ │ │ ├── CMIO_DP_HogMode.h │ │ │ ├── CMIO_DP_Object.cpp │ │ │ ├── CMIO_DP_Object.h │ │ │ ├── CMIO_DP_PlugIn.cpp │ │ │ ├── CMIO_DP_PlugIn.h │ │ │ ├── CMIO_DP_Property.cpp │ │ │ ├── CMIO_DP_Property.h │ │ │ ├── CMIO_DP_Stream.cpp │ │ │ ├── CMIO_DP_Stream.h │ │ │ ├── CMIO_DP_UserInfo.cpp │ │ │ └── CMIO_DP_UserInfo.h │ │ └── Properties │ │ │ ├── CMIO_DP_Property_Base.cpp │ │ │ ├── CMIO_DP_Property_Base.h │ │ │ ├── CMIO_DP_Property_ClientSyncDiscontinuity.cpp │ │ │ ├── CMIO_DP_Property_ClientSyncDiscontinuity.h │ │ │ ├── CMIO_DP_Property_Clock.cpp │ │ │ ├── CMIO_DP_Property_Clock.h │ │ │ ├── CMIO_DP_Property_Deck.cpp │ │ │ ├── CMIO_DP_Property_Deck.h │ │ │ ├── CMIO_DP_Property_DeviceIsAlive.cpp │ │ │ ├── CMIO_DP_Property_DeviceIsAlive.h │ │ │ ├── CMIO_DP_Property_DeviceMaster.cpp │ │ │ ├── CMIO_DP_Property_DeviceMaster.h │ │ │ ├── CMIO_DP_Property_EndOfData.cpp │ │ │ ├── CMIO_DP_Property_EndOfData.h │ │ │ ├── CMIO_DP_Property_FirstOutputPresentationTimeStamp.cpp │ │ │ ├── CMIO_DP_Property_FirstOutputPresentationTimeStamp.h │ │ │ ├── CMIO_DP_Property_FormatList.cpp │ │ │ ├── CMIO_DP_Property_FormatList.h │ │ │ ├── CMIO_DP_Property_HogMode.cpp │ │ │ ├── CMIO_DP_Property_HogMode.h │ │ │ ├── CMIO_DP_Property_NoData.cpp │ │ │ ├── CMIO_DP_Property_NoData.h │ │ │ ├── CMIO_DP_Property_OutputBuffers.cpp │ │ │ ├── CMIO_DP_Property_OutputBuffers.h │ │ │ ├── CMIO_DP_Property_SMPTETimeCallback.cpp │ │ │ ├── CMIO_DP_Property_SMPTETimeCallback.h │ │ │ ├── CMIO_DP_Property_ScheduledOutputNotificationProc.cpp │ │ │ ├── CMIO_DP_Property_ScheduledOutputNotificationProc.h │ │ │ ├── CMIO_DP_Property_SuspendedByUser.cpp │ │ │ └── CMIO_DP_Property_SuspendedByUser.h │ │ ├── GenerateMIGOutput.pl │ │ ├── IOV │ │ └── PlugIn │ │ │ ├── CMIO_DP_IOV_Control.cpp │ │ │ ├── CMIO_DP_IOV_Control.h │ │ │ ├── CMIO_DP_IOV_ControlDictionary.cpp │ │ │ └── CMIO_DP_IOV_ControlDictionary.h │ │ └── Sample │ │ ├── Assistant │ │ ├── CMIO_DPA_Sample_Shared.h │ │ ├── Client │ │ │ ├── CMIO_DPA_Sample_ClientExtras.cpp │ │ │ └── CMIO_DPA_Sample_ClientExtras.h │ │ ├── MIG │ │ │ └── CMIODPASample.defs │ │ ├── Server │ │ │ ├── CMIO_DPA_Sample_Server.cpp │ │ │ ├── CMIO_DPA_Sample_Server_Assistant.cpp │ │ │ ├── CMIO_DPA_Sample_Server_Assistant.h │ │ │ ├── CMIO_DPA_Sample_Server_Common.h │ │ │ ├── CMIO_DPA_Sample_Server_IOBackedAssistant.cpp │ │ │ ├── CMIO_DPA_Sample_Server_IOBackedAssistant.h │ │ │ ├── CMIO_DPA_Sample_Server_MIGInterface.cpp │ │ │ ├── CMIO_DPA_Sample_Server_MIGInterface.h │ │ │ ├── CMIO_DPA_Sample_Server_VCamAssistant.cpp │ │ │ ├── CMIO_DPA_Sample_Server_VCamAssistant.h │ │ │ ├── CMIO_DPA_Sample_VCamServer.cpp │ │ │ └── Device │ │ │ │ ├── CMIO_DPA_Sample_Server_ClientStream.cpp │ │ │ │ ├── CMIO_DPA_Sample_Server_ClientStream.h │ │ │ │ ├── CMIO_DPA_Sample_Server_Deck.cpp │ │ │ │ ├── CMIO_DPA_Sample_Server_Deck.h │ │ │ │ ├── CMIO_DPA_Sample_Server_Device.cpp │ │ │ │ ├── CMIO_DPA_Sample_Server_Device.h │ │ │ │ ├── CMIO_DPA_Sample_Server_Frame.cpp │ │ │ │ ├── CMIO_DPA_Sample_Server_Frame.h │ │ │ │ ├── CMIO_DPA_Sample_Server_IOBackedDevice.cpp │ │ │ │ ├── CMIO_DPA_Sample_Server_IOBackedDevice.h │ │ │ │ ├── CMIO_DPA_Sample_Server_IOBackedFrame.cpp │ │ │ │ ├── CMIO_DPA_Sample_Server_IOBackedFrame.h │ │ │ │ ├── CMIO_DPA_Sample_Server_IOBackedStream.cpp │ │ │ │ ├── CMIO_DPA_Sample_Server_IOBackedStream.h │ │ │ │ ├── CMIO_DPA_Sample_Server_Stream.cpp │ │ │ │ ├── CMIO_DPA_Sample_Server_Stream.h │ │ │ │ ├── CMIO_DPA_Sample_Server_VCamDevice.cpp │ │ │ │ ├── CMIO_DPA_Sample_Server_VCamDevice.h │ │ │ │ ├── CMIO_DPA_Sample_Server_VCamInputStream.cpp │ │ │ │ └── CMIO_DPA_Sample_Server_VCamInputStream.h │ │ ├── com.apple.cmio.DPA.Sample.plist │ │ └── com.apple.cmio.DPA.SampleVCam.plist │ │ ├── KernelExtension │ │ ├── CMIO_KEXT_Sample_ControlIDs.h │ │ ├── IOUSBLog.h │ │ ├── IOVideoSampleDevice.cpp │ │ ├── IOVideoSampleDevice.h │ │ ├── IOVideoSampleDeviceShared.h │ │ ├── IOVideoSampleStream.cpp │ │ ├── IOVideoSampleStream.h │ │ ├── SampleDriver-Info.plist │ │ └── SampleUserClient-Info.plist │ │ ├── PlugIn │ │ ├── CMIO_DP_SampleVCam_PlugInInterface.cpp │ │ ├── CMIO_DP_Sample_ControlIDs.h │ │ ├── CMIO_DP_Sample_Device.cpp │ │ ├── CMIO_DP_Sample_Device.h │ │ ├── CMIO_DP_Sample_IOBackedDevice.cpp │ │ ├── CMIO_DP_Sample_IOBackedDevice.h │ │ ├── CMIO_DP_Sample_PlugIn.cpp │ │ ├── CMIO_DP_Sample_PlugIn.h │ │ ├── CMIO_DP_Sample_PlugInInterface.cpp │ │ ├── CMIO_DP_Sample_Stream.cpp │ │ ├── CMIO_DP_Sample_Stream.h │ │ ├── CMIO_DP_Sample_VirtualDevice.cpp │ │ ├── CMIO_DP_Sample_VirtualDevice.h │ │ ├── Properties │ │ │ ├── CMIO_DP_Sample_Property_HogMode.cpp │ │ │ └── CMIO_DP_Sample_Property_HogMode.h │ │ ├── Sample-Info.plist │ │ ├── Sample.exp │ │ ├── SampleVCam-Info.plist │ │ └── SampleVCam.exp │ │ └── SamplePrefix.h └── PublicUtility │ ├── CMIODebugMacros.cpp │ ├── CMIODebugMacros.h │ ├── CMIODebugPrintf.cpp │ ├── CMIODebugPrintf.h │ ├── CMIO_BitField.h │ ├── CMIO_Buffer.h │ ├── CMIO_CC_608_Scraper.cpp │ ├── CMIO_CC_608_Scraper.h │ ├── CMIO_PropertyAddress.h │ ├── CMIO_SMPTETimeBase.cpp │ ├── CMIO_SMPTETimeBase.h │ ├── CoreMediaAssistant │ ├── CMIO_CMA_BlockBuffer.h │ ├── CMIO_CMA_FormatDescription.h │ ├── CMIO_CMA_SampleBuffer.h │ ├── CMIO_CMA_SimpleQueue.h │ └── CMIO_CMA_Time.h │ ├── CoreVideoAssistant │ ├── CMIO_CVA_Buffer.h │ ├── CMIO_CVA_Image_Buffer.h │ └── CMIO_CVA_Pixel_Buffer.h │ ├── DALAssistant │ ├── CMIO_DALA_Control.cpp │ ├── CMIO_DALA_Control.h │ ├── CMIO_DALA_Device.cpp │ ├── CMIO_DALA_Device.h │ ├── CMIO_DALA_Object.cpp │ ├── CMIO_DALA_Object.h │ ├── CMIO_DALA_Stream.cpp │ ├── CMIO_DALA_Stream.h │ ├── CMIO_DALA_System.cpp │ └── CMIO_DALA_System.h │ ├── IOKitAssistant │ ├── CMIO_IOKA_Iterator.h │ ├── CMIO_IOKA_NotificationPort.cpp │ ├── CMIO_IOKA_NotificationPort.h │ ├── CMIO_IOKA_Object.h │ ├── CMIO_IOKA_PowerNotificationPort.h │ └── CMIO_IOKA_VirtualRange.h │ ├── IOStreamAssistant │ ├── CMIO_IOSA_Assistance.cpp │ └── CMIO_IOSA_Assistance.h │ ├── IOSurfaceAssistant │ ├── CMIO_SA_Assistance.cpp │ └── CMIO_SA_Assistance.h │ ├── IOVideoAssistant │ ├── CMIO_IOVA_Assistance.cpp │ └── CMIO_IOVA_Assistance.h │ └── POSIXThreadAssistant │ ├── CMIO_PTA_Assistance.h │ ├── CMIO_PTA_CFMachPortThread.cpp │ ├── CMIO_PTA_CFMachPortThread.h │ ├── CMIO_PTA_NotificationPortThread.cpp │ └── CMIO_PTA_NotificationPortThread.h └── IOVideo └── IOVideoDebugMacros.h /.gitattributes: -------------------------------------------------------------------------------- 1 | *.tar.gz filter=lfs diff=lfs merge=lfs -text 2 | *.yuv filter=lfs diff=lfs merge=lfs -text 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | BuildResults 2 | xcuserdata 3 | .DS_Store 4 | 5 | -------------------------------------------------------------------------------- /Apple-SampleCode-ReadMe.txt: -------------------------------------------------------------------------------- 1 | ### CoreMediaIO ### 2 | 3 | =========================================================================== 4 | DESCRIPTION: 5 | 6 | The CoreMediaIO Device Abstraction Layer (DAL) is analogous to CoreAudio’s Hardware Abstraction Layer (HAL). Just as the HAL deals with audio streams from audio hardware, the DAL handles video (and muxed) streams from video devices. 7 | This SDK will demonstrate how to create a user-level DAL plugIn, a user-level “assistant” server process that allows the device to vend its video data to several processes at once, and a kernel extension (KEXT) for manipulating the device’s hardware. 8 | 9 | =========================================================================== 10 | BUILD REQUIREMENTS: 11 | 12 | Mac OS X v10.7.4 or later 13 | 14 | =========================================================================== 15 | RUNTIME REQUIREMENTS: 16 | 17 | Mac OS X v10.7.4 or later 18 | 19 | =========================================================================== 20 | PACKAGING LIST: 21 | 22 | Please refer to the "CoreMediaIO DAL Example.pdf" and "DAL Sample Explained.pdf" in the Documentation folder for detailed explanations of the example. 23 | 24 | =========================================================================== 25 | CHANGES FROM PREVIOUS VERSIONS: 26 | 27 | Version 1.0 28 | - First version. 29 | 30 | =========================================================================== 31 | Copyright (C) 2012 Apple Inc. All rights reserved. 32 | -------------------------------------------------------------------------------- /BuildSystem/XcodeProjects/Sample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /BuildSystem/XcodeProjects/Sample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /BuildSystem/XcodeProjects/Sample.xcodeproj/xcshareddata/xcschemes/Sample Kernel Extension.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 66 | 67 | 70 | 71 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /BuildSystem/XcodeProjects/Sample.xcodeproj/xcshareddata/xcschemes/Sample Plugin.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 66 | 67 | 70 | 71 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /BuildSystem/XcodeProjects/Sample.xcodeproj/xcshareddata/xcschemes/Sample User Client.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 66 | 67 | 70 | 71 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /BuildSystem/XcodeProjects/Sample.xcodeproj/xcshareddata/xcschemes/SampleVCam Plugin.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /BuildSystem/XcodeProjects/xcconfigs/CMIOSampleCommon.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // This is the base .xcconfig file for the CoreMediaIO Sample. Settings common to all configurations can be specified here. 3 | // 4 | 5 | XCCONFIG_CMIO_SAMPLE_COMMON = INCLUDED 6 | 7 | PROJROOT = ../.. 8 | 9 | // If the project wants to deposit build results in different locations for different versions of the OS, the $(CONFIGURATIONPREFIX) can be set in the Sample.xcodeproj using a conditional 10 | // build setting. 11 | CONFIGURATIONPREFIX = 12 | 13 | SYMROOT = $(PROJROOT)/BuildResults/$(CMIOROOTNAME) 14 | DSTROOT = $(SYMROOT)/$(CONFIGURATIONPREFIX)$(CONFIGURATION)/root 15 | CONFIGURATION_BUILD_DIR = $(SYMROOT)/$(CONFIGURATIONPREFIX)$(CONFIGURATION)/symbolicroot 16 | 17 | ARCHS = $(ARCHS_STANDARD_32_64_BIT) 18 | DEPLOYMENT_LOCATION = YES 19 | 20 | CMIO_SAMPLE_OTHER_CFLAGS = -fconstant-cfstrings -fstack-protector -D_FORTIFY_SOURCE=2 21 | OTHER_CFLAGS = $(CMIO_SAMPLE_OTHER_CFLAGS) 22 | 23 | CMIO_SAMPLE_OTHER_CPLUSPLUSFLAGS = -Wreorder $(OTHER_CFLAGS) 24 | OTHER_CPLUSPLUSFLAGS = $(CMIO_SAMPLE_OTHER_CPLUSPLUSFLAGS) 25 | 26 | SDKROOT = 27 | 28 | GCC_MODEL_TUNING = G5 29 | GCC_WARN_ABOUT_RETURN_TYPE = YES 30 | GCC_WARN_UNUSED_VARIABLE = YES 31 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES 32 | GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES 33 | 34 | DEAD_CODE_STRIPPING = YES 35 | ALWAYS_SEARCH_USER_PATHS = NO 36 | 37 | RC_ProjectSourceVersion = EngineeringBuild-$(USER) 38 | -------------------------------------------------------------------------------- /BuildSystem/XcodeProjects/xcconfigs/CMIOSampleDebug.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // This is the debug .xcconfig file for the CoreMediaIO Sample. Settings common to all debug configurations can be specified here. 3 | // 4 | 5 | XCCONFIG_CMIO_SAMPLE_DEBUG = INCLUDED 6 | 7 | #include "CMIOSampleCommon.xcconfig" 8 | 9 | COPY_PHASE_STRIP = NO 10 | GCC_OPTIMIZATION_LEVEL = 0 11 | GCC_GENERATE_DEBUGGING_SYMBOLS = YES 12 | GCC_PREPROCESSOR_DEFINITIONS = 13 | -------------------------------------------------------------------------------- /BuildSystem/XcodeProjects/xcconfigs/CMIOSampleRelease.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // This is the release .xcconfig file for the CoreMediaIO Sample. Settings common to all release configurations can be specified here. 3 | // 4 | 5 | XCCONFIG_CMIO_SAMPLE_RELEASE = INCLUDED 6 | 7 | #include "CMIOSampleCommon.xcconfig" 8 | 9 | COPY_PHASE_STRIP = YES 10 | GCC_OPTIMIZATION_LEVEL = s 11 | GCC_GENERATE_DEBUGGING_SYMBOLS = YES 12 | GCC_PREPROCESSOR_DEFINITIONS = -------------------------------------------------------------------------------- /Documentation/Core Media IO DAL Example.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lvsti/CoreMediaIO-DAL-Example/742ccb114735245bf3bc7f5a29d381526b82b720/Documentation/Core Media IO DAL Example.pdf -------------------------------------------------------------------------------- /Documentation/DAL Sample Explained.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lvsti/CoreMediaIO-DAL-Example/742ccb114735245bf3bc7f5a29d381526b82b720/Documentation/DAL Sample Explained.pdf -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Tamas Lustyik 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Prebuilts/Prebuilts ReadMe.txt: -------------------------------------------------------------------------------- 1 | ### CoreMediaIO Prebuilts ### 2 | 3 | =========================================================================== 4 | DESCRIPTION: 5 | 6 | A prebuilt version of the Sample (in Debug & Release form) is provided for convenience. 7 | 8 | =========================================================================== 9 | BUILD REQUIREMENTS: 10 | 11 | Mac OS X v10.7.4 or later 12 | 13 | =========================================================================== 14 | RUNTIME REQUIREMENTS: 15 | 16 | Mac OS X v10.7.4 or later 17 | 18 | =========================================================================== 19 | INSTRUCTIONS 20 | 21 | From Terminal issue a 22 | 23 | sudo darwinup install {path to CoreMediaIO folder}/Prebuilts/Sample-Debug.tar.gz 24 | or 25 | sudo darwinup install {path to CoreMediaIO folder}/Prebuilts/Release-Debug.tar.gz 26 | 27 | =========================================================================== 28 | Copyright (C) 2012 Apple Inc. All rights reserved. 29 | -------------------------------------------------------------------------------- /Prebuilts/Sample-Debug.tar.gz: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:33c6c3dadf3504017b8f3c774221d6e56c393e8f5f3905a06a9e67f1726073d9 3 | size 16538129 4 | -------------------------------------------------------------------------------- /Prebuilts/Sample-Release.tar.gz: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f213d780b2de601eea492bf394bb5feaf926c4199324edd7ce68cc7780efdfd8 3 | size 15545958 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CoreMediaIO-DAL-Example 2 | 3 | Modernized and extended version of Apple's CoreMediaIO sample code. 4 | 5 | ### Before you jump right in 6 | 7 | Apple announced the **deprecation of CMIO DAL plugins** at WWDC 2022, sunsetting them definitely in the next major release after macOS 13 (that is, in macOS 14). As a replacement, [Camera Extensions](https://developer.apple.com/documentation/coremediaio/creating_a_camera_extension_with_core_media_i_o) have been introduced in macOS 12.3 which are now the preferred way to develop camera plugins. If you are about to start development, do yourself a favor: drop support for anything below macOS 12.3 and **don't waste your time with DAL plugins**. 8 | 9 | If you are still here, read on. 10 | 11 | ### Description 12 | 13 | This repository started off as a fork of the official [CoreMediaIO sample code](https://developer.apple.com/library/archive/samplecode/CoreMediaIO/Introduction/Intro.html) by Apple. Unfortunately, the original code didn't age well since it was last updated in 2012 so here you can find the necessary changes to make it compile on modern systems. 14 | 15 | ### Virtual camera support 16 | 17 | The original sample was mainly focused around camera plugins backed by real hardware which may be of little interest to anyone who is not a camera manufacturer. So eventually the code was extended with virtual camera support, i.e. DAL plugins that appear and can act like video sources but have no accompanying hardware. These cameras may draw their frames from whatever source they please, including but not limited to baked-in still images, content generated on-the-fly by the plugin itself, and relayed frames originating from a user-space companion application. (Note that the present code only implements reading from a static framestore.) 18 | 19 | ### Known issues 20 | 21 | - the kext is not being maintained and is most probably dysfunctional 22 | - IPC between the plugin and assistant is still built around the obsolete bootstrap server, this should be replaced by XPC 23 | - and many more, see the [Issues tab](https://github.com/lvsti/CoreMediaIO-DAL-Example/issues) (and help reporting them if you come across one) 24 | 25 | ### Requirements to build 26 | 27 | Xcode 10.1+ 28 | 29 | Note: the sample YUV files in the [KernelExtension](https://github.com/lvsti/CoreMediaIO-DAL-Example/tree/master/Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/KernelExtension) folder have been removed from the repo because the increased traffic continuously exhausted my LFS quota. From now on, please refer to the official [CoreMediaIO sample code](https://developer.apple.com/library/archive/samplecode/CoreMediaIO/Introduction/Intro.html) bundle which also contains these files. 30 | 31 | ### Contributing 32 | 33 | The goal of this project is to maintain an up-to-date and relevant sample code for those who have just made first contact with the CoreMediaIO DAL world. Contributions along these lines are warmly welcome. Improvements, however, that are introducing a new feature or would steer the project away from its general/educational purpose would probably best be placed in a different fork. 34 | 35 | ### License 36 | 37 | MIT 38 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/AUOutputBL.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: AUOutputBL.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | */ 6 | #ifndef __AUOutputBL_h__ 7 | #define __AUOutputBL_h__ 8 | 9 | #include "CAStreamBasicDescription.h" 10 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 11 | #else 12 | #endif 13 | 14 | // ____________________________________________________________________________ 15 | // 16 | // AUOutputBL - Simple Buffer List wrapper targetted to use with retrieving AU output 17 | // Works in one of two ways (both adjustable)... Can use it with NULL pointers, or allocate 18 | // memory to receive the data in. 19 | 20 | // Before using this with any call to AudioUnitRender, it needs to be Prepared 21 | // as some calls to AudioUnitRender can reset the ABL 22 | 23 | class AUOutputBL { 24 | public: 25 | 26 | // you CANNOT use one of these - it will crash! 27 | // AUOutputBL (); 28 | 29 | // this is the constructor that you use 30 | // it can't be reset once you've constructed it 31 | AUOutputBL (const CAStreamBasicDescription &inDesc, UInt32 inDefaultNumFrames = 512); 32 | ~AUOutputBL(); 33 | 34 | void Prepare () 35 | { 36 | Prepare (mFrames); 37 | } 38 | 39 | // this version can throw if this is an allocted ABL and inNumFrames is > AllocatedFrames() 40 | // you can set the bool to true if you want a NULL buffer list even if allocated 41 | // inNumFrames must be a valid number (will throw if inNumFrames is 0) 42 | void Prepare (UInt32 inNumFrames, bool inWantNullBufferIfAllocated = false); 43 | 44 | AudioBufferList* ABL() { return mBufferList; } 45 | 46 | // You only need to call this if you want to allocate a buffer list 47 | // if you want an empty buffer list, just call Prepare() 48 | // if you want to dispose previously allocted memory, pass in 0 49 | // then you either have an empty buffer list, or you can re-allocate 50 | // Memory is kept around if an Allocation request is less than what is currently allocated 51 | void Allocate (UInt32 inNumberFrames); 52 | 53 | UInt32 AllocatedFrames() const { return mFrames; } 54 | 55 | const CAStreamBasicDescription& GetFormat() const { return mFormat; } 56 | 57 | #if DEBUG 58 | void Print(); 59 | #endif 60 | 61 | private: 62 | UInt32 AllocatedBytes () const { return (mBufferSize * mNumberBuffers); } 63 | 64 | CAStreamBasicDescription mFormat; 65 | Byte* mBufferMemory; 66 | AudioBufferList* mBufferList; 67 | UInt32 mNumberBuffers; 68 | UInt32 mBufferSize; 69 | UInt32 mFrames; 70 | 71 | // don't want to copy these.. can if you want, but more code to write! 72 | AUOutputBL () {} 73 | AUOutputBL (const AUOutputBL &c); 74 | AUOutputBL& operator= (const AUOutputBL& c); 75 | }; 76 | 77 | #endif // __AUOutputBL_h__ 78 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/AUParamInfo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: AUParamInfo.cpp 3 | Abstract: AUParamInfo.h 4 | Version: 1.1 5 | */ 6 | #include "AUParamInfo.h" 7 | #include "CAXException.h" 8 | 9 | AUParamInfo::AUParamInfo (AudioUnit inAU, 10 | bool inIncludeExpert, 11 | bool inIncludeReadOnly, 12 | AudioUnitScope inScope, 13 | AudioUnitElement inElement) 14 | : mAU (inAU), 15 | mNumParams (0), 16 | mParamListID(NULL), 17 | mScope (inScope), 18 | mElement (inElement) 19 | { 20 | UInt32 size; 21 | OSStatus result = AudioUnitGetPropertyInfo(mAU, kAudioUnitProperty_ParameterList, inScope, mElement, &size, NULL); 22 | if (size == 0 || result) return; 23 | 24 | int nparams = size / sizeof(AudioUnitPropertyID); 25 | mParamListID = new AudioUnitParameterID[nparams]; 26 | 27 | memset (mParamListID, 0xFF, size); 28 | 29 | AudioUnitParameterID *paramList = new AudioUnitParameterID[nparams]; 30 | 31 | result = AudioUnitGetProperty(mAU, kAudioUnitProperty_ParameterList, mScope, mElement, paramList, &size); 32 | if (result) { 33 | delete [] mParamListID; 34 | delete [] paramList; 35 | mParamListID = NULL; 36 | return; 37 | } 38 | 39 | ParameterMap params; 40 | for (int i = 0; i < nparams; ++i) 41 | { 42 | CAAUParameter auvp (mAU, paramList[i], mScope, mElement); // took out only using global scope in CAAUParameter creation 43 | const AudioUnitParameterInfo ¶mInfo = auvp.ParamInfo(); 44 | 45 | // don't include if parameter can't be read or written 46 | if (!(paramInfo.flags & kAudioUnitParameterFlag_IsWritable) 47 | && !(paramInfo.flags & kAudioUnitParameterFlag_IsReadable)) 48 | continue; 49 | 50 | // only include if expert params wanted 51 | if (!inIncludeExpert && auvp.IsExpert()) 52 | continue; 53 | 54 | // only include if read only params are wanted 55 | if (!(paramInfo.flags & kAudioUnitParameterFlag_IsWritable) 56 | && (paramInfo.flags & kAudioUnitParameterFlag_IsReadable)) 57 | { 58 | if (!inIncludeReadOnly) 59 | continue; 60 | } 61 | 62 | mParamListID[mNumParams] = paramList[i]; 63 | mNumParams++; 64 | 65 | // ok - if we're here, then we have a parameter we are going to display. 66 | UInt32 clump = 0; 67 | auvp.GetClumpID (clump); 68 | mParams[clump].push_back (auvp); 69 | } 70 | 71 | delete [] paramList; 72 | } 73 | 74 | AUParamInfo::~AUParamInfo() 75 | { 76 | delete [] mParamListID; 77 | } 78 | 79 | UInt32 AUParamInfo::NumParamsForClump (UInt32 inClump) const 80 | { 81 | ParameterMap::const_iterator it = mParams.find(inClump); 82 | if (it != mParams.end()) 83 | return static_cast((*it).second.size()); 84 | return 0; 85 | } 86 | 87 | const CAAUParameter* AUParamInfo::GetParamInfo (AudioUnitParameterID inParamID) const 88 | { 89 | for (ParameterMap::const_iterator it = mParams.begin(); it != mParams.end(); ++it) { 90 | const ParameterList &list = (*it).second; 91 | for (ParameterList::const_iterator iter = list.begin(); iter != list.end(); ++iter) { 92 | if (inParamID == (*iter).mParameterID) { 93 | return &(*iter); 94 | } 95 | } 96 | } 97 | return NULL; 98 | } 99 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/AUParamInfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: AUParamInfo.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include "CAAUParameter.h" 10 | 11 | /* 12 | The ParameterMap returned by the Map() method is a map where 13 | - the key is the clumpID 14 | - the value is a ParameterList (vector) 15 | 16 | If you have parameters on multiple scopes (or elements within a scope), then you should create one of these 17 | for each scope-element pair 18 | */ 19 | 20 | class AUParamInfo { 21 | 22 | public: 23 | typedef std::vector ParameterList; 24 | typedef std::map > ParameterMap; 25 | 26 | 27 | 28 | AUParamInfo (AudioUnit inAU, 29 | bool inIncludeExpert, 30 | bool inIncludeReadOnly, 31 | AudioUnitScope inScope = kAudioUnitScope_Global, 32 | AudioUnitElement inElement = 0); 33 | 34 | ~AUParamInfo(); 35 | 36 | const ParameterMap& Map () const { return mParams; } 37 | 38 | // some convenience methods 39 | UInt32 NumParams () const { return mNumParams; } 40 | 41 | AudioUnitParameterID ParamID (UInt32 inIndex) const 42 | { 43 | if (inIndex < mNumParams) return mParamListID[inIndex]; 44 | return 0xFFFFFFFF; 45 | } 46 | 47 | UInt32 NumClumps () const { return static_cast(mParams.size()); } 48 | 49 | UInt32 NumParamsForClump (UInt32 inClump) const; 50 | 51 | // returns NULL if there's no info for the parameter 52 | const CAAUParameter* GetParamInfo (AudioUnitParameterID inParamID) const; 53 | 54 | AudioUnitScope GetScope () const { return mScope; } 55 | AudioUnitElement GetElement () const { return mElement; } 56 | 57 | private: 58 | 59 | AudioUnit mAU; 60 | UInt32 mNumParams; 61 | AudioUnitParameterID * mParamListID; 62 | 63 | ParameterMap mParams; 64 | AudioUnitScope mScope; 65 | AudioUnitElement mElement; 66 | 67 | // disallow 68 | AUParamInfo () {} 69 | AUParamInfo (const AUParamInfo &c) {} 70 | AUParamInfo& operator= (const AUParamInfo& c) { return *this; } 71 | }; 72 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CAAUMIDIMapManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAAUMIDIMapManager.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | */ 6 | #ifndef __CAAUMIDIMapManager_h_ 7 | #define __CAAUMIDIMapManager_h_ 8 | 9 | #include "AUBase.h" 10 | #include "CAAUMIDIMap.h" 11 | #include 12 | #include 13 | 14 | class CAAUMIDIMapManager { 15 | 16 | protected: 17 | 18 | typedef std::vector ParameterMaps; 19 | ParameterMaps mParameterMaps; 20 | 21 | bool hotMapping; 22 | AUParameterMIDIMapping mHotMap; 23 | 24 | public: 25 | 26 | CAAUMIDIMapManager(); 27 | 28 | UInt32 NumMaps(){return static_cast(mParameterMaps.size());} 29 | void GetMaps(AUParameterMIDIMapping* maps); 30 | 31 | int FindParameterIndex(AUParameterMIDIMapping &map); 32 | 33 | void GetHotParameterMap(AUParameterMIDIMapping &outMap); 34 | 35 | void SortedRemoveFromParameterMaps (AUParameterMIDIMapping *maps, UInt32 inNumMaps, bool &outMapDidChange); 36 | OSStatus SortedInsertToParamaterMaps (AUParameterMIDIMapping *maps, UInt32 inNumMaps, AUBase &That); 37 | 38 | void ReplaceAllMaps (AUParameterMIDIMapping* inMappings, UInt32 inNumMaps, AUBase &That); 39 | 40 | bool IsHotMapping(){return hotMapping;} 41 | void SetHotMapping (AUParameterMIDIMapping &inMap){hotMapping = true; mHotMap = inMap; } 42 | 43 | bool HandleHotMapping( UInt8 inStatus, 44 | UInt8 inChannel, 45 | UInt8 inData1, 46 | AUBase &That); 47 | 48 | 49 | bool FindParameterMapEventMatch(UInt8 inStatus, 50 | UInt8 inChannel, 51 | UInt8 inData1, 52 | UInt8 inData2, 53 | UInt32 inBufferOffset, 54 | AUBase& inAUBase); 55 | #if DEBUG 56 | void Print(); 57 | #endif 58 | }; 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CAAudioBufferList.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAAudioBufferList.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | */ 6 | #if !defined(__CAAudioBufferList_h__) 7 | #define __CAAudioBufferList_h__ 8 | 9 | //============================================================================= 10 | // Includes 11 | //============================================================================= 12 | 13 | // System Includes 14 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 15 | #include 16 | #else 17 | #include 18 | #endif 19 | 20 | #include "CAException.h" 21 | #include "CADebugMacros.h" 22 | 23 | //============================================================================= 24 | // Types 25 | //============================================================================= 26 | 27 | typedef AudioBufferList* AudioBufferListPtr; 28 | 29 | //============================================================================= 30 | // CAAudioBufferList 31 | //============================================================================= 32 | 33 | struct CAAudioBufferList 34 | { 35 | 36 | // Construction/Destruction 37 | public: 38 | static AudioBufferList* Create(UInt32 inNumberBuffers); 39 | static void Destroy(AudioBufferList* inBufferList); 40 | static UInt32 CalculateByteSize(UInt32 inNumberBuffers); 41 | 42 | // Operations 43 | public: 44 | static UInt32 GetTotalNumberChannels(const AudioBufferList& inBufferList); 45 | static bool GetBufferForChannel(const AudioBufferList& inBufferList, UInt32 inChannel, UInt32& outBufferNumber, UInt32& outBufferChannel); 46 | static void Clear(AudioBufferList& outBufferList); 47 | static void Copy(const AudioBufferList& inSource, UInt32 inStartingSourceChannel, AudioBufferList& outDestination, UInt32 inStartingDestinationChannel); 48 | static void CopyChannel(const AudioBuffer& inSource, UInt32 inSourceChannel, AudioBuffer& outDestination, UInt32 inDestinationChannel); 49 | static void Sum(const AudioBufferList& inSourceBufferList, AudioBufferList& ioSummedBufferList); 50 | static bool HasData(AudioBufferList& inBufferList); 51 | #if CoreAudio_Debug 52 | static void PrintToLog(const AudioBufferList& inBufferList); 53 | #endif 54 | 55 | static const AudioBufferList* GetEmptyBufferList(); 56 | 57 | }; 58 | 59 | // Declare a variably-sized AudioBufferList on the stack 60 | #define STACK_ABL(name, nbufs) \ 61 | ThrowIf(nbufs < 1 || nbufs > 64, CAException(kAudio_ParamError), "STACK_ABL: invalid number of buffers") \ 62 | const size_t name##_ByteSize = sizeof(AudioBufferList) + (nbufs - 1) * sizeof(AudioBuffer); \ 63 | AudioBufferList &name = *(AudioBufferList *)alloca(name##_ByteSize); \ 64 | name.mNumberBuffers = nbufs; 65 | 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CAAudioTimeStamp.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAAudioTimeStamp.cpp 3 | Abstract: CAAudioTimeStamp.h 4 | Version: 1.1 5 | */ 6 | //============================================================================= 7 | // Includes 8 | //============================================================================= 9 | 10 | #include "CAAudioTimeStamp.h" 11 | 12 | //============================================================================= 13 | // CAAudioTimeStamp 14 | //============================================================================= 15 | 16 | const AudioTimeStamp CAAudioTimeStamp::kZero = { 0.0, 0, 0.0, 0, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0, 0 }; 17 | 18 | bool operator<(const AudioTimeStamp& x, const AudioTimeStamp& y) 19 | { 20 | bool isLessThan = false; 21 | bool isDone = false; 22 | 23 | // check the sample time 24 | if(!isDone) 25 | { 26 | if((x.mFlags & kAudioTimeStampSampleTimeValid) && (y.mFlags & kAudioTimeStampSampleTimeValid)) 27 | { 28 | isLessThan = x.mSampleTime < y.mSampleTime; 29 | isDone = true; 30 | } 31 | } 32 | 33 | // check the host time 34 | if(!isDone) 35 | { 36 | if((x.mFlags & kAudioTimeStampHostTimeValid) && (y.mFlags & kAudioTimeStampHostTimeValid)) 37 | { 38 | isLessThan = x.mHostTime < y.mHostTime; 39 | isDone = true; 40 | } 41 | } 42 | 43 | // check the word clock time 44 | if(!isDone) 45 | { 46 | if((x.mFlags & kAudioTimeStampWordClockTimeValid) && (y.mFlags & kAudioTimeStampWordClockTimeValid)) 47 | { 48 | isLessThan = x.mWordClockTime < y.mWordClockTime; 49 | // commented out to prevent this from being flagged as a dead store by the static analyzer 50 | //isDone = true; 51 | } 52 | } 53 | 54 | return isLessThan; 55 | } 56 | 57 | bool operator==(const AudioTimeStamp& x, const AudioTimeStamp& y) 58 | { 59 | bool isEqual = false; 60 | bool isDone = false; 61 | 62 | // check the sample time 63 | if(!isDone) 64 | { 65 | if((x.mFlags & kAudioTimeStampSampleTimeValid) && (y.mFlags & kAudioTimeStampSampleTimeValid)) 66 | { 67 | isEqual = x.mSampleTime == y.mSampleTime; 68 | isDone = true; 69 | } 70 | } 71 | 72 | // check the host time 73 | if(!isDone) 74 | { 75 | if((x.mFlags & kAudioTimeStampHostTimeValid) && (y.mFlags & kAudioTimeStampHostTimeValid)) 76 | { 77 | isEqual = x.mHostTime == y.mHostTime; 78 | isDone = true; 79 | } 80 | } 81 | 82 | // check the word clock time 83 | if(!isDone) 84 | { 85 | if((x.mFlags & kAudioTimeStampWordClockTimeValid) && (y.mFlags & kAudioTimeStampWordClockTimeValid)) 86 | { 87 | isEqual = x.mWordClockTime == y.mWordClockTime; 88 | // commented out to prevent this from being flagged as a dead store by the static analyzer 89 | //isDone = true; 90 | } 91 | } 92 | 93 | return isEqual; 94 | } 95 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CAAudioTimeStamp.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAAudioTimeStamp.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | */ 6 | #if !defined(__CAAudioTimeStamp_h__) 7 | #define __CAAudioTimeStamp_h__ 8 | 9 | //============================================================================= 10 | // Includes 11 | //============================================================================= 12 | 13 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 14 | #include 15 | #else 16 | #include 17 | #endif 18 | 19 | #include 20 | 21 | //============================================================================= 22 | // CAAudioTimeStamp 23 | //============================================================================= 24 | 25 | struct CAAudioTimeStamp 26 | : 27 | public AudioTimeStamp 28 | { 29 | 30 | // Construction/Destruction 31 | public: 32 | CAAudioTimeStamp() { memset(this, 0, sizeof(AudioTimeStamp)); } 33 | CAAudioTimeStamp(const AudioTimeStamp& v) { memcpy(this, &v, sizeof(AudioTimeStamp)); } 34 | CAAudioTimeStamp(Float64 inSampleTime) { memset(this, 0, sizeof(AudioTimeStamp)); mSampleTime = inSampleTime; mFlags = kAudioTimeStampSampleTimeValid; } 35 | CAAudioTimeStamp(UInt64 inHostTime) { memset(this, 0, sizeof(AudioTimeStamp)); mHostTime = inHostTime; mFlags = kAudioTimeStampHostTimeValid; } 36 | CAAudioTimeStamp(Float64 inSampleTime, UInt64 inHostTime) { memset(this, 0, sizeof(AudioTimeStamp)); mSampleTime = inSampleTime; mHostTime = inHostTime; mFlags = kAudioTimeStampSampleTimeValid | kAudioTimeStampHostTimeValid; } 37 | CAAudioTimeStamp(Float64 inSampleTime, UInt64 inHostTime, Float64 inRateScalar) { memset(this, 0, sizeof(AudioTimeStamp)); mSampleTime = inSampleTime; mHostTime = inHostTime; mRateScalar = inRateScalar; mFlags = kAudioTimeStampSampleTimeValid | kAudioTimeStampHostTimeValid | kAudioTimeStampRateScalarValid; } 38 | 39 | // Assignment 40 | public: 41 | CAAudioTimeStamp& operator=(const AudioTimeStamp& v) { memcpy(this, &v, sizeof(AudioTimeStamp)); return *this; } 42 | 43 | // Constants 44 | public: 45 | static const AudioTimeStamp kZero; 46 | 47 | }; 48 | 49 | bool operator<(const AudioTimeStamp& x, const AudioTimeStamp& y); 50 | bool operator==(const AudioTimeStamp& x, const AudioTimeStamp& y); 51 | inline bool operator!=(const AudioTimeStamp& x, const AudioTimeStamp& y) { return !(x == y); } 52 | inline bool operator<=(const AudioTimeStamp& x, const AudioTimeStamp& y) { return (x < y) || (x == y); } 53 | inline bool operator>=(const AudioTimeStamp& x, const AudioTimeStamp& y) { return !(x < y); } 54 | inline bool operator>(const AudioTimeStamp& x, const AudioTimeStamp& y) { return !((x < y) || (x == y)); } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CABool.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CABool.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | */ 6 | #if !defined(__CABool_h__) 7 | #define __CABool_h__ 8 | 9 | //============================================================================= 10 | // Includes 11 | //============================================================================= 12 | 13 | // System Includes 14 | #include "CADebugMacros.h" 15 | #include "CAException.h" 16 | 17 | //============================================================================= 18 | // CABool 19 | // 20 | // This class implements a boolean value that has a third state that marks 21 | // it as uninitialized. Accessing the value of an instance of this class that 22 | // is uninitialized will throw an exception. 23 | //============================================================================= 24 | 25 | class CABool 26 | { 27 | 28 | // Construction/Destruction 29 | public: 30 | CABool() : mValue(-1) {} 31 | CABool(bool inValue) : mValue(inValue ? 1 : 0) {} 32 | CABool(const CABool& inValue) : mValue(inValue.mValue) {} 33 | ~CABool() {} 34 | 35 | CABool& operator=(bool inValue) { mValue = inValue; return *this; } 36 | CABool& operator=(const CABool& inValue) { mValue = inValue.mValue; return *this; } 37 | 38 | operator bool() const { ThrowIf(mValue == -1, CAException('nope'), "CABool: uninitialized"); return mValue != 0; } 39 | bool IsInitialized() const { return mValue != -1; } 40 | void Uninitialize() { mValue = -1; } 41 | 42 | private: 43 | SInt32 mValue; 44 | 45 | CABool(const void*); // prevent accidental instantiation with a pointer via bool constructor 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CABundleLocker.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CABundleLocker.cpp 3 | Abstract: CABundleLocker.h 4 | Version: 1.1 5 | 6 | */ 7 | #include "CABundleLocker.h" 8 | #include 9 | 10 | /* 11 | some bundle operations are not thread safe, notably CFCopyLocalizedStringFromTableInBundle 12 | */ 13 | 14 | static pthread_mutex_t sCABundleLocker = PTHREAD_MUTEX_INITIALIZER; 15 | 16 | #define RECURSIVE_LOCK 0 17 | 18 | #if RECURSIVE_LOCK 19 | static pthread_once_t sOnce = PTHREAD_ONCE_INIT; 20 | 21 | static void InitCABundleLocker() 22 | { 23 | // have to do this because OS X lacks PTHREAD_MUTEX_RECURSIVE_INITIALIZER_NP 24 | pthread_mutexattr_t attr; 25 | pthread_mutexattr_init(&attr); 26 | pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); 27 | pthread_mutex_init(&sCABundleLocker, &attr); 28 | pthread_mutexattr_destroy(&attr); 29 | } 30 | #endif 31 | 32 | CABundleLocker::CABundleLocker() 33 | { 34 | #if RECURSIVE_LOCK 35 | pthread_once(&sOnce, InitCABundleLocker); 36 | #endif 37 | pthread_mutex_lock(&sCABundleLocker); 38 | } 39 | 40 | CABundleLocker::~CABundleLocker() 41 | { 42 | pthread_mutex_unlock(&sCABundleLocker); 43 | } 44 | 45 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CABundleLocker.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CABundleLocker.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | */ 7 | #ifndef _CABundleLocker_h_ 8 | #define _CABundleLocker_h_ 9 | 10 | #include 11 | 12 | /* 13 | some bundle operations are not thread safe, notably CFCopyLocalizedStringFromTableInBundle 14 | */ 15 | 16 | class CABundleLocker 17 | { 18 | public: 19 | 20 | #if TARGET_OS_MAC 21 | CABundleLocker(); 22 | ~CABundleLocker(); 23 | #else 24 | CABundleLocker() {} 25 | ~CABundleLocker() {} 26 | #endif 27 | }; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CACFData.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CACFData.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | */ 7 | #if !defined(__CACFData_h__) 8 | #define __CACFData_h__ 9 | 10 | //============================================================================= 11 | // Includes 12 | //============================================================================= 13 | 14 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 15 | #include 16 | #include 17 | #else 18 | #include 19 | #include 20 | #endif 21 | 22 | #include "CADebugMacros.h" 23 | 24 | //============================================================================= 25 | // CACFData 26 | //============================================================================= 27 | 28 | class CACFData 29 | { 30 | 31 | // Construction/Destruction 32 | public: 33 | explicit CACFData(CFDataRef inCFData) : mCFData(inCFData), mWillRelease(true) {} 34 | CACFData(CFDataRef inCFData, bool inWillRelease) : mCFData(inCFData), mWillRelease(inWillRelease) {} 35 | CACFData(const void* inData, UInt32 inDataSize) : mCFData(NULL), mWillRelease(true) { mCFData = CFDataCreate(NULL, static_cast(inData), static_cast(inDataSize)); } 36 | ~CACFData() { Release(); } 37 | CACFData(const CACFData& inNumber) : mCFData(inNumber.mCFData), mWillRelease(inNumber.mWillRelease) { Retain(); } 38 | CACFData& operator=(const CACFData& inNumber) { Release(); mCFData = inNumber.mCFData; mWillRelease = inNumber.mWillRelease; Retain(); return *this; } 39 | CACFData& operator=(CFDataRef inCFData) { Release(); mCFData = inCFData; mWillRelease = true; return *this; } 40 | 41 | private: 42 | void Retain() { if(mWillRelease && (mCFData != NULL)) { CFRetain(mCFData); } } 43 | void Release() { if(mWillRelease && (mCFData != NULL)) { CFRelease(mCFData); } } 44 | 45 | CFDataRef mCFData; 46 | bool mWillRelease; 47 | 48 | // Operations 49 | public: 50 | void AllowRelease() { mWillRelease = true; } 51 | void DontAllowRelease() { mWillRelease = false; } 52 | bool IsValid() { return mCFData != NULL; } 53 | 54 | // Value Access 55 | public: 56 | CFDataRef GetCFData() const { return mCFData; } 57 | CFDataRef CopyCFData() const { if(mCFData != NULL) { CFRetain(mCFData); } return mCFData; } 58 | 59 | UInt32 GetSize() const { return ToUInt32(CFDataGetLength(mCFData)); } 60 | const void* GetDataPtr() const { return CFDataGetBytePtr(mCFData); } 61 | void CopyData(UInt32 inStartOffset, void* outData, UInt32 inDataSize) const { CFRange theRange = { static_cast(inStartOffset), static_cast(inDataSize) }; CFDataGetBytes(mCFData, theRange, static_cast(outData)); } 62 | 63 | SInt32 GetSInt32() const { SInt32 theAnswer = 0; CopyData(0, &theAnswer, SizeOf32(SInt32)); return theAnswer; } 64 | Float32 GetFloat32() const { Float32 theAnswer = 0; CopyData(0, &theAnswer, SizeOf32(Float32)); return theAnswer; } 65 | 66 | }; 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CACFDistributedNotification.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CACFDistributedNotification.cpp 3 | Abstract: CACFDistributedNotification.h 4 | Version: 1.1 5 | 6 | */ 7 | //================================================================================================== 8 | // Includes 9 | //================================================================================================== 10 | 11 | // Self Include 12 | #include "CACFDistributedNotification.h" 13 | 14 | // PublicUtility Includes 15 | #include "CADebugMacros.h" 16 | 17 | //================================================================================================== 18 | // CACFDistributedNotification 19 | //================================================================================================== 20 | 21 | void CACFDistributedNotification::AddObserver(const void* inObserver, CFNotificationCallback inCallback, CFStringRef inName, CFNotificationSuspensionBehavior inSuspensionBehavior) 22 | { 23 | #if !TARGET_OS_IPHONE 24 | CFNotificationCenterRef theCenter = CFNotificationCenterGetDistributedCenter(); 25 | CFNotificationSuspensionBehavior theSuspensionBehavior = inSuspensionBehavior; 26 | #else 27 | #pragma unused(inSuspensionBehavior) 28 | CFNotificationCenterRef theCenter = CFNotificationCenterGetDarwinNotifyCenter(); 29 | CFNotificationSuspensionBehavior theSuspensionBehavior = static_cast(0); 30 | #endif 31 | 32 | CFNotificationCenterAddObserver(theCenter, inObserver, inCallback, inName, NULL, theSuspensionBehavior); 33 | } 34 | 35 | void CACFDistributedNotification::RemoveObserver(const void* inObserver, CFStringRef inName) 36 | { 37 | #if !TARGET_OS_IPHONE 38 | CFNotificationCenterRef theCenter = CFNotificationCenterGetDistributedCenter(); 39 | #else 40 | CFNotificationCenterRef theCenter = CFNotificationCenterGetDarwinNotifyCenter(); 41 | #endif 42 | 43 | CFNotificationCenterRemoveObserver(theCenter, inObserver, inName, NULL); 44 | } 45 | 46 | void CACFDistributedNotification::PostNotification(CFStringRef inName, CFDictionaryRef inUserInfo, bool inPostToAllSessions) 47 | { 48 | #if !TARGET_OS_IPHONE 49 | CFNotificationCenterRef theCenter = CFNotificationCenterGetDistributedCenter(); 50 | CFDictionaryRef theUserInfo = inUserInfo; 51 | CFOptionFlags theFlags = kCFNotificationDeliverImmediately; 52 | if(inPostToAllSessions) 53 | { 54 | theFlags += kCFNotificationPostToAllSessions; 55 | } 56 | #else 57 | // flag unsupported features 58 | Assert(inUserInfo == NULL, "CACFDistributedNotification::PostNotification: distributed notifications do not support a payload"); 59 | Assert(inPostToAllSessions, "CACFDistributedNotification::PostNotification: distributed notifications do not support per-session delivery"); 60 | 61 | CFNotificationCenterRef theCenter = CFNotificationCenterGetDarwinNotifyCenter(); 62 | CFDictionaryRef theUserInfo = NULL; 63 | CFOptionFlags theFlags = 0; 64 | #endif 65 | 66 | CFNotificationCenterPostNotificationWithOptions(theCenter, inName, NULL, theUserInfo, theFlags); 67 | } 68 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CACFDistributedNotification.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CACFDistributedNotification.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | */ 7 | #if !defined(__CACFDistributedNotification_h__) 8 | #define __CACFDistributedNotification_h__ 9 | 10 | //================================================================================================== 11 | // Includes 12 | //================================================================================================== 13 | 14 | // System Includes 15 | #include 16 | #include 17 | 18 | //================================================================================================== 19 | // CACFDistributedNotification 20 | //================================================================================================== 21 | 22 | class CACFDistributedNotification 23 | { 24 | 25 | // Operations 26 | public: 27 | static void AddObserver(const void* inObserver, CFNotificationCallback inCallback, CFStringRef inName, CFNotificationSuspensionBehavior inSuspensionBehavior = CFNotificationSuspensionBehaviorCoalesce); 28 | static void RemoveObserver(const void* inObserver, CFStringRef inName); 29 | static void PostNotification(CFStringRef inName, CFDictionaryRef inUserInfo, bool inPostToAllSessions); 30 | 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CACFMachPort.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CACFMachPort.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | */ 7 | #if !defined(__CACFMachPort_h__) 8 | #define __CACFMachPort_h__ 9 | 10 | //================================================================================================== 11 | // Includes 12 | //================================================================================================== 13 | 14 | // System Includes 15 | #include 16 | #include 17 | 18 | //================================================================================================== 19 | // CACFMachPort 20 | // 21 | // This class wraps a CFMachPort. 22 | // 23 | // Note that when you create a CFMachPort object, CF will attach the run loop source for the the 24 | // Mach Port that handles Port Death notifications (aka the Invalidation Callback) to the current 25 | // thread's run loop. This is something over which there is no control, so be sure to create the 26 | // CFMachPort on the thread on which you want to handle Port Death notificaitons on. 27 | //================================================================================================== 28 | 29 | class CACFMachPort 30 | { 31 | 32 | // Construction/Destruction 33 | public: 34 | CACFMachPort(CFMachPortCallBack inCallBack, void* inUserData = NULL); 35 | CACFMachPort(mach_port_t inMachPort, CFMachPortCallBack inCallBack, CFMachPortInvalidationCallBack inInvalidationCallBack, void* inUserData); 36 | virtual ~CACFMachPort(); 37 | 38 | // Attributes 39 | public: 40 | CFMachPortRef GetMachPortRef() const { return mMachPort; } 41 | mach_port_t GetMachPort() const { return CFMachPortGetPort(mMachPort); } 42 | CFRunLoopSourceRef GetRunLoopSource() const { return mRunLoopSource; } 43 | 44 | // Operations 45 | public: 46 | kern_return_t ReceiveMessage(UInt32 inMaxMessageSize, mach_msg_header_t* outMessage, mach_msg_timeout_t inTimeOut); 47 | 48 | // Implementation 49 | protected: 50 | CFMachPortRef mMachPort; 51 | CFRunLoopSourceRef mRunLoopSource; 52 | bool mOwnsPort; 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CACFMessagePort.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CACFMessagePort.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | */ 7 | #if !defined(__CACFMessagePort_h__) 8 | #define __CACFMessagePort_h__ 9 | 10 | //============================================================================= 11 | // Includes 12 | //============================================================================= 13 | 14 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 15 | #include 16 | #else 17 | #include 18 | #endif 19 | 20 | //============================================================================= 21 | // CACFLocalMessagePort 22 | //============================================================================= 23 | 24 | class CACFLocalMessagePort 25 | { 26 | 27 | // Construction/Destruction 28 | public: 29 | CACFLocalMessagePort(CFStringRef inName, CFMessagePortCallBack inPortCallBack, CFMessagePortInvalidationCallBack inInvalidationCallBack, void* inUserData = NULL); 30 | virtual ~CACFLocalMessagePort(); 31 | 32 | // Attributes 33 | public: 34 | bool IsValid() const { return mMessagePort != NULL; } 35 | CFMessagePortRef GetMessagePortRef() const { return mMessagePort; } 36 | CFRunLoopSourceRef GetRunLoopSource() const; 37 | void SetDispatchQueue(dispatch_queue_t inDispatchQueue); 38 | 39 | // Implementation 40 | protected: 41 | CFMessagePortRef mMessagePort; 42 | CFRunLoopSourceRef mRunLoopSource; 43 | dispatch_queue_t mDispatchQueue; 44 | 45 | }; 46 | 47 | //============================================================================= 48 | // CACFRemoteMessagePort 49 | //============================================================================= 50 | 51 | class CACFRemoteMessagePort 52 | { 53 | 54 | // Construction/Destruction 55 | public: 56 | CACFRemoteMessagePort(CFStringRef inName, CFMessagePortInvalidationCallBack inInvalidationCallBack); 57 | virtual ~CACFRemoteMessagePort(); 58 | 59 | // Attributes 60 | public: 61 | bool IsValid() const { return mMessagePort != NULL; } 62 | CFMessagePortRef GetMessagePortRef() const { return mMessagePort; } 63 | CFRunLoopSourceRef GetRunLoopSource() const; 64 | void SetDispatchQueue(dispatch_queue_t inDispatchQueue); 65 | 66 | // Operations 67 | public: 68 | SInt32 SendRequest(SInt32 inMessageID, CFDataRef inData, CFTimeInterval inSendTimeout, CFTimeInterval inReceiveTimout) const { return CFMessagePortSendRequest(mMessagePort, inMessageID, inData, inSendTimeout, inReceiveTimout, NULL, NULL); } 69 | SInt32 SendRequest(SInt32 inMessageID, CFDataRef inData, CFTimeInterval inSendTimeout, CFTimeInterval inReceiveTimout, CFStringRef inReplyMode, CFDataRef& outReturnData) const { return CFMessagePortSendRequest(mMessagePort, inMessageID, inData, inSendTimeout, inReceiveTimout, inReplyMode, &outReturnData); } 70 | 71 | // Implementation 72 | protected: 73 | CFMessagePortRef mMessagePort; 74 | CFRunLoopSourceRef mRunLoopSource; 75 | dispatch_queue_t mDispatchQueue; 76 | 77 | }; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CACFNumber.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CACFNumber.cpp 3 | Abstract: CACFNumber.h 4 | Version: 1.1 5 | 6 | */ 7 | //============================================================================= 8 | // Includes 9 | //============================================================================= 10 | 11 | #include "CACFNumber.h" 12 | 13 | //============================================================================= 14 | // CACFNumber 15 | //============================================================================= 16 | 17 | Float32 CACFNumber::GetFixed32() const 18 | { 19 | SInt32 theFixedValue = GetSInt32(); 20 | 21 | // this is a 16.16 value so convert it to a float 22 | Float32 theSign = theFixedValue < 0 ? -1.0f : 1.0f; 23 | theFixedValue *= (SInt32)theSign; 24 | Float32 theWholePart = (theFixedValue & 0x7FFF0000) >> 16; 25 | Float32 theFractPart = theFixedValue & 0x0000FFFF; 26 | theFractPart /= 65536.0f; 27 | 28 | return theSign * (theWholePart + theFractPart); 29 | } 30 | 31 | Float64 CACFNumber::GetFixed64() const 32 | { 33 | SInt64 theFixedValue = GetSInt64(); 34 | 35 | // this is a 32.32 value so convert it to a double 36 | Float64 theSign = theFixedValue < 0 ? -1.0 : 1.0; 37 | theFixedValue *= (SInt64)theSign; 38 | Float64 theWholePart = (theFixedValue & 0x7FFFFFFF00000000LL) >> 32; 39 | Float64 theFractPart = theFixedValue & 0x00000000FFFFFFFFLL; 40 | theFractPart /= 4294967296.0; 41 | 42 | return theSign * (theWholePart + theFractPart); 43 | } 44 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CACFPreferences.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CACFPreferences.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | */ 7 | #if !defined(__CACFPreferences_h__) 8 | #define __CACFPreferences_h__ 9 | 10 | //================================================================================================== 11 | // Includes 12 | //================================================================================================== 13 | 14 | // System Includes 15 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 16 | #include 17 | #else 18 | #include 19 | #endif 20 | 21 | //================================================================================================== 22 | // CACFPreferences 23 | //================================================================================================== 24 | 25 | class CACFPreferences 26 | { 27 | 28 | // Operations 29 | public: 30 | static CFPropertyListRef CopyValue(CFStringRef inKey, bool inCurrentUser, bool inCurrentHost); 31 | static CFStringRef CopyStringValue(CFStringRef inKey, bool inCurrentUser, bool inCurrentHost); 32 | static CFNumberRef CopyNumberValue(CFStringRef inKey, bool inCurrentUser, bool inCurrentHost); 33 | static CFArrayRef CopyArrayValue(CFStringRef inKey, bool inCurrentUser, bool inCurrentHost); 34 | static CFDictionaryRef CopyDictionaryValue(CFStringRef inKey, bool inCurrentUser, bool inCurrentHost); 35 | static void SetValue(CFStringRef inKey, CFPropertyListRef inValue, bool inCurrentUser, bool inCurrentHost, bool inSynchronize); 36 | static void DeleteValue(CFStringRef inKey, bool inCurrentUser, bool inCurrentHost, bool inSynchronize); 37 | static void Synchronize(bool inCurrentUser, bool inCurrentHost, bool inForce); 38 | static void MarkPrefsOutOfDate(bool inCurrentUser, bool inCurrentHost); 39 | static void MarkPrefsClean(bool inCurrentUser, bool inCurrentHost); 40 | static void SendNotification(CFStringRef inName); 41 | 42 | private: 43 | static bool ArePrefsOutOfDate(bool inCurrentUser, bool inCurrentHost); 44 | 45 | static bool sAnyUserAnyHostPrefsOutOfDate; 46 | static bool sAnyUserCurrentHostPrefsOutOfDate; 47 | static bool sCurrentUserAnyHostPrefsOutOfDate; 48 | static bool sCurrentUserCurrentHostPrefsOutOfDate; 49 | 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CACFString.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CACFString.cpp 3 | Abstract: CACFString.h 4 | Version: 1.1 5 | 6 | */ 7 | //============================================================================= 8 | // Includes 9 | //============================================================================= 10 | 11 | #include "CACFString.h" 12 | 13 | //============================================================================= 14 | // CACFString 15 | //============================================================================= 16 | 17 | UInt32 CACFString::GetStringByteLength(CFStringRef inCFString, CFStringEncoding inEncoding) 18 | { 19 | CFIndex theAnswer = 0; 20 | 21 | if(inCFString != NULL) 22 | { 23 | CFRange theRange = { 0, CFStringGetLength(inCFString) }; 24 | CFStringGetBytes(inCFString, theRange, inEncoding, 0, false, NULL, 0x7FFFFFFF, &theAnswer); 25 | } 26 | 27 | return UInt32(theAnswer); 28 | } 29 | 30 | void CACFString::GetCString(CFStringRef inCFString, char* outString, UInt32& ioStringSize, CFStringEncoding inEncoding) 31 | { 32 | if(ioStringSize > 0) 33 | { 34 | if(inCFString != NULL) 35 | { 36 | CFIndex theLength = 0; 37 | CFRange theRange = { 0, CFStringGetLength(inCFString) }; 38 | CFStringGetBytes(inCFString, theRange, inEncoding, 0, false, (UInt8*)outString, static_cast(ioStringSize - 1), &theLength); 39 | outString[theLength] = 0; 40 | ioStringSize = ToUInt32(theLength) + 1; 41 | } 42 | else 43 | { 44 | outString[0] = 0; 45 | ioStringSize = 1; 46 | } 47 | } 48 | } 49 | 50 | void CACFString::GetUnicodeString(CFStringRef inCFString, UInt16* outString, UInt32& ioStringSize) 51 | { 52 | if(ioStringSize > 0) 53 | { 54 | if(inCFString != NULL) 55 | { 56 | CFRange theStringRange = { 0, CFStringGetLength(inCFString) }; 57 | if(static_cast(theStringRange.length) > ioStringSize) 58 | { 59 | theStringRange.length = static_cast(ioStringSize); 60 | } 61 | CFStringGetCharacters(inCFString, theStringRange, outString); 62 | ioStringSize = ToUInt32(theStringRange.length); 63 | } 64 | else 65 | { 66 | outString[0] = 0; 67 | ioStringSize = 0; 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CAComponent.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAComponent.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | */ 7 | #ifndef __CAComponent_h__ 8 | #define __CAComponent_h__ 9 | 10 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 11 | #else 12 | #include 13 | #endif 14 | 15 | #include "CAComponentDescription.h" 16 | 17 | class CAComponent 18 | { 19 | public: 20 | CAComponent () 21 | : mComp (0), mDesc(), mManuName(0), mAUName(0), mCompName(0) {} 22 | 23 | // if next is specifed that is used to find the next component after that one 24 | CAComponent (const AudioComponentDescription& inDesc, CAComponent* next = 0); 25 | 26 | CAComponent (const CAComponent& y) 27 | : mComp (0), mDesc(), mManuName(0), mAUName(0), mCompName(0) { *this = y; } 28 | 29 | CAComponent (const AudioComponent& comp); 30 | 31 | CAComponent (const AudioComponentInstance& compInst); 32 | 33 | CAComponent (OSType inType, OSType inSubtype = 0, OSType inManu = 0); 34 | 35 | ~CAComponent (); 36 | 37 | CAComponent& operator= (const CAComponent& y); 38 | 39 | // returns true if this object references a valid component 40 | bool IsValid () const { return Comp() != 0; } 41 | 42 | bool HasAUStrings() const { SetCompNames (); return mManuName != 0; } 43 | 44 | // CFStringRef should be retained by caller if needed beyond lifetime of this object 45 | 46 | // Can return NULL if component doesn't follow AU naming conventions 47 | CFStringRef GetAUManu () const { SetCompNames (); return mManuName; } 48 | CFStringRef GetAUName () const { SetCompNames (); return mAUName ? mAUName : mCompName; } 49 | 50 | // Return value of NULL indicates a problem getting that information from the component 51 | CFStringRef GetCompName () const { SetCompNames(); return mCompName; } 52 | 53 | const CAComponentDescription& Desc () const { return mDesc; } 54 | 55 | OSStatus Open (AudioComponentInstance& outInst) const 56 | { 57 | return AudioComponentInstanceNew (Comp(), &outInst); 58 | } 59 | 60 | OSStatus GetVersion (UInt32 &outVersion) const; 61 | 62 | const AudioComponent& Comp() const { return mComp; } 63 | 64 | void Print(FILE* file = stdout) const; 65 | 66 | OSStatus Save (CFPropertyListRef *outData) const; 67 | 68 | OSStatus Restore (CFPropertyListRef &inData); 69 | 70 | private: 71 | AudioComponent mComp; 72 | CAComponentDescription mDesc; 73 | 74 | CFStringRef mManuName, mAUName, mCompName; 75 | 76 | void SetCompNames () const; 77 | void SetCompInfo () const; 78 | void Clear (); 79 | }; 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CAComponentDescription.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAComponentDescription.cpp 3 | Abstract: CAComponentDescription.h 4 | Version: 1.1 5 | 6 | */ 7 | #include "CAComponentDescription.h" 8 | #include "CAStreamBasicDescription.h" 9 | #include 10 | 11 | void CAShowComponentDescription(const AudioComponentDescription *desc) 12 | { 13 | CAComponentDescription::_CAShowComponentDescription (desc, stdout); 14 | } 15 | 16 | void CAComponentDescription::_CAShowComponentDescription(const AudioComponentDescription *desc, FILE* file) 17 | { 18 | if (desc) 19 | { 20 | char str[24]; 21 | fprintf (file, "AudioComponentDescription: %s - ", CAStringForOSType(desc->componentType, str, sizeof(str))); 22 | fprintf (file, "%s - ", CAStringForOSType(desc->componentSubType, str, sizeof(str))); 23 | fprintf (file, "%s", CAStringForOSType(desc->componentManufacturer, str, sizeof(str))); 24 | fprintf (file, ", 0x%X, 0x%X\n", (int)desc->componentFlags, (int)desc->componentFlagsMask); 25 | } 26 | } 27 | 28 | CAComponentDescription::CAComponentDescription (OSType inType, OSType inSubtype, OSType inManu) 29 | { 30 | componentType = inType; 31 | componentSubType = inSubtype; 32 | componentManufacturer = inManu; 33 | componentFlags = 0; 34 | componentFlagsMask = 0; 35 | } 36 | 37 | bool CAComponentDescription::IsAU () const 38 | { 39 | bool flag = IsEffect() || IsMusicDevice() || IsOffline(); 40 | if (flag) return true; 41 | 42 | switch (componentType) { 43 | case kAudioUnitType_Output: 44 | case kAudioUnitType_FormatConverter: 45 | case kAudioUnitType_Mixer: 46 | return true; 47 | } 48 | return false; 49 | } 50 | 51 | inline bool _MatchTest (const OSType &inTypeA, const OSType &inTypeB) 52 | { 53 | return ((inTypeA == inTypeB) || (!inTypeA && !inTypeB) || (inTypeA && !inTypeB) || (!inTypeA && inTypeB)); 54 | } 55 | 56 | bool CAComponentDescription::Matches (const AudioComponentDescription &desc) const 57 | { 58 | bool matches = false; 59 | 60 | // see if the type matches 61 | matches = _MatchTest (componentType, desc.componentType); 62 | 63 | if (matches) 64 | matches = _MatchTest (componentSubType, desc.componentSubType); 65 | 66 | if (matches) 67 | matches = _MatchTest (componentManufacturer, desc.componentManufacturer); 68 | 69 | return matches; 70 | } 71 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CADebugMacros.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CADebugMacros.cpp 3 | Abstract: CADebugMacros.h 4 | Version: 1.1 5 | 6 | */ 7 | #include "CADebugMacros.h" 8 | #include 9 | #include 10 | #if TARGET_API_MAC_OSX 11 | #include 12 | #endif 13 | 14 | #if DEBUG 15 | #include 16 | 17 | void DebugPrint(const char *fmt, ...) 18 | { 19 | va_list args; 20 | va_start(args, fmt); 21 | vprintf(fmt, args); 22 | va_end(args); 23 | } 24 | #endif // DEBUG 25 | 26 | void LogError(const char *fmt, ...) 27 | { 28 | va_list args; 29 | va_start(args, fmt); 30 | #if DEBUG 31 | vprintf(fmt, args); 32 | #endif 33 | #if TARGET_API_MAC_OSX 34 | vsyslog(LOG_ERR, fmt, args); 35 | #endif 36 | va_end(args); 37 | } 38 | 39 | void LogWarning(const char *fmt, ...) 40 | { 41 | va_list args; 42 | va_start(args, fmt); 43 | #if DEBUG 44 | vprintf(fmt, args); 45 | #endif 46 | #if TARGET_API_MAC_OSX 47 | vsyslog(LOG_WARNING, fmt, args); 48 | #endif 49 | va_end(args); 50 | } 51 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CADebugPrintf.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CADebugPrintf.cpp 3 | Abstract: CADebugPrintf.h 4 | Version: 1.1 5 | 6 | */ 7 | //================================================================================================== 8 | // Includes 9 | //================================================================================================== 10 | 11 | // Self Include 12 | #include "CADebugPrintf.h" 13 | 14 | #if DEBUG || CoreAudio_Debug 15 | 16 | #if TARGET_OS_WIN32 17 | #include 18 | #include 19 | #include 20 | extern "C" 21 | int CAWin32DebugPrintf(char* inFormat, ...) 22 | { 23 | char theMessage[1024]; 24 | va_list theArguments; 25 | va_start(theArguments, inFormat); 26 | _vsnprintf(theMessage, 1024, inFormat, theArguments); 27 | va_end(theArguments); 28 | OutputDebugString(theMessage); 29 | return 0; 30 | } 31 | #endif 32 | 33 | #if defined(CoreAudio_UseSideFile) 34 | #include 35 | FILE* sDebugPrintfSideFile = NULL; 36 | extern "C" 37 | void OpenDebugPrintfSideFile() 38 | { 39 | if(sDebugPrintfSideFile == NULL) 40 | { 41 | char theFileName[1024]; 42 | snprintf(theFileName, sizeof(theFileName), CoreAudio_UseSideFile, getpid()); 43 | sDebugPrintfSideFile = fopen(theFileName, "a+"); 44 | DebugPrintfRtn(DebugPrintfFileComma "\n------------------------------\n"); 45 | } 46 | } 47 | #endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CADebugPrintf.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CADebugPrintf.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | */ 7 | #if !defined(__CADebugPrintf_h__) 8 | #define __CADebugPrintf_h__ 9 | 10 | //============================================================================= 11 | // Includes 12 | //============================================================================= 13 | 14 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 15 | #include 16 | #else 17 | #include "CoreAudioTypes.h" 18 | #endif 19 | 20 | //============================================================================= 21 | // Macros to redirect debugging output to various logging services 22 | //============================================================================= 23 | 24 | //#define CoreAudio_UseSysLog 1 25 | //#define CoreAudio_UseSideFile "/CoreAudio-%d.txt" 26 | 27 | #if DEBUG || CoreAudio_Debug 28 | 29 | #if TARGET_OS_WIN32 30 | #if defined(__cplusplus) 31 | extern "C" 32 | #endif 33 | extern int CAWin32DebugPrintf(char* inFormat, ...); 34 | #define DebugPrintfRtn CAWin32DebugPrintf 35 | #define DebugPrintfFile 36 | #define DebugPrintfLineEnding "\n" 37 | #define DebugPrintfFileComma 38 | #else 39 | #if CoreAudio_UseSysLog 40 | #include 41 | #define DebugPrintfRtn syslog 42 | #define DebugPrintfFile LOG_NOTICE 43 | #define DebugPrintfLineEnding "" 44 | #define DebugPrintfFileComma DebugPrintfFile, 45 | #elif defined(CoreAudio_UseSideFile) 46 | #include 47 | #if defined(__cplusplus) 48 | extern "C" 49 | #endif 50 | void OpenDebugPrintfSideFile(); 51 | extern FILE* sDebugPrintfSideFile; 52 | #define DebugPrintfRtn fprintf 53 | #define DebugPrintfFile ((sDebugPrintfSideFile != NULL) ? sDebugPrintfSideFile : stderr) 54 | #define DebugPrintfLineEnding "\n" 55 | #define DebugPrintfFileComma DebugPrintfFile, 56 | #else 57 | #include 58 | #define DebugPrintfRtn fprintf 59 | #define DebugPrintfFile stderr 60 | #define DebugPrintfLineEnding "\n" 61 | #define DebugPrintfFileComma DebugPrintfFile, 62 | #endif 63 | #endif 64 | 65 | #define DebugPrintf(inFormat, ...) DebugPrintfRtn(DebugPrintfFileComma inFormat DebugPrintfLineEnding, ## __VA_ARGS__) 66 | #else 67 | #define DebugPrintfRtn 68 | #define DebugPrintfFile 69 | #define DebugPrintfLineEnding 70 | #define DebugPrintfFileComma 71 | #define DebugPrintf(inFormat, ...) 72 | #endif 73 | 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CADebugger.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CADebugger.cpp 3 | Abstract: CADebugger.h 4 | Version: 1.1 5 | 6 | */ 7 | //============================================================================= 8 | // Includes 9 | //============================================================================= 10 | 11 | #include "CADebugger.h" 12 | 13 | //============================================================================= 14 | // CADebugger 15 | //============================================================================= 16 | 17 | #if TARGET_API_MAC_OSX 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | bool CAIsDebuggerAttached(void) 24 | { 25 | int mib[4]; 26 | struct kinfo_proc info; 27 | size_t size; 28 | 29 | mib[0] = CTL_KERN; 30 | mib[1] = KERN_PROC; 31 | mib[2] = KERN_PROC_PID; 32 | mib[3] = getpid(); 33 | size = sizeof(info); 34 | info.kp_proc.p_flag = 0; 35 | 36 | sysctl(mib, 4, &info, &size, NULL, 0); 37 | 38 | return (info.kp_proc.p_flag & P_TRACED) == P_TRACED; 39 | } 40 | 41 | #endif 42 | 43 | void CADebuggerStop(void) 44 | { 45 | #if CoreAudio_Debug 46 | #if TARGET_API_MAC_OSX 47 | if(CAIsDebuggerAttached()) 48 | { 49 | #if defined(__i386__) || defined(__x86_64__) 50 | asm("int3"); 51 | #else 52 | __builtin_trap(); 53 | #endif 54 | } 55 | else 56 | { 57 | abort(); 58 | } 59 | #else 60 | __debugbreak(); 61 | #endif 62 | #endif 63 | } 64 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CADebugger.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CADebugger.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | */ 7 | #if !defined(__CADebugger_h__) 8 | #define __CADebugger_h__ 9 | 10 | //============================================================================= 11 | // Includes 12 | //============================================================================= 13 | 14 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 15 | #include 16 | #else 17 | #include 18 | #endif 19 | 20 | //============================================================================= 21 | // CADebugger 22 | //============================================================================= 23 | 24 | #if TARGET_API_MAC_OSX 25 | extern bool CAIsDebuggerAttached(void); 26 | #endif 27 | extern void CADebuggerStop(void); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CAException.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAException.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | */ 7 | #if !defined(__CAException_h__) 8 | #define __CAException_h__ 9 | 10 | //============================================================================= 11 | // Includes 12 | //============================================================================= 13 | 14 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 15 | #include 16 | #else 17 | #include "CoreAudioTypes.h" 18 | #endif 19 | 20 | //============================================================================= 21 | // CAException 22 | //============================================================================= 23 | 24 | class CAException 25 | { 26 | 27 | public: 28 | CAException(OSStatus inError) : mError(inError) {} 29 | CAException(const CAException& inException) : mError(inException.mError) {} 30 | CAException& operator=(const CAException& inException) { mError = inException.mError; return *this; } 31 | ~CAException() {} 32 | 33 | OSStatus GetError() const { return mError; } 34 | 35 | protected: 36 | OSStatus mError; 37 | }; 38 | 39 | #define CATry try{ 40 | #define CACatch } catch(...) {} 41 | #define CASwallowException(inExpression) try { inExpression; } catch(...) {} 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CAFilePathUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAFilePathUtils.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2014 Apple Inc. All Rights Reserved. 45 | 46 | */ 47 | #ifndef __CAFilePathUtils_h__ 48 | #define __CAFilePathUtils_h__ 49 | 50 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 51 | #include 52 | #include 53 | #else 54 | #include 55 | #include 56 | #include 57 | #endif 58 | 59 | struct FSRef; 60 | 61 | OSStatus PosixPathToParentFSRefAndName(const char *path, FSRef &outParentDir, CFStringRef &outFileName); 62 | 63 | #if !TARGET_OS_WIN32 64 | #include 65 | #else 66 | char* dirname(const char* inPath); 67 | char* basename(const char* inPath); 68 | #endif 69 | 70 | #endif // __CAFilePathUtils_h__ 71 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CAGuard.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAGuard.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | */ 7 | #if !defined(__CAGuard_h__) 8 | #define __CAGuard_h__ 9 | 10 | //================================================================================================== 11 | // Includes 12 | //============================================================================= 13 | 14 | // Super Class Includes 15 | #include "CAMutex.h" 16 | 17 | #if CoreAudio_Debug 18 | // #define Log_Average_Latency 1 19 | #endif 20 | 21 | //================================================================================================== 22 | // CAGuard 23 | // 24 | // This is your typical mutex with signalling implemented via pthreads. 25 | // Lock() will return true if and only if the guard is locked on that call. 26 | // A thread that already has the guard will receive 'false' if it locks it 27 | // again. Use of the stack-based CAGuard::Locker class is highly recommended 28 | // to properly manage the recursive nesting. The Wait calls with timeouts 29 | // will return true if and only if the timeout period expired. They will 30 | // return false if they receive notification any other way. 31 | //================================================================================================== 32 | 33 | class CAGuard : public CAMutex 34 | { 35 | 36 | // Construction/Destruction 37 | public: 38 | CAGuard(const char* inName); 39 | virtual ~CAGuard(); 40 | 41 | // Actions 42 | public: 43 | virtual void Wait(); 44 | virtual bool WaitFor(UInt64 inNanos); 45 | virtual bool WaitUntil(UInt64 inNanos); 46 | 47 | virtual void Notify(); 48 | virtual void NotifyAll(); 49 | 50 | // Implementation 51 | protected: 52 | #if TARGET_OS_MAC 53 | pthread_cond_t mCondVar; 54 | #else 55 | HANDLE mEvent; 56 | #endif 57 | #if Log_Average_Latency 58 | Float64 mAverageLatencyAccumulator; 59 | UInt32 mAverageLatencyCount; 60 | #endif 61 | 62 | // Helper class to manage taking and releasing recursively 63 | public: 64 | class Locker 65 | { 66 | 67 | // Construction/Destruction 68 | public: 69 | Locker(CAGuard& inGuard) : mGuard(inGuard), mNeedsRelease(false) { mNeedsRelease = mGuard.Lock(); } 70 | ~Locker() { if(mNeedsRelease) { mGuard.Unlock(); } } 71 | 72 | private: 73 | Locker(const Locker&); 74 | Locker& operator=(const Locker&); 75 | 76 | // Actions 77 | public: 78 | void Wait() { mGuard.Wait(); } 79 | bool WaitFor(UInt64 inNanos) { return mGuard.WaitFor(inNanos); } 80 | bool WaitUntil(UInt64 inNanos) { return mGuard.WaitUntil(inNanos); } 81 | 82 | void Notify() { mGuard.Notify(); } 83 | void NotifyAll() { mGuard.NotifyAll(); } 84 | 85 | // Implementation 86 | private: 87 | CAGuard& mGuard; 88 | bool mNeedsRelease; 89 | }; 90 | 91 | }; 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CAHostTimeBase.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAHostTimeBase.cpp 3 | Abstract: CAHostTimeBase.h 4 | Version: 1.1 5 | 6 | */ 7 | //============================================================================= 8 | // Includes 9 | //============================================================================= 10 | 11 | #include "CAHostTimeBase.h" 12 | 13 | Float64 CAHostTimeBase::sFrequency = 0; 14 | Float64 CAHostTimeBase::sInverseFrequency = 0; 15 | UInt32 CAHostTimeBase::sMinDelta = 0; 16 | UInt32 CAHostTimeBase::sToNanosNumerator = 0; 17 | UInt32 CAHostTimeBase::sToNanosDenominator = 0; 18 | pthread_once_t CAHostTimeBase::sIsInited = PTHREAD_ONCE_INIT; 19 | #if Track_Host_TimeBase 20 | UInt64 CAHostTimeBase::sLastTime = 0; 21 | #endif 22 | 23 | //============================================================================= 24 | // CAHostTimeBase 25 | // 26 | // This class provides platform independent access to the host's time base. 27 | //============================================================================= 28 | 29 | void CAHostTimeBase::Initialize() 30 | { 31 | // get the info about Absolute time 32 | #if TARGET_OS_MAC 33 | struct mach_timebase_info theTimeBaseInfo; 34 | mach_timebase_info(&theTimeBaseInfo); 35 | sMinDelta = 1; 36 | sToNanosNumerator = theTimeBaseInfo.numer; 37 | sToNanosDenominator = theTimeBaseInfo.denom; 38 | 39 | // the frequency of that clock is: (sToNanosDenominator / sToNanosNumerator) * 10^9 40 | sFrequency = static_cast(sToNanosDenominator) / static_cast(sToNanosNumerator); 41 | sFrequency *= 1000000000.0; 42 | #elif TARGET_OS_WIN32 43 | LARGE_INTEGER theFrequency; 44 | QueryPerformanceFrequency(&theFrequency); 45 | sMinDelta = 1; 46 | sToNanosNumerator = 1000000000ULL; 47 | sToNanosDenominator = *((UInt64*)&theFrequency); 48 | sFrequency = static_cast(*((UInt64*)&theFrequency)); 49 | #endif 50 | sInverseFrequency = 1.0 / sFrequency; 51 | 52 | #if Log_Host_Time_Base_Parameters 53 | DebugPrintf("Host Time Base Parameters"); 54 | DebugPrintf(" Minimum Delta: %lu", (unsigned long)sMinDelta); 55 | DebugPrintf(" Frequency: %f", sFrequency); 56 | DebugPrintf(" To Nanos Numerator: %lu", (unsigned long)sToNanosNumerator); 57 | DebugPrintf(" To Nanos Denominator: %lu", (unsigned long)sToNanosDenominator); 58 | #endif 59 | } 60 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CAMath.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAMath.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | */ 7 | #ifndef __CAMath_h__ 8 | #define __CAMath_h__ 9 | 10 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 11 | #include 12 | #else 13 | #include 14 | #endif 15 | 16 | inline bool fiszero(Float64 f) { return (f == 0.); } 17 | inline bool fiszero(Float32 f) { return (f == 0.f); } 18 | 19 | inline bool fnonzero(Float64 f) { return !fiszero(f); } 20 | inline bool fnonzero(Float32 f) { return !fiszero(f); } 21 | 22 | inline bool fequal(const Float64 &a, const Float64 &b) { return a == b; } 23 | inline bool fequal(const Float32 &a, const Float32 &b) { return a == b; } 24 | 25 | inline bool fnotequal(const Float64 &a, const Float64 &b) { return !fequal(a, b); } 26 | inline bool fnotequal(const Float32 &a, const Float32 &b) { return !fequal(a, b); } 27 | 28 | #endif // __CAMath_h__ 29 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CAProcess.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAProcess.cpp 3 | Abstract: CAProcess.h 4 | Version: 1.1 5 | 6 | */ 7 | //============================================================================= 8 | // Includes 9 | //============================================================================= 10 | 11 | #include "CAProcess.h" 12 | #include 13 | #include 14 | #include 15 | 16 | //============================================================================= 17 | // CAProcess 18 | //============================================================================= 19 | 20 | bool CAProcess::ProcessExists(pid_t inPID) 21 | { 22 | // pids <= 0 are reserved for special purposes and -1 is 23 | // used as a sentinel value by the HAL. 24 | bool theAnswer = inPID > 0; 25 | 26 | if(theAnswer) 27 | { 28 | // according to kill(2), the process exists if kill(pid, 0) returns 0 29 | int wasKilled = kill(inPID, 0); 30 | if(wasKilled != 0) 31 | { 32 | // The kill call failed for some reason, but there is only one error code that 33 | // that indicates that the process doesn't exist. 34 | theAnswer = errno != ESRCH; 35 | } 36 | } 37 | 38 | 39 | return theAnswer; 40 | } 41 | 42 | pid_t CAProcess::GetPID() 43 | { 44 | if(sPID == -1) 45 | { 46 | sPID = getpid(); 47 | } 48 | 49 | return sPID; 50 | } 51 | 52 | pid_t CAProcess::sPID = -1; 53 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CAProcess.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAProcess.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | */ 7 | #if !defined(__CAProcess_h__) 8 | #define __CAProcess_h__ 9 | 10 | //============================================================================= 11 | // Includes 12 | //============================================================================= 13 | 14 | #include 15 | 16 | //============================================================================= 17 | // CAProcess 18 | // 19 | // Wrapper for utilities for dealing with Unix Processes. 20 | //============================================================================= 21 | 22 | class CAProcess 23 | { 24 | 25 | // operations 26 | public: 27 | static bool ProcessExists(pid_t inPID); 28 | static pid_t GetPID(); 29 | 30 | private: 31 | static pid_t sPID; 32 | 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CAReferenceCounted.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAReferenceCounted.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | */ 7 | #ifndef __CAReferenceCounted_h__ 8 | #define __CAReferenceCounted_h__ 9 | 10 | #include "CAAtomic.h" 11 | 12 | // base class for reference-counted objects 13 | class CAReferenceCounted { 14 | public: 15 | CAReferenceCounted() : mRefCount(1) {} 16 | 17 | void retain() { CAAtomicIncrement32(&mRefCount); } 18 | 19 | void release() 20 | { 21 | SInt32 rc = CAAtomicDecrement32(&mRefCount); 22 | if (rc == 0) { 23 | releaseObject(); 24 | } 25 | } 26 | 27 | 28 | class Retainer { 29 | public: 30 | Retainer(CAReferenceCounted *obj) : mObject(obj) { mObject->retain(); } 31 | ~Retainer() { mObject->release(); } 32 | 33 | private: 34 | CAReferenceCounted * mObject; 35 | }; 36 | 37 | protected: 38 | virtual ~CAReferenceCounted() { } 39 | 40 | virtual void releaseObject () 41 | { 42 | delete this; 43 | } 44 | 45 | #if DEBUG 46 | public: 47 | #endif 48 | SInt32 GetReferenceCount() const { return mRefCount; } 49 | private: 50 | SInt32 mRefCount; 51 | 52 | CAReferenceCounted(const CAReferenceCounted &a); 53 | CAReferenceCounted &operator=(const CAReferenceCounted &a); 54 | }; 55 | 56 | 57 | #endif // __CAReferenceCounted_h__ 58 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CASharedLibrary.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CASharedLibrary.cpp 3 | Abstract: CASharedLibrary.h 4 | Version: 1.1 5 | 6 | */ 7 | //============================================================================= 8 | // Includes 9 | //============================================================================= 10 | 11 | #include "CASharedLibrary.h" 12 | 13 | //#define CASharedLibrary_Use_DYLD 1 14 | #if CASharedLibrary_Use_DYLD 15 | #include 16 | #else 17 | #include 18 | #include 19 | #endif 20 | 21 | //============================================================================= 22 | // CASharedLibrary 23 | //============================================================================= 24 | 25 | void* CASharedLibrary::LoadLibraryAndGetRoutineAddress(const char* inRoutineName, const char* /*inLibraryName*/, const char* inLibraryPath) 26 | { 27 | void* theRoutine = 0; 28 | 29 | #if CASharedLibrary_Use_DYLD 30 | const struct mach_header* theImage = NSAddImage(inLibraryPath, NSADDIMAGE_OPTION_RETURN_ON_ERROR); 31 | if(theImage != 0) 32 | { 33 | NSSymbol theSymbol = NSLookupSymbolInImage(theImage, inRoutineName, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND); 34 | if(theSymbol != 0) 35 | { 36 | theRoutine = NSAddressOfSymbol(theSymbol); 37 | } 38 | } 39 | #else 40 | void* theImage = dlopen(inLibraryPath, RTLD_LAZY); 41 | if(theImage != NULL) 42 | { 43 | // we assume that all routine names passed here have a leading underscore which gets shaved 44 | // off when passed to dlsym 45 | theRoutine = dlsym(theImage, &(inRoutineName[1])); 46 | } 47 | 48 | #endif 49 | 50 | return theRoutine; 51 | } 52 | 53 | void* CASharedLibrary::GetRoutineAddressIfLibraryLoaded(const char* inRoutineName, const char* /*inLibraryName*/, const char* inLibraryPath) 54 | { 55 | void* theRoutine = 0; 56 | 57 | #if CASharedLibrary_Use_DYLD 58 | const struct mach_header* theImage = NSAddImage(inLibraryPath, NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED); 59 | if(theImage != 0) 60 | { 61 | NSSymbol theSymbol = NSLookupSymbolInImage(theImage, inRoutineName, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND); 62 | if(theSymbol != 0) 63 | { 64 | theRoutine = NSAddressOfSymbol(theSymbol); 65 | } 66 | } 67 | #else 68 | void* theImage = dlopen(inLibraryPath, RTLD_LAZY | RTLD_NOLOAD); 69 | if(theImage != NULL) 70 | { 71 | // we assume that all routine names passed here have a leading underscore which gets shaved 72 | // off when passed to dlsym 73 | theRoutine = dlsym(theImage, &(inRoutineName[1])); 74 | } 75 | #endif 76 | 77 | return theRoutine; 78 | } 79 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CASharedLibrary.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CASharedLibrary.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | */ 7 | #if !defined(__CASharedLibrary_h__) 8 | #define __CASharedLibrary_h__ 9 | 10 | //============================================================================= 11 | // CASharedLibrary 12 | //============================================================================= 13 | 14 | class CASharedLibrary 15 | { 16 | 17 | // Symbol Operations 18 | public: 19 | static void* LoadLibraryAndGetRoutineAddress(const char* inRoutineName, const char* inLibraryName, const char* inLibraryPath); 20 | static void* GetRoutineAddressIfLibraryLoaded(const char* inRoutineName, const char* inLibraryName, const char* inLibraryPath); 21 | 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CATink.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CATink.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | */ 7 | #if !defined(__CATink_h__) 8 | #define __CATink_h__ 9 | 10 | //============================================================================= 11 | // Includes 12 | //============================================================================= 13 | 14 | // System Includes 15 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 16 | #include 17 | #else 18 | #include 19 | #endif 20 | 21 | 22 | //============================================================================= 23 | // CATink 24 | // 25 | // A Tink is a small jump island that can make one function appear as if it 26 | // has many addresses. Note that Tinks are not supported for 64 bit environments 27 | // as the APIs that made tinks useful have been replaced by APIs that do away 28 | // with all the reasons for using a tink. 29 | //============================================================================= 30 | 31 | template 32 | class CATink 33 | { 34 | 35 | public: 36 | CATink(F proc) { Set(proc); } 37 | 38 | ~CATink() { Set((F)0xDEADDEAD); } // jump to an obviously bad (odd) address if accessed after destruction 39 | 40 | #if TARGET_CPU_PPC 41 | void Set(F proc) 42 | { 43 | /* 44 | lis r11,0x1234 45 | 00000000: 3D601234 lis r11,4660 46 | ori r11,r11,0x5678 47 | 00000004: 616B5678 ori r11,r11,$5678 48 | mtctr r11 49 | 00000008: 7D6903A6 mtctr r11 50 | bctr 51 | 0000000C: 4E800420 bctr 52 | */ 53 | UInt32 p = UInt32(proc); 54 | mCode[0] = 0x3D600000 | (p >> 16); 55 | mCode[1] = 0x616B0000 | (p & 0xFFFF); 56 | mCode[2] = 0x7D6903A6; 57 | mCode[3] = 0x4E800420; 58 | MakeDataExecutable(mCode, sizeof(mCode)); 59 | } 60 | 61 | operator F () { return F(mCode); } 62 | 63 | private: 64 | UInt32 mCode[4]; 65 | #elif TARGET_CPU_X86 66 | void Set(F proc) 67 | { 68 | /* 69 | : push $0x12345678 70 | : ret 71 | : 0x34567868 72 | : 0x00e8c312 73 | */ 74 | UInt32 p = UInt32(proc); 75 | mCode[0] = ((p & 0xFFFFFF) << 8) | 0x00000068; 76 | mCode[1] = 0xCCCCC300 | (p >> 24); 77 | MakeDataExecutable(mCode, sizeof(mCode)); 78 | } 79 | 80 | operator F () { return F(&mCode[0]); } 81 | 82 | private: 83 | UInt32 mCode[2]; 84 | #else 85 | #warning: CPU not directly supported by CATink 86 | 87 | // For other CPU's, just wrap the function pointer for now. 88 | // this bypasses what we're trying to accomplish with the Tink 89 | // (multiple unique "instances" of a function), but it will at 90 | // least compile and run. 91 | 92 | void Set(F proc) { mProcPtr = proc; } 93 | 94 | operator F () { return mProcPtr; } 95 | private: 96 | F mProcPtr; 97 | #endif 98 | 99 | // Tinks cannot be allocated in STL Containers, so we make a few key methods private 100 | private: 101 | CATink(){} 102 | CATink(const CATink&){} 103 | CATink& operator=(const CATink&){ return *this;} 104 | }; 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CAVectorUnit.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAVectorUnit.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | */ 7 | #ifndef __CAVectorUnit_h__ 8 | #define __CAVectorUnit_h__ 9 | 10 | #include 11 | #include "CAVectorUnitTypes.h" 12 | #include 13 | #include 14 | 15 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 16 | #include 17 | #else 18 | #include "CFBase.h" 19 | #endif 20 | 21 | // Unify checks for vector units. 22 | // Allow setting an environment variable "CA_NoVector" to turn off vectorized code at runtime (very useful for performance testing). 23 | 24 | extern int gCAVectorUnitType; 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | extern SInt32 CAVectorUnit_Examine(); // expensive. use GetType() for lazy initialization and caching. 31 | 32 | static inline SInt32 CAVectorUnit_GetType() 33 | { 34 | int x = gCAVectorUnitType; 35 | return (x != kVecUninitialized) ? x : CAVectorUnit_Examine(); 36 | } 37 | 38 | static inline Boolean CAVectorUnit_HasVectorUnit() 39 | { 40 | return CAVectorUnit_GetType() > kVecNone; 41 | } 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | 48 | #ifdef __cplusplus 49 | class CAVectorUnit { 50 | public: 51 | static SInt32 GetVectorUnitType() { return CAVectorUnit_GetType(); } 52 | static bool HasVectorUnit() { return GetVectorUnitType() > kVecNone; } 53 | static bool HasAltivec() { return GetVectorUnitType() == kVecAltivec; } 54 | static bool HasSSE2() { return GetVectorUnitType() >= kVecSSE2; } 55 | static bool HasSSE3() { return GetVectorUnitType() >= kVecSSE3; } 56 | static bool HasAVX1() { return GetVectorUnitType() >= kVecAVX1; } 57 | static bool HasNeon() { return GetVectorUnitType() == kVecNeon; } 58 | }; 59 | #endif 60 | 61 | #endif // __CAVectorUnit_h__ 62 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CAVectorUnitTypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAVectorUnitTypes.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | */ 7 | #ifndef __CAVectorUnitTypes_h__ 8 | #define __CAVectorUnitTypes_h__ 9 | 10 | enum { 11 | kVecUninitialized = -1, 12 | kVecNone = 0, 13 | kVecAltivec = 1, 14 | kVecSSE2 = 100, 15 | kVecSSE3 = 101, 16 | kVecAVX1 = 110, 17 | kVecNeon = 200 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/CAXException.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CAXException.cpp 3 | Abstract: CAXException.h 4 | Version: 1.1 5 | 6 | */ 7 | #include "CAXException.h" 8 | 9 | CAXException::WarningHandler CAXException::sWarningHandler = NULL; 10 | -------------------------------------------------------------------------------- /Sources/Extras/CoreAudio/PublicUtility/MatrixMixerVolumes.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: MatrixMixerVolumes.h 3 | Abstract: Part of CoreAudio Utility Classes 4 | Version: 1.1 5 | 6 | */ 7 | #ifndef __MatrixMixerVolumes_h__ 8 | #define __MatrixMixerVolumes_h__ 9 | 10 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 11 | #include 12 | #else 13 | #include 14 | #endif 15 | 16 | #if defined(__cplusplus) 17 | extern "C" 18 | { 19 | #endif 20 | 21 | // prints the matrix mixer volumes of a specific audio unit to the given file 22 | void PrintMatrixMixerVolumes (FILE* file, AudioUnit au); 23 | 24 | // prints the mixer volumes for the specific scope of the audio unit 25 | // results will be printed to the speficied file "file" with identifiying string tag "str" 26 | OSStatus PrintBuses (FILE* file, char* str, AudioUnit au, AudioUnitScope inScope); 27 | #if defined(__cplusplus) 28 | } 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/DP/Base/CMIO_DP_Command.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DP_Command.cpp 3 | Abstract: n/a 4 | Version: 1.2 5 | 6 | */ 7 | 8 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 9 | // Includes 10 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 11 | 12 | // Self Include 13 | #include "CMIO_DP_Command.h" 14 | 15 | // Public Utility Includes 16 | #include "CMIODebugMacros.h" 17 | 18 | // CA Public Utility Includes 19 | #include "CAException.h" 20 | 21 | // System Includes 22 | #include 23 | 24 | namespace CMIO { namespace DP 25 | { 26 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 27 | // Command 28 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 29 | Command::Command(UInt32 inCommandID) : 30 | mID(inCommandID) 31 | { 32 | } 33 | 34 | Command::~Command() 35 | { 36 | } 37 | 38 | void Command::Execute(Device* /* inDevice */) 39 | { 40 | } 41 | }} 42 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/DP/Base/CMIO_DP_Command.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DP_Command.h 3 | Abstract: n/a 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DP_Command_h__) 9 | #define __CMIO_DP_Command_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | #include 15 | 16 | namespace CMIO { namespace DP 17 | { 18 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 19 | // Types in the CMIO::DP namespace 20 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 21 | class Device; 22 | 23 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 24 | // Command 25 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 26 | class Command 27 | { 28 | // Construction/Destruction 29 | public: 30 | Command(UInt32 commandID); 31 | virtual ~Command(); 32 | 33 | // Operations 34 | public: 35 | UInt32 GetID() const { return mID; } 36 | virtual void Execute(Device* device); 37 | 38 | private: 39 | UInt32 mID; 40 | }; 41 | }} 42 | #endif 43 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/DP/Base/CMIO_DP_DeviceCommands.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DP_DeviceCommands.cpp 3 | Abstract: n/a 4 | Version: 1.2 5 | 6 | */ 7 | 8 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 9 | // Includes 10 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 11 | 12 | // Self Include 13 | #include "CMIO_DP_DeviceCommands.h" 14 | 15 | // Internal Includes 16 | #include "CMIO_DP_Device.h" 17 | 18 | namespace CMIO { namespace DP 19 | { 20 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 21 | // DeviceCommands 22 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 23 | ExampleCommand::ExampleCommand(UInt32 exampleCommandInput) : 24 | Command(kID), 25 | mExampleCommandState(exampleCommandInput) 26 | { 27 | } 28 | 29 | ExampleCommand::~ExampleCommand() 30 | { 31 | } 32 | 33 | void ExampleCommand::Execute(Device* device) 34 | { 35 | if (device != NULL) 36 | { 37 | //device->SetExample(mExampleCommandState); 38 | } 39 | } 40 | }} 41 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/DP/Base/CMIO_DP_DeviceCommands.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DP_DeviceCommands.h 3 | Abstract: n/a 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DP_DeviceCommands_h__) 9 | #define __CMIO_DP_DeviceCommands_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | // Super Class Includes 16 | #include "CMIO_DP_Command.h" 17 | 18 | // System Includes 19 | #include 20 | 21 | namespace CMIO { namespace DP 22 | { 23 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 24 | // DeviceCommands 25 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 26 | class ExampleCommand : public Command 27 | { 28 | // Constants 29 | public: 30 | enum 31 | { 32 | kID = 'exam' 33 | }; 34 | 35 | // Construction/Destruction 36 | public: 37 | ExampleCommand(UInt32 exampleCommandInput); 38 | virtual ~ExampleCommand(); 39 | 40 | // Operations 41 | public: 42 | virtual void Execute(Device* device); 43 | 44 | private: 45 | UInt32 mExampleCommandState; 46 | }; 47 | }} 48 | #endif 49 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/DP/Base/CMIO_DP_DeviceSettings.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DP_DeviceSettings.h 3 | Abstract: A place holder for saving and 4 | restoring device settings. 5 | Version: 1.2 6 | 7 | */ 8 | 9 | #if !defined(__CMIO_DP_DeviceSettings_h__) 10 | #define __CMIO_DP_DeviceSettings_h__ 11 | 12 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 13 | // Includes 14 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 15 | 16 | // System Includes 17 | #include 18 | 19 | namespace CMIO { namespace DP 20 | { 21 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 22 | // Types in the CMIO::DP namespace 23 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 24 | class Device; 25 | 26 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 27 | // DeviceSettings 28 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 29 | class DeviceSettings 30 | { 31 | // Types 32 | public: 33 | struct ControlInfo 34 | { 35 | UInt32 mSelector; 36 | UInt32 mValueType; 37 | }; 38 | 39 | // Constants 40 | public: 41 | enum 42 | { 43 | kControlValueTypeBool = 0, 44 | kControlValueTypeFloat = 1, 45 | kControlValueType4CC = 2, 46 | kStandardNumberControlsToSave = 0 47 | }; 48 | 49 | static const ControlInfo sStandardControlsToSave[]; 50 | 51 | // Operations 52 | public: 53 | static void SaveToPrefs(const Device& device, const ControlInfo* controlsToSave, UInt32 numberControlsToSave); 54 | static CFDictionaryRef SaveToDictionary(const Device& device, const ControlInfo* controlsToSave, UInt32 numberControlsToSave); 55 | 56 | static void RestoreFromPrefs(Device& device, const ControlInfo* controlsToRestore, UInt32 numberControlsToRestore); 57 | static void RestoreFromDictionary(Device& device, const CFDictionaryRef dictionary, const ControlInfo* controlsToRestore, UInt32 numberControlsToRestore); 58 | }; 59 | }} 60 | #endif 61 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/DP/Base/CMIO_DP_HogMode.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DP_HogMode.h 3 | Abstract: n/a 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DP_HogMode_h__) 9 | #define __CMIO_DP_HogMode_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | // Public Utility Includes 16 | #include "CAProcess.h" 17 | #include "CATokenMap.h" 18 | 19 | // System Includes 20 | #include 21 | 22 | namespace CMIO { namespace DP 23 | { 24 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 25 | // Types 26 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 27 | class Device; 28 | 29 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 30 | // HogMode 31 | // Implements tracking hog mode on behalf of a device. Note that it is currently implemented in terms of a global preference and uses CFDistributedNotificationCenter for notifications. 32 | // It would be better to have this implemented in a way that avoided the disk, such as by having a message protocol for use with Mach messages. 33 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 34 | class HogMode 35 | { 36 | // Construction/Destruction 37 | public: 38 | HogMode(Device* device); 39 | virtual ~HogMode(); 40 | 41 | // Operations 42 | public: 43 | pid_t GetOwner() const; 44 | bool IsFree() const; 45 | bool CurrentProcessIsOwner() const; 46 | bool CurrentProcessIsOwnerOrIsFree() const; 47 | 48 | void Take(); 49 | void Release(); 50 | void SetOwner(pid_t owner) { mOwner = owner; } 51 | 52 | // Implementation 53 | private: 54 | Device* GetDevice() const { return mDevice; } 55 | pid_t GetOwnerFromPreference(bool sendNotifications) const; 56 | void SetOwnerInPreference(pid_t owner) const; 57 | void SendHogModeChangedNotification() const; 58 | static void ChangeNotification(CFNotificationCenterRef center, const void* hogModeToken, CFStringRef notificationName, const void* object, CFDictionaryRef userInfo); 59 | 60 | UInt32 mToken; 61 | Device* mDevice; 62 | CFStringRef mPrefName; 63 | pid_t mOwner; 64 | 65 | static CATokenMap* sTokenMap; 66 | }; 67 | }} 68 | #endif 69 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/DP/Base/CMIO_DP_PlugIn.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DP_PlugIn.h 3 | Abstract: n/a 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DP_PlugIn_h__) 9 | #define __CMIO_DP_PlugIn_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | // Super Class Includes 16 | #include "CMIO_DP_Object.h" 17 | 18 | // CA Public Utility Includes 19 | #include "CACFObject.h" 20 | #include "CAMutex.h" 21 | 22 | // Standard Library Includes 23 | #include 24 | 25 | 26 | namespace CMIO { namespace DP 27 | { 28 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 29 | // PlugIn 30 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 31 | class PlugIn : public Object 32 | { 33 | // Construction/Destruction 34 | public: 35 | PlugIn(CFUUIDRef factoryUUID); 36 | virtual ~PlugIn(); 37 | 38 | virtual void Initialize(); 39 | virtual void InitializeWithObjectID(CMIOObjectID objectID); 40 | virtual void Teardown(); 41 | 42 | // Reference Counting 43 | public: 44 | virtual UInt32 Retain(); 45 | virtual UInt32 Release(); 46 | 47 | // Basic Operations 48 | public: 49 | // virtual dispatch_queue_t GetDispatchQueue() = 0; 50 | virtual CAMutex* GetObjectStateMutex() { return &mStateMutex; } 51 | CAMutex& GetStateMutex() { return mStateMutex; } 52 | virtual void Show() const; 53 | 54 | private: 55 | CAMutex mStateMutex; 56 | 57 | // Device Management 58 | public: 59 | virtual UInt32 GetNumberDevices() const; 60 | virtual Object* GetDeviceByIndex(UInt32 index) const; 61 | virtual Object* GetDeviceByObjectID(CMIOObjectID id) const; 62 | virtual void AddDevice(Object& device); 63 | virtual void RemoveDevice(Object& device); 64 | 65 | protected: 66 | typedef std::map DeviceMap; 67 | DeviceMap mDeviceMap; 68 | 69 | // Implementation 70 | public: 71 | CMIOHardwarePlugInRef GetInterface() { return &mInterface; } 72 | bool SameFactoryUUID(CFUUIDRef uuid) { return mFactoryUUID.IsEqual(uuid); } 73 | 74 | static PlugIn* GetObject(CMIOHardwarePlugInRef ref) { PlugIn* p = (PlugIn*)ref; return (PlugIn*)((Byte*)p - ((Byte*)&p->mInterface - (Byte*)p)); } 75 | 76 | private: 77 | CMIOHardwarePlugInInterface* mInterface; 78 | CACFUUID mFactoryUUID; 79 | UInt32 mRefCount; 80 | 81 | static CMIOHardwarePlugInInterface sInterface; 82 | }; 83 | }} 84 | #endif 85 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/DP/Base/CMIO_DP_Property.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DP_Property.cpp 3 | Abstract: n/a 4 | Version: 1.2 5 | 6 | */ 7 | 8 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 9 | // Includes 10 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 11 | 12 | // Self Include 13 | #include "CMIO_DP_Property.h" 14 | 15 | namespace CMIO { namespace DP 16 | { 17 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 18 | // Property 19 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 20 | Property::Property() 21 | { 22 | } 23 | 24 | Property::~Property() 25 | { 26 | } 27 | 28 | void Property::Initialize() 29 | { 30 | } 31 | 32 | void Property::Teardown() 33 | { 34 | } 35 | 36 | bool Property::IsActive(const CMIOObjectPropertyAddress& /*inAddress*/) const 37 | { 38 | return true; 39 | } 40 | 41 | bool Property::IsPropertySettable(const CMIOObjectPropertyAddress& /*inAddress*/) const 42 | { 43 | return true; 44 | } 45 | 46 | UInt32 Property::GetPropertyDataSize(const CMIOObjectPropertyAddress& /*inAddress*/, UInt32 /*inQualifierDataSize*/, const void* /*inQualifierData*/) const 47 | { 48 | return 0; 49 | } 50 | 51 | void Property::GetPropertyData(const CMIOObjectPropertyAddress& /*inAddress*/, UInt32 /*inQualifierDataSize*/, const void* /*inQualifierData*/, UInt32& ioDataSize, void* /*outData*/) const 52 | { 53 | ioDataSize = 0; 54 | } 55 | 56 | void Property::SetPropertyData(const CMIOObjectPropertyAddress& /*inAddress*/, UInt32 /*inQualifierDataSize*/, const void* /*inQualifierData*/, UInt32 /*inDataSize*/, const void* /*inData*/) 57 | { 58 | } 59 | 60 | UInt32 Property::GetNumberAddressesImplemented() const 61 | { 62 | return 0; 63 | } 64 | 65 | void Property::GetImplementedAddressByIndex(UInt32 /*inIndex*/, CMIOObjectPropertyAddress& /*outAddress*/) const 66 | { 67 | } 68 | }} 69 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/DP/Base/CMIO_DP_Property.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DP_Property.h 3 | Abstract: n/a 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DP_Property_h__) 9 | #define __CMIO_DP_Property_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | // System Includes 16 | #include 17 | 18 | namespace CMIO { namespace DP 19 | { 20 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 21 | // Property 22 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 23 | class Property 24 | { 25 | // Construction/Destruction 26 | public: 27 | Property(); 28 | virtual ~Property(); 29 | 30 | virtual void Initialize(); 31 | virtual void Teardown(); 32 | 33 | private: 34 | Property(const Property&); 35 | Property& operator=(const Property&); 36 | 37 | // Operations 38 | public: 39 | virtual bool IsActive(const CMIOObjectPropertyAddress& inAddress) const; 40 | virtual bool IsPropertySettable(const CMIOObjectPropertyAddress& inAddress) const; 41 | virtual UInt32 GetPropertyDataSize(const CMIOObjectPropertyAddress& inAddress, UInt32 inQualifierDataSize, const void* inQualifierData) const; 42 | virtual void GetPropertyData(const CMIOObjectPropertyAddress& inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 dataSize, UInt32& dataUsed, void* outData) const; 43 | virtual void SetPropertyData(const CMIOObjectPropertyAddress& inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, const void* inData); 44 | 45 | virtual UInt32 GetNumberAddressesImplemented() const; 46 | virtual void GetImplementedAddressByIndex(UInt32 inIndex, CMIOObjectPropertyAddress& outAddress) const; 47 | }; 48 | }} 49 | #endif 50 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/DP/Base/CMIO_DP_UserInfo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DP_UserInfo.cpp 3 | Abstract: n/a 4 | Version: 1.2 5 | 6 | */ 7 | 8 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 9 | // Includes 10 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 11 | 12 | // Self Include 13 | #include "CMIO_DP_UserInfo.h" 14 | 15 | // Public Utility Includes 16 | #include "CMIO_PropertyAddress.h" 17 | 18 | namespace CMIO { namespace DP 19 | { 20 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 21 | // UserInfo() 22 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 23 | void UserInfo::Initialize() 24 | { 25 | // set up the user session status including initializing it 26 | if (!sIsInitialized) 27 | { 28 | PropertyAddress address('user'); // kCMIOHardwarePropertyUserSessionIsActiveOrHeadless 29 | CMIOObjectAddPropertyListener(kCMIOObjectSystemObject, &address, UserSessionListener, NULL); 30 | UserSessionListener(kCMIOObjectSystemObject, 1, &address, NULL); 31 | sIsInitialized = true; 32 | } 33 | } 34 | 35 | void UserInfo::Teardown() 36 | { 37 | if (sIsInitialized) 38 | { 39 | PropertyAddress address('user'); // kCMIOHardwarePropertyUserSessionIsActiveOrHeadless 40 | CMIOObjectRemovePropertyListener(kCMIOObjectSystemObject, &address, UserSessionListener, NULL); 41 | sIsInitialized = false; 42 | } 43 | } 44 | 45 | OSStatus UserInfo::UserSessionListener(CMIOObjectID /*objectID*/, UInt32 /*numberAddresses*/, const CMIOObjectPropertyAddress /*addresses*/[], void* /*clientData*/) 46 | { 47 | PropertyAddress address('user'); // kCMIOHardwarePropertyUserSessionIsActiveOrHeadless 48 | UInt32 userSessionIsActiveOrHeadless = 1; 49 | UInt32 dataUsed = 0; 50 | CMIOObjectGetPropertyData(kCMIOObjectSystemObject, &address, 0, NULL, sizeof(UInt32), &dataUsed, &userSessionIsActiveOrHeadless); 51 | sCurrentUserSessionIsActiveOrHeadless = userSessionIsActiveOrHeadless != 0; 52 | return 0; 53 | } 54 | 55 | bool UserInfo::sIsInitialized = false; 56 | bool UserInfo::sCurrentUserSessionIsActiveOrHeadless = true; 57 | }} 58 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/DP/Base/CMIO_DP_UserInfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DP_UserInfo.h 3 | Abstract: n/a 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DP_UserInfo_h__) 9 | #define __CMIO_DP_UserInfo_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | // System Includes 16 | #include 17 | 18 | namespace CMIO { namespace DP 19 | { 20 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 21 | // UserInfo 22 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 23 | class UserInfo 24 | { 25 | // Construction/Destruction 26 | public: 27 | static void Initialize(); 28 | static void Teardown(); 29 | 30 | // Operations 31 | public: 32 | static bool IsCurrentUserSessionActiveOrHeadless() { return sCurrentUserSessionIsActiveOrHeadless; } 33 | 34 | // Implementation 35 | private: 36 | static OSStatus UserSessionListener(CMIOObjectID objectID, UInt32 numberAddresses, const CMIOObjectPropertyAddress addresses[], void* clientData); 37 | 38 | static bool sIsInitialized; 39 | static bool sCurrentUserSessionIsActiveOrHeadless; 40 | }; 41 | }} 42 | #endif 43 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/DP/Properties/CMIO_DP_Property_Base.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DP_Property_Base.cpp 3 | Abstract: n/a 4 | Version: 1.2 5 | 6 | */ 7 | 8 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 9 | // Includes 10 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 11 | 12 | // Self Include 13 | #include "CMIO_DP_Property_Base.h" 14 | 15 | namespace CMIO { namespace DP { namespace Property 16 | { 17 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 18 | // Base 19 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 20 | Base::Base() 21 | { 22 | } 23 | 24 | Base::~Base() 25 | { 26 | } 27 | 28 | void Base::Initialize() 29 | { 30 | } 31 | 32 | void Base::Teardown() 33 | { 34 | } 35 | 36 | bool Base::IsActive(const CMIOObjectPropertyAddress& /*address*/) const 37 | { 38 | return true; 39 | } 40 | 41 | bool Base::IsPropertySettable(const CMIOObjectPropertyAddress& /*address*/) const 42 | { 43 | return true; 44 | } 45 | 46 | UInt32 Base::GetPropertyDataSize(const CMIOObjectPropertyAddress& /*address*/, UInt32 /*qualifierDataSize*/, const void* /*qualifierData*/) const 47 | { 48 | return 0; 49 | } 50 | 51 | void Base::GetPropertyData(const CMIOObjectPropertyAddress& /*address*/, UInt32 /*qualifierDataSize*/, const void* /*qualifierData*/, UInt32 /*dataSize*/, UInt32& dataUsed, void* /*data*/) const 52 | { 53 | dataUsed = 0; 54 | } 55 | 56 | void Base::SetPropertyData(const CMIOObjectPropertyAddress& /*address*/, UInt32 /*qualifierDataSize*/, const void* /*qualifierData*/, UInt32 /*dataSize*/, const void* /*data*/) 57 | { 58 | } 59 | 60 | UInt32 Base::GetNumberAddressesImplemented() const 61 | { 62 | return 0; 63 | } 64 | 65 | void Base::GetImplementedAddressByIndex(UInt32 /*index*/, CMIOObjectPropertyAddress& /*address*/) const 66 | { 67 | } 68 | }}} 69 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/DP/Properties/CMIO_DP_Property_Base.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DP_Property_Base.h 3 | Abstract: n/a 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DP_Property_Base_h__) 9 | #define __CMIO_DP_Property_Base_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | // System Includes 16 | #include 17 | 18 | namespace CMIO { namespace DP { namespace Property 19 | { 20 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 21 | // Base 22 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 23 | class Base 24 | { 25 | // Construction/Destruction 26 | public: 27 | Base(); 28 | virtual ~Base(); 29 | 30 | virtual void Initialize(); 31 | virtual void Teardown(); 32 | 33 | private: 34 | Base(const Base&); 35 | Base& operator=(const Base&); 36 | 37 | // Operations 38 | public: 39 | virtual bool IsActive(const CMIOObjectPropertyAddress& address) const; 40 | virtual bool IsPropertySettable(const CMIOObjectPropertyAddress& address) const; 41 | virtual UInt32 GetPropertyDataSize(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData) const; 42 | virtual void GetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, UInt32& dataUsed, void* data) const; 43 | virtual void SetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, const void* data); 44 | 45 | virtual UInt32 GetNumberAddressesImplemented() const; 46 | virtual void GetImplementedAddressByIndex(UInt32 index, CMIOObjectPropertyAddress& address) const; 47 | }; 48 | }}} 49 | #endif 50 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/DP/Properties/CMIO_DP_Property_Clock.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DP_Property_Clock.h 3 | Abstract: Implements the kCMIOStreamPropertyClock property. 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DP_Property_Clock_h__) 9 | #define __CMIO_DP_Property_Clock_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | // Super Class Includes 16 | #include "CMIO_DP_Property_Base.h" 17 | 18 | namespace CMIO { namespace DP 19 | { 20 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 21 | // Types in the CMIO::DP namespace 22 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 23 | class Stream; 24 | }}; 25 | 26 | namespace CMIO { namespace DP { namespace Property 27 | { 28 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 29 | // Clock 30 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 31 | class Clock : public Base 32 | { 33 | // Construction/Destruction 34 | public: 35 | Clock(Stream* owningStream) : Base(), mOwningStream(owningStream), mClock(NULL) {} 36 | virtual ~Clock() { if (NULL != mClock) CFRelease(mClock); mClock = NULL; } 37 | 38 | // Property Operations 39 | public: 40 | virtual bool IsActive(const CMIOObjectPropertyAddress& address) const; 41 | virtual bool IsPropertySettable(const CMIOObjectPropertyAddress& address) const; 42 | virtual UInt32 GetPropertyDataSize(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData) const; 43 | virtual void GetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, UInt32& dataUsed, void* data) const; 44 | virtual void SetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, const void* data); 45 | 46 | virtual UInt32 GetNumberAddressesImplemented() const; 47 | virtual void GetImplementedAddressByIndex(UInt32 index, CMIOObjectPropertyAddress& address) const; 48 | 49 | // Property Implementation 50 | public: 51 | void SetClock(CFTypeRef clock) { if (NULL != mClock) { CFRelease(mClock); mClock = NULL; } if (NULL != clock) mClock = CFRetain(clock); } 52 | CFTypeRef GetClock() { return mClock; } 53 | 54 | private: 55 | Stream* mOwningStream; 56 | CFTypeRef mClock; 57 | }; 58 | }}} 59 | #endif 60 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/DP/Properties/CMIO_DP_Property_DeviceIsAlive.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DP_Property_DeviceIsAlive.h 3 | Abstract: Implements the kCMIODevicePropertyDeviceIsAlive property. 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DP_Property_DeviceIsAlive_h__) 9 | #define __CMIO_DP_Property_DeviceIsAlive_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | // Super Class Includes 16 | #include "CMIO_DP_Property_Base.h" 17 | 18 | namespace CMIO { namespace DP 19 | { 20 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 21 | // Types in the CMIO::DP namespace 22 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 23 | class Device; 24 | }}; 25 | 26 | namespace CMIO { namespace DP { namespace Property 27 | { 28 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 29 | // DeviceIsAlive 30 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 31 | class DeviceIsAlive : public Base 32 | { 33 | // Construction/Destruction 34 | public: 35 | DeviceIsAlive(DP::Device& owningDevice, bool isAlive = true) : Base(), mOwningDevice(owningDevice), mIsAlive(isAlive) {} 36 | virtual ~DeviceIsAlive() {} 37 | 38 | // Property Operations 39 | public: 40 | virtual bool IsActive(const CMIOObjectPropertyAddress& address) const; 41 | virtual bool IsPropertySettable(const CMIOObjectPropertyAddress& address) const; 42 | virtual UInt32 GetPropertyDataSize(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData) const; 43 | virtual void GetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, UInt32& dataUsed, void* data) const; 44 | virtual void SetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, const void* data); 45 | 46 | virtual UInt32 GetNumberAddressesImplemented() const; 47 | virtual void GetImplementedAddressByIndex(UInt32 index, CMIOObjectPropertyAddress& address) const; 48 | 49 | // Property Implementation 50 | void SetIsAlive(bool isAlive); 51 | UInt32 IsAlive() { return mIsAlive; }; 52 | 53 | private: 54 | DP::Device& mOwningDevice; 55 | bool mIsAlive; 56 | }; 57 | }}} 58 | #endif 59 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/DP/Properties/CMIO_DP_Property_EndOfData.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DP_Property_EndOfData.h 3 | Abstract: Implements the kCMIOStreamPropertyEndOfData property. 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DP_Property_EndOfData_h__) 9 | #define __CMIO_DP_Property_EndOfData_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | // Super Class Includes 16 | #include "CMIO_DP_Property_Base.h" 17 | 18 | namespace CMIO { namespace DP 19 | { 20 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 21 | // Types in the CMIO::DP namespace 22 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 23 | class Stream; 24 | }}; 25 | 26 | namespace CMIO { namespace DP { namespace Property 27 | { 28 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 29 | // EndOfData 30 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 31 | class EndOfData : public Base 32 | { 33 | // Construction/Destruction 34 | public: 35 | EndOfData(Stream& owningStream) : Base(), mOwningStream(owningStream), mEndOfData(false) {} 36 | virtual ~EndOfData() {} 37 | 38 | private: 39 | Stream& GetOwningStream() const { return mOwningStream; } 40 | Stream& mOwningStream; 41 | 42 | // Property Operations 43 | public: 44 | virtual bool IsActive(const CMIOObjectPropertyAddress& address) const; 45 | virtual bool IsPropertySettable(const CMIOObjectPropertyAddress& address) const; 46 | virtual UInt32 GetPropertyDataSize(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData) const; 47 | virtual void GetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, UInt32& dataUsed, void* data) const; 48 | virtual void SetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, const void* data); 49 | 50 | virtual UInt32 GetNumberAddressesImplemented() const; 51 | virtual void GetImplementedAddressByIndex(UInt32 index, CMIOObjectPropertyAddress& address) const; 52 | 53 | // Property Implementation 54 | public: 55 | void SetEndOfData(Boolean endOfData, bool sendChangeNotifications = true); 56 | UInt32 IsEndOfData() { return mEndOfData; }; 57 | 58 | private: 59 | UInt32 mEndOfData; 60 | }; 61 | }}} 62 | #endif 63 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/DP/Properties/CMIO_DP_Property_SuspendedByUser.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DP_Property_SuspendedByUser.h 3 | Abstract: Implements the kCMIODevicePropertySuspendedByUser property. 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DP_Property_SuspendedByUser_h__) 9 | #define __CMIO_DP_Property_SuspendedByUser_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | // Super Class Includes 16 | #include "CMIO_DP_Property_Base.h" 17 | 18 | namespace CMIO { namespace DP 19 | { 20 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 21 | // Types in the CMIO::DP namespace 22 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 23 | class Device; 24 | }} 25 | 26 | namespace CMIO { namespace DP { namespace Property 27 | { 28 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 29 | // SuspendedByUser 30 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 31 | class SuspendedByUser : public Base 32 | { 33 | // Construction/Destruction 34 | public: 35 | SuspendedByUser(DP::Device& owningDevice, bool suspendedByUser) : Base(), mOwningDevice(owningDevice), mSuspendedByUser(suspendedByUser) {} 36 | virtual ~SuspendedByUser() {} 37 | 38 | private: 39 | DP::Device& GetOwningDevice() const { return mOwningDevice; } 40 | DP::Device& mOwningDevice; 41 | 42 | // Property Operations 43 | public: 44 | virtual bool IsPropertySettable(const CMIOObjectPropertyAddress& address) const { return false; } 45 | virtual UInt32 GetPropertyDataSize(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData) const; 46 | virtual void GetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, UInt32& dataUsed, void* data) const; 47 | 48 | virtual UInt32 GetNumberAddressesImplemented() const { return 1; } 49 | virtual void GetImplementedAddressByIndex(UInt32 index, CMIOObjectPropertyAddress& address) const; 50 | 51 | // Property Implementation 52 | void SetSuspendedByUser(bool suspendedByUser); 53 | bool IsSuspendedByUser() const { return mSuspendedByUser; } 54 | 55 | private: 56 | bool mSuspendedByUser; 57 | }; 58 | }}} 59 | #endif 60 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/IOV/PlugIn/CMIO_DP_IOV_ControlDictionary.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DP_IOV_ControlDictionary.h 3 | Abstract: User space utility functions that extract items from an IOV control dictionary. 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DP_IOV_ControlDictionary_h__) 9 | #define __CMIO_DP_IOV_ControlDictionary_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | // System Includes 16 | #include 17 | #include 18 | 19 | namespace CMIO { namespace DP { namespace IOV 20 | { 21 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 22 | // ControlDictionary 23 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 24 | class ControlDictionary 25 | { 26 | public: 27 | static UInt32 GetControlID(CFDictionaryRef controlDictionary); 28 | static CMIOClassID GetBaseClassID(CFDictionaryRef controlDictionary); 29 | static CMIOClassID GetClassID(CFDictionaryRef controlDictionary); 30 | static CMIOObjectPropertyScope GetPropertyScope(CFDictionaryRef controlDictionary); 31 | static CMIOObjectPropertyElement GetPropertyElement(CFDictionaryRef controlDictionary); 32 | static bool IsReadOnly(CFDictionaryRef controlDictionary); 33 | static UInt32 GetVariant(CFDictionaryRef controlDictionary); 34 | static CFStringRef CopyName(CFDictionaryRef controlDictionary); 35 | 36 | static bool GetBooleanControlValue(CFDictionaryRef controlDictionary); 37 | 38 | static UInt32 GetSelectorControlValue(CFDictionaryRef controlDictionary); 39 | static CFArrayRef CopySelectorControlSelectorMap(CFDictionaryRef controlDictionary); 40 | }; 41 | }}} 42 | #endif 43 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/Assistant/Server/CMIO_DPA_Sample_Server_Common.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DPA_Sample_Server_Common.h 3 | Abstract: Items common to server portion of the Assistant. 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DPA_Sample_Server_Common_h__) 9 | #define __CMIO_DPA_Sample_Server_Common_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | // Public Utility Includes 16 | #include "CMIO_PropertyAddress.h" 17 | 18 | // System Includes 19 | #include 20 | 21 | // Standard Library Includes 22 | #include 23 | #include 24 | 25 | namespace CMIO { namespace DPA { namespace Sample { namespace Server 26 | { 27 | typedef mach_port_t Client; // Port on which client sends message to Assistant 28 | typedef std::set Clients; // Set of clients 29 | 30 | // PropertyShadow 31 | struct PropertyShadow 32 | { 33 | PropertyShadow() : mShadowTime(0) {}; 34 | UInt64 mShadowTime; 35 | }; 36 | 37 | typedef std::map Properties; 38 | 39 | // ControlShadow 40 | struct ControlShadow 41 | { 42 | ControlShadow() : mValueShadowTime(0), mRangeShadowTime(0) {}; 43 | UInt64 mValueShadowTime; 44 | UInt64 mRangeShadowTime; 45 | }; 46 | 47 | typedef std::map Controls; 48 | }}}} 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/Assistant/Server/CMIO_DPA_Sample_Server_IOBackedAssistant.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DPA_Sample_Server_IOBackedAssistant.h 3 | Abstract: Server which handles all the IPC between the various Sample DAL PlugIn instances. 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DPA_Sample_Server_IOBackedAssistant_h__) 9 | #define __CMIO_DPA_Sample_Server_IOBackedAssistant_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | #include "CMIO_DPA_Sample_Server_Assistant.h" 16 | 17 | // Public Utility Includes 18 | #include "CMIO_IOKA_Object.h" 19 | #include "CMIO_PTA_NotificationPortThread.h" 20 | 21 | // Standard Library Includes 22 | #include 23 | 24 | namespace CMIO { namespace DPA { namespace Sample { namespace Server 25 | { 26 | class IOBackedAssistant: public Assistant 27 | { 28 | // Construction/Destruction 29 | public: 30 | static IOBackedAssistant* Instance(); 31 | 32 | public: 33 | IOBackedAssistant(); 34 | static IOBackedAssistant* sInstance; 35 | 36 | public: 37 | virtual kern_return_t GetDeviceStates(Client client, mach_port_t messagePort, DeviceState** deviceStates, mach_msg_type_number_t* length) override; 38 | 39 | // Device Mangagement 40 | public: 41 | static void DeviceArrived(IOBackedAssistant& assistant, io_iterator_t iterator); 42 | void DeviceRemoved(Device& device); 43 | 44 | private: 45 | void InitializeDeviceAddedNotification(); 46 | void CreateDeviceAddedNotification(CFMutableDictionaryRef matchingDictionary); 47 | 48 | typedef std::vector NotificationIterators; 49 | 50 | PTA::NotificationPortThread mNotificationPortThread; // Thread for getting IOKit notifications on 51 | NotificationIterators mDeviceAddedIterators; // A "kIOMatchedNotification" notifcation iterator for each "matching dictionary" 52 | }; 53 | }}}} 54 | #endif 55 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/Assistant/Server/CMIO_DPA_Sample_Server_VCamAssistant.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DPA_SampleVCam_Server_VCamAssistant.h 3 | Abstract: Server which handles all the IPC between the various Sample DAL PlugIn instances. 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DPA_Sample_Server_VCamAssistant_h__) 9 | #define __CMIO_DPA_Sample_Server_VCamAssistant_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | #include "CMIO_DPA_Sample_Server_Assistant.h" 16 | 17 | namespace CMIO { namespace DPA { namespace Sample { namespace Server 18 | { 19 | class VCamAssistant: public Assistant 20 | { 21 | // Construction/Destruction 22 | public: 23 | static VCamAssistant* Instance(); 24 | 25 | public: 26 | VCamAssistant(); 27 | static VCamAssistant* sInstance; 28 | 29 | private: 30 | void CreateDevices(); 31 | }; 32 | }}}} 33 | #endif 34 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/Assistant/Server/Device/CMIO_DPA_Sample_Server_ClientStream.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DPA_Sample_Server_ClientStream.h 3 | Abstract: n/a 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DPA_Sample_Server_ClientStream_h__) 9 | #define __CMIO_DPA_Sample_Server_ClientStream_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | // Internal Includes 16 | #include "CMIO_DPA_Sample_Server_Common.h" 17 | #include "CMIO_DPA_Sample_Shared.h" 18 | 19 | // Public Utilities 20 | #include "CMIO_CMA_SimpleQueue.h" 21 | 22 | // CA Public Utilities 23 | #include "CAGuard.h" 24 | #include "CAPThread.h" 25 | 26 | 27 | namespace CMIO { namespace DPA { namespace Sample { namespace Server 28 | { 29 | class Frame; 30 | 31 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 32 | // ClientStream 33 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 34 | class ClientStream 35 | { 36 | // Construction/Destruction 37 | public: 38 | ClientStream(Client client, mach_port_t messagePort, CAGuard& frameAvailableGuard); 39 | virtual ~ClientStream(); 40 | 41 | // Queue 42 | public: 43 | CMA::SimpleQueue& GetQueue() { return mQueue; } 44 | 45 | private: 46 | CMA::SimpleQueue mQueue; 47 | 48 | // Attributes 49 | public: 50 | void SetDiscontinuityFlags(UInt32 discontinuityFlags) { mDiscontinuityFlags = discontinuityFlags; } 51 | UInt32 GetDiscontinuityFlags() const { return mDiscontinuityFlags; } 52 | 53 | private: 54 | UInt32 mDiscontinuityFlags; 55 | UInt64 mExtendedFrameHostTime; 56 | CMA::SampleBuffer::TimingInfo mExtendedFrameTimingInfo; 57 | 58 | // Message Thread 59 | public: 60 | void StartMessageThread(); 61 | void StopMessageThread(); 62 | 63 | private: 64 | static void* MessageThreadEntry(ClientStream& clientStream); 65 | void SendFrameArrivedMessage(mach_port_t& recipient, Frame& frame); 66 | 67 | mach_port_t mClient; 68 | mach_port_t mMessagePort; 69 | bool mStopMessageLoop; 70 | CAPThread mMessageThread; 71 | CAGuard mMessageThreadGuard; 72 | CAGuard& mFrameAvailableGuard; 73 | }; 74 | }}}} 75 | #endif 76 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/Assistant/Server/Device/CMIO_DPA_Sample_Server_IOBackedFrame.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DPA_Sample_Server_IOBackedFrame.cpp 3 | Abstract: n/a 4 | Version: 1.2 5 | 6 | */ 7 | 8 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 9 | // Includes 10 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 11 | 12 | // Self Include 13 | #include "CMIO_DPA_Sample_Server_IOBackedFrame.h" 14 | 15 | 16 | namespace CMIO { namespace DPA { namespace Sample { namespace Server 17 | { 18 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 19 | // IOBackedFrame 20 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 21 | IOBackedFrame::IOBackedFrame(IOStreamRef stream, 22 | FrameType frameType, 23 | UInt64 hostTime, 24 | const CMA::SampleBuffer::TimingInfo& timingInfo, 25 | UInt32 discontinuityFlags, 26 | UInt32 droppedFrameCount, 27 | UInt64 firstFrameTime, 28 | IOStreamBufferID bufferID, 29 | size_t size, 30 | void* data) : 31 | Frame(frameType, hostTime, timingInfo, discontinuityFlags, droppedFrameCount, firstFrameTime, size, data), 32 | mStream(stream), 33 | mBufferID(bufferID) 34 | { 35 | } 36 | 37 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 38 | // ~IOBackedFrame() 39 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 40 | IOBackedFrame::~IOBackedFrame() 41 | { 42 | // Return the frame to the queue 43 | (**mStream).EnqueueInputBuffer(mStream, mBufferID, 0, 0, 0, 0); 44 | (**mStream).SendInputNotification(mStream, 0xAA); 45 | } 46 | 47 | }}}} 48 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/Assistant/Server/Device/CMIO_DPA_Sample_Server_IOBackedFrame.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DPA_Sample_Server_IOBackedFrame.h 3 | Abstract: n/a 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DPA_Sample_Server_IOBackedFrame_h__) 9 | #define __CMIO_DPA_Sample_Server_IOBackedFrame_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | #include "CMIO_DPA_Sample_Server_Frame.h" 16 | 17 | // System Includes 18 | #include 19 | #include 20 | 21 | namespace CMIO { namespace DPA { namespace Sample { namespace Server 22 | { 23 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 24 | // IOBackedFrame 25 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 26 | class IOBackedFrame: public Frame 27 | { 28 | public: 29 | // Construction/Destruction 30 | IOBackedFrame(IOStreamRef stream, 31 | FrameType frameType, 32 | UInt64 hostTime, 33 | const CMA::SampleBuffer::TimingInfo& timingInfo, 34 | UInt32 discontinuityFlags, 35 | UInt32 droppedFrameCount, 36 | UInt64 firstFrameTime, 37 | IOStreamBufferID bufferID, 38 | size_t size, 39 | void* data); 40 | ~IOBackedFrame(); 41 | 42 | private: 43 | IOStreamRef mStream; 44 | IOBackedFrame& operator=(IOBackedFrame& that); // Unimplemented - don't allow copying 45 | 46 | protected: 47 | IOStreamBufferID mBufferID; 48 | }; 49 | }}}} 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/Assistant/Server/Device/CMIO_DPA_Sample_Server_IOBackedStream.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DPA_Sample_Server_IOBackedStream.h 3 | Abstract: n/a 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DPA_Sample_Server_IOBackedStream_h__) 9 | #define __CMIO_DPA_Sample_Server_IOBackedStream_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | #include "CMIO_DPA_Sample_Server_Stream.h" 16 | 17 | // Public Utility Includes 18 | #include "CMIO_IOKA_Object.h" 19 | #include "CMIO_IOSA_Assistance.h" 20 | 21 | // System Includes 22 | #include 23 | 24 | // Standard Library Includes 25 | #include 26 | 27 | 28 | namespace CMIO { namespace DPA { namespace Sample { namespace Server 29 | { 30 | class IOBackedDevice; 31 | 32 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 33 | // IOBackedStream 34 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 35 | class IOBackedStream: public Stream 36 | { 37 | // Construction/Destruction 38 | public: 39 | IOBackedStream(IOBackedDevice* device, IOKA::Object& registryEntry, CFDictionaryRef streamDictionary, CMIOObjectPropertyScope scope); 40 | virtual ~IOBackedStream(); 41 | 42 | private: 43 | IOBackedStream& operator=(IOBackedStream& that); // Don't allow copying 44 | 45 | protected: 46 | IOKA::Object mRegistryEntry; // The IOKit registry entry for the device 47 | 48 | // Attributes & Properties 49 | public: 50 | IOBackedDevice& GetOwningDevice() { return *((IOBackedDevice*)mDevice); } 51 | IOSA::Stream& GetIOSAStream() { return mIOSAStream; } 52 | 53 | protected: 54 | IOSA::PlugIn mIOSPAlugIn; // IOSA wrapper kIOStreamLibTypeID's IOCFPlugInInterface** 55 | IOSA::Stream mIOSAStream; // IOSA wrapper for IOVideoStreamRef 56 | 57 | virtual void SetStreamFormat(IOVideoStreamDescription *newStreamFormat) override; 58 | 59 | // Management 60 | public: 61 | virtual void Start(Client client, mach_port_t messagePort, UInt32 initialDiscontinuityFlags) override; 62 | virtual void Stop(Client client) override; 63 | 64 | static void StreamOutputCallback(IOStreamRef /*streamRef*/, IOBackedStream& stream); 65 | void FrameArrived(IOStreamBufferQueueEntry& entry); 66 | 67 | protected: 68 | typedef std::list IOStreamBufferQueueEntryFreeList; 69 | IOStreamBufferQueueEntryFreeList mFreeList; 70 | }; 71 | 72 | }}}} 73 | #endif 74 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/Assistant/Server/Device/CMIO_DPA_Sample_Server_VCamDevice.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DPA_Sample_Server_VCamDevice.h 3 | Abstract: n/a 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DPA_Sample_Server_VCamDevice_h__) 9 | #define __CMIO_DPA_Sample_Server_VCamDevice_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | #include "CMIO_DPA_Sample_Server_Device.h" 16 | 17 | namespace CMIO { namespace DPA { namespace Sample { namespace Server 18 | { 19 | class VCamInputStream; 20 | 21 | class VCamDevice: public Device 22 | { 23 | public: 24 | 25 | #pragma mark - 26 | #pragma mark Device 27 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 28 | // Device 29 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 30 | // Construction/Destruction 31 | public: 32 | VCamDevice(); 33 | virtual ~VCamDevice(); 34 | 35 | private: 36 | VCamDevice& operator=(VCamDevice& that); // Don't allow copying 37 | 38 | private: 39 | VCamInputStream* mInputStream; 40 | void CreateStreams(); 41 | 42 | private: 43 | pthread_t mThread; 44 | FILE* mSequenceFile; 45 | size_t mFrameIndex; 46 | size_t mFrameSize; 47 | size_t mFrameCount; 48 | 49 | static void* EmitFrame(void*); 50 | }; 51 | }}}} 52 | #endif 53 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/Assistant/Server/Device/CMIO_DPA_Sample_Server_VCamInputStream.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DPA_Sample_Server_VCamInputStream.h 3 | Abstract: n/a 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DPA_Sample_Server_VCamInputStream_h__) 9 | #define __CMIO_DPA_Sample_Server_VCamInputStream_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | #include "CMIO_DPA_Sample_Server_Stream.h" 16 | 17 | 18 | namespace CMIO { namespace DPA { namespace Sample { namespace Server 19 | { 20 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 21 | // VCamInputStream 22 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 23 | class VCamInputStream: public Stream 24 | { 25 | // Construction/Destruction 26 | public: 27 | VCamInputStream(Device* device, CFDictionaryRef streamDictionary, CMIOObjectPropertyScope scope); 28 | 29 | private: 30 | VCamInputStream& operator=(VCamInputStream& that); // Don't allow copying 31 | 32 | // Format & Frame Rate 33 | protected: 34 | void SetStreamFormat(IOVideoStreamDescription *newStreamFormat) override; 35 | 36 | // Management 37 | public: 38 | virtual void Start(Client client, mach_port_t messagePort, UInt32 initialDiscontinuityFlags) override; 39 | virtual void Stop(Client client) override; 40 | 41 | void FrameArrived(size_t frameSize, uint8_t* frameData, UInt64 vbiTime); 42 | }; 43 | 44 | }}}} 45 | #endif 46 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/Assistant/com.apple.cmio.DPA.Sample.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Label 6 | com.apple.cmio.DPA.Sample 7 | ProgramArguments 8 | 9 | /Library/CoreMediaIO/Plug-Ins/DAL/Sample.plugin/Contents/Resources/SampleAssistant 10 | 11 | MachServices 12 | 13 | com.apple.cmio.DPA.Sample 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/Assistant/com.apple.cmio.DPA.SampleVCam.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Label 6 | com.apple.cmio.DPA.SampleVCam 7 | ProgramArguments 8 | 9 | /Library/CoreMediaIO/Plug-Ins/DAL/SampleVCam.plugin/Contents/Resources/SampleVCamAssistant 10 | 11 | MachServices 12 | 13 | com.apple.cmio.DPA.SampleVCam 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/KernelExtension/CMIO_KEXT_Sample_ControlIDs.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_KEXT_Sample_ControlIDs.h 3 | Abstract: Control ID constants used by the Sample kext and its Assistant 4 | Version: 1.2 5 | */ 6 | 7 | #if !defined(__CMIO_KEXT_Sample_ControlIDs_h__) 8 | #define __CMIO_KEXT_Sample_ControlIDs_h__ 9 | 10 | namespace CMIO { namespace KEXT { namespace Sample 11 | { 12 | enum 13 | { 14 | kDirectionControlID = 2, 15 | kInputSourceSelectorControlID = 3, 16 | kInputChannelSelectorControlID = 4 17 | }; 18 | 19 | enum 20 | { 21 | kSampleSourceTuner = 0, 22 | kSampleSourceComposite = 1, 23 | kSampleSourceSVideo = 2, 24 | }; 25 | }}} 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/KernelExtension/IOUSBLog.h: -------------------------------------------------------------------------------- 1 | // 2 | // IOUSBLog.h 3 | // Sample 4 | // 5 | // Created by Tamás Lustyik on 2018. 11. 28.. 6 | // 7 | 8 | #ifndef IOUSBLog_h 9 | #define IOUSBLog_h 10 | 11 | // contents of this file originate from deprecated header 12 | 13 | // Possible Debug levels. If DEBUG_LEVEL is set to DEBUG_LEVEL_PRODUCTION, all debug logs will be 14 | // stripped of the final code. 15 | #define DEBUG_LEVEL_PRODUCTION 0 16 | #define DEBUG_LEVEL_DEVELOPMENT 1 17 | #define DEBUG_LEVEL_ALPHA 2 18 | #define DEBUG_LEVEL_BETA 3 19 | #define DEBUG_LEVEL_FINAL DEBUG_LEVEL_PRODUCTION 20 | 21 | // Allow clients to define their own debug level. 22 | 23 | #if ( !defined( DEBUG_LEVEL ) ) 24 | #define DEBUG_LEVEL DEBUG_LEVEL_FINAL 25 | #endif 26 | 27 | 28 | #ifdef KERNEL 29 | 30 | #if DEBUG_LEVEL != DEBUG_LEVEL_PRODUCTION 31 | // Info Debug levels. 32 | typedef UInt32 KernelDebugLevel; 33 | 34 | // Info Debug Output Types. 35 | typedef UInt32 KernelDebuggingOutputType; 36 | enum 37 | { 38 | kKernelDebugOutputIOLogType = 0x00000001, 39 | kKernelDebugOutputKextLoggerType = 0x00000002 40 | }; 41 | 42 | extern "C" { 43 | void KernelDebugEnable( bool enable ); 44 | void KernelDebugSetLevel( KernelDebugLevel inLevel ); 45 | void KernelDebugSetOutputType( KernelDebuggingOutputType inType ); 46 | void KernelDebugLogInternal( KernelDebugLevel inLevel, UInt32 inTag, char const *inFormatString, ... ) __attribute__ ((format(printf,3,4)));; 47 | } 48 | 49 | #define KernelDebugLogTag( LEVEL, TAG, ARGS... ) KernelDebugLogInternal( ( LEVEL ), ( TAG ), ## ARGS ) 50 | #else 51 | #define KernelDebugLogTag( LEVEL, TAG, ARGS... ) 52 | #endif 53 | 54 | #define USBLog( LEVEL, ARGS...) KernelDebugLogTag( LEVEL, 'USBF', ## ARGS ) 55 | 56 | #else 57 | 58 | #define USBLog( LEVEL, ARGS...) 59 | 60 | #endif // KERNEL 61 | 62 | #endif /* IOUSBLog_h */ 63 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/KernelExtension/IOVideoSampleDeviceShared.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: IOVideoSampleDeviceShared.h 3 | Abstract: n/a 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__IOVideoSampleDeviceShared_h__) 9 | #define __IOVideoSampleDeviceShared_h__ 10 | 11 | /*! 12 | @enum CodecFlags. 13 | @discussion . 14 | */ 15 | enum 16 | { 17 | kSampleCodecNoFlags = 0, /*! @constant kSampleCodecNoFlags no rates supported. */ 18 | 19 | kSampleCodecFlags_24fps = (1L << 0), /*! @constant kSampleCodecFlags_24fps 0x00000001 framerate 24fps. */ 20 | kSampleCodecFlags_25fps = (1L << 1), /*! @constant kSampleCodecFlags_25fps 0x00000002 framerate 25fps. */ 21 | kSampleCodecFlags_30fps = (1L << 2), /*! @constant kSampleCodecFlags_30fps 0x00000004 framerate 30fps. */ 22 | kSampleCodecFlags_50fps = (1L << 3), /*! @constant kSampleCodecFlags_50fps 0x00000008 framerate 50fps. */ 23 | kSampleCodecFlags_60fps = (1L << 4), /*! @constant kSampleCodecFlags_60fps 0x00000010 framerate 60fps. */ 24 | 25 | kSampleCodecFlags_1001_1000_adjust = (1L << 16), /*! @constant kSampleCodecFlags_1001_1000_adjust 0x00010000 multiply framerate by 1000/1001. */ 26 | kSampleCodecFlags_psf_frame = (1L << 17) /*! @constant kSampleCodecFlags_psf_frame 0x00020000 frame is psf. */ 27 | }; 28 | 29 | enum FrameType 30 | { 31 | kYUV422_720x480, 32 | kYUV422_720x486, 33 | kYUV422_720x576, 34 | kYUV422_1280x720, 35 | kYUV422_1920x1080, 36 | kYUV422_10_720x480, 37 | kYUV422_10_720x486, 38 | kYUV422_10_720x576, 39 | kYUV422_10_1280x720, 40 | kYUV422_10_1920x1080, 41 | kFrameTypePad = 0xFFFFFFFFUL 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/KernelExtension/IOVideoSampleStream.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: IOVideoSampleStream.h 3 | Abstract: n/a 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__IOVideoSampleStream_h__) 9 | #define __IOVideoSampleStream_h__ 10 | 11 | // System Includes 12 | #include 13 | 14 | class IOVideoSampleStream : public IOVideoStream 15 | { 16 | OSDeclareDefaultStructors(IOVideoSampleStream); 17 | 18 | protected: 19 | OSArray* _freeBuffers; 20 | OSArray* _filledBuffers; 21 | 22 | public: 23 | virtual void free(void) override; 24 | 25 | static IOVideoSampleStream* withBuffers(OSArray* buffers, IOStreamMode mode = kIOStreamModeOutput, IOItemCount queueLength = 0, OSDictionary* properties = 0); 26 | 27 | virtual bool initWithBuffers(OSArray* buffers, IOStreamMode mode = kIOStreamModeOutput, IOItemCount queueLength = 0, OSDictionary* properties = 0) override; 28 | 29 | virtual bool handleOpen(IOService* forClient, IOOptionBits options, void* arg) override; 30 | virtual void handleClose(IOService* forClient, IOOptionBits options = 0) override; 31 | 32 | virtual void inputCallback(UInt32 token) override; 33 | virtual void inputSyncCallback(UInt32 token) override; 34 | 35 | IOStreamBuffer* getFilledBuffer(); 36 | void returnBufferToFreeQueue(IOStreamBuffer* buffer); 37 | void postFreeInputBuffer(UInt64 vbiTime, UInt64 outputTime, UInt64 totalFrameCount, UInt64 droppedFrameCount,UInt64 lastDisplayedSequenceNumber); 38 | }; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/KernelExtension/SampleDriver-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | KEXT 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0.0d1 19 | IOKitPersonalities 20 | 21 | IOVideoSampleDevice 22 | 23 | CFBundleIdentifier 24 | com.apple.cmio.driver.Sample 25 | IOClass 26 | IOVideoSampleDevice 27 | IOMatchCategory 28 | IOVideoSampleDevice 29 | IOProviderClass 30 | IOResources 31 | IOResourceMatch 32 | IOBSD 33 | IOUserClientClass 34 | IOVideoDeviceUserClient 35 | 36 | 37 | OSBundleLibraries 38 | 39 | com.apple.iokit.IOStreamFamily 40 | 1.0 41 | com.apple.iokit.IOUSBFamily 42 | 1.8.4 43 | com.apple.iokit.IOVideoFamily 44 | 1.0 45 | com.apple.kpi.iokit 46 | 9.0 47 | com.apple.kpi.libkern 48 | 9.0 49 | com.apple.kpi.mach 50 | 9.0 51 | com.apple.kpi.unsupported 52 | 9.0 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/KernelExtension/SampleUserClient-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | $(PRODUCT_BUNDLE_IDENTIFIER) 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundleName 12 | IOVideoDeviceUserClient 13 | CFBundlePackageType 14 | KEXT 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0.0 19 | IOKitPersonalities 20 | 21 | IOVideoSampleStreamUserClient 22 | 23 | CFBundleIdentifier 24 | com.apple.cmio.driver.SampleUserClient 25 | IOClass 26 | IOVideoDeviceUserClientInit 27 | IOProviderClass 28 | IOVideoSampleDevice 29 | IOProviderMergeProperties 30 | 31 | IOUserClientClass 32 | IOVideoDeviceUserClient 33 | 34 | 35 | 36 | OSBundleLibraries 37 | 38 | com.apple.iokit.IOVideoFamily 39 | 1.0 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/PlugIn/CMIO_DP_Sample_ControlIDs.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DP_Sample_ControlIDs.h 3 | Abstract: Control ID constants used by the Sample Server and its Assistant. 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DP_Sample_ControlIDs_h__) 9 | #define __CMIO_DP_Sample_ControlIDs_h__ 10 | 11 | namespace CMIO { namespace DP { namespace Sample 12 | { 13 | enum 14 | { 15 | kProtocolSelectorControlID = 5 16 | }; 17 | 18 | enum 19 | { 20 | kProtocolSample = 1, 21 | kProtocolSampleBasic = 2, 22 | kProtocolSampleAdvanced = 3 23 | }; 24 | 25 | }}} 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/PlugIn/CMIO_DP_Sample_IOBackedDevice.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DP_Sample_IOBackedDevice.h 3 | Abstract: n/a 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DP_Sample_IOBackedDevice_h__) 9 | #define __CMIO_DP_Sample_IOBackedDevice_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | // Super Class Includes 16 | #include "CMIO_DP_Sample_Device.h" 17 | 18 | // Public Utility Includes 19 | #include "CMIO_IOKA_Object.h" 20 | 21 | 22 | namespace CMIO { namespace DP { namespace Sample 23 | { 24 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 25 | // IOBackedDevice 26 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 27 | class IOBackedDevice : public Device 28 | { 29 | // Construction/Destruction 30 | public: 31 | IOBackedDevice(PlugIn& plugIn, CMIODeviceID deviceID, mach_port_t assistantPort, UInt64 guid, const io_string_t registryPath); 32 | 33 | protected: 34 | IOKA::Object mRegistryEntry; // The IOKit registry entry for the device 35 | 36 | // Controls 37 | public: 38 | virtual CFDictionaryRef CopyControlDictionaryByControlID(UInt32 controlID) const override; 39 | 40 | protected: 41 | virtual void CreateRegistryControls() override; 42 | }; 43 | }}} 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/PlugIn/CMIO_DP_Sample_PlugIn.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DP_Sample_PlugIn.h 3 | Abstract: n/a 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DP_Sample_PlugIn_h__) 9 | #define __CMIO_DP_Sample_PlugIn_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | // Super Class Includes 16 | #include "CMIO_DP_PlugIn.h" 17 | 18 | // Internal Includes 19 | #include "CMIO_DPA_Sample_ClientExtras.h" 20 | 21 | // CA Public Utility Includes 22 | #include "CACFMachPort.h" 23 | 24 | namespace CMIO { namespace DP { namespace Sample 25 | { 26 | class Device; 27 | 28 | class PlugIn : public DP::PlugIn 29 | { 30 | // Construction/Destruction 31 | public: 32 | PlugIn(CFUUIDRef factoryUUID, const char* assistantServiceName); 33 | virtual ~PlugIn(); 34 | 35 | virtual void InitializeWithObjectID(CMIOObjectID objectID); 36 | virtual void Teardown(); 37 | 38 | // Property Access 39 | public: 40 | virtual bool HasProperty(const CMIOObjectPropertyAddress& address) const; 41 | virtual bool IsPropertySettable(const CMIOObjectPropertyAddress& address) const; 42 | virtual UInt32 GetPropertyDataSize(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData) const; 43 | virtual void GetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, UInt32& dataUsed, void* data) const; 44 | virtual void SetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, const void* data); 45 | 46 | // SampleAssistant 47 | protected: 48 | DPA::Sample::Port mAssistantPort; // Mach port used to send messages to SampleAssistant 49 | CACFMachPort* mDeviceEventPort; // Port from which messages are received from SampleAssistant 50 | dispatch_source_t mDeviceEventDispatchSource; // Dispatch source for the device event port 51 | UInt64 mAssistantCrashAnchorTime; // Anchor time for tracking how often the Assistant crashes 52 | UInt32 mAssistantCrashCount; // Number of crashes since the crash anchor time 53 | char* mAssistantServiceName; 54 | 55 | // Device Management 56 | protected: 57 | static void DeviceEvent(PlugIn& plugIn); 58 | void UpdateDeviceStates(); 59 | Device& GetDeviceByGUID(UInt64 guid) const; 60 | void DeviceArrived(UInt64 guid, const io_string_t& registryPath, Boolean isIOBacked); 61 | void DeviceRemoved(Device& device); 62 | }; 63 | }}} 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/PlugIn/CMIO_DP_Sample_VirtualDevice.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DP_Sample_VirtualDevice.cpp 3 | Abstract: n/a 4 | Version: 1.2 5 | 6 | */ 7 | 8 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 9 | // includes 10 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 11 | 12 | // Self Include 13 | #include "CMIO_DP_Sample_VirtualDevice.h" 14 | 15 | #pragma mark - 16 | namespace CMIO { namespace DP { namespace Sample 17 | { 18 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 19 | // VirtualDevice() 20 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 21 | VirtualDevice::VirtualDevice(PlugIn& plugIn, CMIODeviceID deviceID, mach_port_t assistantPort, UInt64 guid): 22 | Device(plugIn, deviceID, assistantPort, guid) 23 | { 24 | mDeviceUID = CFSTR("SampleVCam Video"); 25 | mDeviceName = CFSTR("SampleVCam"); 26 | } 27 | 28 | }}} 29 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/PlugIn/CMIO_DP_Sample_VirtualDevice.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DP_Sample_VirtualDevice.h 3 | Abstract: n/a 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DP_Sample_VirtualDevice_h__) 9 | #define __CMIO_DP_Sample_VirtualDevice_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | // Super Class Includes 16 | #include "CMIO_DP_Sample_Device.h" 17 | 18 | 19 | namespace CMIO { namespace DP { namespace Sample 20 | { 21 | 22 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 23 | // VirtualDevice 24 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 25 | class VirtualDevice : public Device 26 | { 27 | // Construction/Destruction 28 | public: 29 | VirtualDevice(PlugIn& plugIn, CMIODeviceID deviceID, mach_port_t assistantPort, UInt64 guid); 30 | }; 31 | 32 | }}} 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/PlugIn/Properties/CMIO_DP_Sample_Property_HogMode.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DP_Sample_Property_HogMode.h 3 | Abstract: Implements the kCMIODevicePropertyHogMode property with a non-settable value of -1, meaning that the device can be used by any process. 4 | 5 | Version: 1.2 6 | 7 | */ 8 | 9 | #if !defined(__CMIO_DP_Sample_Property_HogMode_h__) 10 | #define __CMIO_DP_Sample_Property_HogMode_h__ 11 | 12 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 13 | // Includes 14 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 15 | 16 | // Super Class Includes 17 | #include "CMIO_DP_Property_Base.h" 18 | 19 | namespace CMIO { namespace DP { namespace Sample { namespace Property 20 | { 21 | class Device; 22 | 23 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 24 | // HogMode 25 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 26 | class HogMode : public CMIO::DP::Property::Base 27 | { 28 | // Construction/Destruction 29 | public: 30 | HogMode() : CMIO::DP::Property::Base() {} 31 | virtual ~HogMode() {} 32 | 33 | // Property Operations 34 | public: 35 | virtual bool IsPropertySettable(const CMIOObjectPropertyAddress& address) const { return false; } 36 | virtual UInt32 GetPropertyDataSize(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData) const; 37 | virtual void GetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, UInt32& dataUsed, void* data) const; 38 | 39 | virtual UInt32 GetNumberAddressesImplemented() const { return 1; } 40 | virtual void GetImplementedAddressByIndex(UInt32 index, CMIOObjectPropertyAddress& address) const; 41 | }; 42 | }}}} 43 | #endif 44 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/PlugIn/Sample-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | Sample 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | Sample Streams 17 | CFBundlePackageType 18 | BNDL 19 | CFBundleShortVersionString 20 | 7.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 7.0 25 | CFPlugInFactories 26 | 27 | E1E3EB8E-3D0F-49C9-8924-A8A40E1E1CAE 28 | AppleCMIODPSampleNewPlugIn 29 | 30 | CFPlugInTypes 31 | 32 | 30010C1C-93BF-11D8-8B5B-000A95AF9C6A 33 | 34 | E1E3EB8E-3D0F-49C9-8924-A8A40E1E1CAE 35 | 36 | 37 | CMIOHardwareAssistantServiceNames 38 | 39 | com.apple.cmio.DPA.Sample 40 | 41 | NoCMIOHardwarePlugInLazyLoadingInfo 42 | 43 | 44 | IOProviderClass 45 | IOVideoSampleDevice 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/PlugIn/Sample.exp: -------------------------------------------------------------------------------- 1 | # 2 | # Only the PlugIn "Factory Function" needs to be exported 3 | # 4 | 5 | _AppleCMIODPSampleNewPlugIn 6 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/PlugIn/SampleVCam-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | SampleVCam 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | SampleVCam 17 | CFBundlePackageType 18 | BNDL 19 | CFBundleShortVersionString 20 | 7.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 7.0 25 | CFPlugInFactories 26 | 27 | 35FDFF29-BFCF-4644-AB77-B759DE932ABE 28 | AppleCMIODPSampleVCamPlugIn 29 | 30 | CFPlugInTypes 31 | 32 | 30010C1C-93BF-11D8-8B5B-000A95AF9C6A 33 | 34 | 35FDFF29-BFCF-4644-AB77-B759DE932ABE 35 | 36 | 37 | CMIOHardwareAssistantServiceNames 38 | 39 | com.apple.cmio.DPA.SampleVCam 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/PlugIn/SampleVCam.exp: -------------------------------------------------------------------------------- 1 | # 2 | # Only the PlugIn "Factory Function" needs to be exported 3 | # 4 | 5 | _AppleCMIODPSampleVCamPlugIn 6 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/DeviceAbstractionLayer/Devices/Sample/SamplePrefix.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: SamplePrefix.h 3 | Abstract: Items used to facilitate building on Lion or Mountain Lion with the same sources. 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__SamplePrefix_h__) 9 | #define __SamplePrefix_h__ 10 | 11 | #include 12 | 13 | class Defer { 14 | public: 15 | Defer(std::function deferredFunc): _deferredFunc(deferredFunc) {} 16 | ~Defer() { _deferredFunc(); } 17 | private: 18 | std::function _deferredFunc; 19 | }; 20 | 21 | #define _CONCAT(x, y) x ## y 22 | #define _CONCAT2(x, y) _CONCAT(x, y) 23 | #define DEFER(...) Defer _CONCAT2(_defer, __LINE__)( __VA_ARGS__ ); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/PublicUtility/CMIODebugPrintf.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIODebugPrintf.cpp 3 | Abstract: CoreMediaIO variant of CADebugPrintf.h 4 | Version: 1.2 5 | 6 | */ 7 | 8 | //================================================================================================== 9 | // Includes 10 | //================================================================================================== 11 | 12 | // Self Include 13 | #include "CMIODebugPrintf.h" 14 | #include 15 | #include 16 | #include 17 | 18 | 19 | #if DEBUG || CoreAudio_Debug || CMIO_Debug 20 | 21 | 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/PublicUtility/CMIODebugPrintf.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIODebugPrintf.h 3 | Abstract: CoreMediaIO variant of CADebugPrintf.h 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIODebugPrintf_h__) 9 | #define __CMIODebugPrintf_h__ 10 | 11 | #include "CADebugPrintf.h" 12 | 13 | #if (DEBUG || ALWAYS_DO_CMIO_DEBUG_MSG) 14 | 15 | // Undefine these items which were defined in CADebugPrintf.h 16 | #undef DebugPrintfRtn 17 | #undef DebugPrintfFile 18 | #undef DebugPrintfLineEnding 19 | 20 | #if CoreAudio_UseSysLog 21 | #include 22 | #define DebugPrintfRtn DebugSysLogPrint 23 | #define DebugPrintfFile LOG_ERR 24 | #define DebugPrintfLineEnding 25 | #else 26 | #include 27 | #define DebugPrintfRtn DebugPrint 28 | #define DebugPrintfFile stderr 29 | #define DebugPrintfLineEnding "\n" 30 | #endif 31 | 32 | 33 | #endif // (DEBUG || ALWAYS_DO_CMIO_DEBUG_MSG) 34 | #endif // !defined(__CMIODebugPrintf_h__) 35 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/PublicUtility/CMIO_BitField.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_BitField.h 3 | Abstract: C bit fields are not strictly defined by ANSI, hence they vary between compiler implementations. Some implementations start at the most significant bit and work towards the 4 | least significant, whereas others start at the least significant bit and work towards the most significant. By using the CMIO::BitField32 class, the implementation is 5 | explicitly controlled. 6 | 7 | Version: 1.2 8 | 9 | */ 10 | 11 | #if !defined(__CMIO_BitField_h__) 12 | #define __CMIO_BitField_h__ 13 | 14 | #include 15 | 16 | namespace CMIO 17 | { 18 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 19 | // BitField32 20 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 21 | class BitField32 22 | { 23 | // Construction/Destruction 24 | public: 25 | BitField32() : mBits(0) {} 26 | BitField32(UInt32 initialData) : mBits(initialData) {} 27 | 28 | private: 29 | UInt32 mBits; 30 | 31 | // Operations 32 | public: 33 | void Set(UInt32 setData, UInt32 startPosition, UInt32 width) { UInt32 alignedSetData = setData << startPosition; UInt32 alignedFieldMask = ((1 << width) - 1) << startPosition; mBits = (alignedSetData & alignedFieldMask) | (mBits & ~alignedFieldMask); } 34 | 35 | // Value Access 36 | public: 37 | operator UInt32() const { return mBits; } 38 | UInt32 Get(UInt32 startPosition, UInt32 width) const { return (mBits >> startPosition) & ((1 << width) - 1); } 39 | }; 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/PublicUtility/CMIO_SMPTETimeBase.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_SMPTETimeBase.h 3 | Abstract: A utility class to assist with a SMPTE time base. 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_SMPTETimeBase_h__) 9 | #define __CMIO_SMPTETimeBase_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | #include 16 | 17 | namespace CMIO 18 | { 19 | typedef UInt32 SMPTE_HMSF; // nibbles: hhmmssff 20 | 21 | class SMPTETimeBase 22 | { 23 | public: 24 | static UInt32 CalculateSMPTECounterFromHMSFs(const SMPTETime& time); 25 | static void CalculateSMPTE_HMSFsFromCounter(SMPTETime& ioTime, bool inKeepTrackOfDaysAsExtraHours); 26 | }; 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/PublicUtility/CoreMediaAssistant/CMIO_CMA_Time.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_CMA_Time.h 3 | Abstract: Helper items for CMTime 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_CMA_Time_h__) 9 | #define __CMIO_CMA_Time_h__ 10 | 11 | // Public Utility 12 | #include "CMIODebugMacros.h" 13 | 14 | // CA Public Utility 15 | #include "CAException.h" 16 | 17 | // System Includes 18 | #include 19 | 20 | // System Includes 21 | 22 | namespace CMIO { namespace CMA 23 | { 24 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 25 | // Time 26 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 27 | class Time 28 | { 29 | public: 30 | static inline void ConformTimescale(CMTime& time, int32_t timescale) 31 | { 32 | if (time.timescale != timescale) 33 | time = CMTimeConvertScale(time, timescale, kCMTimeRoundingMethod_Default); 34 | } 35 | }; 36 | }} 37 | #endif 38 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/PublicUtility/CoreVideoAssistant/CMIO_CVA_Buffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_CVA_Buffer.h 3 | Abstract: C++ wrapper for CVBufferRef 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_CVA_Buffer_h__) 9 | #define __CMIO_CVA_Buffer_h__ 10 | 11 | // Public Utility 12 | #include "CMIODebugMacros.h" 13 | 14 | // CA Public Utility 15 | #include "CAException.h" 16 | 17 | // System Includes 18 | #include 19 | 20 | namespace CMIO { namespace CVA 21 | { 22 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 23 | // Buffer 24 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 25 | class Buffer 26 | { 27 | // Construction/Destruction 28 | public: 29 | Buffer(CVBufferRef ref = NULL, bool retain = false, bool release = true) : mRef(NULL) { Reset(ref, retain, release); } 30 | virtual ~Buffer() { Reset(); } 31 | void Reset(CVBufferRef ref = NULL, bool retain = false, bool release = true) { if (NULL != mRef and mRelease) CFRelease(mRef); if (retain and NULL != ref) CFRetain(ref); mRef = ref; mRelease = release; } 32 | Buffer& operator=(const Buffer& that) { if (this != &that) this->Reset(that.Get(), true, that.WillRelease()); return *this; } 33 | 34 | private: 35 | CVBufferRef mRef; 36 | bool mRelease; 37 | 38 | // Attributes 39 | public: 40 | bool IsValid() const { return mRef != NULL; } 41 | bool WillRelease() const { return mRelease; } 42 | void ShouldRelease(bool release) { mRelease = release; } 43 | 44 | // Value Access 45 | public: 46 | operator CVBufferRef() const { return mRef; } 47 | CVBufferRef Get() const { return mRef; } 48 | }; 49 | }} 50 | #endif 51 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/PublicUtility/CoreVideoAssistant/CMIO_CVA_Image_Buffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_CVA_Image_Buffer.h 3 | Abstract: C++ wrapper for CVImageBufferRef 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_CVA_Image_Buffer_h__) 9 | #define __CMIO_CVA_Image_Buffer_h__ 10 | 11 | // Super Class Include 12 | #include "CMIO_CVA_Buffer.h" 13 | 14 | // System Includes 15 | #include 16 | 17 | namespace CMIO { namespace CVA { namespace Image 18 | { 19 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 20 | // Buffer 21 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 22 | class Buffer : public CVA::Buffer 23 | { 24 | // Construction/Destruction 25 | public: 26 | Buffer(CVImageBufferRef ref = NULL, bool retain = false, bool release = true) : CVA::Buffer(ref, retain, release) {} 27 | virtual ~Buffer() { Reset(); } 28 | Buffer& operator=(const Buffer& that) { if (this != &that) this->Reset(that.Get(), true, that.WillRelease()); return *this; } 29 | 30 | // Value Access 31 | public: 32 | operator CVImageBufferRef() const { return CVA::Buffer::Get(); } 33 | CVImageBufferRef Get() const { return CVA::Buffer::Get(); } 34 | }; 35 | }}} 36 | #endif 37 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/PublicUtility/DALAssistant/CMIO_DALA_System.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_DALA_System.h 3 | Abstract: C++ wrapper for the kCMIOObjectSystemObject 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_DALA_System_h__) 9 | #define __CMIO_DALA_System_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | // System Includes 16 | #include 17 | #include 18 | 19 | namespace CMIO { namespace DALA 20 | { 21 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 22 | // System 23 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 24 | class System 25 | { 26 | // Operations 27 | public: 28 | static bool IsInitingOrExiting(); 29 | static UInt32 GetNumberDevices(); 30 | static void GetDevices(UInt32& ioNumberDevices, CMIODeviceID* devices); 31 | static CMIODeviceID GetDeviceAtIndex(UInt32 index); 32 | static UInt32 GetIndexForDevice(const CMIODeviceID device); 33 | static CMIODeviceID GetDeviceForUID(CFStringRef uid); 34 | 35 | static CMIODeviceID GetDefaultDevice(CMIOObjectPropertyScope scope); 36 | static void SetDefaultDevice(CMIOObjectPropertyScope scope, CMIODeviceID device); 37 | 38 | static bool AllowsIdleSleepDuringIO(); 39 | static void SetAllowsIdleSleepDuringIO(bool allowIdleSleep); 40 | 41 | static bool IsMaster(); 42 | 43 | // Property Operations 44 | public: 45 | static bool HasProperty(const CMIOObjectPropertyAddress& address); 46 | static bool IsPropertySettable(const CMIOObjectPropertyAddress& address); 47 | 48 | static UInt32 GetPropertyDataSize(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData); 49 | static void GetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, UInt32& dataUsed, void* data); 50 | static void SetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, const void* data); 51 | 52 | static void AddPropertyListener(const CMIOObjectPropertyAddress& address, CMIOObjectPropertyListenerProc listenerProc, void* clientData); 53 | static void RemovePropertyListener(const CMIOObjectPropertyAddress& address, CMIOObjectPropertyListenerProc listenerProc, void* clientData); 54 | }; 55 | }} 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/PublicUtility/IOKitAssistant/CMIO_IOKA_Object.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_IOKA_Object.h 3 | Abstract: The IOKit Assisistant (IOKA) consists of various objects to facilitate using the "Acquisition is Initialization" design pattern. 4 | NOTE: the IOKA is sparsely implemented, meaning that it does not attempt to provide wrappers/access to all IOKit features, but just those needed in the CMIO namespace. 5 | 6 | Version: 1.2 7 | 8 | */ 9 | 10 | #if !defined(__CMIO_IOKA_Object_h__) 11 | #define __CMIO_IOKA_Object_h__ 12 | 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | // Includes 15 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 16 | 17 | // Public Utility Includes 18 | #include "CMIODebugMacros.h" 19 | 20 | // CA Public Utility Includes 21 | #include "CAException.h" 22 | 23 | // System Includes 24 | #include 25 | 26 | namespace CMIO { namespace IOKA 27 | { 28 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 29 | // Object 30 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 31 | class Object 32 | { 33 | // Construction/Destruction 34 | public: 35 | Object(const Object& object) : mReference(IO_OBJECT_NULL) { Reset(object); } 36 | explicit Object(io_object_t reference = IO_OBJECT_NULL) : mReference(IO_OBJECT_NULL) { Reset(reference); } 37 | ~Object() { if (IO_OBJECT_NULL != mReference) (void) IOObjectRelease(mReference); } 38 | Object& operator=(const Object& that) { if (this != &that) this->Reset(that); return *this; } 39 | 40 | void Reset(io_object_t reference = IO_OBJECT_NULL) { if (IO_OBJECT_NULL != mReference) (void) IOObjectRelease(mReference); mReference = reference; } 41 | void Reset(const Object& object) 42 | { 43 | if (IO_OBJECT_NULL != mReference) 44 | { 45 | (void) IOObjectRelease(mReference); 46 | mReference = IO_OBJECT_NULL; 47 | } 48 | 49 | if (IO_OBJECT_NULL != object.Get()) 50 | { 51 | IOReturn ioReturn = IOObjectRetain(object.Get()); 52 | ThrowIfError(ioReturn, CAException(ioReturn), "CMIO::IOKA::Object::Reset: IOObjectRetain() failed"); 53 | mReference = object.Get(); 54 | } 55 | } 56 | 57 | private: 58 | io_object_t mReference; 59 | 60 | // Attributes 61 | public: 62 | bool IsValid() const { return IO_OBJECT_NULL != mReference; } 63 | bool ConformsTo(const io_name_t className) { return IOObjectConformsTo(mReference, className); } 64 | 65 | // Value Access 66 | public: 67 | operator io_object_t() const { return mReference; } 68 | io_object_t Get() const { return mReference; } 69 | io_object_t* GetAddress() { return &mReference; } 70 | }; 71 | 72 | }} 73 | #endif 74 | 75 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/PublicUtility/IOKitAssistant/CMIO_IOKA_VirtualRange.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_IOKA_VirtualRange.h 3 | Abstract: CMIO::IOKA::VirtualRange extends the wraps IOVirualRange structure to C++ provide constructors. 4 | Version: 1.2 5 | 6 | */ 7 | 8 | /* 9 | File: CMIO_IOKA_VirtualRange.h 10 | 11 | Contains: CMIO::IOKA::VirtualRange extends the wraps IOVirualRange structure to C++ provide constructors. 12 | 13 | $Log$ 14 | */ 15 | 16 | #if !defined(__CMIO_IOKA_VirtualRange_h__) 17 | #define __CMIO_IOKA_VirtualRange_h__ 18 | 19 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 20 | // Includes 21 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 22 | 23 | // System Includes 24 | #include 25 | 26 | namespace CMIO { namespace IOKA 27 | { 28 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 29 | // VirtualRange 30 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 31 | struct VirtualRange : public IOVirtualRange 32 | { 33 | // Construction/Destruction 34 | public: 35 | VirtualRange() : IOVirtualRange() { address = IO_OBJECT_NULL; length = 0; } 36 | VirtualRange(IOVirtualAddress virtualAddress, IOByteCount byteCount) : IOVirtualRange() { address = virtualAddress; length = byteCount; } 37 | }; 38 | 39 | }} 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/PublicUtility/IOStreamAssistant/CMIO_IOSA_Assistance.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_IOSA_Assistance.cpp 3 | Abstract: The IOStream Assisistant (IOSA) consists of various objects to facilitate using the "Acquisition is Initialization" design pattern. 4 | NOTE: the IOSA is sparsely implemented, meaning that it does not attempt to provide wrappers/access to all IOStream features, but just those needed by the IOStream plugin. 5 | 6 | Version: 1.2 7 | 8 | */ 9 | 10 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 11 | // Includes 12 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 13 | 14 | // Self Include 15 | #include "CMIO_IOSA_Assistance.h" 16 | 17 | namespace CMIO { namespace IOSA 18 | { 19 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 20 | // AllocatePlugIn() 21 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 22 | IOCFPlugInInterface** AllocatePlugIn(io_service_t service) 23 | { 24 | IOCFPlugInInterface** plugIn; 25 | SInt32 score; 26 | 27 | IOReturn ioReturn = IOCreatePlugInInterfaceForService(service, kIOStreamLibTypeID, kIOCFPlugInInterfaceID, &plugIn, &score); 28 | ThrowIfKernelError(ioReturn, CAException(ioReturn), "CMIO::IOSA::AllocatePlugIn() failed"); 29 | 30 | return plugIn; 31 | } 32 | 33 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 34 | // AllocateStream() 35 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 36 | IOStreamRef AllocateStream(IOCFPlugInInterface** plugIn) 37 | { 38 | IOStreamRef stream; 39 | HRESULT hResult = (**plugIn).QueryInterface(plugIn, CFUUIDGetUUIDBytes(kIOStreamInterfaceID), reinterpret_cast(&stream)); 40 | ThrowIfError(hResult, CAException(hResult), "CMIO::IOSA::AllocateStream() failed"); 41 | 42 | return stream; 43 | } 44 | }} 45 | 46 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/PublicUtility/IOSurfaceAssistant/CMIO_SA_Assistance.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_SA_Assistance.cpp 3 | Abstract: The IOSurface Assisistant (SA) consists of various objects to facilitate using the "Acquisition is Initialization" design pattern. 4 | NOTE: the SA is sparsely implemented, meaning that it does not attempt to provide wrappers/access to all IOSurface features, just those needed. 5 | 6 | Version: 1.2 7 | 8 | */ 9 | 10 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 11 | // Includes 12 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 13 | 14 | // Self Include 15 | #include "CMIO_SA_Assistance.h" 16 | 17 | namespace CMIO { namespace SA 18 | { 19 | }} 20 | 21 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/PublicUtility/IOVideoAssistant/CMIO_IOVA_Assistance.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_IOVA_Assistance.cpp 3 | Abstract: The IOVideo Assisistant (IOVA) consists of various objects to facilitate using the "Acquisition is Initialization" design pattern. 4 | NOTE: much of the IOVA is sparsely implemented, meaning that it does not attempt to provide wrappers/access to all IOVideo features, but just those needed by the IOVideo 5 | plugin. 6 | 7 | Version: 1.2 8 | 9 | */ 10 | 11 | // Self Include 12 | #include "CMIO_IOVA_Assistance.h" 13 | 14 | namespace CMIO { namespace IOVA 15 | { 16 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 17 | // AllocatePlugIn() 18 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 19 | IOCFPlugInInterface** AllocatePlugIn(io_service_t service) 20 | { 21 | IOCFPlugInInterface** plugIn; 22 | SInt32 score; 23 | 24 | IOReturn ioReturn = IOCreatePlugInInterfaceForService(service, kIOVideoDeviceLibTypeID, kIOCFPlugInInterfaceID, &plugIn, &score); 25 | ThrowIfKernelError(ioReturn, CAException(ioReturn), "CMIO::IOVA::AllocatePlugIn() failed"); 26 | 27 | return plugIn; 28 | } 29 | 30 | //-------------------------------------------------------------------------------------------------------------------- 31 | // AllocateDevice() 32 | //-------------------------------------------------------------------------------------------------------------------- 33 | IOVideoDeviceRef AllocateDevice(IOCFPlugInInterface** plugIn) 34 | { 35 | IOVideoDeviceRef device; 36 | HRESULT hResult = (**plugIn).QueryInterface(plugIn, CFUUIDGetUUIDBytes(kIOVideoDeviceInterfaceID), reinterpret_cast(&device)); 37 | ThrowIfError(hResult, CAException(hResult), "CMIO::IOVideoDevice::AllocateDevice() failed"); 38 | 39 | return device; 40 | } 41 | 42 | }} 43 | 44 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/PublicUtility/POSIXThreadAssistant/CMIO_PTA_CFMachPortThread.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_PTA_CFMachPortThread.h 3 | Abstract: A thread for getting messages on a Mach port (using the CACFMachPort wrappers) 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_PTA_CFMachPortThread_h__) 9 | #define __CMIO_PTA_CFMachPortThread_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | // Public Utility Includes 16 | #include "CMIO_PTA_Assistance.h" 17 | 18 | // CA Public Utility Includes 19 | #include "CACFObject.h" 20 | 21 | // System Includes 22 | #include 23 | 24 | namespace CMIO { namespace PTA 25 | { 26 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 27 | // CFMachPortThread 28 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 29 | class CFMachPortThread 30 | { 31 | // Thread State 32 | public: 33 | enum State { kInvalid, kStarting, kRunning, kStopping}; 34 | 35 | // Construction/Destruction 36 | public: 37 | CFMachPortThread(CFMachPortCallBack portCallBack = 0, void* userData = 0) : mPort(MACH_PORT_NULL), mPortCallBack(0), mUserData(0), mPThread(0), mRunLoop(0), mState(kInvalid), mStoppingMutex(PTHREAD_MUTEX_RECURSIVE), mStoppingCondition() { Reset(portCallBack, userData); } 38 | ~CFMachPortThread() { Reset(); } 39 | void Reset(CFMachPortCallBack portCallBack = 0, void* userData = 0); 40 | 41 | private: 42 | mach_port_t mPort; 43 | CFMachPortCallBack mPortCallBack; 44 | void* mUserData; 45 | pthread_t mPThread; 46 | CACFObject mRunLoop; 47 | volatile State mState; 48 | Mutex mStoppingMutex; // Used for waiting on mStoppingCondition 49 | Mutex::Condition mStoppingCondition; // Allows for explict control of thread completion 50 | 51 | CFMachPortThread& operator=(CFMachPortThread& rhs); // Don't allow copying 52 | 53 | // Value Access 54 | public: 55 | operator pthread_t() const { return mPThread; } 56 | operator CFRunLoopRef() const { return mRunLoop.GetCFObject(); } 57 | pthread_t GetPThread() const { return mPThread; } 58 | CFRunLoopRef GetRunLoop() const { return mRunLoop.GetCFObject(); } 59 | State GetState() const { return mState; } 60 | mach_port_t GetMachPort() const { return mPort; } 61 | 62 | // Implemenation 63 | private: 64 | static void* Start(CFMachPortThread* thread); 65 | }; 66 | }} 67 | 68 | #endif 69 | 70 | -------------------------------------------------------------------------------- /Sources/Extras/CoreMediaIO/PublicUtility/POSIXThreadAssistant/CMIO_PTA_NotificationPortThread.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CMIO_PTA_NotificationPortThread.h 3 | Abstract: A thread for getting messages on a IOKit Notifcation port (using the CMIO::IOKA::NotificationPort wrappers) 4 | Version: 1.2 5 | 6 | */ 7 | 8 | #if !defined(__CMIO_PTA_NotificationPortThread_h__) 9 | #define __CMIO_PTA_NotificationPortThread_h__ 10 | 11 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Includes 13 | //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 | 15 | // Public Utility Includes 16 | #include "CMIO_IOKA_NotificationPort.h" 17 | #include "CMIO_PTA_Assistance.h" 18 | 19 | // CA Public Utility Includes 20 | #include "CACFObject.h" 21 | 22 | namespace CMIO { namespace PTA 23 | { 24 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 25 | // NotificationPortThread 26 | //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 27 | class NotificationPortThread 28 | { 29 | // Thread State 30 | public: 31 | enum State { kInvalid, kStarting, kRunning, kStopping}; 32 | 33 | // Construction/Destruction 34 | public: 35 | NotificationPortThread(bool spawn = false) : mNotificationPort(NULL), mPThread(NULL), mRunLoop(NULL), mState(kInvalid), mStoppingMutex(PTHREAD_MUTEX_RECURSIVE), mStoppingCondition() { Reset(spawn); } 36 | ~NotificationPortThread() { Reset(); } 37 | void Reset(bool spawn = false); 38 | 39 | private: 40 | IOKA::NotificationPort mNotificationPort; 41 | pthread_t mPThread; 42 | CACFObject mRunLoop; 43 | volatile State mState; 44 | Mutex mStoppingMutex; // Used for waiting on mStoppingCondition 45 | Mutex::Condition mStoppingCondition; // Allows for explict control of thread completion 46 | 47 | NotificationPortThread& operator=(NotificationPortThread& rhs); // Don't allow copying 48 | 49 | // Value Access 50 | public: 51 | operator pthread_t() const { return mPThread; } 52 | operator CFRunLoopRef() const { return mRunLoop.GetCFObject(); } 53 | pthread_t GetPThread() const { return mPThread; } 54 | CFRunLoopRef GetRunLoop() const { return mRunLoop.GetCFObject(); } 55 | State GetState() const { return mState; } 56 | IONotificationPortRef GetNotificationPort() const { return mNotificationPort; } 57 | 58 | // Implemenation 59 | private: 60 | static void* Start(NotificationPortThread* thread); 61 | }; 62 | }} 63 | 64 | #endif 65 | 66 | --------------------------------------------------------------------------------