本文整理汇总了C++中ThrowIfError函数的典型用法代码示例。如果您正苦于以下问题:C++ ThrowIfError函数的具体用法?C++ ThrowIfError怎么用?C++ ThrowIfError使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ThrowIfError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ThrowIfError
void CMPEG1Stream::Pause()
{
ThrowIfError(CheckShutdown());
m_state = STATE_PAUSED;
ThrowIfError(QueueEvent(MEStreamPaused, GUID_NULL, S_OK, nullptr));
}
示例2: 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;
}
示例3: 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;
};
}
示例4: FSGetCatalogInfo
void HLFileSystemObject::SetCreator(UInt32 inCreator)
{
// get the current Finder info from the catalog
FSCatalogInfo theInfo;
OSStatus theError = FSGetCatalogInfo(&mFSRef, kFSCatInfoFinderInfo, &theInfo, NULL, NULL, NULL);
ThrowIfError(theError, CAException(theError), "HLFileSystemObject::SetType: couldn't get the catalog information");
// update just the creator
FInfo* theFinderInfo = reinterpret_cast<FInfo*>(&theInfo.finderInfo);
theFinderInfo->fdCreator = inCreator;
// write it back out
theError = FSSetCatalogInfo(&mFSRef, kFSCatInfoFinderInfo, &theInfo);
ThrowIfError(theError, CAException(theError), "HLFileSystemObject::SetType: couldn't set the catalog information");
}
示例5: ThrowIf
void HLAudioFile::WriteAudioBytes(SInt64 inOffset, UInt32& ioNumberBytes, void* inData, bool inCache)
{
ThrowIf(mAudioFileID == 0, CAException(fnOpnErr), "HLAudioFile::WriteAudioBytes: file isn't prepared");
OSStatus theError = AudioFileWriteBytes(mAudioFileID, inCache, inOffset, &ioNumberBytes, inData);
ThrowIfError(theError, CAException(theError), "HLAudioFile::WriteAudioBytes: couldn't write the data");
}
示例6: AudioHardwareGetPropertyInfo
bool CAAudioHardwareSystem::PropertyIsSettable(AudioHardwarePropertyID inPropertyID)
{
Boolean isWritable = false;
OSStatus theError = AudioHardwareGetPropertyInfo(inPropertyID, NULL, &isWritable);
ThrowIfError(theError, CAException(theError), "CAAudioHardwareSystem::PropertyIsSettable: got an error getting info about a property");
return isWritable != 0;
}
示例7: ThrowIfError
bool
DeviceInstance::GetPropertyReadOnly(const char* name) const
{
bool readOnly;
ThrowIfError(pImpl_->GetPropertyReadOnly(name, readOnly));
return readOnly;
}
示例8: CMIOStreamCopyBufferQueue
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// CopyBufferQueue()
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CMSimpleQueueRef Stream::CopyBufferQueue(CMIODeviceStreamQueueAlteredProc queueAlteredProc, void* queueAlteredRefCon) const
{
CMSimpleQueueRef queue = NULL;
OSStatus err = CMIOStreamCopyBufferQueue(GetObjectID(), queueAlteredProc, queueAlteredRefCon, &queue);
ThrowIfError(err, CAException(err), "CMIO::DALA::Stream::CopyBufferQueue: CMIOStreamCopyBufferQueue() failed");
return queue;
}
示例9: FSGetCatalogInfo
bool HLDirectoryFactory::ObjectIsA(const FSRef& inFSRef) const
{
FSCatalogInfo theCatalogInfo;
OSStatus theError = FSGetCatalogInfo(&inFSRef, kFSCatInfoNodeFlags, &theCatalogInfo, NULL, NULL, NULL);
ThrowIfError(theError, CAException(theError), "HLDirectoryFactory::ObjectIsA: couldn't get the catalog info");
return (theCatalogInfo.nodeFlags & kFSNodeIsDirectoryMask) != 0;
}
示例10: AudioStreamGetPropertyInfo
bool CAAudioHardwareStream::PropertyIsSettable(UInt32 inChannel, AudioHardwarePropertyID inPropertyID) const
{
Boolean isWritable = false;
OSStatus theError = AudioStreamGetPropertyInfo(GetAudioStreamID(), inChannel, inPropertyID, NULL, &isWritable);
ThrowIfError(theError, CAException(theError), "CAAudioHardwareStream::PropertyIsSettable: got an error getting info about a property");
return isWritable != 0;
}
示例11: AudioObjectIsPropertySettable
bool CAHALAudioObject::IsPropertySettable(AudioObjectPropertyAddress& inAddress) const
{
Boolean isSettable = false;
OSStatus theError = AudioObjectIsPropertySettable(mObjectID, &inAddress, &isSettable);
ThrowIfError(theError, CAException(theError), "CAHALAudioObject::IsPropertySettable: got an error getting info about a property");
return isSettable != 0;
}
示例12: AudioObjectGetPropertyDataSize
UInt32 CAHALAudioObject::GetPropertyDataSize(AudioObjectPropertyAddress& inAddress, UInt32 inQualifierDataSize, const void* inQualifierData) const
{
UInt32 theDataSize = 0;
OSStatus theError = AudioObjectGetPropertyDataSize(mObjectID, &inAddress, inQualifierDataSize, inQualifierData, &theDataSize);
ThrowIfError(theError, CAException(theError), "CAHALAudioObject::GetPropertyDataSize: got an error getting the property data size");
return theDataSize;
}
示例13: AudioDeviceCreateIOProcIDWithBlock
//#if defined(__BLOCKS__) && (__MAC_OS_X_VERSION_MAX_ALLOWED > __MAC_10_6)
AudioDeviceIOProcID CAHALAudioDevice::CreateIOProcIDWithBlock(dispatch_queue_t inDispatchQueue, AudioDeviceIOBlock inIOBlock)
{
AudioDeviceIOProcID theAnswer = NULL;
OSStatus theError = AudioDeviceCreateIOProcIDWithBlock(&theAnswer, mObjectID, inDispatchQueue, inIOBlock);
ThrowIfError(theError, CAException(theError), "CAHALAudioDevice::CreateIOProcIDWithBlock: got an error creating the IOProc ID");
return theAnswer;
}
示例14: AudioFileClose
void HLAudioFile::Close()
{
if(mOpenCount > 0)
{
// only close the file if it is open
// decrement the open count
--mOpenCount;
if(mOpenCount == 0)
{
// no one wants the file open, so really close it
OSStatus theError = 0;
if(mAudioFileID != 0)
{
theError = AudioFileClose(mAudioFileID);
mAudioFileID = 0;
}
// clear the permissions
mOpenForReading = false;
mOpenForWriting = false;
// check for errors
ThrowIfError(theError, CAException(theError), "HLAudioFile::Close: couldn't close the fork");
}
}
}
示例15: 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;
}