本文整理汇总了C++中CODEC_THROW函数的典型用法代码示例。如果您正苦于以下问题:C++ CODEC_THROW函数的具体用法?C++ CODEC_THROW怎么用?C++ CODEC_THROW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CODEC_THROW函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CODEC_THROW
void ACFLACCodec::SetMagicCookie(const void* inMagicCookieData, UInt32 inMagicCookieDataByteSize)
{
if(mIsInitialized)
{
CODEC_THROW(kAudioCodecStateError);
}
if(inMagicCookieDataByteSize > 256) // the largest cookie we can store
{
CODEC_THROW(kAudioCodecBadPropertySizeError);
}
else // store the cookie
{
memcpy (mMagicCookie, (const void *)(inMagicCookieData), inMagicCookieDataByteSize);
mMagicCookieLength = inMagicCookieDataByteSize;
mCookieSet = 1;
}
ParseMagicCookie(inMagicCookieData, inMagicCookieDataByteSize, &mStreamInfo);
if (inMagicCookieDataByteSize > 0)
{
mCookieDefined = true;
}
else
{
mCookieDefined = false;
}
}
示例2: DebugMessage
void ACAppleIMA4Encoder::SetCurrentInputFormat(const AudioStreamBasicDescription& inInputFormat)
{
if(!mIsInitialized)
{
// check to make sure the input format is legal
if( (inInputFormat.mFormatID != kAudioFormatLinearPCM) ||
(inInputFormat.mFormatFlags != (kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked)) ||
(inInputFormat.mBitsPerChannel != 16))
{
#if VERBOSE
DebugMessage("ACAppleIMA4Encoder::SetCurrentInputFormat: only support 16 bit native endian signed integer for input");
#endif
CODEC_THROW(kAudioCodecUnsupportedFormatError);
}
// Do some basic sanity checking
if(inInputFormat.mSampleRate < 0.0)
{
#if VERBOSE
DebugMessage("ACAppleIMA4Encoder::SetCurrentInputFormat: input sample rates may not be negative");
#endif
CODEC_THROW(kAudioCodecUnsupportedFormatError);
}
if(inInputFormat.mChannelsPerFrame > kMaxIMA4Channels)
{
#if VERBOSE
DebugMessage("ACAppleIMA4Encoder::SetCurrentInputFormat: only supports mono or stereo");
#endif
CODEC_THROW(kAudioCodecUnsupportedFormatError);
}
// tell our base class about the new format
ACAppleIMA4Codec::SetCurrentInputFormat(inInputFormat);
// The encoder does no sample rate conversion nor channel manipulation
if (inInputFormat.mChannelsPerFrame == 0)
{
mInputFormat.mChannelsPerFrame = mOutputFormat.mChannelsPerFrame;
}
else
{
mOutputFormat.mChannelsPerFrame = mInputFormat.mChannelsPerFrame;
}
if (inInputFormat.mSampleRate == 0.0)
{
mInputFormat.mSampleRate = mOutputFormat.mSampleRate;
}
else
{
mOutputFormat.mSampleRate = mInputFormat.mSampleRate;
}
// Fix derived values
mInputFormat.mBytesPerFrame = mInputFormat.mBytesPerPacket = (mInputFormat.mBitsPerChannel >> 3) * mInputFormat.mChannelsPerFrame;
mInputFormat.mFramesPerPacket = 1;
// Zero out everything that has to be zero
mInputFormat.mReserved = 0;
}
else
{
示例3: switch
void ACFLACCodec::SetProperty(AudioCodecPropertyID inPropertyID, UInt32 inPropertyDataSize, const void* inPropertyData)
{
switch(inPropertyID)
{
case kAudioCodecPropertyCurrentInputSampleRate:
if(mIsInitialized)
{
CODEC_THROW(kAudioCodecIllegalOperationError);
}
if(inPropertyDataSize == sizeof(Float64))
{
mInputFormat.mSampleRate = *((Float64*)inPropertyData);
}
else
{
CODEC_THROW(kAudioCodecBadPropertySizeError);
}
break;
case kAudioCodecPropertyFormatInfo:
case kAudioCodecPropertyHasVariablePacketByteSizes:
case kAudioCodecPropertyCurrentOutputSampleRate:
case kAudioCodecPropertyAvailableInputChannelLayouts:
case kAudioCodecPropertyAvailableOutputChannelLayouts:
case kAudioCodecPropertyPacketFrameSize:
case kAudioCodecPropertyMaximumPacketByteSize:
CODEC_THROW(kAudioCodecIllegalOperationError);
break;
default:
ACBaseCodec::SetProperty(inPropertyID, inPropertyDataSize, inPropertyData);
break;
}
}
示例4: GetUsedInputBufferByteSize
void ACSimpleCodec::AppendInputData(const void* inInputData, UInt32& ioInputDataByteSize, UInt32& ioNumberPackets, const AudioStreamPacketDescription* inPacketDescription)
{
// this buffer handling code doesn't care about such things as the packet descriptions
if(!mIsInitialized) CODEC_THROW(kAudioCodecStateError);
// this is a ring buffer we're dealing with, so we need to set up a few things
UInt32 theUsedByteSize = GetUsedInputBufferByteSize();
UInt32 theAvailableByteSize = GetInputBufferByteSize() - theUsedByteSize;
UInt32 theMaxAvailableInputBytes = ioInputDataByteSize; // we can't consume more than we get
const Byte* theInputData = static_cast<const Byte*>(inInputData);
// >>jamesmcc: added this because ioNumberPackets was not being updated if less was taken than given.
// THIS ASSUMES CBR!
UInt32 bytesPerPacketOfInput = mInputFormat.mBytesPerPacket;
UInt32 theAvailablePacketSize = theAvailableByteSize / bytesPerPacketOfInput;
UInt32 minPacketSize = ioNumberPackets < theAvailablePacketSize ? ioNumberPackets : theAvailablePacketSize;
UInt32 minByteSize = minPacketSize * bytesPerPacketOfInput;
// we can copy only as much data as there is or up to how much space is availiable
ioNumberPackets = minPacketSize;
ioInputDataByteSize = minByteSize;
// ioInputDataByteSize had better be <= to theMaxAvailableInputBytes or we're screwed
if (ioInputDataByteSize > theMaxAvailableInputBytes)
{
CODEC_THROW(kAudioCodecStateError);
}
// <<jamesmcc
// now we have to copy the data taking into account the wrap around and where the start is
if(mInputBufferEnd + ioInputDataByteSize < mInputBufferByteSize)
{
// no wrap around here
memcpy(mInputBuffer + mInputBufferEnd, theInputData, ioInputDataByteSize);
// adjust the end point
mInputBufferEnd += ioInputDataByteSize;
}
else
{
// the copy will wrap
// copy the first part
UInt32 theBeforeWrapByteSize = mInputBufferByteSize - mInputBufferEnd;
memcpy(mInputBuffer + mInputBufferEnd, theInputData, theBeforeWrapByteSize);
// and the rest
UInt32 theAfterWrapByteSize = ioInputDataByteSize - theBeforeWrapByteSize;
memcpy(mInputBuffer, theInputData + theBeforeWrapByteSize, theAfterWrapByteSize);
// adjust the end point
mInputBufferEnd = theAfterWrapByteSize;
}
}
示例5: dbg_printf
void CAOggFLACDecoder::SetCurrentInputFormat(const AudioStreamBasicDescription& inInputFormat)
{
if (!mIsInitialized) {
if (inInputFormat.mFormatID != kAudioFormatXiphOggFramedFLAC) {
dbg_printf("CAOggFLACDecoder::SetFormats: only support Xiph FLAC (Ogg-framed) for input\n");
CODEC_THROW(kAudioCodecUnsupportedFormatError);
}
XCACodec::SetCurrentInputFormat(inInputFormat);
} else {
CODEC_THROW(kAudioCodecStateError);
}
}
示例6: switch
void ACShepA52Codec::GetProperty(AudioCodecPropertyID inPropertyID, UInt32& ioPropertyDataSize, void* outPropertyData) {
switch(inPropertyID) {
case kAudioCodecPropertyManufacturerCFString:
{
if (ioPropertyDataSize != sizeof(CFStringRef)) {
CODEC_THROW(kAudioCodecBadPropertySizeError);
}
CFStringRef name = CFCopyLocalizedStringFromTableInBundle(CFSTR("Shepmaster Productions"), CFSTR("CodecNames"), GetCodecBundle(), CFSTR(""));
*(CFStringRef*)outPropertyData = name;
break;
}
case kAudioCodecPropertyMaximumPacketByteSize:
if(ioPropertyDataSize == sizeof(UInt32)) {
*reinterpret_cast<UInt32*>(outPropertyData) = 3840; //Stolen from liba52 docs
} else {
CODEC_THROW(kAudioCodecBadPropertySizeError);
}
break;
case kAudioCodecPropertyRequiresPacketDescription:
if(ioPropertyDataSize == sizeof(UInt32)) {
*reinterpret_cast<UInt32*>(outPropertyData) = 0;
} else {
CODEC_THROW(kAudioCodecBadPropertySizeError);
}
break;
case kAudioCodecPropertyHasVariablePacketByteSizes:
if(ioPropertyDataSize == sizeof(UInt32)) {
*reinterpret_cast<UInt32*>(outPropertyData) = 1;
} else {
CODEC_THROW(kAudioCodecBadPropertySizeError);
}
break;
case kAudioCodecPropertyPacketFrameSize:
if(ioPropertyDataSize == sizeof(UInt32)) {
*reinterpret_cast<UInt32*>(outPropertyData) = 6 * 256; // A frame has 6 blocks of 256 samples
} else {
CODEC_THROW(kAudioCodecBadPropertySizeError);
}
break;
default:
ACSimpleCodec::GetProperty(inPropertyID, ioPropertyDataSize, outPropertyData);
}
}
示例7: dbg_printf
void CASpeexDecoder::SetMagicCookie(const void* inMagicCookieData, UInt32 inMagicCookieDataByteSize)
{
dbg_printf(" >> [%08lx] CASpeexDecoder :: SetMagicCookie()\n", (UInt32) this);
if (mIsInitialized)
CODEC_THROW(kAudioCodecStateError);
SetCookie(inMagicCookieData, inMagicCookieDataByteSize);
InitializeCompressionSettings();
if (!mCompressionInitialized)
CODEC_THROW(kAudioCodecUnsupportedFormatError);
dbg_printf("<.. [%08lx] CASpeexDecoder :: SetMagicCookie()\n", (UInt32) this);
}
示例8: GetInputBufferContiguousByteSize
void ACSimpleCodec::ConsumeInputData(UInt32 inConsumedByteSize)
{
// this is a convenience routine to make maintaining the ring buffer state easy
UInt32 theContiguousRange = GetInputBufferContiguousByteSize();
if(inConsumedByteSize > GetUsedInputBufferByteSize()) CODEC_THROW(kAudioCodecUnspecifiedError);
if(inConsumedByteSize <= theContiguousRange)
{
// the region to consume doesn't wrap
// figure out how much to consume
inConsumedByteSize = (theContiguousRange < inConsumedByteSize) ? theContiguousRange : inConsumedByteSize;
// clear the consumed bits
memset(mInputBuffer + mInputBufferStart, 0, inConsumedByteSize);
// adjust the start
mInputBufferStart += inConsumedByteSize;
}
else
{
// the region to consume will wrap
// clear the bits to the end of the buffer
memset(mInputBuffer + mInputBufferStart, 0, theContiguousRange);
// now clear the bits left from the start
memset(mInputBuffer, 0, inConsumedByteSize - theContiguousRange);
// adjust the start
mInputBufferStart = inConsumedByteSize - theContiguousRange;
}
}
示例9: CODEC_THROW
void ACBaseCodec::SetMagicCookie(const void* outMagicCookieData, UInt32 inMagicCookieDataByteSize)
{
if(mIsInitialized)
{
CODEC_THROW(kAudioCodecStateError);
}
}
示例10: SetCurrentInputFormat
void ACShepA52Codec::Initialize(const AudioStreamBasicDescription* inInputFormat,
const AudioStreamBasicDescription* inOutputFormat,
const void* inMagicCookie, UInt32 inMagicCookieByteSize) {
// use the given arguments, if necessary
if(inInputFormat != NULL)
{
SetCurrentInputFormat(*inInputFormat);
}
if(inOutputFormat != NULL)
{
SetCurrentOutputFormat(*inOutputFormat);
}
// make sure the sample rate and number of channels match between the input format and the output format
if( (mInputFormat.mSampleRate != mOutputFormat.mSampleRate))
{
CODEC_THROW(kAudioCodecUnsupportedFormatError);
}
ACSimpleCodec::Initialize(inInputFormat, inOutputFormat, inMagicCookie, inMagicCookieByteSize);
}
示例11: SetCurrentInputFormat
void ACFLACCodec::Initialize(const AudioStreamBasicDescription* inInputFormat, const AudioStreamBasicDescription* inOutputFormat, const void* inMagicCookie, UInt32 inMagicCookieByteSize)
{
// use the given arguments, if necessary
if(inInputFormat != NULL)
{
SetCurrentInputFormat(*inInputFormat);
}
if(inOutputFormat != NULL)
{
SetCurrentOutputFormat(*inOutputFormat);
}
// make sure the sample rate and number of channels match between the input format and the output format
if( (mInputFormat.mSampleRate != mOutputFormat.mSampleRate) ||
(mInputFormat.mChannelsPerFrame != mOutputFormat.mChannelsPerFrame))
{
#if VERBOSE
printf("The channels and sample rates don't match, mInputFormat.mSampleRate == %f, mOutputFormat.mSampleRate == %f, mInputFormat.mChannelsPerFrame == %lu, mOutputFormat.mChannelsPerFrame == %lu\n",
mInputFormat.mSampleRate, mOutputFormat.mSampleRate, mInputFormat.mChannelsPerFrame, mOutputFormat.mChannelsPerFrame);
#endif
CODEC_THROW(kAudioCodecUnsupportedFormatError);
}
if(inMagicCookie != NULL)
{
SetMagicCookie(inMagicCookie, inMagicCookieByteSize);
}
ACBaseCodec::Initialize(inInputFormat, inOutputFormat, inMagicCookie, inMagicCookieByteSize);
}
示例12: ReallocateInputBuffer
void ACSimpleCodec::Initialize(const AudioStreamBasicDescription* inInputFormat, const AudioStreamBasicDescription* inOutputFormat, const void* inMagicCookie, UInt32 inMagicCookieByteSize)
{
ReallocateInputBuffer(mInputBufferByteSize - kBufferPad);
// By definition CBR has this greater than 0. We must avoid a div by 0 error in AppendInputData()
// Note this will cause us to fail initialization which is intended
if (mInputFormat.mBytesPerPacket == 0)
{
CODEC_THROW(kAudioCodecUnsupportedFormatError);
}
ACBaseCodec::Initialize(inInputFormat, inOutputFormat, inMagicCookie, inMagicCookieByteSize);
}
示例13: CODEC_THROW
void CAOggFLACDecoder::InPacket(const void* inInputData, const AudioStreamPacketDescription* inPacketDescription)
{
if (!mCompressionInitialized)
CODEC_THROW(kAudioCodecUnspecifiedError);
ogg_page op;
if (!WrapOggPage(&op, inInputData, inPacketDescription->mDataByteSize + inPacketDescription->mStartOffset, inPacketDescription->mStartOffset))
CODEC_THROW(kAudioCodecUnspecifiedError);
dbg_printf("[ oFD] : [%08lx] InPacket() [%4.4s] %ld\n", (UInt32) this, (char *) (static_cast<const Byte*> (inInputData) + inPacketDescription->mStartOffset),
ogg_page_pageno(&op));
ogg_packet opk;
SInt32 packet_count = 0;
int oret;
AudioStreamPacketDescription flac_packet_desc = {0, 0, 0};
UInt32 page_packets = ogg_page_packets(&op);
ogg_stream_pagein(&mO_st, &op);
while ((oret = ogg_stream_packetout(&mO_st, &opk)) != 0) {
if (oret < 0) {
page_packets--;
continue;
}
packet_count++;
flac_packet_desc.mDataByteSize = opk.bytes;
CAFLACDecoder::InPacket(opk.packet, &flac_packet_desc);
}
if (packet_count > 0)
complete_pages += 1;
mFramesBufferedList.push_back(OggPagePacket(packet_count, inPacketDescription->mVariableFramesInPacket));
}
示例14: switch
void ACAppleIMA4Encoder::SetProperty(AudioCodecPropertyID inPropertyID, UInt32 inPropertyDataSize, const void* inPropertyData)
{
switch(inPropertyID)
{
case kAudioCodecPropertyAvailableInputSampleRates:
case kAudioCodecPropertyAvailableOutputSampleRates:
case kAudioCodecPropertyZeroFramesPadded:
case kAudioCodecPropertyPrimeInfo:
CODEC_THROW(kAudioCodecIllegalOperationError);
break;
default:
ACAppleIMA4Codec::SetProperty(inPropertyID, inPropertyDataSize, inPropertyData);
break;
}
}
示例15: switch
void ACSimpleCodec::SetProperty(AudioCodecPropertyID inPropertyID, UInt32 inPropertyDataSize, const void* inPropertyData)
{
switch(inPropertyID)
{
case kAudioCodecPropertyInputBufferSize:
if(inPropertyDataSize == sizeof(UInt32))
{
ReallocateInputBuffer(*reinterpret_cast<const UInt32*>(inPropertyData));
}
else
{
CODEC_THROW(kAudioCodecBadPropertySizeError);
}
break;
default:
ACBaseCodec::SetProperty(inPropertyID, inPropertyDataSize, inPropertyData);
break;
}
}