×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Jun 2012
    Posts
    1

    Game Enabler Ogg Vorbis playback problem

    Hello everyone,

    I recently discovered the Qt Game Enabler library and wanted to use it in my Symbian project which uses Qt Components.

    I have successfully grabbed just the audio part and am able to playback Ogg Vorbis with a small problem. When I first play a music file and it reaches to the end, instead of going back to the start (as I have set it to loop infinitely) it will go back a couple of seconds and play until the end. When it ends the second time, that's when it correctly goes back to the beginning and the whole cycle begins again (goes to the end, back a couple of seconds, goes to the end, back to the beginning and so on and so forth).

    I have managed to find out where in the code it decides to go back a couple of seconds, but don't know enough to make any changes.

    The source file is called VorbisSource and is an GameEnabler::AudioSource. The relevant source code that plays the audio is the following:

    Code:
        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;
        }
    At some point, the maxMixAmount is set to zero (which I believe is at the end of the file), and instead of ending the sound, it goes back a couple of seconds according to this line of code:

    Code:
    m_fixedPos = m_fixedInc > 0 ? channelLength<<12 : 0;
    My first thought was maybe because the vorbis file had a variable bit rate and the VorbisSource wasn't expecting it, but upon changing this, the same problem occurs. It also doesn't matter which file I choose, it's the same behavior.

    My next guess is that it's shifting by the wrong amount, but I have no idea what the right amount is.

    Here is some output information from Game Enabler if it helps:
    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

    Thank you in advance.

  2. #2
    Registered User
    Join Date
    Jun 2012
    Posts
    1

    Re: Game Enabler Ogg Vorbis playback problem

    Hi,

    it shifts the correct amout, but it overflows. Try with the latest code from svn (http://projects.developer.nokia.com/...nabler/browser) , or replace;
    unsigned int channelLength
    with;
    quint64 channelLength

Similar Threads

  1. Ogg Vorbis MMF plugin for S60 v3?
    By dagb in forum Audio
    Replies: 0
    Last Post: 2007-07-08, 12:13
  2. Vorbis OGG
    By corwin78 in forum Audio
    Replies: 3
    Last Post: 2007-01-19, 14:50
  3. AAC, MP3 playback problem on N71
    By josephtkc in forum Symbian Media (Closed)
    Replies: 0
    Last Post: 2006-02-17, 06:41
  4. speaker enabler
    By Xpiral in forum Symbian
    Replies: 1
    Last Post: 2005-08-20, 07:59

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×