Copy link to clipboard
Copied
Hi,
I found out that Adobe Air Sound playing class is conflicting with microphone recording using native extension. The sound classs overrides the Audio Session used in recording extension written in ObjC (ios platform). By default, the extension set audio session to PlayAndRecord.
However after a sound play in AS3, new Sound(), sound.play(); the mic will stop getting any input.
If sound is played via a native extension using AVAudioPlayer, mic and sound play will work perfectly.
We have tried fixes by setting different modes in Adobe Air (after and before a sound play)
SoundMixer.audioPlaybackMode = AudioPlaybackMode.AMBIENT;
SoundMixer.audioPlaybackMode = AudioPlaybackMode.MEDIA;
SoundMixer.audioPlaybackMode = AudioPlaybackMode.VOICE;
Adobe needs to provide all the Audio Session available in iOS platform, eg. PlayAndRecord.
This is crucial for mic input Apps, we are working a lot with audio fingerprinting, please add this audio session.
I have submitted a bug report for this. https://bugbase.adobe.com/index.cfm?event=bug&id=3628271
Actual Result:
After a sound play through AS3, native mic will stop working as audio session seems to be conflicting each other
Expected Result:
Both mic and sound playing work perfectly
Any Workarounds:
Play via a native extension
Copy link to clipboard
Copied
We're facing the same problem. Have you been able to address it please?
Copy link to clipboard
Copied
Hi,
I'm facing the same problem, just wondering if you figured out a way around it or if the issue still exists with the current AIR releases?
Regards,
Michael
Copy link to clipboard
Copied
It is still there, I just encountered it.
My current "workaround" was to start the native recording after I start playing my sound (I'm playing only one Sound so I can afford it). In that case it works just fine as well.
I've got a sound mixer class so all the sounds that are playing are really not Sound, just virtual sounds - and I'm using the sampleDataEvent method of playing the resulting Sound. So I have the guarantee no Sound will start playing in the middle of the recording.
As for the other cases, I'm thinking if it wouldn't be possible to create wrapper class for Sound, create a wrapper for play method(I'm doing that now for my sound mixer as well)...then you have a way to know when a sound is about to be played. Then you can notify the ANE that .play happened, and you have a chance to do something. Hopefully to resume the microphone recording. But not sure, if there would be any hearable pauses etc.
Copy link to clipboard
Copied
I seem to be finding the same issue, (or maybe somewhat related) in AIR 17.
My app plays video and stops, then opens the Mic for voice recording, closes the Mic and then plays video again. For some reason, the audio from the video (or any sound whatsoever after that first recording) is never heard again. We've found out that if you lock -> unlock the device (or switch between apps), audio is back, until you open the mic again.
Copy link to clipboard
Copied
Could you please share a sample project to help us narrow down this problem.?
Regards
Adobe AIR Team
Copy link to clipboard
Copied
Sure thing.
It has a small sample video and a Native Extension for voice recognition. Before recognising, it plays the video flawlessly. After recognising, the video plays without audio (and rather slowly). If instead of video we had sound only, it wouldn't be audible either.
If it's any help, the ANE sets up the audio session via
AVAudioSession *sessionInstance = [AVAudioSession sharedInstance];
and the Audio Unit as
OEContinuousAudioUnit *_audioDriver;
and closes the audio unit via
if(self.audioDriver.audioUnitState == kAudioUnitIsStarted) {
error = [self.audioDriver stopAudioUnit];
if(error) {
[self announceTeardownFailureForReason:[NSString stringWithFormat:@"Error: there was a problem stopping the audio unit: %@.", error]];
return error;
}
}
Copy link to clipboard
Copied
Hi,
The issue is reproducible at our end and I have logged an internal bug for the same. Our team is investigating this at our end. I will keep you informed.
Thanks
Adobe AIR Team
Copy link to clipboard
Copied
Do you solve the sound.play problem?Can you give me a hint?
We ' ve also encountered the same problem .
Thanks
Copy link to clipboard
Copied
The solution provided by Adobe worked:
So please try without [[AVAudioSession sharedInstance] setActive:NO error:nil]
Also: we had to go to an ANE because we couldn't implement all that we had in AS3 with the Microphone class, but maybe you could. For us that was, at some point, certainly an option.
Copy link to clipboard
Copied
Hi,
could you please share your ANE source code with me i need it to debug your sample project.
Thanks
Adobe Air Team
Copy link to clipboard
Copied
Hmmm. I'm not sure. We'll try extracting a functional piece of the whole project so we can share it with you.
Do you think you can give us an estimate of when could this be fixed?
Copy link to clipboard
Copied
hi
in the project you shared the problem begins when the videoDisplay class starts interacting with your ANE.
it would be helpful to understand where the things start to go wrong.
thanks
Adobe AIR Team
Copy link to clipboard
Copied
While we extract a test project we can give you this piece of code: it gave us the same problems with video/audio playing when called from the ANE (but not with a iOS native application). It has two methods: one starts the audio session and the other one closes it:
#import "SONTestAudioSession.h"
#import "OEAudioUtilities.h"
#import "OELogging.h"
#import "OENotification.h"
static const NSInteger kMaxRetries = 3;
static const float retryInterval = 0.5;
@interface SONTestAudioSession()
{
NSInteger retries;
}
@end
@implementation SONTestAudioSession
- (void) start
{
NSLog(@"%s", __PRETTY_FUNCTION__);
retries = 0;
AVAudioSession *sessionInstance = [AVAudioSession sharedInstance];
NSError *error = nil;
[sessionInstance setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionMixWithOthers | AVAudioSessionCategoryOptionAllowBluetooth | AVAudioSessionCategoryOptionDefaultToSpeaker error:&error]; // We are just defaulting to mixing.
if(error.code != noErr) {
ReportError((OSStatus)error.code, @"Error: Could not activate the av session audio category.");
}
}
- (void) stop
{
NSLog(@"%s", __PRETTY_FUNCTION__);
NSError *error = nil;
[[AVAudioSession sharedInstance] setActive:NO error:&error];
if(error.code != noErr) {
NSLog(@"%s Failed to set inactive. Retry...", __PRETTY_FUNCTION__);
if (retries < kMaxRetries) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(retryInterval * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
retries++;
[self stop]; // call self again, until it reaches max retries
});
} else {
ReportError((OSStatus)error.code, @"Error: Could not set session inactive."); // failed to de-activate the audio session
}
} else {
NSLog(@"%s Session inactive", __PRETTY_FUNCTION__);
}
[[AVAudioSession sharedInstance] setMode:AVAudioSessionModeDefault error:&error];
}
@e
Copy link to clipboard
Copied
you are using [[AVAudioSession sharedInstance] setActive:NO error:nil]
this is causing an exception from AVAudioSession
"Deactivating an audio session that has running I/O. All I/O should be stopped or paused prior to deactivating the audio session."
this is resulting in all audio/video session being closed .
the problem gets solved if the you don't STOP the AVAudioSession.
So please try without [[AVAudioSession sharedInstance] setActive:NO error:nil]
Also AS3 provides Microphone class for recording you may also try that.