From f16db6c958627ddb5f29b5a0b914dcd58047373a Mon Sep 17 00:00:00 2001 From: sonora Date: Mon, 25 Jul 2016 14:20:18 +0200 Subject: [PATCH] force re-init players after stop() to ckeck impact on 2810 --- OsmAnd/src/net/osmand/plus/OsmandApplication.java | 3 --- OsmAnd/src/net/osmand/plus/voice/MediaCommandPlayerImpl.java | 5 +++++ OsmAnd/src/net/osmand/plus/voice/TTSCommandPlayerImpl.java | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index cf4d58233f..f6a032f856 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -410,9 +410,6 @@ public class OsmandApplication extends MultiDexApplication { } } else { - // Test for Issues #1351 and #2810 - //player = null; - if (player == null || !Algorithms.objectEquals(voiceProvider, player.getCurrentVoice()) || force) { appInitializer.initVoiceDataInDifferentThread(uiContext, voiceProvider, run, showDialog); } diff --git a/OsmAnd/src/net/osmand/plus/voice/MediaCommandPlayerImpl.java b/OsmAnd/src/net/osmand/plus/voice/MediaCommandPlayerImpl.java index f01124f48f..0ec76cf37c 100644 --- a/OsmAnd/src/net/osmand/plus/voice/MediaCommandPlayerImpl.java +++ b/OsmAnd/src/net/osmand/plus/voice/MediaCommandPlayerImpl.java @@ -61,6 +61,11 @@ public class MediaCommandPlayerImpl extends AbstractPrologCommandPlayer implemen if (mediaPlayer != null){ mediaPlayer.stop(); } + // TODO: Issue #2810: Audio focus issues when ongoing prompt is interrupted by stop(), i.e. when off-route is detected. Temp workaround is to nullify and always re-init player. + //if (ctx != null && ctx.getSettings().AUDIO_STREAM_GUIDANCE.get() == 0) { + mediaPlayer.release(); + mediaPlayer = null; + //} if (ctx != null) { abandonAudioFocus(); } diff --git a/OsmAnd/src/net/osmand/plus/voice/TTSCommandPlayerImpl.java b/OsmAnd/src/net/osmand/plus/voice/TTSCommandPlayerImpl.java index 79453d6490..a72e7dc179 100644 --- a/OsmAnd/src/net/osmand/plus/voice/TTSCommandPlayerImpl.java +++ b/OsmAnd/src/net/osmand/plus/voice/TTSCommandPlayerImpl.java @@ -134,6 +134,10 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer { if (mTts != null){ mTts.stop(); } + // TODO: Issue #2810: Audio focus issues when ongoing prompt is interrupted by stop(), i.e. when off-route is detected. Temp workaround is to nullify and always re-init player. + //if (ctx != null && ctx.getSettings().AUDIO_STREAM_GUIDANCE.get() == 0) { + mTts = null; + //} if (ctx != null) { abandonAudioFocus(); }