App crash when attach microphone to a net stream
Hi there,
An emergency issue not sure could someone help.
My app ran well before, but now it always crash at the point when I attache the microphone to a netstream, The app running on IOS 10.2.1 (I'm not sure if this related to any iOS version update) and the app's development SDK is Flex4.15 Air25. The code is as bellow:
private function getMicrophone(codec:String):Microphone {
var mic:Microphone = null;
mic = Microphone.getEnhancedMicrophone();
if (mic) {
var options:MicrophoneEnhancedOptions = new MicrophoneEnhancedOptions();
options.mode = MicrophoneEnhancedMode.FULL_DUPLEX;
options.autoGain = false;
options.echoPath = 128;
options.nonLinearProcessing = true;
mic['enhancedOptions'] = options;
mic.setUseEchoSuppression(true);
} else {
mic = Microphone.getMicrophone();
}
if (mic == null) {
trace("No microphone! <o>");
} else {
mic.addEventListener(StatusEvent.STATUS, onMicStatusEvent);
mic.setLoopBack(false);
mic.setSilenceLevel(0, 20000);
mic.gain = 60;
if (codec == "SPEEX") {
mic.encodeQuality = 6;
mic.codec = SoundCodec.SPEEX;
mic.framesPerPacket = 1;
mic.rate = 16;
trace("Using SPEEX wideband codec");
} else {
mic.codec = SoundCodec.NELLYMOSER;
mic.rate = 8;
trace("Using Nellymoser codec");
}
}
return mic;
}
private function setupMicrophone(codec:String, pushToTalk:Boolean):void {
if (noMicrophone()) {
_mic = null;
return;
}
_mic = getMicrophone(codec);
_mic.gain = pushToTalk ? 0 : _defaultMicGain;
}
public function publish(connection:NetConnection, streamName:String, codec:String, pushToTalk:Boolean):void {
_outgoingStream = new NetStream(connection);
_outgoingStream.client = this;
_outgoingStream.addEventListener(NetStatusEvent.NET_STATUS, onNetStatusEvent);
_outgoingStream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncErrorEvent);
setupMicrophone(codec, pushToTalk);
if (_mic) {
_outgoingStream.attachAudio(_mic); <--- It Crash at this line
_outgoingStream.publish(streamName, "live");
}
}
I tried to delete and reinstall the app and it even didn't prompt for mic access permission when call Microphone.getEnhancedMicrophone method. I've tried Microphone.getMicrophone(), but the problem is still there. The app just simply crash without any error message. Thanks in advance If someone knows the trick or can provide some bug tracing methodologies !
