X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c0badb709a86b91a203416784b649e3d00c699c7..e9f935cb70df10fb95df5a884178265b716b69c9:/src/msw/mediactrl.cpp diff --git a/src/msw/mediactrl.cpp b/src/msw/mediactrl.cpp index afa432cd22..32adbe9836 100644 --- a/src/msw/mediactrl.cpp +++ b/src/msw/mediactrl.cpp @@ -38,9 +38,9 @@ #include "wx/log.h" #include "wx/dcclient.h" #include "wx/timer.h" + #include "wx/math.h" // log10 & pow #endif -#include "wx/math.h" // log10 & pow #include "wx/msw/private.h" // user info and wndproc setting/getting #include "wx/dynlib.h" @@ -48,11 +48,7 @@ // Externals (somewhere in src/msw/app.cpp and src/msw/window.cpp) //--------------------------------------------------------------------------- extern "C" WXDLLIMPEXP_BASE HINSTANCE wxGetInstance(void); -#ifdef __WXWINCE__ -extern WXDLLIMPEXP_CORE wxChar *wxCanvasClassName; -#else extern WXDLLIMPEXP_CORE const wxChar *wxCanvasClassName; -#endif LRESULT WXDLLIMPEXP_CORE APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); @@ -586,7 +582,7 @@ struct IMediaPlayer2 : public IMediaPlayer { STDMETHOD(get_DVD)(struct IMediaPlayerDvd __RPC_FAR *__RPC_FAR *ppdispatch) PURE; STDMETHOD(GetMediaParameter)(long EntryNum, BSTR bstrParameterName, BSTR __RPC_FAR *pbstrParameterValue) PURE; - STDMETHOD(GetMediaParameterName(long EntryNum, long Index, BSTR __RPC_FAR *pbstrParameterName) PURE; + STDMETHOD(GetMediaParameterName)(long EntryNum, long Index, BSTR __RPC_FAR *pbstrParameterName) PURE; STDMETHOD(get_EntryCount)(long __RPC_FAR *pNumberEntries) PURE; STDMETHOD(GetCurrentEntry)(long __RPC_FAR *pEntryNumber) PURE; STDMETHOD(SetCurrentEntry)(long EntryNumber) PURE; @@ -729,7 +725,7 @@ struct INSPlay : public INSOPlay STDMETHOD(put_BaseURL)(BSTR pbstrBaseURL) PURE; STDMETHOD(get_DefaultFrame)(BSTR __RPC_FAR *pbstrDefaultFrame) PURE; STDMETHOD(put_DefaultFrame)(BSTR pbstrDefaultFrame) PURE; - STDMETHOD(AboutBox))(void) PURE; + STDMETHOD(AboutBox)(void) PURE; STDMETHOD(Cancel)(void) PURE; STDMETHOD(GetCodecInstalled)(long CodecNum, VARIANT_BOOL __RPC_FAR *pCodecInstalled) PURE; STDMETHOD(GetCodecDescription)(long CodecNum, BSTR __RPC_FAR *pbstrCodecDescription) PURE; @@ -1484,7 +1480,7 @@ public: wxTimer* m_pTimer; wxSize m_bestSize; -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL wxDynamicLibrary m_dllQuartz; LPAMGETERRORTEXT m_lpAMGetErrorText; wxString GetErrorString(HRESULT hrdsv); @@ -1507,7 +1503,7 @@ class WXDLLIMPEXP_MEDIA wxMCIMediaBackend : public wxMediaBackendCommonBase { public: wxMCIMediaBackend(); - ~wxMCIMediaBackend(); + virtual ~wxMCIMediaBackend(); virtual bool CreateControl(wxControl* ctrl, wxWindow* parent, wxWindowID id, @@ -1665,22 +1661,6 @@ enum //--------------------------------------------------------------------------- // QT Library //--------------------------------------------------------------------------- -#define wxDL_METHOD_DEFINE( rettype, name, args, shortargs, defret ) \ - typedef rettype (* name ## Type) args ; \ - name ## Type pfn_ ## name; \ - rettype name args \ - { if (m_ok) return pfn_ ## name shortargs ; return defret; } - -#define wxDL_VOIDMETHOD_DEFINE( name, args, shortargs ) \ - typedef void (* name ## Type) args ; \ - name ## Type pfn_ ## name; \ - void name args \ - { if (m_ok) pfn_ ## name shortargs ; } - -#define wxDL_METHOD_LOAD( lib, name, success ) \ - pfn_ ## name = (name ## Type) lib.GetSymbol( wxT(#name), &success ); \ - if (!success) return false - class WXDLLIMPEXP_MEDIA wxQuickTimeLibrary { @@ -1791,83 +1771,78 @@ public: bool wxQuickTimeLibrary::Initialize() { - m_ok = false; - // Turn off the wxDynamicLibrary logging as we're prepared to handle the // errors wxLogNull nolog; - if (!m_dll.Load(wxT("qtmlClient.dll"))) - { + m_ok = m_dll.Load(wxT("qtmlClient.dll")); + if ( !m_ok ) return false; - } - wxDL_METHOD_LOAD( m_dll, StartMovie, m_ok ); - wxDL_METHOD_LOAD( m_dll, StopMovie, m_ok ); - wxDL_METHOD_LOAD( m_dll, IsMovieDone, m_ok ); - wxDL_METHOD_LOAD( m_dll, GoToBeginningOfMovie, m_ok ); - wxDL_METHOD_LOAD( m_dll, GetMoviesError, m_ok ); - wxDL_METHOD_LOAD( m_dll, EnterMovies, m_ok ); - wxDL_METHOD_LOAD( m_dll, ExitMovies, m_ok ); - wxDL_METHOD_LOAD( m_dll, InitializeQTML, m_ok ); - wxDL_METHOD_LOAD( m_dll, TerminateQTML, m_ok ); - wxDL_METHOD_LOAD( m_dll, NativePathNameToFSSpec, m_ok ); - wxDL_METHOD_LOAD( m_dll, OpenMovieFile, m_ok ); - wxDL_METHOD_LOAD( m_dll, CloseMovieFile, m_ok ); - wxDL_METHOD_LOAD( m_dll, NewMovieFromFile, m_ok ); - wxDL_METHOD_LOAD( m_dll, GetMovieRate, m_ok ); - wxDL_METHOD_LOAD( m_dll, SetMovieRate, m_ok ); - wxDL_METHOD_LOAD( m_dll, MoviesTask, m_ok ); - wxDL_METHOD_LOAD( m_dll, BlockMove, m_ok ); - wxDL_METHOD_LOAD( m_dll, NewHandleClear, m_ok ); - wxDL_METHOD_LOAD( m_dll, NewMovieFromDataRef, m_ok ); - wxDL_METHOD_LOAD( m_dll, DisposeHandle, m_ok ); - wxDL_METHOD_LOAD( m_dll, GetMovieNaturalBoundsRect, m_ok ); - wxDL_METHOD_LOAD( m_dll, GetMovieIndTrackType, m_ok ); - wxDL_METHOD_LOAD( m_dll, CreatePortAssociation, m_ok ); - wxDL_METHOD_LOAD( m_dll, DestroyPortAssociation, m_ok ); - wxDL_METHOD_LOAD( m_dll, GetNativeWindowPort, m_ok ); - wxDL_METHOD_LOAD( m_dll, SetMovieGWorld, m_ok ); - wxDL_METHOD_LOAD( m_dll, DisposeMovie, m_ok ); - wxDL_METHOD_LOAD( m_dll, SetMovieBox, m_ok ); - wxDL_METHOD_LOAD( m_dll, SetMovieTimeScale, m_ok ); - wxDL_METHOD_LOAD( m_dll, GetMovieDuration, m_ok ); - wxDL_METHOD_LOAD( m_dll, GetMovieTimeBase, m_ok ); - wxDL_METHOD_LOAD( m_dll, GetMovieTimeScale, m_ok ); - wxDL_METHOD_LOAD( m_dll, GetMovieTime, m_ok ); - wxDL_METHOD_LOAD( m_dll, SetMovieTime, m_ok ); - wxDL_METHOD_LOAD( m_dll, GetMovieVolume, m_ok ); - wxDL_METHOD_LOAD( m_dll, SetMovieVolume, m_ok ); - wxDL_METHOD_LOAD( m_dll, SetMovieTimeValue, m_ok ); - wxDL_METHOD_LOAD( m_dll, NewMovieController, m_ok ); - wxDL_METHOD_LOAD( m_dll, DisposeMovieController, m_ok ); - wxDL_METHOD_LOAD( m_dll, MCSetVisible, m_ok ); - wxDL_METHOD_LOAD( m_dll, PrePrerollMovie, m_ok ); - wxDL_METHOD_LOAD( m_dll, PrerollMovie, m_ok ); - wxDL_METHOD_LOAD( m_dll, GetMoviePreferredRate, m_ok ); - wxDL_METHOD_LOAD( m_dll, GetMovieLoadState, m_ok ); - wxDL_METHOD_LOAD( m_dll, MCDoAction, m_ok ); - wxDL_METHOD_LOAD( m_dll, MCSetControllerBoundsRect, m_ok ); - wxDL_METHOD_LOAD( m_dll, NativeEventToMacEvent, m_ok ); - wxDL_METHOD_LOAD( m_dll, MCIsPlayerEvent, m_ok ); - wxDL_METHOD_LOAD( m_dll, MCSetMovie, m_ok ); - wxDL_METHOD_LOAD( m_dll, MCSetActionFilterWithRefCon, m_ok ); - wxDL_METHOD_LOAD( m_dll, MCGetControllerInfo, m_ok ); - wxDL_METHOD_LOAD( m_dll, BeginUpdate, m_ok ); - wxDL_METHOD_LOAD( m_dll, UpdateMovie, m_ok ); - wxDL_METHOD_LOAD( m_dll, EndUpdate, m_ok ); - wxDL_METHOD_LOAD( m_dll, GetMoviesStickyError, m_ok ); - - m_ok = true; - - return true; + wxDL_METHOD_LOAD( m_dll, StartMovie ); + wxDL_METHOD_LOAD( m_dll, StopMovie ); + wxDL_METHOD_LOAD( m_dll, IsMovieDone ); + wxDL_METHOD_LOAD( m_dll, GoToBeginningOfMovie ); + wxDL_METHOD_LOAD( m_dll, GetMoviesError ); + wxDL_METHOD_LOAD( m_dll, EnterMovies ); + wxDL_METHOD_LOAD( m_dll, ExitMovies ); + wxDL_METHOD_LOAD( m_dll, InitializeQTML ); + wxDL_METHOD_LOAD( m_dll, TerminateQTML ); + wxDL_METHOD_LOAD( m_dll, NativePathNameToFSSpec ); + wxDL_METHOD_LOAD( m_dll, OpenMovieFile ); + wxDL_METHOD_LOAD( m_dll, CloseMovieFile ); + wxDL_METHOD_LOAD( m_dll, NewMovieFromFile ); + wxDL_METHOD_LOAD( m_dll, GetMovieRate ); + wxDL_METHOD_LOAD( m_dll, SetMovieRate ); + wxDL_METHOD_LOAD( m_dll, MoviesTask ); + wxDL_METHOD_LOAD( m_dll, BlockMove ); + wxDL_METHOD_LOAD( m_dll, NewHandleClear ); + wxDL_METHOD_LOAD( m_dll, NewMovieFromDataRef ); + wxDL_METHOD_LOAD( m_dll, DisposeHandle ); + wxDL_METHOD_LOAD( m_dll, GetMovieNaturalBoundsRect ); + wxDL_METHOD_LOAD( m_dll, GetMovieIndTrackType ); + wxDL_METHOD_LOAD( m_dll, CreatePortAssociation ); + wxDL_METHOD_LOAD( m_dll, DestroyPortAssociation ); + wxDL_METHOD_LOAD( m_dll, GetNativeWindowPort ); + wxDL_METHOD_LOAD( m_dll, SetMovieGWorld ); + wxDL_METHOD_LOAD( m_dll, DisposeMovie ); + wxDL_METHOD_LOAD( m_dll, SetMovieBox ); + wxDL_METHOD_LOAD( m_dll, SetMovieTimeScale ); + wxDL_METHOD_LOAD( m_dll, GetMovieDuration ); + wxDL_METHOD_LOAD( m_dll, GetMovieTimeBase ); + wxDL_METHOD_LOAD( m_dll, GetMovieTimeScale ); + wxDL_METHOD_LOAD( m_dll, GetMovieTime ); + wxDL_METHOD_LOAD( m_dll, SetMovieTime ); + wxDL_METHOD_LOAD( m_dll, GetMovieVolume ); + wxDL_METHOD_LOAD( m_dll, SetMovieVolume ); + wxDL_METHOD_LOAD( m_dll, SetMovieTimeValue ); + wxDL_METHOD_LOAD( m_dll, NewMovieController ); + wxDL_METHOD_LOAD( m_dll, DisposeMovieController ); + wxDL_METHOD_LOAD( m_dll, MCSetVisible ); + wxDL_METHOD_LOAD( m_dll, PrePrerollMovie ); + wxDL_METHOD_LOAD( m_dll, PrerollMovie ); + wxDL_METHOD_LOAD( m_dll, GetMoviePreferredRate ); + wxDL_METHOD_LOAD( m_dll, GetMovieLoadState ); + wxDL_METHOD_LOAD( m_dll, MCDoAction ); + wxDL_METHOD_LOAD( m_dll, MCSetControllerBoundsRect ); + wxDL_METHOD_LOAD( m_dll, NativeEventToMacEvent ); + wxDL_METHOD_LOAD( m_dll, MCIsPlayerEvent ); + wxDL_METHOD_LOAD( m_dll, MCSetMovie ); + wxDL_METHOD_LOAD( m_dll, MCSetActionFilterWithRefCon ); + wxDL_METHOD_LOAD( m_dll, MCGetControllerInfo ); + wxDL_METHOD_LOAD( m_dll, BeginUpdate ); + wxDL_METHOD_LOAD( m_dll, UpdateMovie ); + wxDL_METHOD_LOAD( m_dll, EndUpdate ); + wxDL_METHOD_LOAD( m_dll, GetMoviesStickyError ); + + return m_ok; } class WXDLLIMPEXP_MEDIA wxQTMediaBackend : public wxMediaBackendCommonBase { public: wxQTMediaBackend(); - ~wxQTMediaBackend(); + virtual ~wxQTMediaBackend(); virtual bool CreateControl(wxControl* ctrl, wxWindow* parent, wxWindowID id, @@ -1950,7 +1925,7 @@ private: wxQTMediaBackend *m_qtb; WXHWND m_hwnd; - DECLARE_NO_COPY_CLASS(wxQTMediaEvtHandler) + wxDECLARE_NO_COPY_CLASS(wxQTMediaEvtHandler); }; @@ -1967,7 +1942,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxAMMediaBackend, wxMediaBackend) //--------------------------------------------------------------------------- // Usual debugging macros //--------------------------------------------------------------------------- -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL #define MAX_ERROR_TEXT_LEN 160 // Get the error string for Active Movie @@ -1979,14 +1954,14 @@ wxString wxAMMediaBackend::GetErrorString(HRESULT hrdsv) { return wxString::Format(wxT("DirectShow error \"%s\" \n") wxT("(numeric %X)\n") - wxT("occured"), + wxT("occurred"), szError, (int)hrdsv); } else { return wxString::Format(wxT("Unknown error \n") wxT("(numeric %X)\n") - wxT("occured"), + wxT("occurred"), (int)hrdsv); } } @@ -1995,7 +1970,6 @@ wxString wxAMMediaBackend::GetErrorString(HRESULT hrdsv) #define wxVERIFY(x) wxASSERT((x)) #define wxAMLOG(x) wxLogDebug(GetErrorString(x)) #else -#define wxAMVERIFY(x) (x) #define wxVERIFY(x) (x) #define wxAMLOG(x) #define wxAMFAIL(x) @@ -2134,7 +2108,7 @@ public: pGB->Release(); } - ~wxAMPlayTimer() + virtual ~wxAMPlayTimer() { SAFE_RELEASE(m_pME); } @@ -2219,11 +2193,7 @@ wxAMMediaBackend::~wxAMMediaBackend() //--------------------------------------------------------------------------- void wxAMMediaBackend::Clear() { - if (m_pTimer) - { - delete m_pTimer; - m_pTimer = NULL; - } + wxDELETE(m_pTimer); } //--------------------------------------------------------------------------- @@ -2239,8 +2209,8 @@ bool wxAMMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent, { // First get the AMGetErrorText procedure in // debug mode for more meaningful messages -#ifdef __WXDEBUG__ - if ( m_dllQuartz.Load(_T("quartz.dll"), wxDL_VERBATIM) ) +#if wxDEBUG_LEVEL + if ( m_dllQuartz.Load(wxT("quartz.dll"), wxDL_VERBATIM) ) { m_lpAMGetErrorText = (LPAMGETERRORTEXT) m_dllQuartz.GetSymbolAorW(wxT("AMGetErrorText")); @@ -2804,7 +2774,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMCIMediaBackend, wxMediaBackend) // Usual debugging macros for MCI returns //--------------------------------------------------------------------------- -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL #define wxMCIVERIFY(arg) \ { \ DWORD nRet; \ @@ -2812,7 +2782,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMCIMediaBackend, wxMediaBackend) { \ TCHAR sz[5000]; \ mciGetErrorString(nRet, sz, 5000); \ - wxFAIL_MSG(wxString::Format(_T("MCI Error:%s"), sz)); \ + wxFAIL_MSG(wxString::Format(wxT("MCI Error:%s"), sz)); \ } \ } #else @@ -2950,7 +2920,7 @@ bool wxMCIMediaBackend::Load(const wxString& fileName) // omit this it tells MCI to select the device instead. This is good // because we have no reliable way of "enumerating" the devices in MCI MCI_OPEN_PARMS openParms; - openParms.lpstrElementName = (wxChar*) fileName.c_str(); + openParms.lpstrElementName = fileName.wx_str(); if (mciSendCommand(0, MCI_OPEN, MCI_OPEN_ELEMENT, (DWORD)(LPVOID)&openParms) != 0) @@ -3949,11 +3919,7 @@ void wxQTMediaBackend::Cleanup() { m_bPlaying = false; - if (m_timer) - { - delete m_timer; - m_timer = NULL; - } + wxDELETE(m_timer); m_lib.StopMovie(m_movie);