• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Is it problematic to use Microphone.getEnhancedMicrophone() more than once on the same device?

Explorer ,
Apr 29, 2014 Apr 29, 2014

Copy link to clipboard

Copied

Here's an interesting little experiment:

     Alert.show((Microphone.getEnhancedMicrophone() == Microphone.getEnhancedMicrophone()).toString());

     Alert.show((Microphone.getMicrophone() == Microphone.getMicrophone()).toString());

They both show "false", even though the calls to getMicrophone() and getEnhancedMicrophone() always point to the same device.

I'm making an R&D app right now, and this is a potential problem for me.  I've designed the app around it being able to refresh the list of available mics, and for the user to be able to go back and forth between different mics and be able to hear themselves, among other things.

If they turn on loop back for a mic, then re-select the same mic, it'll create a different object for that same exact device, and after turning off loop back for the previous instance (and removing all references to that instance), it'll turn on loop back for the new instance.  The problem?  It's hard to tell for sure, but there appears to possibly be some sort of issue with the Flash Player taking a minute to garbage collect the old instance, and during that time, the Flash Player trying to read audio out of that device and loop it back twice, as opposed to once.

It's hard to tell whether this is really happening, or whether the distortion I'm hearing is purely two-second transition from one instance to the other, but there are also questions in my mind about the viability of just trying to track each individual device in a Dictionary; if multiple devices have the same name and keep getting pulled out of one port and plugged into another, there seem to be problems in being able to keep track of indivdual devices very well in that case.

So is this a really big issue for an app that's designed to let people keep switching mics back and forth, as well as letting them refresh the list of available mics over and over?  Or as long as setLoopBack(false); and setSilenceLevel(100); are called on every instance before its references are removed, will there not be any sort of disturbance in future instances' audio (or any other issue, aside from late GC)?  Thanks!

TOPICS
ActionScript

Views

358

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 29, 2014 Apr 29, 2014

Copy link to clipboard

Copied

The docs state you can only have one enhanced Microphone, so the second time you call to get an enhanced mic, you're nulling out the first reference automatically, so they'll never equal each other.

Important: At any given time you can have only a single instance of enhanced microphone device. All other Microphone instances stop providing audio data

Garbage collection was always magical. Things are only removed when necessary. You can attempt to mark it ready for cleanup with System.gc() but there's no guarantee it will dump right then. You should take steps to mute the mic you're trying to dereference so it won't bother you until it gets GC'd.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 29, 2014 Apr 29, 2014

Copy link to clipboard

Copied

What about Microphone.getMicrophone() not being equal to Microphone.getMicrophone()?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 29, 2014 Apr 29, 2014

Copy link to clipboard

Copied

LATEST

You're creating a reference. The constructor that runs factorizes some other classes into your object such as flash.media.SoundTransform. Due to instantiating a "new" SoundTransform, it differs from the other mic references SoundTransform. Thus the object is not identical. The debug panel shows you easier:

refdifference.png

If you really just want to see if it's attached to the same device, simply compare the index value.

if (mic1.index == mic2.index) {

     // same audio recording device

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines