add silence only to first BT SCO prompt of each batch
This commit is contained in:
parent
967e7a13d0
commit
f77a3d5f6b
3 changed files with 15 additions and 14 deletions
|
@ -182,7 +182,7 @@ public class VoiceRouter {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trigger close prompts earlier to allow for BT SCO connection delay
|
// 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;
|
btScoDelayDistance = currentSpeed * (double) AbstractPrologCommandPlayer.BT_SCO_DELAY / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
public static final int BT_SCO_DELAY = 1500;
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
|
||||||
* and the call back to onUtteranceCompletedListener(). This allows us to
|
* and the call back to onUtteranceCompletedListener(). This allows us to
|
||||||
* optimize use of requesting and abandoning audio focus.
|
* optimize use of requesting and abandoning audio focus.
|
||||||
*/
|
*/
|
||||||
private int ttsRequests;
|
private static int ttsRequests;
|
||||||
private float cSpeechRate = 1;
|
private float cSpeechRate = 1;
|
||||||
|
|
||||||
// Called from the calculating route thread.
|
// Called from the calculating route thread.
|
||||||
|
@ -105,19 +105,20 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
|
||||||
}
|
}
|
||||||
sendAlertToPebble(bld.toString());
|
sendAlertToPebble(bld.toString());
|
||||||
if (mTts != null && !vrt.isMute()) {
|
if (mTts != null && !vrt.isMute()) {
|
||||||
if (ttsRequests++ == 0)
|
if (ttsRequests++ == 0) {
|
||||||
requestAudioFocus();
|
requestAudioFocus();
|
||||||
log.debug("ttsRequests="+ttsRequests);
|
// Delay prompts to allow BT SCO connection being established
|
||||||
// Delay prompts to allow BT SCO connection being established
|
if (ctx.getSettings().AUDIO_STREAM_GUIDANCE.get() == 0) {
|
||||||
if (ctx.getSettings().AUDIO_STREAM_GUIDANCE.get() == 0) {
|
ttsRequests++;
|
||||||
ttsRequests++;
|
if (android.os.Build.VERSION.SDK_INT <= 21) {
|
||||||
if (android.os.Build.VERSION.SDK_INT <= 21) {
|
params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID,""+System.currentTimeMillis());
|
||||||
params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID,""+System.currentTimeMillis());
|
mTts.playSilence(BT_SCO_DELAY, TextToSpeech.QUEUE_ADD, params);
|
||||||
mTts.playSilence(BT_SCO_DELAY, TextToSpeech.QUEUE_ADD, params);
|
} else {
|
||||||
} else {
|
mTts.playSilentUtterance(BT_SCO_DELAY, TextToSpeech.QUEUE_ADD, ""+System.currentTimeMillis());
|
||||||
mTts.playSilentUtterance(BT_SCO_DELAY, TextToSpeech.QUEUE_ADD, ""+System.currentTimeMillis());
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.debug("ttsRequests="+ttsRequests);
|
||||||
params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID,""+System.currentTimeMillis());
|
params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID,""+System.currentTimeMillis());
|
||||||
mTts.speak(bld.toString(), TextToSpeech.QUEUE_ADD, params);
|
mTts.speak(bld.toString(), TextToSpeech.QUEUE_ADD, params);
|
||||||
// Audio focus will be released when onUtteranceCompleted() completed is called by the TTS engine.
|
// 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.
|
// The call back is on a binder thread.
|
||||||
@Override
|
@Override
|
||||||
public synchronized void onUtteranceCompleted(String utteranceId) {
|
public synchronized void onUtteranceCompleted(String utteranceId) {
|
||||||
if (--ttsRequests == 0)
|
if (--ttsRequests <= 0)
|
||||||
abandonAudioFocus();
|
abandonAudioFocus();
|
||||||
log.debug("ttsRequests="+ttsRequests);
|
log.debug("ttsRequests="+ttsRequests);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue