A Few Bugs

omniter

14-01-2009 00:51:07

Heya, Kreso.

First off, great job on this project. I've already integrated it into my engine for video playback. =) I heard you're pretty busy lately, and you're gonna resume development soon, so in the meantime, I thought I'd bring some stuff your attention.

This is probably not a bug so much as an incomplete feature, but seeking and looping don't work. When I try to seek, the video travels to the desired time, then quickly scrubs back to where it was before. It's the same when i stop and continue. Instead of continuing where the video left off, it fast-forwards to where the video would be if it hadn't been paused at all.

Another problem is that I find the memory used by the videos is not being freed up at all. This is very strange because I looked through your code, and I could find nothing wrong. I noticed this because as a temporary solution to the lack of looping, I'm freeing and reloading video clips, and this would cause my memory usage to climb continuously before crashing my program.

Finally, I thought you might to try out this tiny modification: It seems that when you destroy a video, you also destroy the texture unit it was occupying. I think this isn't a good approach, because the texture unit wasn't created by the video, so it should be left the way it was. I modified TheoraVideoDriver to save off the original texture name of the texture unit, and upon destruction, instead of removing the texture unit, simply restore the original texture name and also restore the original texture transformation. This was a very nice change, because I was able to play a video on a random surface, then get rid of it, and leave the original object intact, for as many times as I wanted. =)

Anyway, until you get back, I'm going to put the video module of my engine on hold and work on something else. Again, thanks for the great work!

Kreso

18-01-2009 15:00:07

Hi,

thanks for your bug reports, they are greatly appreciated! Here are my replies:


This is probably not a bug so much as an incomplete feature, but seeking and looping don't work. When I try to seek, the video travels to the desired time, then quickly scrubs back to where it was before. It's the same when i stop and continue. Instead of continuing where the video left off, it fast-forwards to where the video would be if it hadn't been paused at all.

yes, seeking and looping is not implemented yet. it's on my todo list and will certainly be developed.

Another problem is that I find the memory used by the videos is not being freed up at all. This is very strange because I looked through your code, and I could find nothing wrong. I noticed this because as a temporary solution to the lack of looping, I'm freeing and reloading video clips, and this would cause my memory usage to climb continuously before crashing my program.

weird, I'll look into it.

Finally, I thought you might to try out this tiny modification: It seems that when you destroy a video, you also destroy the texture unit it was occupying. I think this isn't a good approach, because the texture unit wasn't created by the video, so it should be left the way it was. I modified TheoraVideoDriver to save off the original texture name of the texture unit, and upon destruction, instead of removing the texture unit, simply restore the original texture name and also restore the original texture transformation. This was a very nice change, because I was able to play a video on a random surface, then get rid of it, and leave the original object intact, for as many times as I wanted. =)

sounds good, can you post the patch?

omniter

22-01-2009 14:44:20

Sure. =) I'm not quite sure how though. Never submitted patches before. Do I just paste the changes here (it was literally 4 lines), or do I use the Tracker?

Kreso

22-01-2009 14:52:46

nah, jush paste the lines, since it's that small a change, it should be simple to pin point.

omniter

23-01-2009 00:08:07

Here you go! I marked all the changes with asterisk-prefixed comments. It should be self-explanatory.

In TheoraVideoDriver.h:

class _OgreTheoraExport TheoraAudioDriver
{
...
String mTextureName;
String mMaterialName;
String mOriginalTextureName; // ********* added this line
...
}


In TheoraVideoDriver.cpp:

TheoraVideoDriver::~TheoraVideoDriver()
{
...

// ********* modified this section
if( !(material.isNull()) )
{
// restore original texture and reset texture transform
TextureUnitState* t = material->getTechnique(mTec)->getPass(mPass)->getTextureUnitState( mUnit );
t->setTextureName(mOriginalTextureName);
t->setTextureTransform(Matrix4::IDENTITY);
}

...
}

...

void TheoraVideoDriver::attachVideoToTextureUnit(
const String &sMaterialName, const String &sTextureName,
const String &sGroupName, int TechniqueLevel, int PassLevel,
int TextureUnitStateLevel, int width, int height)
{
...

// Grab Our material, then find the Texture Unit
MaterialPtr material = MaterialManager::getSingleton().getByName( sMaterialName );
TextureUnitState* t = material->getTechnique(mTec)->getPass(mPass)->getTextureUnitState(mUnit);

mOriginalTextureName = t->getTextureName(); // ********* added this line

...
}

Kreso

27-01-2009 09:07:23

I took care of memory destruction.

haven't got arround to tackle the texture destruction policy, will decide later.