Echo cancellation microphone will make app die in Android 4.4.x
Hi
Such as the title.
Use Android 4.4.x
1.Using echo cancellation microphone.
2.App:create NetConnection、publish NetStream(streamName:"mystream_mobile") 、play NetStream(streamName:"mystream_web")
3.Web:create NetConnection、publish NetStream(streamName:"mystream_web") 、play NetStream(streamName:"mystream_mobile")
4.There is no problem with the first run. But the second run, web can hear the voice of the app, but app can not hear the voice of the web.
5.Second times, to clear the NetConnection and NetStream, APP on the card dead.
I try to use Android, 5.0+ IOS are no problem, in the 4.4.2 Android 4.4.4 Android on the emergence of this problem.
Thanks.
This is my Code:
protected function button1_clickHandler(event:MouseEvent):void
{
_conn = new NetConnection();
_conn.client = this;
_conn.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);
_conn.connect("rtmp://192.168.0.242/live");
}
protected function netStatusHandler(event:NetStatusEvent):void
{
trace(event.info.code);
switch(event.info.code)
{
case "NetConnection.Connect.Success":
{
streamInit();
break;
}
default:
{
break;
}
}
}
private function streamInit():void
{
if(_conn)
{
var option:MicrophoneEnhancedOptions = new MicrophoneEnhancedOptions();
option.mode = MicrophoneEnhancedMode.FULL_DUPLEX;
option.echoPath = 128;
_mic = Microphone.getEnhancedMicrophone();
_mic.enhancedOptions = option;
_mic.codec=SoundCodec.SPEEX;
_mic.framesPerPacket=1;
_mic.setSilenceLevel(0,2000);
// _mic = Microphone.getMicrophone();
//_mic.setLoopBack(true);
_mic.rate = 22;
_mic.gain=60;
_puns = new NetStream(_conn);
_puns.attachAudio(_mic);
_puns.client = this;
_puns.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);
_puns.publish("myLive_web");
_plns = new NetStream(_conn);
_plns.client = this;
_plns.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);
_plns.play("myLive_mobile");
}
}
public function onBWDone():void
{
trace("onBWDone");
}
public function onFI(info:Object):void
{
trace("onFI");
}
public function onMetaData(info:Object):void
{
trace(info);
}
public function onPlayStatus(info:Object=null):void
{
trace("onPlayStatus");
}
public function onSeekPoint(info:Object=null):void
{
trace("onSeekPoint");
}
protected function button2_clickHandler(event:MouseEvent):void
{
trace("destroy...");
if(_plns)
{
_plns.close();
_plns.removeEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);
_plns = null;
}
if(_puns)
{
_puns.close();
_puns.removeEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);
_puns = null;
}
if(_conn)
{
_conn.close();
_conn.removeEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);
_conn = null;
}
_mic = null;
}
<s:Button click="button1_clickHandler(event)" label="Connect"/>
<s:Button click="button2_clickHandler(event)" label="Destroy"/>
