void CASpeexDecoder::Initialize(const AudioStreamBasicDescription* inInputFormat, const AudioStreamBasicDescription* inOutputFormat, const void* inMagicCookie, UInt32 inMagicCookieByteSize) { dbg_printf(" >> [%08lx] CASpeexDecoder :: Initialize(%d, %d, %d)\n", (UInt32) this, inInputFormat != NULL, inOutputFormat != NULL, inMagicCookieByteSize != 0); if(inInputFormat != NULL) { SetCurrentInputFormat(*inInputFormat); } if(inOutputFormat != NULL) { SetCurrentOutputFormat(*inOutputFormat); } if ((mInputFormat.mSampleRate != mOutputFormat.mSampleRate) || (mInputFormat.mChannelsPerFrame != mOutputFormat.mChannelsPerFrame)) { CODEC_THROW(kAudioCodecUnsupportedFormatError); } // needs to be called after input & output format have been set BDCInitialize(kSpeexDecoderInBufferSize); //if (inMagicCookieByteSize == 0) // CODEC_THROW(kAudioCodecUnsupportedFormatError); if (inMagicCookieByteSize != 0) { SetMagicCookie(inMagicCookie, inMagicCookieByteSize); } XCACodec::Initialize(inInputFormat, inOutputFormat, inMagicCookie, inMagicCookieByteSize); dbg_printf("<.. [%08lx] CASpeexDecoder :: Initialize(%d, %d, %d)\n", (UInt32) this, inInputFormat != NULL, inOutputFormat != NULL, inMagicCookieByteSize != 0); }
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); }
void ACBaseCodec::SetProperty(AudioCodecPropertyID inPropertyID, UInt32 inPropertyDataSize, const void* inPropertyData) { // No property can be set when the codec is initialized if(mIsInitialized) { CODEC_THROW(kAudioCodecIllegalOperationError); } switch(inPropertyID) { case kAudioCodecPropertyCurrentInputFormat: if(inPropertyDataSize == SizeOf32(AudioStreamBasicDescription)) { SetCurrentInputFormat(*reinterpret_cast<const AudioStreamBasicDescription*>(inPropertyData)); } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyCurrentOutputFormat: if(inPropertyDataSize == SizeOf32(AudioStreamBasicDescription)) { SetCurrentOutputFormat(*reinterpret_cast<const AudioStreamBasicDescription*>(inPropertyData)); } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyMagicCookie: SetMagicCookie(inPropertyData, inPropertyDataSize); break; case kAudioCodecPropertyMinimumNumberOutputPackets : case kAudioCodecPropertyMinimumNumberInputPackets : case kAudioCodecPropertyInputBufferSize: case kAudioCodecPropertyNameCFString: case kAudioCodecPropertyManufacturerCFString: case kAudioCodecPropertyFormatCFString: case kAudioCodecPropertySupportedInputFormats: case kAudioCodecPropertySupportedOutputFormats: case kAudioCodecPropertyUsedInputBufferSize: case kAudioCodecPropertyIsInitialized: case kAudioCodecPropertyAvailableNumberChannels: case kAudioCodecPropertyPrimeMethod: case kAudioCodecPropertyPrimeInfo: case kAudioCodecPropertyOutputFormatsForInputFormat: case kAudioCodecPropertyInputFormatsForOutputFormat: case kAudioCodecPropertyDoesSampleRateConversion: case kAudioCodecPropertyRequiresPacketDescription: CODEC_THROW(kAudioCodecIllegalOperationError); break; default: CODEC_THROW(kAudioCodecUnknownPropertyError); break; }; }