Thanks Michael, changes now merged and submitted to SVN.

On Thu, Aug 21, 2008 at 7:39 PM, Guerrero, Michael (CIV)
<[EMAIL PROTECTED]> wrote:
> Hi Robert, I started using the quicktime plugin which worked great if a
> movie was played only once.  However, I ran across the following problem:
>
> (copied from the mailing list, Date: 2008-08-21 01:02:34 GMT)
>
>
>
> …if you load a movie then
>
> quit/delete that movie and then try to load another movie, the
>
> QuicktimeInitializer will be NULL.  The reasons for this can be seen by
>
> examining the following code from QTUtils.cpp
>
>
>
> void initQuicktime(bool erase) {
>
>
>
> static osg::ref_ptr<QuicktimeInitializer> s_qt_init = new
> QuicktimeInitializer();
>
>     if (erase)
>
>         s_qt_init = NULL;
>
> }
>
>
>
> void exitQuicktime() {
>
>     initQuicktime(true);
>
> }
>
>
>
> After my first loaded video is destroyed, initQuicktime(true) is called
> which
>
> deletes the reference to the QuicktimeInitializer.  After this happens,
> there is
>
> no getting  it back since it is a static var.
>
>
>
> Fixing this required a few changes.  The main ones were places that had
> static variable (like the one above) which would prevent quicktime from
> being properly initialized the second time around.  My fix for what is above
> is the following:
>
>
>
> void initQuicktime(bool erase) {
>
>
>
>         static osg::ref_ptr<QuicktimeInitializer> s_qt_init = new
> QuicktimeInitializer();
>
>         if (erase) {
>
>             s_qt_init = NULL;
>
>         } else if (!s_qt_init.valid())
>
>         {
>
>             s_qt_init = new QuicktimeInitializer();
>
>         }
>
>     }
>
>
>
> However, there is another static variable hidden in the QuicktimeInitializer
> constructor:
>
>
>
>                        QuicktimeInitializer() :osg::Referenced() {
>
>                              static bool s_fQuicktimeInited = 0;
>
>                              if (!s_fQuicktimeInited) {
>
>                                  #ifndef __APPLE__
>
>                                      InitializeQTML(0);
>
>                                  #endif
>
>                                  OSErr err = EnterMovies();
>
>                                  if (err!=0)
>
>                                     osg::notify(osg::FATAL) << "Error while
> initializing quicktime: " << err << endl;
>
>                                  else
>
>                                     osg::notify(osg::DEBUG_INFO) <<
> "Quicktime initialized successfully"  << endl;
>
>                                  registerQTReader();
>
>                                  s_fQuicktimeInited = true;
>
>                              }
>
>
>
> This variable is redundant since this is only called from the initQuicktime
> function that already has a static bool guarding it.  So I kept the static
> var only for the registration of the QTReader which doesn't need to be done
> more than once.  Here is the changed version:
>
>
>
>             QuicktimeInitializer() :osg::Referenced() {
>
>
>
>                  #ifndef __APPLE__
>
>                      InitializeQTML(0);
>
>                  #endif
>
>                  OSErr err = EnterMovies();
>
>                  if (err!=0)
>
>                     osg::notify(osg::FATAL) << "Error while initializing
> quicktime: " << err << endl;
>
>                  else
>
>                     osg::notify(osg::DEBUG_INFO) << "Quicktime initialized
> successfully"  << endl;
>
>
>
>                  static bool registered = false;
>
>
>
>                  if (!registered){
>
>                   registerQTReader();
>
>                  }
>
>             }
>
>
>
> Another misuse of the api was forgetting to "close" opened movie files.
> I've added this in the destructor of MovieData.  This required storing the
> reference id which had to be added as part of the class.  This was done as
> suggested by the developer docs at
> http://developer.apple.com/documentation/QuickTime/Reference/QTRef_MovieToolkit/Reference/reference.html#//apple_ref/c/func/OpenMovieFile
> which states "Your application must open a movie file before reading movie
> data from it or writing movie data to it. You can open a movie file more
> than once; be sure to call CloseMovieFile once for each time you call this
> function. Note that opening the movie file with write permission does not
> prevent other applications from reading data from the movie file."
>
>
>
> The files that I am submitting should be up to date with what is in the
> trunk.
>
> QTUtils has not changed in 9 months.
>
> MovieData has not changed in 1 year.
>
>
>
> Thanks for the awesome support,
>
> Michael Guerrero
>
> Delta3D
>
> _______________________________________________
> osg-submissions mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
>
>
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to