23
23
24
24
package com .iluwatar .event .queue ;
25
25
26
+ import org .slf4j .Logger ;
27
+ import org .slf4j .LoggerFactory ;
28
+
26
29
import java .io .File ;
27
30
import java .io .IOException ;
28
31
38
41
*
39
42
*/
40
43
public class Audio {
44
+ private static final Logger LOGGER = LoggerFactory .getLogger (Audio .class );
45
+ private static final Audio INSTANCE = new Audio ();
41
46
42
47
private static final int MAX_PENDING = 16 ;
43
48
@@ -55,7 +60,7 @@ public class Audio {
55
60
}
56
61
57
62
public static Audio getInstance () {
58
- return SingletonHolder . getAudioInstance () ;
63
+ return INSTANCE ;
59
64
}
60
65
61
66
/**
@@ -141,14 +146,11 @@ private void update() {
141
146
clip .open (audioStream );
142
147
clip .start ();
143
148
} catch (LineUnavailableException e ) {
144
- System .err .println ("Error occoured while loading the audio: The line is unavailable" );
145
- e .printStackTrace ();
149
+ LOGGER .trace ("Error occoured while loading the audio: The line is unavailable" , e );
146
150
} catch (IOException e ) {
147
- System .err .println ("Input/Output error while loading the audio" );
148
- e .printStackTrace ();
151
+ LOGGER .trace ("Input/Output error while loading the audio" , e );
149
152
} catch (IllegalArgumentException e ) {
150
- System .err .println ("The system doesn't support the sound: " + e .getMessage ());
151
- e .printStackTrace ();
153
+ LOGGER .trace ("The system doesn't support the sound: " + e .getMessage (), e );
152
154
}
153
155
}
154
156
@@ -172,11 +174,4 @@ public PlayMessage[] getPendingAudio() {
172
174
return pendingAudio ;
173
175
}
174
176
175
- private static class SingletonHolder {
176
- private static final Audio INSTANCE = new Audio ();
177
-
178
- static Audio getAudioInstance () {
179
- return INSTANCE ;
180
- }
181
- }
182
177
}
0 commit comments