Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions lib/funcs/local_pk_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ class PKServer with ChangeNotifier{
bool get connected => _connection?.connectionState == RTCPeerConnectionState.RTCPeerConnectionStateConnected;
String? connectpwd;

@override
void dispose() {
disconnect();
super.dispose();
}

Future<void> initHost(bool isHoster, BuildContext context, {String? offer}) async {
isServer = isHoster;

Expand Down Expand Up @@ -108,7 +114,7 @@ class PKServer with ChangeNotifier{
};

// 增加超时保护(某些网络下可能收不到完成信号)
return completer.future.timeout(const Duration(minutes: 1), onTimeout: () async {
return completer.future.timeout(const Duration(seconds: 15), onTimeout: () async {
logger.info("ICE 收集超时,尝试使用当前收集到的 Candidate");
String sdp = (await _connection!.getLocalDescription())!.sdp!;
sdp = optimizeSdp(sdp);
Expand Down Expand Up @@ -239,7 +245,7 @@ class PKServer with ChangeNotifier{
if(message == "ping") {
logger.finer("[$packageid] 回复心跳包");
_channel!.send(RTCDataChannelMessage("pong"));
Future.delayed(Duration(seconds: 1), (){
Future.delayed(Duration(seconds: 5), (){
if(_channel?.state == RTCDataChannelState.RTCDataChannelOpen) {
logger.finer("发送心跳包");
_channel!.send(RTCDataChannelMessage("ping"));
Expand Down Expand Up @@ -378,9 +384,6 @@ class PKServer with ChangeNotifier{
pkState.sideTookenTime = data["tookenTime"];
over = true;
}
if(pkState.selfTookenTime != null && pkState.sideTookenTime != null) {
disconnect();
}
notifyListeners();
}
}
Expand Down
6 changes: 3 additions & 3 deletions lib/vars/global.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ class Global with ChangeNotifier {
Future<void> refreshApp() async {
logger.info("应用设置中");
AppData appData = AppData();
if(AppData().config.audio.audioSource == 2) await appData.loadTTS(AppData().config.audio.playRate);
if(AppData().config.egg.stella) await appData.loadEggs();
if(appData.config.audio.audioSource == 2) await appData.loadTTS(appData.config.audio.playRate);
if(appData.config.egg.stella) await appData.loadEggs();
changeLoggerBehavior();
updateTheme();
notifyListeners();
Expand Down Expand Up @@ -195,7 +195,7 @@ class AppData {

// load TTS model if any
Future<void> loadTTS(double playRate) async {
if(kIsWeb || vitsTTS != null || modelTTSDownloaded) return;
if(kIsWeb || vitsTTS != null || !modelTTSDownloaded) return;
logger.info("TTS: 加载本地TTS中");
sherpa_onnx.initBindings();
final vits = sherpa_onnx.OfflineTtsVitsModelConfig(
Expand Down
Loading