[Jrisk-cvs] SF.net SVN: domination-code:[2605] Domination
Brought to you by:
yuranet
|
From: <yu...@us...> - 2024-12-31 03:13:57
|
Revision: 2605
http://sourceforge.net/p/domination/code/2605
Author: yuranet
Date: 2024-12-31 03:13:54 +0000 (Tue, 31 Dec 2024)
Log Message:
-----------
if there is some big issue with playing audio, give up after 10 attempts
Modified Paths:
--------------
Domination/sharedUI/src_mapstore_lobby/net/yura/domination/audio/SimpleAudio.java
Domination/swingUI/lib/midletrunner.jar
Modified: Domination/sharedUI/src_mapstore_lobby/net/yura/domination/audio/SimpleAudio.java
===================================================================
--- Domination/sharedUI/src_mapstore_lobby/net/yura/domination/audio/SimpleAudio.java 2024-12-28 00:50:03 UTC (rev 2604)
+++ Domination/sharedUI/src_mapstore_lobby/net/yura/domination/audio/SimpleAudio.java 2024-12-31 03:13:54 UTC (rev 2605)
@@ -24,7 +24,8 @@
Map<String, Player> currentMusicPlayers = new HashMap(); // filename -> player
- private boolean outOfMemoryError;
+ private int consecutiveStartErrors;
+ private boolean fatalAudioSystemError;
/**
* we need a single thread for starting and stopping music
@@ -71,7 +72,7 @@
}
public void play(final String fileName) {
- if (outOfMemoryError) return;
+ if (fatalAudioSystemError) return;
purge(soundThread.getQueue(), fileName);
@@ -84,12 +85,12 @@
player = getPlayer(fileName);
player.addPlayerListener(SimpleAudio.this);
player.start(); // can throw oom
+ consecutiveStartErrors = 0;
}
catch (Exception ex) {
startError(fileName, player, ex);
}
catch (Error oom) { // OutOfMemoryError and NoClassDefFoundError
- outOfMemoryError = true;
startError(fileName, player, oom);
}
}
@@ -106,7 +107,7 @@
*/
@Override
public void start(final String fileName) {
- if (outOfMemoryError) return;
+ if (fatalAudioSystemError) return;
purge(musicThread.getQueue(), fileName);
@@ -119,12 +120,12 @@
player.setLoopCount(-1);
currentMusicPlayers.put(fileName, player);
player.start(); // can throw oom
+ consecutiveStartErrors = 0;
}
catch (Exception ex) {
startError(fileName, player, ex);
}
catch (Error oom) { // OutOfMemoryError and NoClassDefFoundError
- outOfMemoryError = true;
startError(fileName, player, oom);
}
}
@@ -136,6 +137,15 @@
}
private void startError(String fileName, Player player, Throwable ex) {
+ consecutiveStartErrors++;
+ if (ex instanceof Error) { // OutOfMemoryError and NoClassDefFoundError
+ fatalAudioSystemError = true;
+ }
+ if (consecutiveStartErrors > 10) {
+ // we can get some very random errors, maybe the computer has no sound card
+ // java.lang.IllegalArgumentException: No line matching interface Clip supporting format PCM_SIGNED unknown sample rate, 16 bit, stereo, 4 bytes/frame, big-endian is supported.
+ fatalAudioSystemError = true;
+ }
LOGGER.log(Level.WARNING, "unable to play " + fileName, ex);
try {
currentMusicPlayers.remove(fileName);
Modified: Domination/swingUI/lib/midletrunner.jar
===================================================================
(Binary files differ)
|