@@ -23,10 +23,9 @@ public class HXSound {
2323 private static HXSound hxSound ; // HXSound instance variable.
2424
2525 // AUDIO VARIABLES:
26- // private boolean isEnabled; // Used for determining if the sound system is enabled or not.
26+ 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 .READY ; // Used to determine the current status of the sound system.
3029 private LinkedList <HXSoundEngine > hxSoundEngines ; // LinkedList object which contains the HXSoundEngine instances.
3130
3231 // CONSTANT VARIABLES:
@@ -36,13 +35,6 @@ public class HXSound {
3635 // LOGGING VARIABLES:
3736 private static final String LOG_TAG = HXSound .class .getSimpleName ();
3837
39- /** ENUM ___________________________________________________________________________________ **/
40-
41- private enum HXSoundStatus {
42- READY ,
43- DISABLED
44- }
45-
4638 /** INSTANCE METHOD ________________________________________________________________________ **/
4739
4840 // instance(): Returns the hxSound instance.
@@ -90,7 +82,6 @@ private void initializeSoundEngines() {
9082 i ++;
9183 }
9284
93- hxSoundStatus = HXSoundStatus .READY ;
9485 HXLog .d (LOG_TAG , "BUILD: All HXSoundEngines are ready." );
9586 }
9687
@@ -126,7 +117,7 @@ public synchronized boolean playSoundFx(int resource, boolean isLooped, Context
126117 return false ;
127118 }
128119
129- if (! hxSoundStatus . equals ( HXSoundStatus . DISABLED ) ) {
120+ if (isEnabled ) {
130121
131122 if (hxSoundEngines == null ) {
132123 initializeSoundEngines ();
@@ -195,7 +186,7 @@ public static void resumeSounds() {
195186 // clear(): Releases resources held by this singleton and other objects associated with this
196187 // object. This method should be called when the singleton object is no longer in use.
197188 public static void clear () {
198- if (hxSound != null ) {
189+ if (hxSound != null && hxSound . hxSoundEngines != null ) {
199190 hxSound .release ();
200191 hxSound = null ;
201192 }
@@ -204,12 +195,7 @@ public static void clear() {
204195 // enable(): Used to enable or disable the HXSound system.
205196 public static void enable (boolean isEnabled ) {
206197 instance ();
207-
208- if (isEnabled ) {
209- hxSound .hxSoundStatus = HXSoundStatus .READY ;
210- } else {
211- hxSound .hxSoundStatus = HXSoundStatus .DISABLED ;
212- }
198+ hxSound .isEnabled = isEnabled ;
213199 }
214200
215201 // engines(): Specifies the number of sound engine instances to be enabled. This feature is only
@@ -241,15 +227,12 @@ private void release() {
241227 HXLog .d (LOG_TAG , "RELEASE: release(): Releasing all HXSoundEngine instances..." );
242228
243229 // Releases all HXSoundEngine instances.
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 ;
230+ int i = 0 ;
231+ for (int x : new int [numberOfEngines ]) {
232+ hxSoundEngines .get (i ).release ();
233+ HXLog .d (LOG_TAG , "RELEASE: release(): HXSoundEngine (" + i + ") is released." );
234+ i ++;
252235 }
253- hxSound = null ;
236+ hxSoundEngines = null ;
254237 }
255238}
0 commit comments