当前位置: 首页>>代码示例>>C++>>正文


C++ ThrowIfError函数代码示例

本文整理汇总了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));
}
开发者ID:badreddine-dlaila,项目名称:Windows-8.1-Universal-App,代码行数:8,代码来源:MPEG1Stream.cpp

示例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;
}
开发者ID:fruitsamples,项目名称:AudioCodecs,代码行数:58,代码来源:SMACIMAsdec.cpp

示例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;
    };
}
开发者ID:MaddTheSane,项目名称:a52codec,代码行数:57,代码来源:SMACscom.cpp

示例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");
}
开发者ID:fruitsamples,项目名称:HAL,代码行数:15,代码来源:HLFileSystemObject.cpp

示例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");
}
开发者ID:fruitsamples,项目名称:HAL,代码行数:7,代码来源:HLAudioFile.cpp

示例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;
}
开发者ID:BitMax,项目名称:openitg,代码行数:7,代码来源:CAAudioHardwareSystem.cpp

示例7: ThrowIfError

bool
DeviceInstance::GetPropertyReadOnly(const char* name) const
{
   bool readOnly;
   ThrowIfError(pImpl_->GetPropertyReadOnly(name, readOnly));
   return readOnly;
}
开发者ID:PI-SRau,项目名称:micro-manager,代码行数:7,代码来源:DeviceInstance.cpp

示例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;
	}
开发者ID:AdamDiment,项目名称:CocoaSampleCode,代码行数:10,代码来源:CMIO_DALA_Stream.cpp

示例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;
}
开发者ID:fruitsamples,项目名称:HAL,代码行数:7,代码来源:HLDirectory.cpp

示例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;
}
开发者ID:NikolaiUgelvik,项目名称:sooperlooper,代码行数:7,代码来源:CAAudioHardwareStream.cpp

示例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;
}
开发者ID:NikolaiUgelvik,项目名称:sooperlooper,代码行数:7,代码来源:CAHALAudioObject.cpp

示例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;
}
开发者ID:NikolaiUgelvik,项目名称:sooperlooper,代码行数:7,代码来源:CAHALAudioObject.cpp

示例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;
}
开发者ID:Michael-Lfx,项目名称:iOS,代码行数:8,代码来源:CAHALAudioDevice.cpp

示例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");
		}
	}
}
开发者ID:fruitsamples,项目名称:HAL,代码行数:28,代码来源:HLAudioFile.cpp

示例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;
}
开发者ID:fruitsamples,项目名称:HAL,代码行数:33,代码来源:HLAudioFile.cpp


注:本文中的ThrowIfError函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。