diff android-project/src/org/libsdl/app/SDLActivity.java @ 4996:8d7315668e35

Fixed audio buffer lifecycle and implemented audio shutdown
author Sam Lantinga <slouken@libsdl.org>
date Thu, 13 Jan 2011 12:32:55 -0800
parents 9f9bea41e88f
children a514bfe6952a
line wrap: on
line diff
--- a/android-project/src/org/libsdl/app/SDLActivity.java	Thu Jan 13 11:14:20 2011 -0800
+++ b/android-project/src/org/libsdl/app/SDLActivity.java	Thu Jan 13 12:32:55 2011 -0800
@@ -139,7 +139,7 @@
                 i += result;
             } else if (result == 0) {
                 try {
-                    Thread.sleep(10);
+                    Thread.sleep(1);
                 } catch(InterruptedException e) {
                     // Nom nom
                 }
@@ -157,7 +157,7 @@
                 i += result;
             } else if (result == 0) {
                 try {
-                    Thread.sleep(10);
+                    Thread.sleep(1);
                 } catch(InterruptedException e) {
                     // Nom nom
                 }
@@ -168,6 +168,23 @@
         }
     }
 
+    public static void audioQuit() {
+        if (mAudioThread != null) {
+            try {
+                mAudioThread.join();
+            } catch(Exception e) {
+                Log.v("SDL", "Problem stopping audio thread: " + e);
+            }
+            mAudioThread = null;
+
+            Log.v("SDL", "Finished waiting for audio thread");
+        }
+
+        if (mAudioTrack != null) {
+            mAudioTrack.stop();
+            mAudioTrack = null;
+        }
+    }
 }
 
 /**
@@ -233,13 +250,11 @@
 
         // Now wait for the SDL thread to quit
         if (mSDLThread != null) {
-            //synchronized (mSDLThread) {
-                try {
-                    mSDLThread.join();
-                } catch(Exception e) {
-                    Log.v("SDL", "Problem stopping thread: " + e);
-                }
-            //}
+            try {
+                mSDLThread.join();
+            } catch(Exception e) {
+                Log.v("SDL", "Problem stopping thread: " + e);
+            }
             mSDLThread = null;
 
             //Log.v("SDL", "Finished waiting for SDL thread");