Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-07-04 10:01:07 +02:00
commit 39a1576399
3 changed files with 15 additions and 14 deletions

View file

@ -182,7 +182,7 @@ public class VoiceRouter {
}
// Trigger close prompts earlier to allow for BT SCO connection delay
if (settings.AUDIO_STREAM_GUIDANCE.get() == 0) {
if ((settings.AUDIO_STREAM_GUIDANCE.get() == 0) && !AbstractPrologCommandPlayer.btScoStatus) {
btScoDelayDistance = currentSpeed * (double) AbstractPrologCommandPlayer.BT_SCO_DELAY / 1000;
}

View file

@ -307,7 +307,7 @@ public abstract class AbstractPrologCommandPlayer implements CommandPlayer, Stat
}
}
private static boolean btScoStatus = false;
public static boolean btScoStatus = false;
public static final int BT_SCO_DELAY = 1500;

View file

@ -92,7 +92,7 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
* and the call back to onUtteranceCompletedListener(). This allows us to
* optimize use of requesting and abandoning audio focus.
*/
private int ttsRequests;
private static int ttsRequests;
private float cSpeechRate = 1;
// Called from the calculating route thread.
@ -105,19 +105,20 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
}
sendAlertToPebble(bld.toString());
if (mTts != null && !vrt.isMute()) {
if (ttsRequests++ == 0)
if (ttsRequests++ == 0) {
requestAudioFocus();
log.debug("ttsRequests="+ttsRequests);
// Delay prompts to allow BT SCO connection being established
if (ctx.getSettings().AUDIO_STREAM_GUIDANCE.get() == 0) {
ttsRequests++;
if (android.os.Build.VERSION.SDK_INT <= 21) {
params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID,""+System.currentTimeMillis());
mTts.playSilence(BT_SCO_DELAY, TextToSpeech.QUEUE_ADD, params);
} else {
mTts.playSilentUtterance(BT_SCO_DELAY, TextToSpeech.QUEUE_ADD, ""+System.currentTimeMillis());
// Delay prompts to allow BT SCO connection being established
if (ctx.getSettings().AUDIO_STREAM_GUIDANCE.get() == 0) {
ttsRequests++;
if (android.os.Build.VERSION.SDK_INT <= 21) {
params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID,""+System.currentTimeMillis());
mTts.playSilence(BT_SCO_DELAY, TextToSpeech.QUEUE_ADD, params);
} else {
mTts.playSilentUtterance(BT_SCO_DELAY, TextToSpeech.QUEUE_ADD, ""+System.currentTimeMillis());
}
}
}
log.debug("ttsRequests="+ttsRequests);
params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID,""+System.currentTimeMillis());
mTts.speak(bld.toString(), TextToSpeech.QUEUE_ADD, params);
// Audio focus will be released when onUtteranceCompleted() completed is called by the TTS engine.
@ -211,7 +212,7 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
// The call back is on a binder thread.
@Override
public synchronized void onUtteranceCompleted(String utteranceId) {
if (--ttsRequests == 0)
if (--ttsRequests <= 0)
abandonAudioFocus();
log.debug("ttsRequests="+ttsRequests);
}