mciqtz32: Stop the graph when the file is no longer playing.

This commit is contained in:
Andrew Eikum 2012-03-28 11:09:32 -05:00 committed by Alexandre Julliard
parent 105caa28bf
commit 8e88a5a6fa
2 changed files with 25 additions and 2 deletions

View File

@ -180,6 +180,12 @@ static DWORD MCIQTZ_mciOpen(UINT wDevID, DWORD dwFlags,
goto err; goto err;
} }
hr = IGraphBuilder_QueryInterface(wma->pgraph, &IID_IMediaEvent, (void**)&wma->mevent);
if (FAILED(hr)) {
TRACE("Cannot get IMediaEvent interface (hr = %x)\n", hr);
goto err;
}
hr = IGraphBuilder_QueryInterface(wma->pgraph, &IID_IVideoWindow, (void**)&wma->vidwin); hr = IGraphBuilder_QueryInterface(wma->pgraph, &IID_IVideoWindow, (void**)&wma->vidwin);
if (FAILED(hr)) { if (FAILED(hr)) {
TRACE("Cannot get IVideoWindow interface (hr = %x)\n", hr); TRACE("Cannot get IVideoWindow interface (hr = %x)\n", hr);
@ -246,6 +252,9 @@ err:
if (wma->pgraph) if (wma->pgraph)
IGraphBuilder_Release(wma->pgraph); IGraphBuilder_Release(wma->pgraph);
wma->pgraph = NULL; wma->pgraph = NULL;
if (wma->mevent)
IMediaEvent_Release(wma->mevent);
wma->mevent = NULL;
if (wma->pmctrl) if (wma->pmctrl)
IMediaControl_Release(wma->pmctrl); IMediaControl_Release(wma->pmctrl);
wma->pmctrl = NULL; wma->pmctrl = NULL;
@ -276,6 +285,7 @@ static DWORD MCIQTZ_mciClose(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpP
IUnknown_Release(wma->vidwin); IUnknown_Release(wma->vidwin);
IUnknown_Release(wma->vidbasic); IUnknown_Release(wma->vidbasic);
IUnknown_Release(wma->seek); IUnknown_Release(wma->seek);
IMediaEvent_Release(wma->mevent);
IGraphBuilder_Release(wma->pgraph); IGraphBuilder_Release(wma->pgraph);
IMediaControl_Release(wma->pmctrl); IMediaControl_Release(wma->pmctrl);
if (wma->uninit) if (wma->uninit)
@ -654,9 +664,21 @@ static DWORD MCIQTZ_mciStatus(UINT wDevID, DWORD dwFlags, LPMCI_DGV_STATUS_PARMS
IMediaControl_GetState(wma->pmctrl, -1, &state); IMediaControl_GetState(wma->pmctrl, -1, &state);
if (state == State_Stopped) if (state == State_Stopped)
lpParms->dwReturn = MCI_MODE_STOP; lpParms->dwReturn = MCI_MODE_STOP;
else if (state == State_Running) else if (state == State_Running) {
LONG code;
LONG_PTR p1, p2;
lpParms->dwReturn = MCI_MODE_PLAY; lpParms->dwReturn = MCI_MODE_PLAY;
else if (state == State_Paused)
do {
hr = IMediaEvent_GetEvent(wma->mevent, &code, &p1, &p2, 0);
if (hr == S_OK && code == EC_COMPLETE){
lpParms->dwReturn = MCI_MODE_STOP;
IMediaControl_Stop(wma->pmctrl);
}
} while (hr == S_OK);
} else if (state == State_Paused)
lpParms->dwReturn = MCI_MODE_PAUSE; lpParms->dwReturn = MCI_MODE_PAUSE;
break; break;
} }

View File

@ -32,6 +32,7 @@ typedef struct {
IGraphBuilder* pgraph; IGraphBuilder* pgraph;
IMediaControl* pmctrl; IMediaControl* pmctrl;
IMediaSeeking* seek; IMediaSeeking* seek;
IMediaEvent* mevent;
IVideoWindow* vidwin; IVideoWindow* vidwin;
IBasicVideo* vidbasic; IBasicVideo* vidbasic;
DWORD time_format; DWORD time_format;