gpt4 book ai didi

android - TTS 回调 : dispatch completed to 1

转载 作者:行者123 更新时间:2023-11-30 04:45:12 26 4
gpt4 key购买 nike

我创建了一个实现 OnUtteranceCompleteListener 的小型 TTS 应用程序,虽然一切似乎都按预期工作,但我在 LogCat 上注意到以下内容(每个完成的话语一个):

03-01 20:47:06.436: VERBOSE/TtsService(381): TTS callback: dispatch completed to 1

同样,这似乎是良性的,但我不明白“1”是什么意思。所有话语的所有此类行都表示“完成到 1”,即使对于大于 1 的话语 ID 也是如此。

此日志中的“1”是什么意思?

顺便说一句,这条消息不是由我的代码生成的,而是由 TTS 引擎 (Pico) 本身生成的。

最佳答案

查看 TTSService.java源代码可在 http://eyes-free.googlecode.com 获得你可以找到函数dispatchUtteranceCompletedCallback():

private void dispatchUtteranceCompletedCallback(String utteranceId, String packageName) {
/* Legacy support for TTS */
final int oldN = mCallbacksOld.beginBroadcast();
for (int i = 0; i < oldN; i++) {
try {
mCallbacksOld.getBroadcastItem(i).markReached("");
} catch (RemoteException e) {
// The RemoteCallbackList will take care of removing
// the dead object for us.
}
}
try {
mCallbacksOld.finishBroadcast();
} catch (IllegalStateException e) {
// May get an illegal state exception here if there is only
// one app running and it is trying to quit on completion.
// This is the exact scenario triggered by MakeBagel
return;
}
/* End of legacy support for TTS */
ITtsCallbackBeta cb = mCallbacksMap.get(packageName);
if (cb == null) {
return;
}
Log.v(SERVICE_TAG, "TTS callback: dispatch started");
// Broadcast to all clients the new value.
final int N = mCallbacks.beginBroadcast();
try {
cb.utteranceCompleted(utteranceId);
} catch (RemoteException e) {
// The RemoteCallbackList will take care of removing
// the dead object for us.
}
mCallbacks.finishBroadcast();
Log.v(SERVICE_TAG, "TTS callback: dispatch completed to " + N);
}

1为N的当前值,由mCallbacks.beginBroadcast()的返回值初始化。

beginBroadcast()是类 RemoteCallbackList 的方法其文档说明它:

Returns the number of callbacks in the broadcast, to be used with getBroadcastItem(int) to determine the range of indices you can supply

这有帮助吗?

关于android - TTS 回调 : dispatch completed to 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5162682/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com