]> hydra-www.ietfng.org Git - acmetensortoys-watchviz/commitdiff
Fixes in Audio{Canvas,Provider}
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Mon, 4 Jul 2016 22:10:28 +0000 (18:10 -0400)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Mon, 4 Jul 2016 22:10:28 +0000 (18:10 -0400)
Notably "stop" and "release" had gotten lost somewhere along the way.
While here, catch some behavior that seems to happen only at crashing,
just to keep the logs saner.

vizlib/src/main/java/com/acmetensortoys/watchviz/vizlib/AudioCanvas.java
vizlib/src/main/java/com/acmetensortoys/watchviz/vizlib/AudioProvider.java

index 6fdae5852b5674742de479262caf80d038402376..fee43b59204888de14dc4610198564b1fad350da 100644 (file)
@@ -43,7 +43,17 @@ public class AudioCanvas implements Renderer {
                                     mAp.remove(this);
                                 }
                             }
-                            Canvas cv = h.lockCanvas();
+                            final Canvas cv;
+                            try {
+                                cv = h.lockCanvas();
+                            } catch (IllegalArgumentException iae) {
+                                // Canvas must not exist and we have just somehow missed the
+                                // destroy callback (this sometimes appears to happen when the
+                                // application is in the midst of crashing).  Go ahead and
+                                // unsubscribe us, so the messages at least stop happening.
+                                mAp.remove(this);
+                                return;
+                            }
                             if (cv == null) {
                                 // the surface must have been destroyed out from under us;
                                 // just stop here, on the presumption that we will be
index 7eafa4ecf812d4065410c19795df04002e5666f9..6771c727152c1f685ea6bc444200e61ff4348a45 100644 (file)
@@ -85,6 +85,8 @@ public class AudioProvider {
                         ar.onAudio(samples, fft);
                     }
                 }
+                ar.stop();
+                ar.release();
             }
         };
         audioSourceThread.start();
@@ -97,6 +99,7 @@ public class AudioProvider {
                 try {
                     audioSourceThread.join();
                 } catch (InterruptedException ie) {
+                    Log.w("AudioProvider", "join interrupted");
                     ;
                 } finally {
                     audioSourceThread = null;