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
|
||||
if (settings.AUDIO_STREAM_GUIDANCE.get() == 0) {
|
||||
if ((settings.AUDIO_STREAM_GUIDANCE.get() == 0) && !AbstractPrologCommandPlayer.btScoStatus) {
|
||||
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;
|
||||
|
||||
|
|
|
@ -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,9 +105,8 @@ 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++;
|
||||
|
@ -118,6 +117,8 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
|
|||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue