本文整理汇总了C++中ThrowIf函数的典型用法代码示例。如果您正苦于以下问题:C++ ThrowIf函数的具体用法?C++ ThrowIf怎么用?C++ ThrowIf使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ThrowIf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clCreateKernelsInProgram
CLWProgram::CLWProgram(cl_program program)
: ReferenceCounter<cl_program, clRetainProgram, clReleaseProgram>(program)
{
cl_int status = CL_SUCCESS;
cl_uint numKernels;
status = clCreateKernelsInProgram(*this, 0, nullptr, &numKernels);
ThrowIf(numKernels == 0, CL_BUILD_ERROR, "clCreateKernelsInProgram return 0 kernels");
ThrowIf(status != CL_SUCCESS, status, "clCreateKernelsInProgram failed");
std::vector<cl_kernel> kernels(numKernels);
status = clCreateKernelsInProgram(*this, numKernels, &kernels[0], nullptr);
ThrowIf(status != CL_SUCCESS, status, "clCreateKernelsInProgram failed");
std::for_each(kernels.begin(), kernels.end(), [this](cl_kernel k)
{
size_t size = 0;
cl_int res;
res = clGetKernelInfo(k, CL_KERNEL_FUNCTION_NAME, 0, nullptr, &size);
ThrowIf(res != CL_SUCCESS, res, "clGetKernelInfo failed");
std::vector<char> temp(size);
res = clGetKernelInfo(k, CL_KERNEL_FUNCTION_NAME, size, &temp[0], nullptr);
ThrowIf(res != CL_SUCCESS, res, "clGetKernelInfo failed");
std::string funcName(temp.begin(), temp.end()-1);
kernels_[funcName] = CLWKernel::Create(k);
});
}
示例2: AudioFileOpen
void HLAudioFile::Open(bool inForReading, bool inForWriting)
{
if(mOpenCount == 0)
{
// only actully open the file the first time
// save off the permissions
mOpenForReading = inForReading;
mOpenForWriting = inForWriting;
// open the file
SInt8 thePermissions = 0;
if(mOpenForReading)
{
thePermissions += fsRdPerm;
}
if(mOpenForWriting)
{
thePermissions += fsWrPerm;
}
OSStatus theError = AudioFileOpen(&mFSRef, thePermissions, 0, &mAudioFileID);
ThrowIfError(theError, CAException(theError), "HLAudioFile::Open: couldn't open the file");
}
else
{
// file is already open, so it's an error if someone tries to add permissions
ThrowIf((mOpenForReading && !mOpenForWriting) && inForWriting, CAException(fBsyErr), "HLAudioFile::Open: can't add write permissions");
ThrowIf((!mOpenForReading && mOpenForWriting) && inForReading, CAException(fBsyErr), "HLAudioFile::Open: can't add read permissions");
}
// increment the open count
++mOpenCount;
}
示例3: ThrowIf
void HP_Object::SetPropertyData(const AudioObjectPropertyAddress& inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, const void* inData, const AudioTimeStamp* inWhen)
{
ThrowIf(!IsPropertySettable(inAddress), CAException(kAudioHardwareIllegalOperationError), "HP_Object::SetPropertyData: address isn't settable");
switch(inAddress.mSelector)
{
case kAudioObjectPropertyListenerAdded:
ThrowIf(inDataSize != sizeof(AudioObjectPropertyAddress), CAException(kAudioHardwareBadPropertySizeError), "IOA_Device::SetPropertyData: wrong data size for kAudioObjectPropertyListenerAdded");
PropertyListenerAdded(*(static_cast<const AudioObjectPropertyAddress*>(inData)));
break;
case kAudioObjectPropertyListenerRemoved:
ThrowIf(inDataSize != sizeof(AudioObjectPropertyAddress), CAException(kAudioHardwareBadPropertySizeError), "IOA_Device::SetPropertyData: wrong data size for kAudioObjectPropertyListenerRemoved");
PropertyListenerRemoved(*(static_cast<const AudioObjectPropertyAddress*>(inData)));
break;
default:
{
HP_Property* theProperty = FindActivePropertyByAddress(inAddress);
if(theProperty != NULL)
{
theProperty->SetPropertyData(inAddress, inQualifierDataSize, inQualifierData, inDataSize, inData, inWhen);
}
else
{
DebugMessage("HP_Object::SetPropertyData: unknown property");
Throw(CAException(kAudioHardwareUnknownPropertyError));
}
}
break;
};
}
示例4: switch
void SelectorControl::GetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, UInt32& dataUsed, void* data) const
{
switch (address.mSelector)
{
case kCMIOSelectorControlPropertyCurrentItem:
ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::SelectorControl::GetPropertyData: wrong data size for kCMIOSelectorControlPropertyCurrentItem");
*static_cast<UInt32*>(data) = GetCurrentItemID();
dataUsed = sizeof(UInt32);
break;
case kCMIOSelectorControlPropertyAvailableItems:
{
UInt32 numberItemsToGet = std::min((UInt32)(dataSize / sizeof(UInt32)), GetNumberItems());
UInt32* itemIDs = static_cast<UInt32*>(data);
for(UInt32 index = 0; index < numberItemsToGet; ++index)
{
itemIDs[index] = GetItemIDForIndex(index);
}
dataUsed = numberItemsToGet * sizeof(UInt32);
}
break;
case kCMIOSelectorControlPropertyItemName:
ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::SelectorControl::GetPropertyData: wrong data size for kCMIOSelectorControlPropertyItemName");
ThrowIf(qualifierDataSize != sizeof(UInt32), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::SelectorControl::GetPropertyData: wrong qualifier size for kCMIOSelectorControlPropertyItemName");
*static_cast<CFStringRef*>(data) = CopyItemNameByID(*static_cast<const UInt32*>(qualifierData));
dataUsed = sizeof(CFStringRef);
break;
default:
Control::GetPropertyData(address, qualifierDataSize, qualifierData, dataSize, dataUsed, data);
break;
};
}
示例5: switch
void HP_PreferredChannels::GetPropertyData(const AudioObjectPropertyAddress& inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32& ioDataSize, void* outData) const
{
bool isInput = inAddress.mScope == kAudioDevicePropertyScopeInput;
switch(inAddress.mSelector)
{
case kAudioDevicePropertyPreferredChannelsForStereo:
{
ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_PreferredChannels::GetPropertyData: wrong data size for kAudioDevicePropertyPreferredChannelsForStereo");
UInt32* theStereoChannels = static_cast<UInt32*>(outData);
// initialize the output
theStereoChannels[0] = 1;
theStereoChannels[1] = 2;
// get the preference
CACFArray thePrefStereoChannels(isInput ? mPreferredInputStereoChannels : mPreferredOutputStereoChannels, false);
if(thePrefStereoChannels.IsValid())
{
// get the values from the array
thePrefStereoChannels.GetUInt32(0, theStereoChannels[0]);
thePrefStereoChannels.GetUInt32(1, theStereoChannels[1]);
}
if (!isInput)
{
// update the cached value if necessary
memcpy(const_cast<HP_PreferredChannels*>(this)->mOutputStereoPair, theStereoChannels, sizeof(UInt32)*2);
}
}
break;
case kAudioDevicePropertyPreferredChannelLayout:
{
ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_PreferredChannels::GetPropertyData: wrong data size for kAudioDevicePropertyPreferredChannelLayout");
AudioChannelLayout* theChannelLayout = static_cast<AudioChannelLayout*>(outData);
// fetch the default layout from the device
mDevice->GetDefaultChannelLayout(isInput, *theChannelLayout);
// get the pref
CACFDictionary thePrefChannelLayout(isInput ? mPreferredInputChannelLayout : mPreferredOutputChannelLayout, false);
if(thePrefChannelLayout.IsValid())
{
HP_PreferredChannels_ConstructLayoutFromDictionary(thePrefChannelLayout, *theChannelLayout);
}
}
break;
case 'srdd':
{
ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_PreferredChannels::GetPropertyData: wrong data size for 'srdd'");
AudioChannelLayout* theChannelLayout = static_cast<AudioChannelLayout*>(outData);
// fetch the default layout from the device
mDevice->GetDefaultChannelLayout(isInput, *theChannelLayout);
}
break;
};
}
示例6: OpenComponent
ComponentInstance SMACIMAsdec::InitializeIMAAudioDecoder(Component inDecoderComponent, const AudioStreamBasicDescription& inFormat)
{
UInt32 theSize;
ComponentInstance theDecoder = OpenComponent(inDecoderComponent);
ThrowIf(theDecoder == NULL, badComponentInstance, "SMACIMAsdec::InitializeIMAAudioDecoder: couldn't open the component");
// first, give the decoder the info we have
theSize = sizeof(AudioStreamBasicDescription);
ComponentResult theError = AudioCodecSetProperty(theDecoder, kAudioCodecPropertyCurrentInputFormat, theSize, &inFormat);
ThrowIfError(theError, (CAException)theError, "SMACIMAsdec::InitializeIMAAudioDecoder: got an error setting the input format");
// now find out what it can output
theError = AudioCodecGetPropertyInfo(theDecoder, kAudioCodecPropertySupportedOutputFormats, &theSize, NULL);
ThrowIfError(theError, (CAException)theError, "SMACIMAsdec::InitializeIMAAudioDecoder: got an error getting the available output format list size");
UInt32 theNumberAvailableOutputFormats = theSize / sizeof(AudioStreamBasicDescription);
AudioStreamBasicDescription* theAvailableOutputFormats = new AudioStreamBasicDescription[theNumberAvailableOutputFormats];
try
{
theSize = theNumberAvailableOutputFormats * sizeof(AudioStreamBasicDescription);
theError = AudioCodecGetProperty(theDecoder, kAudioCodecPropertySupportedOutputFormats, &theSize, theAvailableOutputFormats);
ThrowIfError(theError, (CAException)theError, "SMACIMAsdec::InitializeIMAAudioDecoder: got an error getting the available output formats");
// find an acceptable output format
AudioStreamBasicDescription* theOutputFormat = FindNEFloatFormat(theAvailableOutputFormats, theNumberAvailableOutputFormats);
ThrowIf(theOutputFormat == NULL, badFormat, "SMACIMAsdec::InitializeIMAAudioDecoder: couldn't find an acceptable output format");
// finish filling out the output format
theOutputFormat->mSampleRate = inFormat.mSampleRate;
theOutputFormat->mChannelsPerFrame = inFormat.mChannelsPerFrame;
theOutputFormat->mBytesPerFrame = 4 * inFormat.mChannelsPerFrame;
theOutputFormat->mFormatID = kAudioFormatLinearPCM;
theOutputFormat->mFormatFlags = kAudioFormatFlagsNativeFloatPacked;
theOutputFormat->mBytesPerPacket = 4 * inFormat.mChannelsPerFrame;
theOutputFormat->mFramesPerPacket = 1;
theOutputFormat->mBitsPerChannel = 32;
// tell the decoder about it
theSize = sizeof(AudioStreamBasicDescription);
theError = AudioCodecSetProperty(theDecoder, kAudioCodecPropertyCurrentOutputFormat, theSize, theOutputFormat);
ThrowIfError(theError, (CAException)theError, "SMACIMAsdec::InitializeIMAAudioDecoder: got an error setting the output format");
delete[] theAvailableOutputFormats;
theAvailableOutputFormats = NULL;
}
catch(...)
{
delete[] theAvailableOutputFormats;
throw;
}
// finally initialize the decoder
theError = AudioCodecInitialize(theDecoder, NULL, NULL, NULL, 0);
ThrowIfError(theError, (CAException)theError, "SMACIMAsdec::InitializeIMAAudioDecoder: got an error initializing the decoder");
return theDecoder;
}
示例7: switch
void BGM_PlugIn::GetPropertyData(AudioObjectID inObjectID, pid_t inClientPID, const AudioObjectPropertyAddress& inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, UInt32& outDataSize, void* outData) const
{
switch(inAddress.mSelector)
{
case kAudioObjectPropertyManufacturer:
// This is the human readable name of the maker of the plug-in.
ThrowIf(inDataSize < sizeof(CFStringRef), CAException(kAudioHardwareBadPropertySizeError), "BGM_PlugIn::GetPropertyData: not enough space for the return value of kAudioObjectPropertyManufacturer");
*reinterpret_cast<CFStringRef*>(outData) = CFSTR("Background Music contributors");
outDataSize = sizeof(CFStringRef);
break;
case kAudioObjectPropertyOwnedObjects:
case kAudioPlugInPropertyDeviceList:
{
// This plug-in object only owns the device
AudioObjectID* theReturnedDeviceList = reinterpret_cast<AudioObjectID*>(outData);
if(inDataSize >= sizeof(AudioObjectID))
{
theReturnedDeviceList[0] = kObjectID_Device;
// say how much we returned
outDataSize = sizeof(AudioObjectID);
}
else
{
outDataSize = 0;
}
}
break;
case kAudioPlugInPropertyTranslateUIDToDevice:
{
// This property translates the UID passed in the qualifier as a CFString into the
// AudioObjectID for the device the UID refers to or kAudioObjectUnknown if no device
// has the UID.
ThrowIf(inQualifierDataSize < sizeof(CFStringRef), CAException(kAudioHardwareBadPropertySizeError), "BGM_PlugIn::GetPropertyData: the qualifier size is too small for kAudioPlugInPropertyTranslateUIDToDevice");
ThrowIf(inDataSize < sizeof(AudioObjectID), CAException(kAudioHardwareBadPropertySizeError), "BGM_PlugIn::GetPropertyData: not enough space for the return value of kAudioPlugInPropertyTranslateUIDToDevice");
CFStringRef theUID = *reinterpret_cast<const CFStringRef*>(inQualifierData);
*reinterpret_cast<AudioObjectID*>(outData) =
CFEqual(theUID, BGM_Device::GetInstance().CopyDeviceUID()) ? kObjectID_Device : kAudioObjectUnknown;
outDataSize = sizeof(AudioObjectID);
}
break;
case kAudioPlugInPropertyResourceBundle:
// The resource bundle is a path relative to the path of the plug-in's bundle.
// To specify that the plug-in bundle itself should be used, we just return the
// empty string.
ThrowIf(inDataSize < sizeof(AudioObjectID), CAException(kAudioHardwareBadPropertySizeError), "BGM_GetPlugInPropertyData: not enough space for the return value of kAudioPlugInPropertyResourceBundle");
*reinterpret_cast<CFStringRef*>(outData) = CFSTR("");
outDataSize = sizeof(CFStringRef);
break;
default:
BGM_Object::GetPropertyData(inObjectID, inClientPID, inAddress, inQualifierDataSize, inQualifierData, inDataSize, outDataSize, outData);
break;
};
}
示例8: switch
void SMACscom::SetInfo(SoundSource inSourceID, OSType inSelector, void* inData)
{
switch(inSelector)
{
case siCompressionParams:
{
// process the the new params and produce an initialized
// AudioCodec instance
ComponentInstance theEncoder = SetCompressionParams(inData);
ThrowIf(theEncoder == NULL, badFormat, "SMACscom::SetInfo: siCompressionParams didn't generate an encoder");
// get rid of the input data
mSourceData = NULL;
mOutputData.desc.sampleCount = 0;
mOutputData.bufferSize = 0;
mOutputData.frameCount = 0;
mOutputData.commonFrameSize = 0;
// close the old encoder if necessary
if((mEncoder != NULL) && (theEncoder != mEncoder))
{
CloseComponent(mEncoder);
}
// use the new one
mEncoder = theEncoder;
// get the number of frames in 1 packet of data
UInt32 theSize = sizeof(UInt32);
ComponentResult theError = AudioCodecGetProperty(mEncoder, kAudioCodecPropertyPacketFrameSize, &theSize, &mPacketFrameSize);
ThrowIfError(theError, (CAException)theError, "SMACscom::SetInfo: siCompressionParams got an error from AudioCodecGetProperty while getting the packet frame size");
// get the maximum number of bytes in 1 packet of data
theSize = sizeof(UInt32);
theError = AudioCodecGetProperty(mEncoder, kAudioCodecPropertyMaximumPacketByteSize, &theSize, &mMaxPacketByteSize);
ThrowIfError(theError, (CAException)theError, "SMACscom::SetInfo: siCompressionParams got an error from AudioCodecGetProperty while getting the maximum packet byte size");
// toss the old output buffer
delete[] mOutputBuffer;
// allocate enough space for 1 packet of data, since that's
// that's all this component will produce per call to GetSourceData
mOutputBuffer = new Byte[mMaxPacketByteSize];
}
break;
case siSourceIsExhausted:
// in this case it seems to be passed by value -- ugh!
mSourceIsExhausted = (Boolean)((UInt32)inData);
// Now pass this on, so no break!
default:
ThrowIf(mSourceComponent == NULL, siUnknownInfoType, "SMACscom::SetInfo: no source to pass request to")
ComponentResult theError = SoundComponentSetInfo(mSourceComponent, inSourceID, inSelector, inData);
ThrowIfError(theError, (CAException)theError, "SMACscom::SetInfo: got an error from SoundComponentSetInfo");
break;
};
}
示例9: AppleCMIODPSampleNewPlugIn
void* AppleCMIODPSampleNewPlugIn(CFAllocatorRef allocator, CFUUIDRef requestedTypeUUID)
{
if (not CFEqual(requestedTypeUUID, kCMIOHardwarePlugInTypeID))
return 0;
try
{
// Before going any further, make sure the SampleAssistant process is registerred with Mach's bootstrap service. Normally, this would be done by having an appropriately
// configured plist in /Library/LaunchDaemons, but if that is done then the process will be owned by root, thus complicating the debugging process. Therefore, in the event that the
// plist is missing (as would be the case for most debugging efforts) attempt to register the SampleAssistant now. It will fail gracefully if allready registered.
mach_port_t assistantServicePort;
name_t assistantServiceName = "com.apple.cmio.DPA.Sample";
kern_return_t err = bootstrap_look_up(bootstrap_port, assistantServiceName, &assistantServicePort);
if (BOOTSTRAP_SUCCESS != err)
{
// Create an URL to SampleAssistant that resides at "/Library/CoreMediaIO/Plug-Ins/DAL/Sample.plugin/Contents/Resources/SampleAssistant"
CACFURL assistantURL(CFURLCreateWithFileSystemPath(NULL, CFSTR("/Library/CoreMediaIO/Plug-Ins/DAL/Sample.plugin/Contents/Resources/SampleAssistant"), kCFURLPOSIXPathStyle, false));
ThrowIf(not assistantURL.IsValid(), CAException(-1), "AppleCMIODPSampleNewPlugIn: unable to create URL for the SampleAssistant");
// Get the maximum size of the of the file system representation of the SampleAssistant's absolute path
CFIndex length = CFStringGetMaximumSizeOfFileSystemRepresentation(CACFString(CFURLCopyFileSystemPath(CACFURL(CFURLCopyAbsoluteURL(assistantURL.GetCFObject())).GetCFObject(), kCFURLPOSIXPathStyle)).GetCFString());
// Get the file system representation
CAAutoFree<char> path(length);
(void) CFURLGetFileSystemRepresentation(assistantURL.GetCFObject(), true, reinterpret_cast<UInt8*>(path.get()), length);
mach_port_t assistantServerPort;
err = bootstrap_create_server(bootstrap_port, path, getuid(), true, &assistantServerPort);
ThrowIf(BOOTSTRAP_SUCCESS != err, CAException(err), "AppleCMIODPSampleNewPlugIn: couldn't create server");
err = bootstrap_check_in(assistantServerPort, assistantServiceName, &assistantServicePort);
// The server port is no longer needed so get rid of it
(void) mach_port_deallocate(mach_task_self(), assistantServerPort);
// Make sure the call to bootstrap_create_service() succeeded
ThrowIf(BOOTSTRAP_SUCCESS != err, CAException(err), "AppleCMIODPSampleNewPlugIn: couldn't create SampleAssistant service port");
}
// The service port is not longer needed so get rid of it
(void) mach_port_deallocate(mach_task_self(), assistantServicePort);
CMIO::DP::Sample::PlugIn* plugIn = new CMIO::DP::Sample::PlugIn(requestedTypeUUID);
plugIn->Retain();
return plugIn->GetInterface();
}
catch (...)
{
return NULL;
}
}
示例10: theStateMutex
void HP_Stream::GetPropertyData(const AudioObjectPropertyAddress& inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32& ioDataSize, void* outData) const
{
// take and hold the state mutex
CAMutex::Locker theStateMutex(const_cast<HP_Device*>(mOwningDevice)->GetStateMutex());
switch(inAddress.mSelector)
{
case kAudioObjectPropertyName:
ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_Stream::GetPropertyData: wrong data size for kAudioObjectPropertyName");
*static_cast<CFStringRef*>(outData) = CopyStreamName();
break;
case kAudioObjectPropertyManufacturer:
ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_Stream::GetPropertyData: wrong data size for kAudioObjectPropertyName");
*static_cast<CFStringRef*>(outData) = CopyStreamManufacturerName();
break;
case kAudioObjectPropertyElementName:
ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_Stream::GetPropertyData: wrong data size for kAudioObjectPropertyElementName");
*static_cast<CFStringRef*>(outData) = CopyElementFullName(inAddress);
break;
case kAudioObjectPropertyElementCategoryName:
ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_Stream::GetPropertyData: wrong data size for kAudioObjectPropertyElementCategoryName");
*static_cast<CFStringRef*>(outData) = CopyElementCategoryName(inAddress);
break;
case kAudioObjectPropertyElementNumberName:
ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_Stream::GetPropertyData: wrong data size for kAudioObjectPropertyElementNumberName");
*static_cast<CFStringRef*>(outData) = CopyElementNumberName(inAddress);
break;
case kAudioStreamPropertyDirection:
ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_Stream::GetPropertyData: wrong data size for kAudioStreamPropertyDirection");
*static_cast<UInt32*>(outData) = IsInput() ? 1 : 0;
break;
case kAudioStreamPropertyTerminalType:
ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_Stream::GetPropertyData: wrong data size for kAudioStreamPropertyTerminalType");
*static_cast<UInt32*>(outData) = GetTerminalType();
break;
case kAudioStreamPropertyStartingChannel:
ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_Stream::GetPropertyData: wrong data size for kAudioStreamPropertyStartingChannel");
*static_cast<UInt32*>(outData) = GetStartingDeviceChannelNumber();
break;
case kAudioStreamPropertyLatency:
ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_Stream::GetPropertyData: wrong data size for kAudioStreamPropertyLatency");
*static_cast<UInt32*>(outData) = GetLatency();
break;
default:
HP_Object::GetPropertyData(inAddress, inQualifierDataSize, inQualifierData, ioDataSize, outData);
break;
};
}
示例11: FindIMAAudioDecoderComponent
// Normally, QuickTime will call this directly. In IMA it doesn't.
// The compression params are or contain the "MagicCookie" used by the codec
// When this is called we can initialize the codec as we will have all the necessary information
// to do so.
ComponentInstance SMACIMAsdec::SetDecompressionParams(const void* inData)
{
AudioStreamBasicDescription theInputFormat = {mSampleRate, kIMAAudioGeneralFormatID, 0, kIMA4BlockBytes, kIMA4BlockSamples, 0, mNumChannels, 0, 0 };
// use the format to locate a suitable decoder
Component theDecoderComponent = FindIMAAudioDecoderComponent(theInputFormat);
ThrowIf(theDecoderComponent == NULL, badFormat, "SMACIMAsdec::SetDecompressionParams: couldn't find a decoder");
ComponentInstance theDecoder = InitializeIMAAudioDecoder(theDecoderComponent, theInputFormat);
ThrowIf(theDecoder == NULL, badFormat, "SMACIMAsdec::SetDecompressionParams: couldn't initialize the decoder");
return theDecoder;
}
示例12: pthread_mutexattr_init
JackPosixMutex::JackPosixMutex(const char* name)
{
// Use recursive mutex
pthread_mutexattr_t mutex_attr;
int res;
res = pthread_mutexattr_init(&mutex_attr);
ThrowIf(res != 0, JackException("JackBasePosixMutex: could not init the mutex attribute"));
res = pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE);
ThrowIf(res != 0, JackException("JackBasePosixMutex: could not settype the mutex"));
res = pthread_mutex_init(&fMutex, &mutex_attr);
ThrowIf(res != 0, JackException("JackBasePosixMutex: could not init the mutex"));
pthread_mutexattr_destroy(&mutex_attr);
}
示例13: clGetEventProfilingInfo
float CLWEvent::GetDuration() const
{
cl_ulong commandStart, commandEnd;
cl_int status = CL_SUCCESS;
status = clGetEventProfilingInfo(*this, CL_PROFILING_COMMAND_START, sizeof(cl_ulong), &commandStart, nullptr);
ThrowIf(status != CL_SUCCESS, status, "clGetEventProfilingInfo failed");
status = clGetEventProfilingInfo(*this, CL_PROFILING_COMMAND_END, sizeof(cl_ulong), &commandEnd, nullptr);
ThrowIf(status != CL_SUCCESS, status, "clGetEventProfilingInfo failed");
return (float)(commandEnd - commandStart) / 1000000.f;
}
示例14: HP_HardwarePlugIn_DeviceCreateIOProcIDWithBlock
static OSStatus HP_HardwarePlugIn_DeviceCreateIOProcIDWithBlock(AudioHardwarePlugInRef inSelf, AudioDeviceIOProcID* outIOProcID, AudioDeviceID inDeviceID, dispatch_queue_t inDispatchQueue, AudioDeviceIOBlock inBlock)
{
OSStatus theError = kAudioHardwareNoError;
try
{
// check the function arguments
ThrowIfNULL(inSelf, CAException(kAudioHardwareIllegalOperationError), "HP_HardwarePlugIn_DeviceCreateIOProcIDWithBlock: no plug-in");
ThrowIf(inBlock == 0, CAException(kAudioHardwareIllegalOperationError), "HP_HardwarePlugIn_DeviceCreateIOProcIDWithBlock: no IOBlock to add");
ThrowIfNULL(outIOProcID, CAException(kAudioHardwareIllegalOperationError), "HP_HardwarePlugIn_DeviceCreateIOProcIDWithBlock: nowhere to put the return value");
// find the device for the given ID
HP_Device* theDevice = HP_Object::GetDeviceByID(inDeviceID);
ThrowIfNULL(theDevice, CAException(kAudioHardwareBadDeviceError), "HP_HardwarePlugIn_DeviceCreateIOProcIDWithBlock: no device with given ID");
// do the work
*outIOProcID = theDevice->Do_CreateIOProcIDWithBlock(inDispatchQueue, inBlock);
}
catch(const CAException& inException)
{
theError = inException.GetError();
}
catch(...)
{
theError = kAudioHardwareUnspecifiedError;
}
return theError;
}
示例15: ThrowIf
UInt32 ZKMORHP_SelectorControl::GetItemKindByID(UInt32 inItemID) const
{
SelectorMap::const_iterator theIterator = mSelectorMap.find(inItemID);
ThrowIf(theIterator == mSelectorMap.end(), CAException(kAudioHardwareIllegalOperationError), "ZKMORHP_SelectorControl::GetItemKindByID: ID not in selector map");
return theIterator->second.mItemKind;
}