The microphone code is very similar to what you have posted. I can successfully use the enhanced microphone. When it is enabled, the issue I am having is exhibited.
A simple test I am using:
Use ffmpeg to stream a stereo mp3 file to the media server. I am using the following ffmpeg command line:
ffmpeg -re -i ~/alone.mp3 -vn -acodec copy -ac 2 -f flv rtmp://myserver.com:1935/video/3Daudio/alone
In this case the file is encoded at 44.1 kHz.
The client uses a netstream to play with bufferTime = 0
Without the microphone, the playback is as expected. With a normal microphone, not the enhanced microphone, the playback is as expected but there is little to no echo cancellation.
When the enhanced microphone is enabled, again using similar code to your post, the mp3 playback becomes severely distorted and is unacceptable.
In my opinion, this is an issue with the AEC algorithms of the enhancedMicrophone and stereo playback of a 'live' stream. If I modify the client playback code to bufferTime > 0, the mp3 playback is normal but there is no echo cancellation.
OK got it.
Maybe lower the gain level to 30 or 40 and see if the audio distortion is less.
That may help but it may be a flashplayer issue as you said.