From: Nathaniel Wesley Filardo Date: Mon, 4 Jul 2016 22:10:28 +0000 (-0400) Subject: Fixes in Audio{Canvas,Provider} X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=893f1d530ca5f64a9779869d0f72a70a2ac5072b;p=acmetensortoys-watchviz Fixes in Audio{Canvas,Provider} 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. --- diff --git a/vizlib/src/main/java/com/acmetensortoys/watchviz/vizlib/AudioCanvas.java b/vizlib/src/main/java/com/acmetensortoys/watchviz/vizlib/AudioCanvas.java index 6fdae58..fee43b5 100644 --- a/vizlib/src/main/java/com/acmetensortoys/watchviz/vizlib/AudioCanvas.java +++ b/vizlib/src/main/java/com/acmetensortoys/watchviz/vizlib/AudioCanvas.java @@ -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 diff --git a/vizlib/src/main/java/com/acmetensortoys/watchviz/vizlib/AudioProvider.java b/vizlib/src/main/java/com/acmetensortoys/watchviz/vizlib/AudioProvider.java index 7eafa4e..6771c72 100644 --- a/vizlib/src/main/java/com/acmetensortoys/watchviz/vizlib/AudioProvider.java +++ b/vizlib/src/main/java/com/acmetensortoys/watchviz/vizlib/AudioProvider.java @@ -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;