1

私は最近、Qt Game Enablerライブラリを発見し、Qt コンポーネントを使用する私の Symbian プロジェクトで使用したいと考えました。

ライブラリのオーディオ部分だけを取得することに成功し、Ogg Vorbis ファイルを小さな問題で再生できました。ファイルを再生して初めて最後に到達すると、最初に戻るのではなく (無限にループするように設定しているため)、数秒戻って最後まで再生されます。2 回目に終了すると、正しく最初に戻り、サイクル全体が再び開始されます (最後に移動し、数秒戻って、再び最後に移動し、最初に戻るなど)。前方へ)。

コード内で数秒戻ることを決定した場所を見つけることができましたが、変更を加えるのに十分な知識がありません。

ソース ファイルは VorbisSource と呼ばれ、GameEnabler::AudioSource です。オーディオを再生する関連ソース コードは次のとおりです。

unsigned int channelLength(m_decoder->decodedLength() - 2);
unsigned int samplesToWrite(bufferLength / 2);
unsigned int amount(0);
unsigned int totalMixed(0);

while (samplesToWrite > 0) {
    unsigned int samplesLeft;

    if (m_fixedInc == 0) {
        // No speed set. Will lead to division by zero error if not set.
        setSpeed(GEDefaultAudioSpeed);
    }

    samplesLeft = m_fixedInc > 0 ? channelLength - (m_fixedPos >> 12) :
        (m_fixedPos >> 12);

    // This is how much we can mix at least.
    unsigned int maxMixAmount = (int)(((long long int)(samplesLeft) << 12) /
                             qAbs(m_fixedInc));

    if (maxMixAmount > samplesToWrite) {
        maxMixAmount = samplesToWrite;
    }

    if (maxMixAmount > 0) {
        amount = mixBlock(target+totalMixed * 2, maxMixAmount);

        if (amount == 0) {
            // Error!
            break;
        }

        totalMixed += amount;
    }
    else {
        amount = 0;
        m_fixedPos = m_fixedInc > 0 ? channelLength<<12 : 0; // <------------------------------- THIS IS WHERE THE PROBLEM IS
    }

    // The sample ended. Check the looping variables and see what to do.
    if ((m_fixedPos >> 12) >= channelLength || m_fixedPos <= 0) {
        m_fixedPos += m_fixedInc > 0 ? -((qint64)channelLength << 12) :
            ((qint64)channelLength << 12);

        if (m_loopCount > 0)
            m_loopCount--;

        if (m_loopCount == 0) {
            // No more loops, stop the sample and return the amount of
            // samples already mixed.
            stop();
            break;
        }
    }

    samplesToWrite -= amount;

    if (samplesToWrite < 1)
        break;
}

ある時点で maxMixAmount がゼロに設定され (これはファイルの末尾にあると思われます)、サウンドを終了する代わりに、次のコード行に従って数秒戻ります。

m_fixedPos = m_fixedInc > 0 ? channelLength<<12 : 0;

私が最初に考えたのは、vorbis ファイルのビット レートが可変であり、VorbisSource がそれを予期していなかったためかもしれませんが、これを変更すると、同じ問題が発生します。どのファイルを選択しても同じ動作です。

私の次の推測は、それが間違った量だけシフトしているということですが、正しい量がどれくらいかわかりません.

Game Enabler からの出力情報が役立つ場合は、次のとおりです。

GE::AudioOut::AudioOut(GE::AudioSource*, QObject*) : 65 : Buffer size:  32768 
virtual void GE::AudioOut::run() : 145 : Starting thread. 
int GE::VorbisDecoder::vorbisInit() : 400 : stb vorbis init complete, used 3527 bytes, error 0 
int GE::VorbisDecoder::vorbisInit() : 408 :    sample_rate: 44100 
int GE::VorbisDecoder::vorbisInit() : 409 :       channels: 1 
int GE::VorbisDecoder::vorbisInit() : 410 : max_frame_size: 2048 

前もって感謝します。

4

0 に答える 0