QTAudioReader cleanup


#1

Hey Julian, in juce_QuicktimeAudioFormat I think you need a

#if JUCE_MAC

        ExitMoviesOnThread ();

#endif

I also think the EnterMoviesOnThread(0) call should be moved up a little… so

#if JUCE_MAC

        EnterMoviesOnThread (0);

#endif
 if (EnterMovies() != noErr)
            return;

Here’s the relevent Apple Docs

EnterMoviesOnThread

[quote]Discussion
This function is analogous to EnterMovies. It initializes QuickTime and prepares QuickTime for calls from its thread. Unlike EnterMovies, this function allows the client to indicate if its access to QuickTime requires sharing of QuickTime state with the main thread. The default is to maintain a private state.

Your application should call this function on threads you create. Calling it on the main thread should be done if QuickTime will be used from the main thread.

If a client doesn’t call this function on a spawned preemptive thread and then makes a QuickTime call (including EnterMovies), the global QuickTime state will be shared with the main (or application) thread. This behavior ensures compatibility with current applications accessing QuickTime from multiple threads.

The first call to this function will change the components thread mode unless the kQTEnterMoviesFlagDontSetComponentsThreadMode flag is passed. All subsequent calls will leave the components thread mode unaffected.[/quote]

ExitMoviesOnThread

[quote]This function should be called before exiting from a spawned thread that uses QuickTime. It undoes the setup performed by EnterMoviesOnThread. Each call to EnterMoviesOnThread should be matched with a call to this function. This function should not be called on a thread without a previous call to EnterMoviesOnThread.

After the last call to this function is made on a thread, subsequent calls to QuickTime functions without calling EnterMoviesOnThread first will result in threads sharing the main thread’s state just as though the application didn’t use EnterMoviesOnThread or this function. This behavior ensures compatibility. Thus callers should bracket all QuickTime calls on secondary threads between an initial call to EnterMoviesOnThread and final call to this function.

If you do not call this function, certain cleanup may not occur, potentially causing resource leaks.[/quote]


#2

Ah yes, thanks very much!