X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0c81ef7fceb1618c2d7436591d73235accd36a60..6cef0db28018fd2644ee4e38af715872e5242459:/src/mac/carbon/mediactrl.cpp diff --git a/src/mac/carbon/mediactrl.cpp b/src/mac/carbon/mediactrl.cpp index 23ad82a570..9d525f5b59 100644 --- a/src/mac/carbon/mediactrl.cpp +++ b/src/mac/carbon/mediactrl.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: mac/carbon/mediactrl.cpp +// Name: src/mac/carbon/mediactrl.cpp // Purpose: Built-in Media Backends for Mac // Author: Ryan Norton // Modified by: @@ -36,11 +36,17 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" +#if wxUSE_MEDIACTRL + #include "wx/mediactrl.h" +#ifndef WX_PRECOMP + #include "wx/log.h" + #include "wx/timer.h" +#endif + // uma is for wxMacFSSpec #include "wx/mac/uma.h" -#include "wx/timer.h" // standard QT stuff #ifndef __DARWIN__ @@ -51,7 +57,13 @@ #include #endif -#if wxUSE_MEDIACTRL +#if !defined(__LP64__) +#define USE_QUICKTIME 1 +#else +#define USE_QUICKTIME 0 +#endif + +#if USE_QUICKTIME //--------------------------------------------------------------------------- // Height and Width of movie controller in the movie control (apple samples) @@ -71,7 +83,7 @@ class WXDLLIMPEXP_MEDIA wxQTMediaBackend : public wxMediaBackendCommonBase { public: wxQTMediaBackend(); - ~wxQTMediaBackend(); + virtual ~wxQTMediaBackend(); virtual bool CreateControl(wxControl* ctrl, wxWindow* parent, wxWindowID id, @@ -146,13 +158,13 @@ public: wxMediaCtrlPlayerControls m_interfaceflags; // Saved interface flags // Event handlers and UPPs/Callbacks - EventHandlerRef m_windowEventHandler; + EventHandlerRef m_windowEventHandler; EventHandlerUPP m_windowUPP; MoviePrePrerollCompleteUPP m_preprerollupp; MCActionFilterWithRefConUPP m_mcactionupp; - GWorldPtr m_movieWorld; //Offscreen movie GWorld + GWorldPtr m_movieWorld; //Offscreen movie GWorld friend class wxQTMediaEvtHandler; @@ -319,7 +331,6 @@ wxQTMediaBackend::~wxQTMediaBackend() // Dispose of the movie controller ::DisposeMovieController(m_mc); m_mc = NULL; - DisposeMCActionFilterWithRefConUPP(m_mcactionupp); // Dispose of offscreen GWorld ::DisposeGWorld(m_movieWorld); @@ -405,9 +416,9 @@ bool wxQTMediaBackend::Load(const wxString& fileName) if (m_movie) Cleanup(); - ::ClearMoviesStickyError(); // clear previous errors so + ::ClearMoviesStickyError(); // clear previous errors so // GetMoviesStickyError is useful - + OSErr err = noErr; short movieResFile; FSSpec sfFile; @@ -427,13 +438,9 @@ bool wxQTMediaBackend::Load(const wxString& fileName) newMovieActive, NULL); // wasChanged - // - // check GetMoviesStickyError() because it may not find the - // proper codec and play black video and other strange effects, - // not to mention mess up the dynamic backend loading scheme - // of wxMediaCtrl - so it just does what the QuickTime player does - // - if (err == noErr && ::GetMoviesStickyError() == noErr) + // Do not use ::GetMoviesStickyError() here because it returns -2009 + // a.k.a. invalid track on valid mpegs + if (err == noErr && ::GetMoviesError() == noErr) { ::CloseMovieFile(movieResFile); @@ -463,7 +470,7 @@ bool wxQTMediaBackend::Load(const wxURI& location) if (m_movie) Cleanup(); - ::ClearMoviesStickyError(); // clear previous errors so + ::ClearMoviesStickyError(); // clear previous errors so // GetMoviesStickyError is useful wxString theURI = location.BuildURI(); @@ -473,7 +480,7 @@ bool wxQTMediaBackend::Load(const wxURI& location) const char* theURIString; #if wxUSE_UNICODE - wxCharBuffer buf = wxConvLocal.cWC2MB(theURI, theURI.length(), &len); + wxCharBuffer buf = wxConvLocal.cWC2MB(theURI.wc_str(), theURI.length(), &len); theURIString = buf; #else theURIString = theURI; @@ -517,9 +524,8 @@ bool wxQTMediaBackend::Load(const wxURI& location) // require it if you don't use a Movie Controller, // which we don't by default. // - m_preprerollupp = - NewMoviePrePrerollCompleteUPP( wxQTMediaBackend::PPRMProc ); - ::PrePrerollMovie( m_movie, timeNow, playRate, + m_preprerollupp = wxQTMediaBackend::PPRMProc; + ::PrePrerollMovie( m_movie, timeNow, playRate, m_preprerollupp, (void*)this); return true; @@ -563,8 +569,7 @@ void wxQTMediaBackend::DoNewMovieController() // Setup a callback so we can tell when the user presses // play on the player controls - m_mcactionupp = - NewMCActionFilterWithRefConUPP( wxQTMediaBackend::MCFilterProc ); + m_mcactionupp = wxQTMediaBackend::MCFilterProc; ::MCSetActionFilterWithRefCon( m_mc, m_mcactionupp, (long)this ); wxASSERT(::GetMoviesError() == noErr); @@ -592,13 +597,13 @@ void wxQTMediaBackend::DoNewMovieController() { kEventClassWindow, kEventWindowActivated }, { kEventClassWindow, kEventWindowDeactivated } }; - m_windowUPP = + m_windowUPP = NewEventHandlerUPP( wxQTMediaBackend::WindowEventHandler ); InstallWindowEventHandler( wrTLW, m_windowUPP, GetEventTypeCount( theWindowEventTypes ), theWindowEventTypes, - this, + this, &m_windowEventHandler ); } else @@ -621,9 +626,6 @@ void wxQTMediaBackend::DoNewMovieController() //--------------------------------------------------------------------------- void wxQTMediaBackend::FinishLoad() { - // Dispose of the PrePrerollMovieUPP if we used it - DisposeMoviePrePrerollCompleteUPP(m_preprerollupp); - // get the real size of the movie DoLoadBestSize(); @@ -974,7 +976,7 @@ void wxQTMediaBackend::DoSetControllerVisible( | ((flags & wxMEDIACTRLPLAYERCONTROLS_VOLUME) ? 0 : (1 << 2)/*mcFlagSuppressSpeakerButton*/) //if we take care of repainting ourselves - // | (1 << 4) /*mcFlagDontInvalidate*/ + // | (1 << 4) /*mcFlagDontInvalidate*/ ); ::MCDoAction(m_mc, 38/*mcActionSetFlags*/, (void*)mcFlags); @@ -1070,8 +1072,8 @@ wxLongLong wxQTMediaBackend::GetDownloadProgress() //--------------------------------------------------------------------------- wxLongLong wxQTMediaBackend::GetDownloadTotal() { - return wxQTMediaBackend::GetDataSizeFromStart( - ::GetMovieDuration(m_movie) + return wxQTMediaBackend::GetDataSizeFromStart( + ::GetMovieDuration(m_movie) ); } @@ -1098,12 +1100,12 @@ void wxQTMediaBackend::MacVisibilityChanged() { if(!m_mc || !m_ctrl->m_bLoaded) return; //not initialized yet - - if(m_ctrl->MacIsReallyShown()) + + if(m_ctrl->IsShownOnScreen()) { //The window is being shown again, so set the GWorld of the //controller back to the port of the parent WindowRef - WindowRef wrTLW = + WindowRef wrTLW = (WindowRef) m_ctrl->MacGetTopLevelWindowRef(); ::MCSetControllerPort(m_mc, (CGrafPtr) GetWindowPort(wrTLW)); @@ -1114,7 +1116,7 @@ void wxQTMediaBackend::MacVisibilityChanged() //We are being hidden - set the GWorld of the controller //to the offscreen GWorld ::MCSetControllerPort(m_mc, m_movieWorld); - wxASSERT(::GetMoviesError() == noErr); + wxASSERT(::GetMoviesError() == noErr); } } @@ -1124,7 +1126,7 @@ void wxQTMediaBackend::MacVisibilityChanged() // Suggestion from Greg Hazel to repaint the movie when idle // (on pause also) //--------------------------------------------------------------------------- -void wxQTMediaEvtHandler::OnEraseBackground(wxEraseEvent& evt) +void wxQTMediaEvtHandler::OnEraseBackground(wxEraseEvent& WXUNUSED(evt)) { // Work around Nasty OSX drawing bug: // http://lists.apple.com/archives/QuickTime-API/2002/Feb/msg00311.html @@ -1199,18 +1201,18 @@ pascal Boolean wxQTMediaBackend::MCFilterProc( // messages to our moviecontroller so it can receive mouse clicks etc. //--------------------------------------------------------------------------- pascal OSStatus wxQTMediaBackend::WindowEventHandler( - EventHandlerCallRef inHandlerCallRef, + EventHandlerCallRef WXUNUSED(inHandlerCallRef), EventRef inEvent, void *inUserData) { wxQTMediaBackend* be = (wxQTMediaBackend*) inUserData; - + // Only process keyboard messages on this window if it actually // has focus, otherwise it will steal keystrokes from other windows! // As well as when it is not loaded properly as it // will crash in MCIsPlayerEvent if((GetEventClass(inEvent) == kEventClassKeyboard && - wxWindow::FindFocus() != be->m_ctrl) + wxWindow::FindFocus() != be->m_ctrl) || !be->m_ctrl->m_bLoaded) return eventNotHandledErr; @@ -1219,7 +1221,7 @@ pascal OSStatus wxQTMediaBackend::WindowEventHandler( ConvertEventRefToEventRecord( inEvent, &theEvent ); OSStatus err; - // TODO: Apple says MCIsPlayerEvent is depreciated and + // TODO: Apple says MCIsPlayerEvent is depreciated and // MCClick, MCKey, MCIdle etc. should be used // (RN: Of course that's what they say about // CreateMovieControl and HIMovieView as well, LOL!) @@ -1232,6 +1234,8 @@ pascal OSStatus wxQTMediaBackend::WindowEventHandler( return eventNotHandledErr; } +#endif + // in source file that contains stuff you don't directly use #include "wx/html/forcelnk.h" FORCE_LINK_ME(basewxmediabackends)