Page 7 of 30

Re: OpenMW 0.29.0

Posted: 19 Feb 2014, 22:04
by cc9cii
Sorry if I'm stating the obvious but mVideoState::AudioTrack is uninitialised which results in a null pointer when trying to get its audio clock value:

Code: Select all

        // accumulate the clock difference
        double diff = mVideoState->get_master_clock() - mVideoState->get_audio_clock();
        mAudioDiffAccum = diff + mAudioDiffAvgCoef * mAudioDiffAccum;
        if(mAudioDiffAvgCount < AUDIO_DIFF_AVG_NB)
            mAudioDiffAvgCount++;
        else
Looking further it is initialised here but with an empty object according to the debugger:

Code: Select all

    switch(codecCtx->codec_type)
    {
    case AVMEDIA_TYPE_AUDIO:
        this->audio_st = pFormatCtx->streams + stream_index;

        decoder.reset(new MovieAudioDecoder(this));
        this->AudioTrack = MWBase::Environment::get().getSoundManager()->playTrack(decoder, MWBase::SoundManager::Play_TypeMovie);
        if(!this->AudioTrack)
        {
            avcodec_close((*this->audio_st)->codec);
            this->audio_st = NULL;
            return -1;
        }
        break;
So we don't seem to have a SoundManager initialised at this point, i.e. stream_open().

Re: OpenMW 0.29.0

Posted: 19 Feb 2014, 23:43
by cc9cii
EDIT: scratch crazy comment ;-)

Anyway, not sure why the code is in the audio codec part of the switch statement. Aren't we playing a video?

Re: OpenMW 0.29.0

Posted: 20 Feb 2014, 00:01
by scrawl
This analysis is not quite correct.

The problem is that since corristo's change, SoundManager::playTrack will actually decode samples, which means the virtual Sound_Decoder::read method will be called. And for the video, that is a MovieAudioDecoder::read which calls get_audio_clock(), and that depends on the AudioTrack pointer already being set up. However, since we haven't even returned from the playTrack method yet, the pointer is not set.

Re: OpenMW 0.29.0

Posted: 20 Feb 2014, 00:03
by cc9cii
:-) Thanks scrawl for setting me straight. I was just poking around and thinking out loud so it wasn't really a considered analysis as such. :-)

Re: OpenMW 0.29.0

Posted: 20 Feb 2014, 00:06
by scrawl
edit: ok

Re: OpenMW 0.29.0

Posted: 20 Feb 2014, 00:07
by cc9cii
I was typing as fast as I could to correct it but it was still too late!

Re: OpenMW 0.29.0

Posted: 20 Feb 2014, 00:14
by Chris
Well crap, I missed that when aiding corristo.

It may be enough to just revert commit 51fb9f65ea5086433fa0d1db12197b133a9b27fd so that it decodes the initial batch in the decode thread, rather than on play. I rather dislike first-time-only special cases, but that seems to be the way to go here for now.

Re: OpenMW 0.29.0

Posted: 20 Feb 2014, 11:15
by gus
I think I got the culprit. In ESM writter, line 85,86,

Code: Select all

        writeT<int>(0); // Size goes here
        writeT<int>(0); // Unused header?
should be

Code: Select all

        writeT<uint32_t>(0); // Size goes here
        writeT<uint32_t>(0); // Unused header?
it seems to work with this change.

Re: OpenMW 0.29.0

Posted: 20 Feb 2014, 12:35
by Zini
Thanks. Applying fix now. Should have checked this part first. But then, this should also cause reloading content files saved with OpenCS to break on Windows. I guess no one ever tried that.

Re: OpenMW 0.29.0

Posted: 20 Feb 2014, 12:38
by Zini
The version handling fix is kinda annoying. Now I can't update the version number (which I normally do shortly after creating the release branch) without adding a tag.