@@ -44,6 +44,10 @@ static ALCdevice* s_ALDevice = nullptr;
4444static ALCcontext* s_ALContext = nullptr ;
4545static ax::AudioEngineImpl* s_instance = nullptr ;
4646
47+ #if defined(__APPLE__)
48+ bool __axmolAudioSessionInterrupted = false ;
49+ #endif
50+
4751namespace ax
4852{
4953static void pauseAudioDevice ()
@@ -122,15 +126,14 @@ static void resumeAudioDevice()
122126
123127- (void )handleInterruption:(NSNotification*)notification
124128{
125- static bool isAudioSessionInterrupted = false ;
126- static bool resumeOnBecomingActive = false ;
129+ static bool resumeOnBecomingActive = false ;
127130
128131 if ([notification.name isEqualToString:AVAudioSessionInterruptionNotification])
129132 {
130133 NSInteger reason = [[[notification userInfo] objectForKey:AVAudioSessionInterruptionTypeKey] integerValue];
131134 if (reason == AVAudioSessionInterruptionTypeBegan)
132135 {
133- isAudioSessionInterrupted = true ;
136+ __axmolAudioSessionInterrupted = true ;
134137
135138 AXLOGD (" AVAudioSessionInterruptionTypeBegan, alcMakeContextCurrent(nullptr)" );
136139
@@ -139,7 +142,7 @@ static void resumeAudioDevice()
139142 }
140143 else if (reason == AVAudioSessionInterruptionTypeEnded)
141144 {
142- isAudioSessionInterrupted = false ;
145+ __axmolAudioSessionInterrupted = false ;
143146
144147 if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive)
145148 {
@@ -174,7 +177,7 @@ static void resumeAudioDevice()
174177 if (resumeOnBecomingActive)
175178 {
176179 resumeOnBecomingActive = false ;
177- if (!isAudioSessionInterrupted )
180+ if (!__axmolAudioSessionInterrupted )
178181 ax::pauseAudioDevice ();
179182
180183 AXLOGD (" UIApplicationDidBecomeActiveNotification, resume audio device" );
@@ -189,7 +192,7 @@ static void resumeAudioDevice()
189192
190193 ax::resumeAudioDevice ();
191194 }
192- else if (isAudioSessionInterrupted )
195+ else if (__axmolAudioSessionInterrupted )
193196 {
194197 AXLOGD (" Audio session is still interrupted!" );
195198 }
@@ -851,7 +854,7 @@ void AudioEngineImpl::stop(AUDIO_ID audioID)
851854 return ;
852855
853856 auto player = iter->second ;
854- player->destroy ();
857+ player->stop ();
855858
856859 // Call '_updatePlayersState' method to cleanup immediately since the schedule may be cancelled without any
857860 // notification.
@@ -863,7 +866,7 @@ void AudioEngineImpl::stopAll()
863866 std::lock_guard<std::recursive_mutex> lck (_threadMutex);
864867 for (auto && player : _audioPlayers)
865868 {
866- player.second ->destroy ();
869+ player.second ->stop ();
867870 }
868871 // Note: Don't set the flag to false here, it should be set in 'update' function.
869872 // Otherwise, the state got from alSourceState may be wrong
0 commit comments