2

OpenSL ES を使用して音楽プレーヤーを作成しました。ライブラリから警告メッセージが1つ出てくる以外は問題なく動作しlibOpenSLESます。これがメッセージです。

03-05 00:10:15.367: W/libOpenSLES(12055): Missed SL_PLAYEVENT_HEADATNEWPOS for position 7000; current position 724009
...
03-05 00:10:27.226: W/libOpenSLES(12055): Missed SL_PLAYEVENT_HEADATNEWPOS for position 329015; current position 816013

メディアトラックを探しているときに来ます。警告なしでシークできる場合もあれば、ログにメッセージが表示される場合もあります。

実装は非常に簡単です。初期化時に、シーク コントロールを取得します。

SLObjectItf decoder;
SLSeekItf seek;
...

SLresult result = (*decoder)->GetInterface(decoder, SL_IID_SEEK, &seek);

その後、ユーザーがトラック位置を変更すると、次のようにSetPositionメソッドを呼び出します。

SLresult result = (*seek)->SetPosition(seek, position, SL_SEEKMODE_ACCURATE);

どちらの呼び出しも成功の結果を返し、位置の変更も常に機能します。唯一の問題は、上記の警告メッセージです。

このメッセージが表示される理由とそれを回避する方法はありますか?

アップデート:

賞金の半分は自動的に割り当てられましたが、質問にはまだ答えがありません。問題の原因と回避方法はわかりません。

4

1 に答える 1

2

そのログ メッセージの一部を Google で簡単に検索すると、次のコード スニップが見つかりました。ログの印刷はここの真ん中にあります (完全なソース)。

    // nextVirtualMarkerMs will be set to the position of the next upcoming virtual marker
    int32_t nextVirtualMarkerMs;
    if (mObservedPositionMs <= virtualMarkerMs && virtualMarkerMs <= positionMs) {
        // we did pass through the virtual marker, now compute the next virtual marker
        mDeliveredNewPosMs = virtualMarkerMs;
        nextVirtualMarkerMs = virtualMarkerMs + mPositionUpdatePeriodMs;
        // re-synchronize if we missed an update
        if (nextVirtualMarkerMs <= positionMs) {
            SL_LOGW("Missed SL_PLAYEVENT_HEADATNEWPOS for position %d; current position %d",
                    nextVirtualMarkerMs, positionMs);
            // try to catch up by setting next goal to current position plus update period
            mDeliveredNewPosMs = positionMs;
            nextVirtualMarkerMs = positionMs + mPositionUpdatePeriodMs;
        }
        notify(PLAYEREVENT_PLAY, (int32_t) SL_PLAYEVENT_HEADATNEWPOS, true /*async*/);

検索で特定のポイントを通過すると、追いつく必要があり (ジャンプ)、おそらく更新が見逃されました。これがログに示されていることであり、マーカーの位置を再同期する必要があります。

更新 上記のコード スニップ全体は、コードを正しく解釈する場合のワンショット (安定した一時的な状態) の一時停止時間を計算するためのものです。ワンショットの定義、行 116 :

    // deferred (non-0 timeout) handler for SL_PLAYEVENT_*
    // As used here, "one-shot" is the software equivalent of a "retriggerable monostable
    // multivibrator" from electronics.  Briefly, a one-shot is a timer that can be triggered
    // to fire at some point in the future.  It is "retriggerable" because while the timer
    // is active, it is possible to replace the current timeout value by a new value.
    // This is done by cancelling the current timer (using a generation count),
    // and then posting another timer with the new desired value.

そして、コードが追いつくために頻繁にジャンプするため、ログメッセージが表示されると思います。そんなに頻繁にジャンプしないようにしますか?ちなみに警告ログです、次回はこのコードパスで追いつきます。

于 2014-03-07T19:28:17.767 に答える