Game Development Community

Why is MagicalTrevor so Magical? :)

by Lateral Punk · in Torque Game Engine · 05/22/2006 (11:47 am) · 48 replies

Hi,
I've read the documentation on MagicalTrevor, but I do not understand really what it is used for. In my case, I'm trying to get video working in the fxVideoRenderObject using the areTorquePopular.ogg file. It renders correctly, but half-way during playback, it gets very choppy and the console outputs "MagicalTrevor::advancetime - no last occurrence for buffer found". It eventually just stops playing. I investigated the code and I tried simply commenting out the call to MagicalTrevor:advanceTime:
F64 TheoraTexture::getTheoraTime()
{
   //if(mHasVorbis)
   //{
   //   // We have audio, so synch to audio track.
   //   ALint buf=-1;
   //   alGetSourcei(mVorbisBuffer->mSource, AL_BUFFER, &buf);
   //   mCurrentTime += mMagicalTrevor.advanceTime(buf);
   //   return mCurrentTime;
   //}
   //else
   {
      // We have no audio, just synch to start time.
      return (double)0.001 * (double)(Platform::getRealMilliseconds() - mStartTick);
   }
}

and I get much better performance, and the audio/video is in sync. I guess the choppiness in the original code occurs because of the tight loop inside of advanceTime. Anyways, I just want to understand the logic behind MagicalTrevor. Is it so that if we had more than 1 video playing, MagicalTrevor is used for some organization of the buffers? I don't fully understand it (after all, it's magical :). Any help would be greatly appreciated.

thanks
Page «Previous 1 2 3 Last »
#1
05/22/2006 (1:40 pm)
Further investigation has led me to believe that my above code doesn't really fix anything at all. I put it back to the way it was originally, and tried the video in the 2D GUI video control, and the playback is flawless. It's just not as good in the 3D world. I'm starting to think that it maybe that we have lots stuff going on in our world and that trying to playback the video might be making it choppy. I need to further investigate the matter I guess. If anyone is also getting choppy playback of the theora video using the fxvideorenderobject in 3D can they please post here?

thanks
#2
05/22/2006 (2:45 pm)
This is what I obtain in the log:

[5/22/06 14:43:05][Wrn] MagicalTrevor::advancetime - no last occurrence for buffer 230328888 found!
[5/22/06 14:43:06][Wrn] MagicalTrevor::advancetime - no last occurrence for buffer 0 found!
[5/22/06 14:43:08][Wrn] MagicalTrevor::advancetime - no last occurrence for buffer 0 found!
[5/22/06 14:43:10][Wrn] MagicalTrevor::advancetime - no last occurrence for buffer 0 found!
[5/22/06 14:43:11][Wrn] MagicalTrevor::advancetime - no last occurrence for buffer 0 found!
[5/22/06 14:43:15][Wrn] MagicalTrevor::advancetime - no last occurrence for buffer 0 found!

what should I make of this?
#3
05/22/2006 (8:48 pm)
Maybe OpenAL is stalling out or getting saturated? Does the video do the same thing sans audio?

MagicalTrevor tracks (as I believe its docs outline) the audio buffers which are in flight for a video, and what timeslices each represents, so that it can tell by the currently playing buffer how much time has elapsed.
#4
05/23/2006 (10:19 am)
Hi Ben,
I thought the same thing about the audio, so I created a file using ffmpeg2theora-0.16.exe with the --nosound, tested it in VLC and it was as expected, video but no audio. I then used the fxVideoRenderObject to display this video in my environment, and basically the same choppy playback as the video and audio configuration. In addition, it occurs basically at the same play time too, about 35 seconds into playback. I also ran it in debug mode to ensure that there really was no audio, and it all checked out. I next tried outputing the lowest quality video/audio with ffmpeg2theora-0.16.exe, and the same results. Same 35 seconds too. If MagicalTrevor tracks audio, then I don't believe it is at fault here :) I must restate that using the GuiControl to playback the video works flawlessly.
I then tried to even further narrow things down, so I tried the video using fresh TGE14 code (obviously added the fxvideorenderobject resource). Surprisingly enough, I saw the same artifacts at about the same time, 35 seconds. So I don't believe it has to do with OpenAL or the audio, but could be wrong? Can you advise further on what I should try?

thanks
#5
05/23/2006 (12:33 pm)
I'd try using the memory tracking techniques that Pat Wilson wrote up on TDN (tdn.garagegames.com/wiki/MemoryManager) to see if maybe there's a memory leak.

