fix(audio): 백그라운드 시 SFX 미정지 + GameAudioController 메모리 누수 수정
Some checks failed
CI / analyze-and-test (push) Has been cancelled
Some checks failed
CI / analyze-and-test (push) Has been cancelled
- SfxChannelPool.stopAll() 추가: 모든 SFX 즉시 정지 + 대기열 비우기 - pauseAll()에서 SFX 풀도 정지하도록 변경 - game_play_screen dispose에서 _audioController.dispose() 호출 추가
This commit is contained in:
@@ -364,6 +364,9 @@ class AudioService {
|
|||||||
try {
|
try {
|
||||||
await _staticBgmPlayer?.stop();
|
await _staticBgmPlayer?.stop();
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
|
// SFX도 즉시 정지
|
||||||
|
await _playerSfxPool?.stopAll();
|
||||||
|
await _monsterSfxPool?.stopAll();
|
||||||
_currentBgm = null;
|
_currentBgm = null;
|
||||||
debugPrint('[AudioService] All audio paused (was playing: $_pausedBgm)');
|
debugPrint('[AudioService] All audio paused (was playing: $_pausedBgm)');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,6 +195,22 @@ class SfxChannelPool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 모든 SFX 즉시 정지 및 대기열 비우기
|
||||||
|
Future<void> stopAll() async {
|
||||||
|
_pendingQueue.clear();
|
||||||
|
final players = _staticPlayers[name];
|
||||||
|
final busy = _staticBusy[name];
|
||||||
|
if (players == null) return;
|
||||||
|
for (var i = 0; i < players.length; i++) {
|
||||||
|
try {
|
||||||
|
await players[i].stop();
|
||||||
|
} catch (_) {}
|
||||||
|
if (busy != null && i < busy.length) {
|
||||||
|
busy[i] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// 리소스 해제
|
/// 리소스 해제
|
||||||
Future<void> dispose() async {
|
Future<void> dispose() async {
|
||||||
final players = _staticPlayers[name];
|
final players = _staticPlayers[name];
|
||||||
|
|||||||
@@ -248,6 +248,7 @@ class _GamePlayScreenState extends State<GamePlayScreen>
|
|||||||
void dispose() {
|
void dispose() {
|
||||||
_stateNotifier.dispose();
|
_stateNotifier.dispose();
|
||||||
_notificationService.dispose();
|
_notificationService.dispose();
|
||||||
|
_audioController.dispose();
|
||||||
WidgetsBinding.instance.removeObserver(this);
|
WidgetsBinding.instance.removeObserver(this);
|
||||||
widget.controller.removeListener(_onControllerChanged);
|
widget.controller.removeListener(_onControllerChanged);
|
||||||
widget.controller.onReturnRewardAvailable = null; // Phase 7: 콜백 정리
|
widget.controller.onReturnRewardAvailable = null; // Phase 7: 콜백 정리
|
||||||
|
|||||||
Reference in New Issue
Block a user