diff options
-rw-r--r-- | pacc/pacc-d3d9.c | 12 | ||||
-rw-r--r-- | pacc/pacc-win.h | 2 | ||||
-rw-r--r-- | win32/main.c | 9 |
3 files changed, 19 insertions, 4 deletions
diff --git a/pacc/pacc-d3d9.c b/pacc/pacc-d3d9.c index 5189afd..e645366 100644 --- a/pacc/pacc-d3d9.c +++ b/pacc/pacc-d3d9.c @@ -34,6 +34,8 @@ struct pacc_ctx { void *renderptr; HANDLE renderthread; HANDLE rendermtx; + UINT msg_reset; + HWND msg_wnd; }; struct pacc_buf { @@ -423,7 +425,10 @@ static DWORD WINAPI pacc_renderproc(void *ptr) { 1.0, 0); } pc->d3d9d->lpVtbl->EndScene(pc->d3d9d); - pc->d3d9d->lpVtbl->Present(pc->d3d9d, 0, 0, 0, 0); + HRESULT res = pc->d3d9d->lpVtbl->Present(pc->d3d9d, 0, 0, 0, 0); + if (res == D3DERR_DEVICELOST) { + PostMessage(pc->msg_wnd, pc->msg_reset, 0, 0); + } } ReleaseMutex(pc->rendermtx); } @@ -463,7 +468,8 @@ struct pacc_win_vtable pacc_win_vtable = { struct pacc_ctx *pacc_init_d3d9( HWND hwnd, pacc_rendercb *rendercb, void *renderptr, - struct pacc_vtable *vt, struct pacc_win_vtable *winvt) { + struct pacc_vtable *vt, struct pacc_win_vtable *winvt, + UINT msg_reset, HWND msg_wnd) { struct pacc_ctx *pc = malloc(sizeof(*pc)); if (!pc) goto err; RECT wr; @@ -474,6 +480,8 @@ struct pacc_ctx *pacc_init_d3d9( .hwnd = hwnd, .rendercb = rendercb, .renderptr = renderptr, + .msg_reset = msg_reset, + .msg_wnd = msg_wnd, }; atomic_init(&pc->killthread, false); pc->rendermtx = CreateMutex(0, FALSE, 0); diff --git a/pacc/pacc-win.h b/pacc/pacc-win.h index 47c09d1..e8bacc1 100644 --- a/pacc/pacc-win.h +++ b/pacc/pacc-win.h @@ -15,7 +15,7 @@ struct pacc_win_vtable { void (*renderctrl)(struct pacc_ctx *ctx, bool enable); }; -struct pacc_ctx *pacc_init_d3d9(HWND hwnd, pacc_rendercb *rendercb, void *renderptr, struct pacc_vtable *vt, struct pacc_win_vtable *winvt); +struct pacc_ctx *pacc_init_d3d9(HWND hwnd, pacc_rendercb *rendercb, void *renderptr, struct pacc_vtable *vt, struct pacc_win_vtable *winvt, UINT msg_reset, HWND msg_wnd); #endif // MYON_PACC_WIN_H_INCLUDED diff --git a/win32/main.c b/win32/main.c index 026250d..e3fb702 100644 --- a/win32/main.c +++ b/win32/main.c @@ -39,6 +39,10 @@ enum { ID_CONFIG, }; +enum { + WM_PACC_RESET = WM_USER, +}; + #define FMPLAYER_CLASSNAME L"myon_fmplayer_ym2608_win32" #define FMPLAYER_CDSTAG 0xFD809800UL @@ -703,6 +707,9 @@ static LRESULT CALLBACK wndproc( return DLGC_WANTMESSAGE; } break; + case WM_PACC_RESET: + // TODO + break; } return DefWindowProc(hwnd, msg, wParam, lParam); } @@ -789,7 +796,7 @@ int CALLBACK wWinMain(HINSTANCE hinst, HINSTANCE hpinst, wr.right-wr.left, wr.bottom-wr.top, 0, 0, g.hinst, 0 ); - g.pc = pacc_init_d3d9(g.fmdspwnd, render_cb, 0, &g.pacc, &g.pacc_win); + g.pc = pacc_init_d3d9(g.fmdspwnd, render_cb, 0, &g.pacc, &g.pacc_win, WM_PACC_RESET, g.mainwnd); if (!g.pc) { MessageBox(g.mainwnd, L"Error", L"Cannot initialize Direct3D", MB_ICONSTOP); return 0; |