TTS回调:调度完成至1

发布于 2024-10-20 03:36:10 字数 379 浏览 2 评论 0原文

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

03-01 20:47:06.436: 详细/TtsService(381):TTS 回调: 发送完成至 1

再次,这似乎是良性的,但我不明白“1”的含义。所有话语的所有此类行都显示“已完成到 1”,即使对于大于 1 的话语 ID。

“1”在此日志中意味着什么?

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

I created a small TTS app implementing OnUtteranceCompleteListener and, while things seem to be working exactly as expected, I noticed the following on LogCat (one for each completed utterance):

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

Again, this seems to be benign but I don't understand what '1' means. All such lines for all utterances say "completed to 1", even for utterance IDs that are greater than 1.

What does '1' mean in this log?

BTW, this message is not generated by my code but rather by the TTS engine (Pico) itself.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

紫竹語嫣☆ 2024-10-27 03:36:10

查看 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 及其文档指出:

返回回调的数量
广播,与使用
getBroadcastItem(int) 来确定
您可以提供的指数范围

这有帮助吗?

Looking at the TTSService.java source code available at http://eyes-free.googlecode.com you can find the function 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 is the current value of N, which is initialized by the return value from mCallbacks.beginBroadcast().

beginBroadcast() is a method of the class RemoteCallbackList and its documentation states that it:

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

Does this help?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文