refactor(audio): 오디오 서비스 정리 및 SFX 풀 개선
This commit is contained in:
@@ -174,7 +174,8 @@ class AudioService {
|
||||
return;
|
||||
} catch (e) {
|
||||
debugPrint(
|
||||
'[AudioService] BGM player attempt ${attempt + 1} failed: $e');
|
||||
'[AudioService] BGM player attempt ${attempt + 1} failed: $e',
|
||||
);
|
||||
_staticBgmPlayer = null;
|
||||
if (attempt == maxRetries - 1) {
|
||||
debugPrint('[AudioService] BGM disabled');
|
||||
@@ -269,7 +270,9 @@ class AudioService {
|
||||
// "Loading interrupted"는 새 BGM 요청으로 인한 정상 중단
|
||||
if (errorStr.contains('Loading interrupted') ||
|
||||
errorStr.contains('abort')) {
|
||||
debugPrint('[AudioService] BGM $name loading interrupted (new request)');
|
||||
debugPrint(
|
||||
'[AudioService] BGM $name loading interrupted (new request)',
|
||||
);
|
||||
return; // 플레이어 재생성 불필요
|
||||
}
|
||||
|
||||
|
||||
@@ -12,11 +12,8 @@ import 'package:just_audio/just_audio.dart';
|
||||
///
|
||||
/// 플레이어 인스턴스를 static으로 관리하여 핫 리로드에서도 안전합니다.
|
||||
class SfxChannelPool {
|
||||
SfxChannelPool({
|
||||
required this.name,
|
||||
this.poolSize = 4,
|
||||
double volume = 0.8,
|
||||
}) : _volume = volume;
|
||||
SfxChannelPool({required this.name, this.poolSize = 4, double volume = 0.8})
|
||||
: _volume = volume;
|
||||
|
||||
/// 채널명 (디버그용)
|
||||
final String name;
|
||||
@@ -76,7 +73,8 @@ class SfxChannelPool {
|
||||
// 기존 플레이어가 있으면 재사용 (핫 리로드 대응)
|
||||
if (_staticPlayers[name]!.isNotEmpty) {
|
||||
debugPrint(
|
||||
'[SfxChannelPool:$name] Reusing ${_staticPlayers[name]!.length} existing players');
|
||||
'[SfxChannelPool:$name] Reusing ${_staticPlayers[name]!.length} existing players',
|
||||
);
|
||||
_staticInitialized[name] = true;
|
||||
completer.complete();
|
||||
return;
|
||||
@@ -96,9 +94,12 @@ class SfxChannelPool {
|
||||
if (successCount > 0) {
|
||||
_staticInitialized[name] = true;
|
||||
debugPrint(
|
||||
'[SfxChannelPool:$name] Initialized with $successCount/$poolSize players');
|
||||
'[SfxChannelPool:$name] Initialized with $successCount/$poolSize players',
|
||||
);
|
||||
} else {
|
||||
debugPrint('[SfxChannelPool:$name] All players failed - audio disabled');
|
||||
debugPrint(
|
||||
'[SfxChannelPool:$name] All players failed - audio disabled',
|
||||
);
|
||||
}
|
||||
|
||||
completer.complete();
|
||||
@@ -140,7 +141,8 @@ class SfxChannelPool {
|
||||
return player;
|
||||
} catch (e) {
|
||||
debugPrint(
|
||||
'[SfxChannelPool:$name] Player $index attempt ${attempt + 1} failed: $e');
|
||||
'[SfxChannelPool:$name] Player $index attempt ${attempt + 1} failed: $e',
|
||||
);
|
||||
if (attempt == maxRetries - 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user