Open alenQingshan opened 8 years ago
我的也有同样的问题,崩溃在下面这个函数的 AudioConverterNewSpecific 这一行,请问是什么原因?
(BOOL)createAudioConvert { //根据输入样本初始化一个编码转换器 if (m_converter != nil) { return TRUE; }
AudioStreamBasicDescription inputFormat = {0}; inputFormat.mSampleRate = _configuration.audioSampleRate; inputFormat.mFormatID = kAudioFormatLinearPCM; inputFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked; inputFormat.mChannelsPerFrame = (UInt32)_configuration.numberOfChannels; inputFormat.mFramesPerPacket = 1; inputFormat.mBitsPerChannel = 16; inputFormat.mBytesPerFrame = inputFormat.mBitsPerChannel / 8 inputFormat.mChannelsPerFrame; inputFormat.mBytesPerPacket = inputFormat.mBytesPerFrame inputFormat.mFramesPerPacket;
AudioStreamBasicDescription outputFormat; // 这里开始是输出音频格式 memset(&outputFormat, 0, sizeof(outputFormat)); outputFormat.mSampleRate = inputFormat.mSampleRate; // 采样率保持一致 outputFormat.mFormatID = kAudioFormatMPEG4AAC; // AAC编码 kAudioFormatMPEG4AAC kAudioFormatMPEG4AAC_HE_V2 outputFormat.mChannelsPerFrame = (UInt32)_configuration.numberOfChannels;; outputFormat.mFramesPerPacket = 1024; // AAC一帧是1024个字节
const OSType subtype = kAudioFormatMPEG4AAC; AudioClassDescription requestedCodecs[2] = { { kAudioEncoderComponentType, subtype, kAppleSoftwareAudioCodecManufacturer }, { kAudioEncoderComponentType, subtype, kAppleHardwareAudioCodecManufacturer } }; OSStatus result = AudioConverterNewSpecific(&inputFormat, &outputFormat, 2, requestedCodecs, &m_converter); if (result != noErr) return NO;
return YES; }
Thank you
LFHardwareAudioEncoder在第114行的,inputFormat调用崩溃(iOS10),对音频模块不熟悉,求解答!!!