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:
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
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
#42
06/05/2006 (3:31 pm)
Ok cool. thanks for the explanation.
#43
06/06/2006 (10:17 am)
Also, from the looks of it, I really don't see any need for the mutex inside of MagicalTrevor. The only method that really gets called a lot is advanceTime, and that is mostly done by the decoding (instantiated) thread. I really think that the mutex should be removed because there is no contesting happening between the two threads. What do you think?
#44
06/06/2006 (1:28 pm)
I believe I added that to try to prevent any weird threading issues around Trevor whilst debugging some annoying stuff... if removing it fixes something, cool - I'd just leave it if it appears to be working properly and isn't a performance hit.
#45
06/06/2006 (1:47 pm)
It's a performance hit of 10 addional opcodes ;) I think removing it is safe, I've basically divided the theoraplayer.cc code into two halves: torque thread, and theora thread. I don't see any weird threading issues to occur with MagicalTrevor, so I would believe it is safe to remove the mutex.
#46
06/06/2006 (4:28 pm)
Compared to what the thread's doing, I think that's probably a pretty cheap cost... but hey, if it's a safe change, go for it.. :)
#47
06/29/2006 (2:30 pm)
Hey, i've not forgotten this thread and all your help. When I get some free time in the next week, I'll be writing up a new resource for fixing some "issues" with the current theora code. It will basically be an update resource. Also, I'll be submitting a really cool new resource on integrating libcurl (http://curl.haxx.se/libcurl/) into TGE. Both pieces of work are courtesy of my time at Doppelganger (formely known as Evil Twin Studios), the people behind The Lounge. Keep you posted!
#48
06/29/2006 (4:10 pm)
Cool, look forward to seeing it! Thanks!
Associate Ben Garney
But video and audio have to be in synch and on many systems just going off of start duration isn't good enough - you need to know where you are in both streams so you can keep everything in the right place.
Try testing on a more modest system. ;)