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

Enable autoGain & echoCancel when streaming: setting failed with error code -10879 #343

Closed
pigheartCN opened this issue Jun 11, 2024 · 2 comments

Comments

@pigheartCN
Copy link

pigheartCN commented Jun 11, 2024

The following code setup failed
`
let propsize = UInt32(MemoryLayout.size)

        var echoCancel = false
        var a = AudioUnitSetProperty(audioEngine.inputNode.audioUnit!,
                             kAUVoiceIOProperty_BypassVoiceProcessing,
                             kAudioUnitScope_Global,
                             AudioUnitElement(bus),
                             &echoCancel,
                             propsize)
        if a != noErr {
            print("record  can't enable Global echoCancellation:\(a)")
        }

        var autoGain = true
        var b = AudioUnitSetProperty(audioEngine.inputNode.audioUnit!,
                             kAUVoiceIOProperty_VoiceProcessingEnableAGC,
                             kAudioUnitScope_Global,
                             AudioUnitElement(bus),
                             &autoGain,
                             propsize)
        if b != noErr {
            print("record  can't enable Global enableAGC:\(b)")
        }

`

@pigheartCN
Copy link
Author

the log:
record can't enable Global echoCancellation:-10879
record can't enable Global enableAGC:-10879

@pigheartCN
Copy link
Author

pigheartCN commented Jun 11, 2024

Use the following way to set up, you can achieve the effect
if #available(iOS 13.0, *) { inputNode.isVoiceProcessingBypassed = false inputNode.isVoiceProcessingAGCEnabled = true try inputNode.setVoiceProcessingEnabled(true) } else { // Fallback on earlier versions }

However, with quite a few crashes appear in the following method
audioEngine.inputNode.installTap(onBus: bus, bufferSize: 2048, format: srcFormat) { (buffer, _) -> Void in self.stream( buffer: buffer, dstFormat: dstFormat, converter: converter, recordEventHandler: recordEventHandler ) }

The log is as follows:
`CrashDoctor Diagnosis: Application threw exception com.apple.coreaudio.avfaudio: required condition is false: IsFormatSampleRateAndChannelCountValid(format)
Thread 0 Crashed:
0 CoreFoundation 0x0000000197206b28 __exceptionPreprocess + [ : 164]

1 libobjc.A.dylib 0x000000018f062f78 objc_exception_throw + [ : 60]

2 CoreFoundation 0x000000019728c234 +[NSException raise:format:]

3 AVFAudio 0x00000001b0bf2a84 AVAE_RaiseException(NSString*, ...) + [ : 52]

4 AVFAudio 0x00000001b0c54c78 AUGraphNodeBaseV3::CreateRecordingTap(unsigned long, unsigned int, AVAudioFormat*, void ( block_pointer)(AVAudioPCMBuffer*, AVAudioTime*)) + [ : 760]

5 AVFAudio 0x00000001b0cccf1c -[AVAudioNode installTapOnBus:bufferSize:format:block:] + [ : 1420]

6 record_darwin 0x000000010e0934ac RecorderStreamDelegate.start(config:recordEventHandler:) + [ : 0]

7 record_darwin 0x000000010e08cd70 Recorder.startStream(config:) + [Recorder.swift : 53]

8 record_darwin 0x000000010e09a25c $s13record_darwin17SwiftRecordPluginC6handle_6resultySo17FlutterMethodCallC_yypSgctF015$syXlSgIeyBy_ypM7Iegn_TRyXlSgIeyBy_Tf1ncn_nTf4nng_n + [SwiftRecordPlugin.swift : 96]

9 record_darwin 0x000000010e097648 @objc SwiftRecordPlugin.handle(_:result:) + [ : 0] `

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

1 participant