@@ -26,7 +26,7 @@ public class HXSound {
2626 //private boolean isEnabled; // Used for determining if the sound system is enabled or not.
2727 private int currentEngine ; // Used for determining the active HXSoundEngine instance.
2828 private int numberOfEngines ; // Used for determining the number of HXSoundEngine instances.
29- private HXSoundStatus hxSoundStatus = HXSoundStatus .NOT_READY ; // Used to determine the current status of the sound system.
29+ private HXSoundStatus hxSoundStatus = HXSoundStatus .READY ; // Used to determine the current status of the sound system.
3030 private LinkedList <HXSoundEngine > hxSoundEngines ; // LinkedList object which contains the HXSoundEngine instances.
3131
3232 // CONSTANT VARIABLES:
@@ -39,9 +39,7 @@ public class HXSound {
3939 /** ENUM ___________________________________________________________________________________ **/
4040
4141 private enum HXSoundStatus {
42- NOT_READY ,
4342 READY ,
44- RELEASED ,
4543 DISABLED
4644 }
4745
@@ -128,12 +126,12 @@ public synchronized boolean playSoundFx(int resource, boolean isLooped, Context
128126 return false ;
129127 }
130128
131- if (hxSoundStatus .equals (HXSoundStatus .NOT_READY ) || hxSoundStatus .equals (HXSoundStatus .RELEASED )) {
132- initializeSoundEngines ();
133- }
134-
135129 if (!hxSoundStatus .equals (HXSoundStatus .DISABLED )) {
136130
131+ if (hxSoundEngines == null ) {
132+ initializeSoundEngines ();
133+ }
134+
137135 HXLog .d (LOG_TAG , "SOUND: Attempting to play sound effect on HXSoundEngine (" + currentEngine + ")..." );
138136 hxSoundEngines .get (currentEngine ).prepareSoundFx (resource , isLooped , context );
139137
@@ -243,14 +241,15 @@ private void release() {
243241 HXLog .d (LOG_TAG , "RELEASE: release(): Releasing all HXSoundEngine instances..." );
244242
245243 // Releases all HXSoundEngine instances.
246- int i = 0 ;
247- for (int x : new int [numberOfEngines ]) {
248- hxSoundEngines .get (i ).release ();
249- HXLog .d (LOG_TAG , "RELEASE: release(): HXSoundEngine (" + i + ") is released." );
250- i ++;
244+ if (hxSoundEngines != null ) {
245+ int i = 0 ;
246+ for (int x : new int [numberOfEngines ]) {
247+ hxSoundEngines .get (i ).release ();
248+ HXLog .d (LOG_TAG , "RELEASE: release(): HXSoundEngine (" + i + ") is released." );
249+ i ++;
250+ }
251+ hxSoundEngines = null ;
251252 }
252-
253- hxSoundEngines = null ;
254- hxSoundStatus = HXSoundStatus .RELEASED ;
253+ hxSound = null ;
255254 }
256255}
0 commit comments