[6.10.0][Feat]新增排队超时机制
This commit is contained in:
@@ -209,9 +209,12 @@ class IFlyTekTts : IMogoTTS, InitListener {
|
||||
var index = -1
|
||||
for (i in linkedList.indices.reversed()) {
|
||||
val nodeLevel = linkedList[i].second
|
||||
// 只有高优先级才插入到前面,等于的情况下是插到后面
|
||||
if (level > nodeLevel) {
|
||||
if (linkedList[i].first.isTimeout()) {
|
||||
linkedList.removeAt(i)
|
||||
} else if (level > nodeLevel) { // 只有高优先级才插入到前面,等于的情况下是插到后面
|
||||
index = i
|
||||
} else { // 再往前元素优先级更大,直接break
|
||||
break
|
||||
}
|
||||
}
|
||||
if (index >= 0) {
|
||||
@@ -227,6 +230,7 @@ class IFlyTekTts : IMogoTTS, InitListener {
|
||||
|
||||
private fun speakMultiLangTTSWithLevel(ttsEntity: MultiLangTtsEntity, ttsLevel: Int) {
|
||||
ttsEngine?.let {
|
||||
ttsEntity.markTime()
|
||||
if (ttsLevel == curTtsLevel) {
|
||||
// 对应p3、p2级别的排队
|
||||
if (ttsLevel == 0 || ttsLevel == 1) {
|
||||
@@ -379,13 +383,29 @@ class IFlyTekTts : IMogoTTS, InitListener {
|
||||
* 语音合成下一个MultiLangTtsEntity
|
||||
*/
|
||||
private fun ttsNextMultiLangEntity() {
|
||||
if (!linkedList.isEmpty()) {
|
||||
val ttsPair = linkedList.removeFirst()
|
||||
i(TAG, "排队播放的下一条文本为:" + ttsPair.first + ",级别为:" + ttsPair.second)
|
||||
curTtsLevel = ttsPair.second
|
||||
startSpeak(ttsPair.first.ttsNext())
|
||||
var ttsPair: Pair<MultiLangTtsEntity, Int>?
|
||||
val ttsList = linkedList
|
||||
if (!ttsList.isEmpty()) {
|
||||
ttsPair = ttsList.removeFirst()
|
||||
while (ttsPair != null && ttsPair.first.isTimeout()) {
|
||||
if (!ttsList.isEmpty()) {
|
||||
ttsPair = ttsList.removeFirst()
|
||||
} else {
|
||||
ttsPair = null
|
||||
break
|
||||
}
|
||||
}
|
||||
if (ttsPair != null) {
|
||||
i(
|
||||
TAG,
|
||||
"排队播放的下一条文本为:" + ttsPair.first + ",级别为:" + ttsPair.second
|
||||
)
|
||||
speakMultiLangTTSWithLevel(ttsPair.first, ttsPair.second)
|
||||
} else {
|
||||
i(TAG, "未超时的队列为空!")
|
||||
}
|
||||
} else {
|
||||
i(TAG, "队列为空")
|
||||
i(TAG, "队列为空!")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user