cleanup - more reformatting; fixed bug introduced in prior commit

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37141 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Surovell
2006-01-25 23:07:33 +00:00
parent 6591df24b6
commit a7d5151df0

View File

@@ -2331,7 +2331,9 @@ bool wxMCIMediaBackend::Load(const wxString& fileName)
if ( mciSendCommand(0, MCI_OPEN, MCI_OPEN_ELEMENT, if ( mciSendCommand(0, MCI_OPEN, MCI_OPEN_ELEMENT,
(DWORD)(LPVOID)&openParms) != 0) (DWORD)(LPVOID)&openParms) != 0)
{
return false; return false;
}
m_hDev = openParms.wDeviceID; m_hDev = openParms.wDeviceID;
@@ -2343,8 +2345,8 @@ bool wxMCIMediaBackend::Load(const wxString& fileName)
if (mciSendCommand(m_hDev, MCI_SET, MCI_SET_TIME_FORMAT, if (mciSendCommand(m_hDev, MCI_SET, MCI_SET_TIME_FORMAT,
(DWORD)(LPVOID)&setParms) != 0) (DWORD)(LPVOID)&setParms) != 0)
{ {
}
return false; return false;
}
// tell the MCI device to display the video in our wxMediaCtrl // tell the MCI device to display the video in our wxMediaCtrl
MCI_DGV_WINDOW_PARMS windowParms; MCI_DGV_WINDOW_PARMS windowParms;
@@ -2514,7 +2516,9 @@ wxLongLong wxMCIMediaBackend::GetPosition()
if (mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM, if (mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM,
(DWORD)(LPSTR)&statusParms) != 0) (DWORD)(LPSTR)&statusParms) != 0)
{
return 0; return 0;
}
return statusParms.dwReturn; return statusParms.dwReturn;
} }
@@ -2533,7 +2537,9 @@ double wxMCIMediaBackend::GetVolume()
if (mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM, if (mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM,
(DWORD)(LPSTR)&statusParms) != 0) (DWORD)(LPSTR)&statusParms) != 0)
{
return 0; return 0;
}
return ((double)statusParms.dwReturn) / 1000.0; return ((double)statusParms.dwReturn) / 1000.0;
} }
@@ -2558,7 +2564,9 @@ bool wxMCIMediaBackend::SetVolume(double dVolume)
// MCI_DGV_SETAUDIO + (_ITEM | _VALUE) // MCI_DGV_SETAUDIO + (_ITEM | _VALUE)
0x00800000L | 0x01000000L, 0x00800000L | 0x01000000L,
(DWORD)(LPSTR)&audioParms) != 0) (DWORD)(LPSTR)&audioParms) != 0)
{
return false; return false;
}
return true; return true;
} }
@@ -2575,7 +2583,9 @@ wxLongLong wxMCIMediaBackend::GetDuration()
if (mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM, if (mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM,
(DWORD)(LPSTR)&statusParms) != 0) (DWORD)(LPSTR)&statusParms) != 0)
{
return 0; return 0;
}
return statusParms.dwReturn; return statusParms.dwReturn;
} }
@@ -2941,43 +2951,48 @@ bool wxQTMediaBackend::Load(const wxString& fileName)
if (m_movie) if (m_movie)
Cleanup(); Cleanup();
bool result = true;
OSErr err = noErr;
short movieResFile = 0; //= 0 because of annoying VC6 warning short movieResFile = 0; //= 0 because of annoying VC6 warning
FSSpec sfFile; FSSpec sfFile;
if (m_lib.NativePathNameToFSSpec( err = m_lib.NativePathNameToFSSpec(
(char*) (const char*) fileName.mb_str(), (char*) (const char*) fileName.mb_str(),
&sfFile, 0) != noErr) &sfFile, 0);
result = (err == noErr);
if (result)
{ {
return false; err = m_lib.OpenMovieFile(&sfFile, &movieResFile, fsRdPerm);
result = (err == noErr);
} }
if (m_lib.OpenMovieFile (&sfFile, &movieResFile, fsRdPerm) != noErr) if (result)
return false; {
short movieResID = 0;
Str255 movieName;
short movieResID = 0; err = m_lib.NewMovieFromFile(
Str255 movieName;
OSErr err = m_lib.NewMovieFromFile(
&m_movie, &m_movie,
movieResFile, movieResFile,
&movieResID, &movieResID,
movieName, movieName,
newMovieActive, newMovieActive,
NULL ); //wasChanged NULL ); // wasChanged
result = (err == noErr && m_lib.GetMoviesStickyError() == noErr);
// m_lib.GetMoviesStickyError() because it may not find the // check m_lib.GetMoviesStickyError() because it may not find the
// proper codec and play black video and other strange effects, // proper codec and play black video and other strange effects,
// not to mention mess up the dynamic backend loading scheme // not to mention mess up the dynamic backend loading scheme
// of wxMediaCtrl - so it just does what the QuickTime player does // of wxMediaCtrl - so it just does what the QuickTime player does
if (err == noErr && m_lib.GetMoviesStickyError() == noErr) if (result)
{ {
m_lib.CloseMovieFile (movieResFile); m_lib.CloseMovieFile(movieResFile);
FinishLoad();
FinishLoad(); }
return true;
} }
else
return false; return result;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@@ -2999,7 +3014,7 @@ void wxQTMediaBackend::PPRMProc (Movie theMovie,
long lTime = pBE->m_lib.GetMovieTime(theMovie,NULL); long lTime = pBE->m_lib.GetMovieTime(theMovie,NULL);
Fixed rate = pBE->m_lib.GetMoviePreferredRate(theMovie); Fixed rate = pBE->m_lib.GetMoviePreferredRate(theMovie);
pBE->m_lib.PrerollMovie(theMovie,lTime,rate); pBE->m_lib.PrerollMovie(theMovie, lTime, rate);
pBE->m_timer = new wxQTLoadTimer(pBE->m_movie, pBE, &pBE->m_lib); pBE->m_timer = new wxQTLoadTimer(pBE->m_movie, pBE, &pBE->m_lib);
pBE->m_timer->Start(MOVIE_DELAY); pBE->m_timer->Start(MOVIE_DELAY);
} }
@@ -3047,24 +3062,24 @@ bool wxQTMediaBackend::Load(const wxURI& location)
playRate = m_lib.GetMoviePreferredRate(m_movie); playRate = m_lib.GetMoviePreferredRate(m_movie);
wxASSERT(m_lib.GetMoviesError() == noErr); wxASSERT(m_lib.GetMoviesError() == noErr);
// Note that the callback here is optional, // Note that the callback here is optional,
// but without it PrePrerollMovie can be buggy // but without it PrePrerollMovie can be buggy
// (see Apple ml). Also, some may wonder // (see Apple ml). Also, some may wonder
// why we need this at all - this is because // why we need this at all - this is because
// Apple docs say QuickTime streamed movies // Apple docs say QuickTime streamed movies
// require it if you don't use a Movie Controller, // require it if you don't use a Movie Controller,
// which we don't by default. // which we don't by default.
// //
m_lib.PrePrerollMovie(m_movie, timeNow, playRate, m_lib.PrePrerollMovie(m_movie, timeNow, playRate,
(WXFARPROC)wxQTMediaBackend::PPRMProc, (WXFARPROC)wxQTMediaBackend::PPRMProc,
(void*)this); (void*)this);
return true; return true;
} }
else else
return false; return false;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// wxQTMediaBackend::FinishLoad // wxQTMediaBackend::FinishLoad
// //
@@ -3081,11 +3096,12 @@ void wxQTMediaBackend::FinishLoad()
// Create the playing/streaming timer // Create the playing/streaming timer
m_timer = new wxQTPlayTimer(m_movie, (wxQTMediaBackend*) this, &m_lib); m_timer = new wxQTPlayTimer(m_movie, (wxQTMediaBackend*) this, &m_lib);
wxASSERT(m_timer); wxASSERT(m_timer);
m_timer->Start(MOVIE_DELAY, wxTIMER_CONTINUOUS); m_timer->Start(MOVIE_DELAY, wxTIMER_CONTINUOUS);
// get the real size of the movie // get the real size of the movie
Rect outRect; Rect outRect;
memset(&outRect, 0, sizeof(Rect)); // for annoying VC6 warning memset(&outRect, 0, sizeof(Rect)); // suppress annoying VC6 warning
m_lib.GetMovieNaturalBoundsRect (m_movie, &outRect); m_lib.GetMovieNaturalBoundsRect (m_movie, &outRect);
wxASSERT(m_lib.GetMoviesError() == noErr); wxASSERT(m_lib.GetMoviesError() == noErr);
@@ -3172,7 +3188,7 @@ bool wxQTMediaBackend::Stop()
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// wxQTMediaBackend::GetPlaybackRate // wxQTMediaBackend::GetPlaybackRate
// //
// 1) Get the movie playback rate from ::GetMovieRate // Get the movie playback rate from ::GetMovieRate
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
double wxQTMediaBackend::GetPlaybackRate() double wxQTMediaBackend::GetPlaybackRate()
{ {
@@ -3182,7 +3198,7 @@ double wxQTMediaBackend::GetPlaybackRate()
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// wxQTMediaBackend::SetPlaybackRate // wxQTMediaBackend::SetPlaybackRate
// //
// 1) Convert dRate to Fixed and Set the movie rate through SetMovieRate // Convert dRate to Fixed and Set the movie rate through SetMovieRate
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool wxQTMediaBackend::SetPlaybackRate(double dRate) bool wxQTMediaBackend::SetPlaybackRate(double dRate)
{ {
@@ -3199,12 +3215,12 @@ bool wxQTMediaBackend::SetPlaybackRate(double dRate)
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool wxQTMediaBackend::SetPosition(wxLongLong where) bool wxQTMediaBackend::SetPosition(wxLongLong where)
{ {
//NB: For some reason SetMovieTime does not work // NB: For some reason SetMovieTime does not work
//correctly with the Quicktime Windows SDK (6) // correctly with the Quicktime Windows SDK (6)
//From Muskelkatermann at the wxForum // From Muskelkatermann at the wxForum
//http://www.solidsteel.nl/users/wxwidgets/viewtopic.php?t=2957 // http://www.solidsteel.nl/users/wxwidgets/viewtopic.php?t=2957
//RN - note that I have not verified this but there // RN - note that I have not verified this but there
//is no harm in calling SetMovieTimeValue instead // is no harm in calling SetMovieTimeValue instead
#if 0 #if 0
TimeRecord theTimeRecord; TimeRecord theTimeRecord;
memset(&theTimeRecord, 0, sizeof(TimeRecord)); memset(&theTimeRecord, 0, sizeof(TimeRecord));
@@ -3290,8 +3306,8 @@ wxLongLong wxQTMediaBackend::GetDuration()
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// wxQTMediaBackend::GetState // wxQTMediaBackend::GetState
// //
// Determines the current state - if we are at the beginning we // Determines the current state:
// are stopped // if we are at the beginning, then we are stopped
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
wxMediaState wxQTMediaBackend::GetState() wxMediaState wxQTMediaBackend::GetState()
{ {
@@ -3343,11 +3359,13 @@ bool wxQTMediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags)
{ {
if (m_pMC) if (m_pMC)
{ {
//restore old wndproc // restore old wndproc
wxSetWindowProc((HWND)m_ctrl->GetHWND(), wxWndProc); wxSetWindowProc((HWND)m_ctrl->GetHWND(), wxWndProc);
m_lib.DisposeMovieController(m_pMC); m_lib.DisposeMovieController(m_pMC);
m_pMC = NULL; m_pMC = NULL;
m_bestSize.y -= 16; //movie controller height
// movie controller height
m_bestSize.y -= 16;
} }
if (flags && m_movie) if (flags && m_movie)
@@ -3355,7 +3373,7 @@ bool wxQTMediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags)
Rect rect; Rect rect;
wxRect wxrect = m_ctrl->GetClientRect(); wxRect wxrect = m_ctrl->GetClientRect();
//make room for controller // make room for controller
if (wxrect.width < 320) if (wxrect.width < 320)
wxrect.width = 320; wxrect.width = 320;
@@ -3373,33 +3391,31 @@ bool wxQTMediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags)
m_lib.MCDoAction(m_pMC, 32, (void*)true); //mcActionSetKeysEnabled m_lib.MCDoAction(m_pMC, 32, (void*)true); //mcActionSetKeysEnabled
m_lib.MCSetActionFilterWithRefCon(m_pMC, m_lib.MCSetActionFilterWithRefCon(m_pMC,
(WXFARPROC)wxQTMediaBackend::MCFilterProc, (void*)this); (WXFARPROC)wxQTMediaBackend::MCFilterProc, (void*)this);
m_bestSize.y += 16; //movie controller height m_bestSize.y += 16; // movie controller height
// // By default the movie controller uses its own colour palette
// By default the movie controller uses its own color // for the movie which can be bad on some files, so turn it off.
// pallette for the movie which can be bad on some files - // Also turn off its frame/border for the movie
// so turn it off. Also turn off its frame/border for // Also take care of a couple of the interface flags here
// the movie
//
// Also we take care of a couple of the interface flags here
//
long mcFlags = 0; long mcFlags = 0;
m_lib.MCDoAction(m_pMC, 39/*mcActionGetFlags*/, (void*)&mcFlags); m_lib.MCDoAction(m_pMC, 39/*mcActionGetFlags*/, (void*)&mcFlags);
mcFlags |= ( //(1<< 0)/*mcFlagSuppressMovieFrame*/ |
(1<< 3)/*mcFlagsUseWindowPalette*/ mcFlags |=
| ((flags & wxMEDIACTRLPLAYERCONTROLS_STEP) // (1<< 0) /*mcFlagSuppressMovieFrame*/ |
(1<< 3) /*mcFlagsUseWindowPalette*/
| ((flags & wxMEDIACTRLPLAYERCONTROLS_STEP)
? 0 : (1<< 1) /*mcFlagSuppressStepButtons*/) ? 0 : (1<< 1) /*mcFlagSuppressStepButtons*/)
| ((flags & wxMEDIACTRLPLAYERCONTROLS_VOLUME) | ((flags & wxMEDIACTRLPLAYERCONTROLS_VOLUME)
? 0 : (1<< 2) /*mcFlagSuppressSpeakerButton*/) ? 0 : (1<< 2) /*mcFlagSuppressSpeakerButton*/)
// | (1<< 4) /*mcFlagDontInvalidate*/ //if we take care of repainting ourselves // | (1<< 4) /*mcFlagDontInvalidate*/ // if we take care of repainting ourselves
); ;
m_lib.MCDoAction(m_pMC, 38/*mcActionSetFlags*/, (void*)mcFlags); m_lib.MCDoAction(m_pMC, 38/*mcActionSetFlags*/, (void*)mcFlags);
//intercept the wndproc of our control window // intercept the wndproc of our control window
wxSetWindowProc((HWND)m_ctrl->GetHWND(), wxSetWindowProc((HWND)m_ctrl->GetHWND(), wxQTMediaBackend::QTWndProc);
wxQTMediaBackend::QTWndProc);
//set the user data of our window // set the user data of our window
wxSetWindowUserData((HWND)m_ctrl->GetHWND(), this); wxSetWindowUserData((HWND)m_ctrl->GetHWND(), this);
} }
} }
@@ -3414,34 +3430,36 @@ bool wxQTMediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags)
// //
// Callback for when the movie controller recieves a message // Callback for when the movie controller recieves a message
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
Boolean Boolean wxQTMediaBackend::MCFilterProc(MovieController WXUNUSED(theController),
wxQTMediaBackend::MCFilterProc(MovieController WXUNUSED(theController),
short action, short action,
void * WXUNUSED(params), void * WXUNUSED(params),
LONG_PTR refCon) LONG_PTR refCon)
{ {
if (action != 1) // don't process idle events wxQTMediaBackend* pThis = (wxQTMediaBackend*)refCon;
{
wxQTMediaBackend* pThis = (wxQTMediaBackend*)refCon;
switch (action) switch (action)
{ {
case 8: case 8:
// play button triggered - MC will set movie to opposite state // play button triggered - MC will set movie to opposite state
// of current - playing ? paused : playing // of current - playing ? paused : playing
if (pThis)
pThis->m_bPlaying = !(pThis->m_bPlaying); pThis->m_bPlaying = !(pThis->m_bPlaying);
// NB: Sometimes it doesn't redraw properly - // NB: Sometimes it doesn't redraw properly -
// if you click on the button but don't move the mouse // if you click on the button but don't move the mouse
// the button will not change its state until you move // the button will not change its state until you move
// mcActionDraw and Refresh/Update combo do nothing // mcActionDraw and Refresh/Update combo do nothing
// to help this unfortunately // to help this unfortunately
break; break;
default: case 1:
break; // don't process idle events
} break;
default:
break;
} }
return 0; return 0;
} }
@@ -3464,7 +3482,7 @@ void wxQTMediaBackend::Move(int WXUNUSED(x), int WXUNUSED(y), int w, int h)
{ {
if (m_movie) if (m_movie)
{ {
//make room for controller // make room for controller
if (m_pMC) if (m_pMC)
{ {
if (w < 320) if (w < 320)
@@ -3489,8 +3507,8 @@ void wxQTMediaBackend::Move(int WXUNUSED(x), int WXUNUSED(y), int w, int h)
// Suggestion from Greg Hazel to repaint the movie when idle // Suggestion from Greg Hazel to repaint the movie when idle
// (on pause also) // (on pause also)
// //
// TODO: We may be repainting too much here - under what exact circumstances // TODO: We may be repainting too much here - under what exact circumstances
// do we need this? I think Move also repaints correctly for the Movie // do we need this? I think Move also repaints correctly for the Movie
// Controller, so in that instance we don't need this either // Controller, so in that instance we don't need this either
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void wxQTMediaEvtHandler::OnEraseBackground(wxEraseEvent& evt) void wxQTMediaEvtHandler::OnEraseBackground(wxEraseEvent& evt)
@@ -3503,22 +3521,21 @@ void wxQTMediaEvtHandler::OnEraseBackground(wxEraseEvent& evt)
m_pLib.MCDoAction(m_qtb->m_pMC, 2 /*mcActionDraw*/, m_pLib.MCDoAction(m_qtb->m_pMC, 2 /*mcActionDraw*/,
m_pLib.GetNativeWindowPort(m_hwnd)); m_pLib.GetNativeWindowPort(m_hwnd));
} }
else // no movie controller else if ( m_qtb->m_movie )
{ {
if ( m_qtb->m_movie ) // no movie controller
{ CGrafPtr port = (CGrafPtr)m_pLib.GetNativeWindowPort(m_hwnd);
CGrafPtr port = (CGrafPtr)m_pLib.GetNativeWindowPort(m_hwnd);
m_pLib.BeginUpdate(port); m_pLib.BeginUpdate(port);
m_pLib.UpdateMovie(m_qtb->m_movie); m_pLib.UpdateMovie(m_qtb->m_movie);
wxASSERT(m_pLib.GetMoviesError() == noErr); wxASSERT(m_pLib.GetMoviesError() == noErr);
m_pLib.EndUpdate(port); m_pLib.EndUpdate(port);
} }
else // no movie else
{ {
// let the system repaint the window // no movie
evt.Skip(); // let the system repaint the window
} evt.Skip();
} }
} }