Update AudioSessionManager.mm
Signed-off-by: rohithzmoi <166651631+rohithzmoi@users.noreply.github.com>
This commit is contained in:
parent
e45a7b7d14
commit
a335bb630c
|
|
@ -18,6 +18,11 @@
|
|||
#import <AVFoundation/AVFoundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
|
||||
|
||||
extern "C" void AudioEngine_stop_playback();
|
||||
extern "C" void AudioEngine_start_playback();
|
||||
|
||||
static UIBackgroundTaskIdentifier bgTask = UIBackgroundTaskInvalid;
|
||||
|
||||
|
||||
|
|
@ -81,12 +86,18 @@ extern "C" void setupAVAudioSession() {
|
|||
reason == AVAudioSessionRouteChangeReasonNewDeviceAvailable ||
|
||||
reason == AVAudioSessionRouteChangeReasonOverride) {
|
||||
NSLog(@"Audio route change detected, attempting to reactivate...");
|
||||
// Call C++ function to stop playback
|
||||
AudioEngine_stop_playback();
|
||||
NSError *activationError = nil;
|
||||
BOOL reactivationSuccess = [session setActive:YES error:&activationError];
|
||||
AudioEngine_start_playback();
|
||||
if (!reactivationSuccess) {
|
||||
NSLog(@"Error re-activating AVAudioSession after route change: %@, code: %ld", activationError.localizedDescription, (long)activationError.code);
|
||||
} else {
|
||||
NSLog(@"Audio session successfully reactivated after route change");
|
||||
|
||||
// Call C++ function to start playback
|
||||
//AudioEngine_start_playback();
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
|
|
|||
Loading…
Reference in New Issue