Do other videos break after 35 seconds?

What happens if you wait like 5 minutes before you start the video? Still the same time?

Is there a newer theora lib available?
#6
05/24/2006 (9:46 am)
Hi Ben,
yes I was currently looking into tracking the memory usage described in the above wiki. What program do you use to make OGG theora/vorbis files? I've not tried any other movie, I guess i should try that first.
Quote:
What happens if you wait like 5 minutes before you start the video? Still the same time?
Yeah same results. Actually, what I've narrowed it down is to basically just stare at the video without doing anything else (like moving around), and approximately after 30s, the choppy playback starts to occur.
What I've started to do now is get the SVN trunk of ogg, vorbis, and theora, compile the libraries myself (were you aware that they now have DLLs also?), and use the latest. Also, I noticed that for TheoraTexture, most of the code is very similar to the player_example.c file from Theoroa's example folder. So what I'm going to do is kind of a "diff" and see if I can conclude anything from that. I mean the biggest difference between their approach and yours was they used signals and you used mutexes for the audio/video syncronization. I don't know, still need to look into it.
But the thing that gets me the most is that it plays back perfectly in the GUI control. No hiccups there. It doesn't make sense, because even when you just have a fullscreen Theora GUI control running, your CPU is still maxed out at 95-100% the same as when in the game. So that would lead me to conclude that the 3D models are not a factor. And I must re-iterate that this behaviour of choppy playback also occurs in the released TGE14 code base.

Anymore insight?

I'll keep you posted with my "diff" approach and if I can find some "leaks" that are relavant
#7
05/24/2006 (9:48 am)
Ffmpeg2theora, not sure what version we used, latest is your best bet.
#8
05/24/2006 (9:55 am)
I added more to my above post I was just testing the [quote] tag :)
#9
05/24/2006 (10:13 am)
What if you completely disable all audio in the game?
#10
05/24/2006 (10:21 am)
How would that help? I already tested a video file without audio, and the results were the same? I will try your approach anyways, but I really think the problem here is the manner in which MagicalTrevor is doing audio/video syncronization, but I could be wrong.
#11
05/24/2006 (10:23 am)
No, I mean, turn off ALL audio, OpenAL often spawns secondary threads which could be eating cycles that the theora thread needs.
#12
05/24/2006 (11:06 am)
I will give that a shot. Keep you posted.
#13
05/24/2006 (6:58 pm)
Ok, I just removed opeanal.dll and wrap_oal.dll, and yeah you were right, the video playback is PERFECT! Obviously there is no sound. So what does this mean, you say that the OpenAL's threads are taking up cycles, then how can this be improved? I mean you need OpenAL for all the sound effects, we can't simply remove it out of the system. Can streaming and not streaming our sounds make a difference? So what may be my options now? thanks for your input.
#14
05/24/2006 (8:38 pm)
Might want to try turning off streaming sources, other subsets of your sound, and find out what sets it off. You might have found a bug in OAL, or maybe just an unfortunate side effect.

If you're interested in helping do an audio layer rewrite, we're looking for a contractor to task with that... ;)
#15
05/25/2006 (10:41 am)
Yeah I was contemplating the same thing, but I was thinking it would be non-streaming sources, because they take a second or two to load on demand. I really hope it is not an unfortunate side effect. I'm thinking of downloading the latest OAL code and compile the DLL myself (if possible). Audio layer rewrite, wow that would be an honour...Let me run some more test cases and report back here...thanks for your input so far!
#16
05/29/2006 (11:47 am)
I discovered a memory leak in theoraPlayer.cc. The mTextureHandle is not being properly deallocated. Please insert this line:

void TheoraTexture::destroyTexture()
{
.....
SAFE_DELETE(mTextureHandle);
}
#17
05/29/2006 (12:06 pm)
Hmm... But isn't the texture handle automagically cleaned up?
#18
05/29/2006 (12:09 pm)
No it was not being cleaned up on mission exit. Why is the texture manager suppose to be doing that? Nonetheless, it's safe to put it there just to ensure/force it.
#19
05/29/2006 (12:12 pm)
Oh hey, what do you know - it's a TextureHandle* and not a TextureHandle. Yup, you're right!

(If it was a straight TextureHandle then the class destructor would have taken care of it.)
#20
05/29/2006 (12:15 pm)
Bug #1620, thanks for pointing it out!
Page «Previous 1 2 3 Last »