Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LFHardwareAudioEncoder第80行的inputFormat问题 #22

Open
alenQingshan opened this issue Oct 17, 2016 · 2 comments
Open

LFHardwareAudioEncoder第80行的inputFormat问题 #22

alenQingshan opened this issue Oct 17, 2016 · 2 comments

Comments

@alenQingshan
Copy link

LFHardwareAudioEncoder在第114行的,inputFormat调用崩溃(iOS10),对音频模块不熟悉,求解答!!!

@dungeonsnd
Copy link

我的也有同样的问题,崩溃在下面这个函数的 AudioConverterNewSpecific 这一行,请问是什么原因?

#pragma mark -- CustomMethod

  • (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;
    }

@kongdelong
Copy link

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants