Theora Replay Bug
by Chris Skinner · in Torque Game Engine · 10/27/2006 (8:53 am) · 9 replies
The issue I am having is that my ogg plays fine the first time I run it. However, if I call a subsequent setFile on my theora player my video plays in slow motion without sound. I thought I found a fix at www.garagegames.com/mg/forums/result.thread.php?qt=36287 however I discovered that this fix had already been implemented in my version. I am using TGE 1.4 (w/ Torque Lighting Kit). I saw that James Chambers had a similar issue but no one ever replied to it. His issue can be found here: www.garagegames.com/mg/forums/result.thread.php?qt=41185
Any suggestions?
Any suggestions?
About the author
#2
01/25/2007 (10:33 am)
Well. I never found a solution. However, I know where to look. I've discovered that downloading and installing the latest OpenAL drivers fixes the video replay issue without any code modification. However, the sound (i.e. no sound) issue still exists. I discovered that if I play a movie and then move my character once the movie ends, the movie will play perfectly. However, if I try to play the movie two times in succession without moving my character, the sound problem still occurs. I believe moving the character fixes the problem because movement causes a sound to play (e.g. sounds from feet). This sound calls one OpenAl playsound method. The sound from the theora movie calls a different one. I believe that both methods use the same buffers and variables. The sound method called from player movement must successfully deconstruct its resources whereas the Theora movie player method does not. It's just a matter of finding out where they differ. I haven't had the time to troubleshoot it. For my purposes, our character always moves after the movie plays. Thus all buffers are refreshed and the movie is good to go the next time it needs to be played. It is a shame that this issue has not been resolved. I've posted this error multiple times in multiple threads. No one has yet to resolve the isse. Please let me know if you do.
#3
By the way, what version of Torque are you using?
-Trond
01/25/2007 (12:30 pm)
Thanks for the hints, I'll definately look deeper into it. I've experienced that using the "pause theora" resource available, I can pause a "stalled" movie and unpause it and it usually starts playing fine again. As Ben Garney noted in one of these movie-sound-sync threads, the MagicalTrevor might be responsible for some of this madness. MagicalTrevor seems to stay close to the functions that make or break the sound playback :)By the way, what version of Torque are you using?
-Trond
#4
I've tripple checked MagicalTrevor over a series of days. Everything there is good. There is always the possibility that I missed something. If so please let me know. However, I would focus on the area that I mentioned (i.e. OpenAL wrapper).
I am using Torque 1.4 with the lighting kit.
01/25/2007 (1:54 pm)
Trond,I've tripple checked MagicalTrevor over a series of days. Everything there is good. There is always the possibility that I missed something. If so please let me know. However, I would focus on the area that I mentioned (i.e. OpenAL wrapper).
I am using Torque 1.4 with the lighting kit.
#5
I have been fiddling around with this issue most of today, but I have yet to figure out _why_ replay doesn't work. However, based on the observation that the movie continues to play well after having been paused/unpaused, I have found a hacky workaround. It seems to work without any obvious negative sideeffects for me, but it's really dirty. Looks like I'll have to settle with that for now, as I don't really have time to find an "elegant" solution at the moment.
The "solution" is to quickly pause/unpause the movie right after calling alxPlay in the mPlaying loop in TheoraTexture::playLoop(), something like this:
If you (or anyone else) find the reason and/or a better solution, I would be very happy to hear about it :)
-Trond
01/26/2007 (3:51 am)
I'd have to agree with you, the mysterious MagicalTrevor seems to be ok from what I can see. Also, I tried to play some ingame sound before restarting the movie, and it worked, just as you said :) I have been fiddling around with this issue most of today, but I have yet to figure out _why_ replay doesn't work. However, based on the observation that the movie continues to play well after having been paused/unpaused, I have found a hacky workaround. It seems to work without any obvious negative sideeffects for me, but it's really dirty. Looks like I'll have to settle with that for now, as I don't really have time to find an "elegant" solution at the moment.
The "solution" is to quickly pause/unpause the movie right after calling alxPlay in the mPlaying loop in TheoraTexture::playLoop(), something like this:
// if we haven't started yet, start it! :)
if(!isAudioActive && mHasVorbis)
{
alxPlay(mVorbisHandle);
isAudioActive = true;
//Trond: HACK - seems to fix replay with sound.
alxPause(mVorbisHandle);
alxUnPause(mVorbisHandle);
}If you (or anyone else) find the reason and/or a better solution, I would be very happy to hear about it :)
-Trond
#6
It might be dirty but it works. While looking at your code, I remembered where the problem lied. It is in alxPlay(). I believe alxPlay has multiple signatures. One is used by character movement and the other by Theora. Any way, if you have time I'd suggest looking there. If not, your fix looks good.
01/26/2007 (5:28 am)
Trond,It might be dirty but it works. While looking at your code, I remembered where the problem lied. It is in alxPlay(). I believe alxPlay has multiple signatures. One is used by character movement and the other by Theora. Any way, if you have time I'd suggest looking there. If not, your fix looks good.
#7
EDIT: Thanks for the tip on the alxPlay-function by the way, that sounds reasonable. I'll see if I get around to it sometime later :)
-Trond
01/30/2007 (12:56 am)
I just thought I should mention - the quickfix you had to make the movie replay without sound, changing the safety-check number from 500 to 5, can make the movie and sound get out of sync (this occured on one of our computers). Seems like that portion makes sure the movie follows the sound. I'd recommend leaving the safety number at 500, as it made the out of sync problem go away.EDIT: Thanks for the tip on the alxPlay-function by the way, that sounds reasonable. I'll see if I get around to it sometime later :)
-Trond
#8
I've been having similar trouble and have tracked it to something being wrong when playing streamed sounds with the alxplay. Loaded sounds are fine. I beleive all theora sounds are treated as streamed.
I found this after giving up on trying to play theora with sounds and playing them separately. When you play streamed sounds you get a ticking when the sound has completed which I assume is the sound not stopping and closing properly. When I change to a memory based sound then the prob went away.
I had previouly suspected that (in Theora) an audio handle wasn't being released properly and this confirmed my suspicions. If I manually stop the Theora sound handle with alxStop then everything works fine.
So heres the kicker. If you call an alxStopAll BEFORE you play any Theora file with sound then everything remains okay. You only have to call it onces at the beggining and after that everything is fine(ie you can play any file with sound). So I'm guessing something isnt being initialised properly at start up with the pool of audio handles. Its still a hack but points to alxPly being the culprit.
I still dont have a solution to the stream audio though.
03/20/2007 (7:01 pm)
I concur with the problem being with alxPlayI've been having similar trouble and have tracked it to something being wrong when playing streamed sounds with the alxplay. Loaded sounds are fine. I beleive all theora sounds are treated as streamed.
I found this after giving up on trying to play theora with sounds and playing them separately. When you play streamed sounds you get a ticking when the sound has completed which I assume is the sound not stopping and closing properly. When I change to a memory based sound then the prob went away.
I had previouly suspected that (in Theora) an audio handle wasn't being released properly and this confirmed my suspicions. If I manually stop the Theora sound handle with alxStop then everything works fine.
So heres the kicker. If you call an alxStopAll BEFORE you play any Theora file with sound then everything remains okay. You only have to call it onces at the beggining and after that everything is fine(ie you can play any file with sound). So I'm guessing something isnt being initialised properly at start up with the pool of audio handles. Its still a hack but points to alxPly being the culprit.
I still dont have a solution to the stream audio though.
#9
08/01/2007 (10:21 am)
I dont know why, but i dont have the alxPause and the alxUnPause in my engine, i tried to use the alxStop or alxStopAll but it crash the engine. Any help ?
Trond Abusdal
Default Studio Name
F64 TheoraTexture::getTheoraTime() { if(mHasVorbis && false) { // 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); } }I'd appreciate it very much if you let me know if you find/found a solution to this problem :)
-Trond