audio resume fix
This commit is contained in:
1 parent
9d2df484d1
commit
9e2ef6cc0d
1 file changed
+33
-5
@@ -402,14 +402,42 @@ void AudioEngineInit(int sampleRate, int channelCount) {
|
|||||||
|
|
||||||
+ (void)resetSysAudioPlayback {
|
+ (void)resetSysAudioPlayback {
|
||||||
audioSessionInterrupted = true;
|
audioSessionInterrupted = true;
|
||||||
[audioPlayerNode stop];
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0),
|
||||||
[audioEngine stop];
|
dispatch_get_main_queue(), ^{
|
||||||
AudioEngineInit(audioConfig.sampleRate, audioConfig.channelCount);
|
@try {
|
||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5*NSEC_PER_SEC), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
if (audioPlayerNode) {
|
||||||
audioSessionInterrupted = false;
|
[audioPlayerNode stop];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (audioEngine) {
|
||||||
|
[audioEngine stop];
|
||||||
|
[audioEngine reset];
|
||||||
|
|
||||||
|
if (audioPlayerNode) {
|
||||||
|
[audioEngine disconnectNodeInput:audioPlayerNode];
|
||||||
|
[audioEngine disconnectNodeOutput:audioPlayerNode];
|
||||||
|
[audioEngine detachNode:audioPlayerNode];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
audioEngine = nil;
|
||||||
|
audioPlayerNode = nil;
|
||||||
|
|
||||||
|
AudioEngineInit(audioConfig.sampleRate, audioConfig.channelCount);
|
||||||
|
}
|
||||||
|
@catch (NSException *exception) {
|
||||||
|
NSLog(@"resetSysAudioPlayback failed: %@, reason: %@",
|
||||||
|
exception.name,
|
||||||
|
exception.reason);
|
||||||
|
}
|
||||||
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)),
|
||||||
|
dispatch_get_main_queue(), ^{
|
||||||
|
audioSessionInterrupted = false;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ArDecodeAndPlaySample(char* sampleData, int sampleLength)
|
void ArDecodeAndPlaySample(char* sampleData, int sampleLength)
|
||||||
{
|
{
|
||||||
if(appDidEnterBackgroundWithoutPip && muteInBackground) return;
|
if(appDidEnterBackgroundWithoutPip && muteInBackground) return;
|
||||||
|
|||||||
Reference in new issue
Block a user