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; short movieResID = 0;
Str255 movieName; Str255 movieName;
OSErr err = m_lib.NewMovieFromFile( 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;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@@ -3058,13 +3073,13 @@ bool wxQTMediaBackend::Load(const wxURI& location)
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)
{ {
@@ -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()
{ {
@@ -3347,7 +3363,9 @@ bool wxQTMediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags)
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)
@@ -3375,29 +3393,27 @@ bool wxQTMediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags)
(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*/ |
mcFlags |=
// (1<< 0) /*mcFlagSuppressMovieFrame*/ |
(1<< 3) /*mcFlagsUseWindowPalette*/ (1<< 3) /*mcFlagsUseWindowPalette*/
| ((flags & wxMEDIACTRLPLAYERCONTROLS_STEP) | ((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,13 +3430,10 @@ 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;
@@ -3429,6 +3442,7 @@ wxQTMediaBackend::MCFilterProc(MovieController WXUNUSED(theController),
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 -
@@ -3438,10 +3452,14 @@ wxQTMediaBackend::MCFilterProc(MovieController WXUNUSED(theController),
// to help this unfortunately // to help this unfortunately
break; break;
case 1:
// don't process idle events
break;
default: default:
break; break;
} }
}
return 0; return 0;
} }
@@ -3503,10 +3521,9 @@ 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);
@@ -3514,13 +3531,13 @@ void wxQTMediaEvtHandler::OnEraseBackground(wxEraseEvent& evt)
wxASSERT(m_pLib.GetMoviesError() == noErr); wxASSERT(m_pLib.GetMoviesError() == noErr);
m_pLib.EndUpdate(port); m_pLib.EndUpdate(port);
} }
else // no movie else
{ {
// no movie
// let the system repaint the window // let the system repaint the window
evt.Skip(); evt.Skip();
} }
} }
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// End QT Backend // End QT Backend