1 | /* Copyright (c) 2001, Stanford University
|
---|
2 | * All rights reserved
|
---|
3 | *
|
---|
4 | * See the file LICENSE.txt for information on redistributing this software.
|
---|
5 | */
|
---|
6 |
|
---|
7 | #include "cr_spu.h"
|
---|
8 | #include "cr_net.h"
|
---|
9 | #include "cr_error.h"
|
---|
10 | #include "cr_mem.h"
|
---|
11 | #include "cr_string.h"
|
---|
12 | #include "cr_net.h"
|
---|
13 | #include "cr_environment.h"
|
---|
14 | #include "cr_process.h"
|
---|
15 | #include "cr_rand.h"
|
---|
16 | #include "cr_netserver.h"
|
---|
17 | #include "stub.h"
|
---|
18 | #include <stdlib.h>
|
---|
19 | #include <string.h>
|
---|
20 | #include <signal.h>
|
---|
21 | #include <iprt/initterm.h>
|
---|
22 | #include <iprt/thread.h>
|
---|
23 | #include <iprt/err.h>
|
---|
24 | #include <iprt/asm.h>
|
---|
25 | #ifndef WINDOWS
|
---|
26 | # include <sys/types.h>
|
---|
27 | # include <unistd.h>
|
---|
28 | #endif
|
---|
29 |
|
---|
30 | #ifdef VBOX_WITH_WDDM
|
---|
31 | #include <d3d9types.h>
|
---|
32 | #include <D3dumddi.h>
|
---|
33 | #include "../../WINNT/Graphics/Video/common/wddm/VBoxMPIf.h"
|
---|
34 | #include "../../WINNT/Graphics/Video/disp/wddm/VBoxDispMp.h"
|
---|
35 | #endif
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * If you change this, see the comments in tilesortspu_context.c
|
---|
39 | */
|
---|
40 | #define MAGIC_CONTEXT_BASE 500
|
---|
41 |
|
---|
42 | #define CONFIG_LOOKUP_FILE ".crconfigs"
|
---|
43 |
|
---|
44 | #ifdef WINDOWS
|
---|
45 | #define PYTHON_EXE "python.exe"
|
---|
46 | #else
|
---|
47 | #define PYTHON_EXE "python"
|
---|
48 | #endif
|
---|
49 |
|
---|
50 | #ifdef WINDOWS
|
---|
51 | static char* gsViewportHackApps[] = {"googleearth.exe", NULL};
|
---|
52 | #endif
|
---|
53 |
|
---|
54 | static bool stub_initialized = 0;
|
---|
55 | #ifdef WINDOWS
|
---|
56 | static CRmutex stub_init_mutex;
|
---|
57 | #define STUB_INIT_LOCK() do { crLockMutex(&stub_init_mutex); } while (0)
|
---|
58 | #define STUB_INIT_UNLOCK() do { crUnlockMutex(&stub_init_mutex); } while (0)
|
---|
59 | #else
|
---|
60 | #define STUB_INIT_LOCK() do { } while (0)
|
---|
61 | #define STUB_INIT_UNLOCK() do { } while (0)
|
---|
62 | #endif
|
---|
63 |
|
---|
64 | /* NOTE: 'SPUDispatchTable glim' is declared in NULLfuncs.py now */
|
---|
65 | /* NOTE: 'SPUDispatchTable stubThreadsafeDispatch' is declared in tsfuncs.c */
|
---|
66 | Stub stub;
|
---|
67 | #ifdef CHROMIUM_THREADSAFE
|
---|
68 | static bool g_stubIsCurrentContextTSDInited;
|
---|
69 | CRtsd g_stubCurrentContextTSD;
|
---|
70 | #endif
|
---|
71 |
|
---|
72 |
|
---|
73 | static void stubInitNativeDispatch( void )
|
---|
74 | {
|
---|
75 | #define MAX_FUNCS 1000
|
---|
76 | SPUNamedFunctionTable gl_funcs[MAX_FUNCS];
|
---|
77 | int numFuncs;
|
---|
78 |
|
---|
79 | numFuncs = crLoadOpenGL( &stub.wsInterface, gl_funcs );
|
---|
80 |
|
---|
81 | stub.haveNativeOpenGL = (numFuncs > 0);
|
---|
82 |
|
---|
83 | /* XXX call this after context binding */
|
---|
84 | numFuncs += crLoadOpenGLExtensions( &stub.wsInterface, gl_funcs + numFuncs );
|
---|
85 |
|
---|
86 | CRASSERT(numFuncs < MAX_FUNCS);
|
---|
87 |
|
---|
88 | crSPUInitDispatchTable( &stub.nativeDispatch );
|
---|
89 | crSPUInitDispatch( &stub.nativeDispatch, gl_funcs );
|
---|
90 | crSPUInitDispatchNops( &stub.nativeDispatch );
|
---|
91 | #undef MAX_FUNCS
|
---|
92 | }
|
---|
93 |
|
---|
94 |
|
---|
95 | /** Pointer to the SPU's real glClear and glViewport functions */
|
---|
96 | static ClearFunc_t origClear;
|
---|
97 | static ViewportFunc_t origViewport;
|
---|
98 | static SwapBuffersFunc_t origSwapBuffers;
|
---|
99 | static DrawBufferFunc_t origDrawBuffer;
|
---|
100 | static ScissorFunc_t origScissor;
|
---|
101 |
|
---|
102 | static void stubCheckWindowState(WindowInfo *window, GLboolean bFlushOnChange)
|
---|
103 | {
|
---|
104 | bool bForceUpdate = false;
|
---|
105 | bool bChanged = false;
|
---|
106 |
|
---|
107 | #ifdef WINDOWS
|
---|
108 | /* @todo install hook and track for WM_DISPLAYCHANGE */
|
---|
109 | {
|
---|
110 | DEVMODE devMode;
|
---|
111 |
|
---|
112 | devMode.dmSize = sizeof(DEVMODE);
|
---|
113 | EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devMode);
|
---|
114 |
|
---|
115 | if (devMode.dmPelsWidth!=window->dmPelsWidth || devMode.dmPelsHeight!=window->dmPelsHeight)
|
---|
116 | {
|
---|
117 | crDebug("Resolution changed(%d,%d), forcing window Pos/Size update", devMode.dmPelsWidth, devMode.dmPelsHeight);
|
---|
118 | window->dmPelsWidth = devMode.dmPelsWidth;
|
---|
119 | window->dmPelsHeight = devMode.dmPelsHeight;
|
---|
120 | bForceUpdate = true;
|
---|
121 | }
|
---|
122 | }
|
---|
123 | #endif
|
---|
124 |
|
---|
125 | bChanged = stubUpdateWindowGeometry(window, bForceUpdate) || bForceUpdate;
|
---|
126 |
|
---|
127 | #if defined(GLX) || defined (WINDOWS)
|
---|
128 | if (stub.trackWindowVisibleRgn)
|
---|
129 | {
|
---|
130 | bChanged = stubUpdateWindowVisibileRegions(window) || bChanged;
|
---|
131 | }
|
---|
132 | #endif
|
---|
133 |
|
---|
134 | if (stub.trackWindowVisibility && window->type == CHROMIUM && window->drawable) {
|
---|
135 | const int mapped = stubIsWindowVisible(window);
|
---|
136 | if (mapped != window->mapped) {
|
---|
137 | crDebug("Dispatched: WindowShow(%i, %i)", window->spuWindow, mapped);
|
---|
138 | stub.spu->dispatch_table.WindowShow(window->spuWindow, mapped);
|
---|
139 | window->mapped = mapped;
|
---|
140 | bChanged = true;
|
---|
141 | }
|
---|
142 | }
|
---|
143 |
|
---|
144 | if (bFlushOnChange && bChanged)
|
---|
145 | {
|
---|
146 | stub.spu->dispatch_table.Flush();
|
---|
147 | }
|
---|
148 | }
|
---|
149 |
|
---|
150 | static bool stubSystemWindowExist(WindowInfo *pWindow)
|
---|
151 | {
|
---|
152 | #ifdef WINDOWS
|
---|
153 | if (pWindow->hWnd!=WindowFromDC(pWindow->drawable))
|
---|
154 | {
|
---|
155 | return false;
|
---|
156 | }
|
---|
157 | #else
|
---|
158 | Window root;
|
---|
159 | int x, y;
|
---|
160 | unsigned int border, depth, w, h;
|
---|
161 | Display *dpy;
|
---|
162 |
|
---|
163 | dpy = stubGetWindowDisplay(pWindow);
|
---|
164 |
|
---|
165 | XLOCK(dpy);
|
---|
166 | if (!XGetGeometry(dpy, pWindow->drawable, &root, &x, &y, &w, &h, &border, &depth))
|
---|
167 | {
|
---|
168 | XUNLOCK(dpy);
|
---|
169 | return false;
|
---|
170 | }
|
---|
171 | XUNLOCK(dpy);
|
---|
172 | #endif
|
---|
173 |
|
---|
174 | return true;
|
---|
175 | }
|
---|
176 |
|
---|
177 | static void stubCheckWindowsCB(unsigned long key, void *data1, void *data2)
|
---|
178 | {
|
---|
179 | WindowInfo *pWindow = (WindowInfo *) data1;
|
---|
180 | ContextInfo *pCtx = (ContextInfo *) data2;
|
---|
181 |
|
---|
182 | if (pWindow == pCtx->currentDrawable
|
---|
183 | || pWindow->type!=CHROMIUM
|
---|
184 | || pWindow->pOwner!=pCtx)
|
---|
185 | {
|
---|
186 | return;
|
---|
187 | }
|
---|
188 |
|
---|
189 | if (!stubSystemWindowExist(pWindow))
|
---|
190 | {
|
---|
191 | #ifdef WINDOWS
|
---|
192 | crWindowDestroy((GLint)pWindow->hWnd);
|
---|
193 | #else
|
---|
194 | crWindowDestroy((GLint)pWindow->drawable);
|
---|
195 | #endif
|
---|
196 | return;
|
---|
197 | }
|
---|
198 |
|
---|
199 | stubCheckWindowState(pWindow, GL_FALSE);
|
---|
200 | }
|
---|
201 |
|
---|
202 | static void stubCheckWindowsState(void)
|
---|
203 | {
|
---|
204 | ContextInfo *context = stubGetCurrentContext();
|
---|
205 |
|
---|
206 | CRASSERT(stub.trackWindowSize || stub.trackWindowPos);
|
---|
207 |
|
---|
208 | if (!context)
|
---|
209 | return;
|
---|
210 |
|
---|
211 | #if defined(WINDOWS) && defined(VBOX_WITH_WDDM)
|
---|
212 | if (stub.bRunningUnderWDDM)
|
---|
213 | return;
|
---|
214 | #endif
|
---|
215 |
|
---|
216 | #if defined(CR_NEWWINTRACK) && !defined(WINDOWS)
|
---|
217 | crLockMutex(&stub.mutex);
|
---|
218 | #endif
|
---|
219 |
|
---|
220 | stubCheckWindowState(context->currentDrawable, GL_TRUE);
|
---|
221 | crHashtableWalk(stub.windowTable, stubCheckWindowsCB, context);
|
---|
222 |
|
---|
223 | #if defined(CR_NEWWINTRACK) && !defined(WINDOWS)
|
---|
224 | crUnlockMutex(&stub.mutex);
|
---|
225 | #endif
|
---|
226 | }
|
---|
227 |
|
---|
228 |
|
---|
229 | /**
|
---|
230 | * Override the head SPU's glClear function.
|
---|
231 | * We're basically trapping this function so that we can poll the
|
---|
232 | * application window size at a regular interval.
|
---|
233 | */
|
---|
234 | static void SPU_APIENTRY trapClear(GLbitfield mask)
|
---|
235 | {
|
---|
236 | stubCheckWindowsState();
|
---|
237 | /* call the original SPU glClear function */
|
---|
238 | origClear(mask);
|
---|
239 | }
|
---|
240 |
|
---|
241 | /**
|
---|
242 | * As above, but for glViewport. Most apps call glViewport before
|
---|
243 | * glClear when a window is resized.
|
---|
244 | */
|
---|
245 | static void SPU_APIENTRY trapViewport(GLint x, GLint y, GLsizei w, GLsizei h)
|
---|
246 | {
|
---|
247 | stubCheckWindowsState();
|
---|
248 | /* call the original SPU glViewport function */
|
---|
249 | if (!stub.viewportHack)
|
---|
250 | {
|
---|
251 | origViewport(x, y, w, h);
|
---|
252 | }
|
---|
253 | else
|
---|
254 | {
|
---|
255 | ContextInfo *context = stubGetCurrentContext();
|
---|
256 | int winX, winY;
|
---|
257 | unsigned int winW, winH;
|
---|
258 | WindowInfo *pWindow;
|
---|
259 | pWindow = context->currentDrawable;
|
---|
260 | stubGetWindowGeometry(pWindow, &winX, &winY, &winW, &winH);
|
---|
261 | origViewport(0, 0, winW, winH);
|
---|
262 | }
|
---|
263 | }
|
---|
264 |
|
---|
265 | static void SPU_APIENTRY trapSwapBuffers(GLint window, GLint flags)
|
---|
266 | {
|
---|
267 | stubCheckWindowsState();
|
---|
268 | origSwapBuffers(window, flags);
|
---|
269 | }
|
---|
270 |
|
---|
271 | static void SPU_APIENTRY trapDrawBuffer(GLenum buf)
|
---|
272 | {
|
---|
273 | stubCheckWindowsState();
|
---|
274 | origDrawBuffer(buf);
|
---|
275 | }
|
---|
276 |
|
---|
277 | static void SPU_APIENTRY trapScissor(GLint x, GLint y, GLsizei w, GLsizei h)
|
---|
278 | {
|
---|
279 | int winX, winY;
|
---|
280 | unsigned int winW, winH;
|
---|
281 | WindowInfo *pWindow;
|
---|
282 | ContextInfo *context = stubGetCurrentContext();
|
---|
283 | pWindow = context->currentDrawable;
|
---|
284 | stubGetWindowGeometry(pWindow, &winX, &winY, &winW, &winH);
|
---|
285 | origScissor(0, 0, winW, winH);
|
---|
286 | }
|
---|
287 |
|
---|
288 | /**
|
---|
289 | * Use the GL function pointers in <spu> to initialize the static glim
|
---|
290 | * dispatch table.
|
---|
291 | */
|
---|
292 | static void stubInitSPUDispatch(SPU *spu)
|
---|
293 | {
|
---|
294 | crSPUInitDispatchTable( &stub.spuDispatch );
|
---|
295 | crSPUCopyDispatchTable( &stub.spuDispatch, &(spu->dispatch_table) );
|
---|
296 |
|
---|
297 | if (stub.trackWindowSize || stub.trackWindowPos || stub.trackWindowVisibleRgn) {
|
---|
298 | /* patch-in special glClear/Viewport function to track window sizing */
|
---|
299 | origClear = stub.spuDispatch.Clear;
|
---|
300 | origViewport = stub.spuDispatch.Viewport;
|
---|
301 | origSwapBuffers = stub.spuDispatch.SwapBuffers;
|
---|
302 | origDrawBuffer = stub.spuDispatch.DrawBuffer;
|
---|
303 | origScissor = stub.spuDispatch.Scissor;
|
---|
304 | stub.spuDispatch.Clear = trapClear;
|
---|
305 | stub.spuDispatch.Viewport = trapViewport;
|
---|
306 |
|
---|
307 | if (stub.viewportHack)
|
---|
308 | stub.spuDispatch.Scissor = trapScissor;
|
---|
309 | /*stub.spuDispatch.SwapBuffers = trapSwapBuffers;
|
---|
310 | stub.spuDispatch.DrawBuffer = trapDrawBuffer;*/
|
---|
311 | }
|
---|
312 |
|
---|
313 | crSPUCopyDispatchTable( &glim, &stub.spuDispatch );
|
---|
314 | }
|
---|
315 |
|
---|
316 | // Callback function, used to destroy all created contexts
|
---|
317 | static void hsWalkStubDestroyContexts(unsigned long key, void *data1, void *data2)
|
---|
318 | {
|
---|
319 | stubDestroyContext(key);
|
---|
320 | }
|
---|
321 |
|
---|
322 | /**
|
---|
323 | * This is called when we exit.
|
---|
324 | * We call all the SPU's cleanup functions.
|
---|
325 | */
|
---|
326 | static void stubSPUTearDownLocked(void)
|
---|
327 | {
|
---|
328 | crDebug("stubSPUTearDownLocked");
|
---|
329 |
|
---|
330 | #ifdef WINDOWS
|
---|
331 | # ifndef CR_NEWWINTRACK
|
---|
332 | stubUninstallWindowMessageHook();
|
---|
333 | # endif
|
---|
334 | #endif
|
---|
335 |
|
---|
336 | #ifdef CR_NEWWINTRACK
|
---|
337 | ASMAtomicWriteBool(&stub.bShutdownSyncThread, true);
|
---|
338 | #endif
|
---|
339 |
|
---|
340 | //delete all created contexts
|
---|
341 | stubMakeCurrent( NULL, NULL);
|
---|
342 |
|
---|
343 | /* the lock order is windowTable->contextTable (see wglMakeCurrent_prox, glXMakeCurrent)
|
---|
344 | * this is why we need to take a windowTable lock since we will later do stub.windowTable access & locking */
|
---|
345 | crHashtableLock(stub.windowTable);
|
---|
346 | crHashtableWalk(stub.contextTable, hsWalkStubDestroyContexts, NULL);
|
---|
347 | crHashtableUnlock(stub.windowTable);
|
---|
348 |
|
---|
349 | /* shutdown, now trap any calls to a NULL dispatcher */
|
---|
350 | crSPUCopyDispatchTable(&glim, &stubNULLDispatch);
|
---|
351 |
|
---|
352 | crSPUUnloadChain(stub.spu);
|
---|
353 | stub.spu = NULL;
|
---|
354 |
|
---|
355 | #ifndef Linux
|
---|
356 | crUnloadOpenGL();
|
---|
357 | #endif
|
---|
358 |
|
---|
359 | #ifndef WINDOWS
|
---|
360 | crNetTearDown();
|
---|
361 | #endif
|
---|
362 |
|
---|
363 | #ifdef GLX
|
---|
364 | if (stub.xshmSI.shmid>=0)
|
---|
365 | {
|
---|
366 | shmctl(stub.xshmSI.shmid, IPC_RMID, 0);
|
---|
367 | shmdt(stub.xshmSI.shmaddr);
|
---|
368 | }
|
---|
369 | crFreeHashtable(stub.pGLXPixmapsHash, crFree);
|
---|
370 | #endif
|
---|
371 |
|
---|
372 | crFreeHashtable(stub.windowTable, crFree);
|
---|
373 | crFreeHashtable(stub.contextTable, NULL);
|
---|
374 |
|
---|
375 | crMemset(&stub, 0, sizeof(stub));
|
---|
376 |
|
---|
377 | }
|
---|
378 |
|
---|
379 | /**
|
---|
380 | * This is called when we exit.
|
---|
381 | * We call all the SPU's cleanup functions.
|
---|
382 | */
|
---|
383 | static void stubSPUTearDown(void)
|
---|
384 | {
|
---|
385 | STUB_INIT_LOCK();
|
---|
386 | if (stub_initialized)
|
---|
387 | {
|
---|
388 | stubSPUTearDownLocked();
|
---|
389 | stub_initialized = 0;
|
---|
390 | }
|
---|
391 | STUB_INIT_UNLOCK();
|
---|
392 | }
|
---|
393 |
|
---|
394 | static void stubSPUSafeTearDown(void)
|
---|
395 | {
|
---|
396 | #ifdef CHROMIUM_THREADSAFE
|
---|
397 | CRmutex *mutex;
|
---|
398 | #endif
|
---|
399 |
|
---|
400 | if (!stub_initialized) return;
|
---|
401 | stub_initialized = 0;
|
---|
402 |
|
---|
403 | #ifdef CHROMIUM_THREADSAFE
|
---|
404 | mutex = &stub.mutex;
|
---|
405 | crLockMutex(mutex);
|
---|
406 | #endif
|
---|
407 | crDebug("stubSPUSafeTearDown");
|
---|
408 |
|
---|
409 | #ifdef WINDOWS
|
---|
410 | # ifndef CR_NEWWINTRACK
|
---|
411 | stubUninstallWindowMessageHook();
|
---|
412 | # endif
|
---|
413 | #endif
|
---|
414 |
|
---|
415 | #if defined(CR_NEWWINTRACK)
|
---|
416 | crUnlockMutex(mutex);
|
---|
417 | # if defined(WINDOWS)
|
---|
418 | if (RTThreadGetState(stub.hSyncThread)!=RTTHREADSTATE_TERMINATED)
|
---|
419 | {
|
---|
420 | HANDLE hNative;
|
---|
421 | DWORD ec=0;
|
---|
422 |
|
---|
423 | hNative = OpenThread(SYNCHRONIZE|THREAD_QUERY_INFORMATION|THREAD_TERMINATE,
|
---|
424 | false, RTThreadGetNative(stub.hSyncThread));
|
---|
425 | if (!hNative)
|
---|
426 | {
|
---|
427 | crWarning("Failed to get handle for sync thread(%#x)", GetLastError());
|
---|
428 | }
|
---|
429 | else
|
---|
430 | {
|
---|
431 | crDebug("Got handle %p for thread %#x", hNative, RTThreadGetNative(stub.hSyncThread));
|
---|
432 | }
|
---|
433 |
|
---|
434 | ASMAtomicWriteBool(&stub.bShutdownSyncThread, true);
|
---|
435 |
|
---|
436 | if (PostThreadMessage(RTThreadGetNative(stub.hSyncThread), WM_QUIT, 0, 0))
|
---|
437 | {
|
---|
438 | RTThreadWait(stub.hSyncThread, 1000, NULL);
|
---|
439 |
|
---|
440 | /*Same issue as on linux, RTThreadWait exits before system thread is terminated, which leads
|
---|
441 | * to issues as our dll goes to be unloaded.
|
---|
442 | *@todo
|
---|
443 | *We usually call this function from DllMain which seems to be holding some lock and thus we have to
|
---|
444 | * kill thread via TerminateThread.
|
---|
445 | */
|
---|
446 | if (WaitForSingleObject(hNative, 100)==WAIT_TIMEOUT)
|
---|
447 | {
|
---|
448 | crDebug("Wait failed, terminating");
|
---|
449 | if (!TerminateThread(hNative, 1))
|
---|
450 | {
|
---|
451 | crDebug("TerminateThread failed");
|
---|
452 | }
|
---|
453 | }
|
---|
454 | if (GetExitCodeThread(hNative, &ec))
|
---|
455 | {
|
---|
456 | crDebug("Thread %p exited with ec=%i", hNative, ec);
|
---|
457 | }
|
---|
458 | else
|
---|
459 | {
|
---|
460 | crDebug("GetExitCodeThread failed(%#x)", GetLastError());
|
---|
461 | }
|
---|
462 | }
|
---|
463 | else
|
---|
464 | {
|
---|
465 | crDebug("Sync thread killed before DLL_PROCESS_DETACH");
|
---|
466 | }
|
---|
467 |
|
---|
468 | if (hNative)
|
---|
469 | {
|
---|
470 | CloseHandle(hNative);
|
---|
471 | }
|
---|
472 | }
|
---|
473 | #else
|
---|
474 | if (stub.hSyncThread!=NIL_RTTHREAD)
|
---|
475 | {
|
---|
476 | ASMAtomicWriteBool(&stub.bShutdownSyncThread, true);
|
---|
477 | {
|
---|
478 | /*RTThreadWait might return too early, which cause our code being unloaded while RT thread wrapper is still running*/
|
---|
479 | int rc = pthread_join(RTThreadGetNative(stub.hSyncThread), NULL);
|
---|
480 | if (!rc)
|
---|
481 | {
|
---|
482 | crDebug("pthread_join failed %i", rc);
|
---|
483 | }
|
---|
484 | }
|
---|
485 | }
|
---|
486 | #endif
|
---|
487 | crLockMutex(mutex);
|
---|
488 | #endif
|
---|
489 |
|
---|
490 | #ifndef WINDOWS
|
---|
491 | crNetTearDown();
|
---|
492 | #endif
|
---|
493 |
|
---|
494 | #ifdef CHROMIUM_THREADSAFE
|
---|
495 | crUnlockMutex(mutex);
|
---|
496 | crFreeMutex(mutex);
|
---|
497 | #endif
|
---|
498 | crMemset(&stub, 0, sizeof(stub));
|
---|
499 | }
|
---|
500 |
|
---|
501 |
|
---|
502 | static void stubExitHandler(void)
|
---|
503 | {
|
---|
504 | stubSPUSafeTearDown();
|
---|
505 | }
|
---|
506 |
|
---|
507 | /**
|
---|
508 | * Called when we receive a SIGTERM signal.
|
---|
509 | */
|
---|
510 | static void stubSignalHandler(int signo)
|
---|
511 | {
|
---|
512 | stubSPUSafeTearDown();
|
---|
513 | exit(0); /* this causes stubExitHandler() to be called */
|
---|
514 | }
|
---|
515 |
|
---|
516 | #ifndef RT_OS_WINDOWS
|
---|
517 | # ifdef CHROMIUM_THREADSAFE
|
---|
518 | static DECLCALLBACK(void) stubThreadTlsDtor(void *pvValue)
|
---|
519 | {
|
---|
520 | ContextInfo *pCtx = (ContextInfo*)pvValue;
|
---|
521 | VBoxTlsRefRelease(pCtx);
|
---|
522 | }
|
---|
523 | # endif
|
---|
524 | #endif
|
---|
525 |
|
---|
526 |
|
---|
527 | /**
|
---|
528 | * Init variables in the stub structure, install signal handler.
|
---|
529 | */
|
---|
530 | static void stubInitVars(void)
|
---|
531 | {
|
---|
532 | WindowInfo *defaultWin;
|
---|
533 |
|
---|
534 | #ifdef CHROMIUM_THREADSAFE
|
---|
535 | crInitMutex(&stub.mutex);
|
---|
536 | #endif
|
---|
537 |
|
---|
538 | /* At the very least we want CR_RGB_BIT. */
|
---|
539 | stub.haveNativeOpenGL = GL_FALSE;
|
---|
540 | stub.spu = NULL;
|
---|
541 | stub.appDrawCursor = 0;
|
---|
542 | stub.minChromiumWindowWidth = 0;
|
---|
543 | stub.minChromiumWindowHeight = 0;
|
---|
544 | stub.maxChromiumWindowWidth = 0;
|
---|
545 | stub.maxChromiumWindowHeight = 0;
|
---|
546 | stub.matchChromiumWindowCount = 0;
|
---|
547 | stub.matchChromiumWindowID = NULL;
|
---|
548 | stub.matchWindowTitle = NULL;
|
---|
549 | stub.ignoreFreeglutMenus = 0;
|
---|
550 | stub.threadSafe = GL_FALSE;
|
---|
551 | stub.trackWindowSize = 0;
|
---|
552 | stub.trackWindowPos = 0;
|
---|
553 | stub.trackWindowVisibility = 0;
|
---|
554 | stub.trackWindowVisibleRgn = 0;
|
---|
555 | stub.mothershipPID = 0;
|
---|
556 | stub.spu_dir = NULL;
|
---|
557 |
|
---|
558 | stub.freeContextNumber = MAGIC_CONTEXT_BASE;
|
---|
559 | stub.contextTable = crAllocHashtable();
|
---|
560 | #ifndef RT_OS_WINDOWS
|
---|
561 | # ifdef CHROMIUM_THREADSAFE
|
---|
562 | if (!g_stubIsCurrentContextTSDInited)
|
---|
563 | {
|
---|
564 | crInitTSDF(&g_stubCurrentContextTSD, stubThreadTlsDtor);
|
---|
565 | g_stubIsCurrentContextTSDInited = true;
|
---|
566 | }
|
---|
567 | # endif
|
---|
568 | #endif
|
---|
569 | stubSetCurrentContext(NULL);
|
---|
570 |
|
---|
571 | stub.windowTable = crAllocHashtable();
|
---|
572 |
|
---|
573 | #ifdef CR_NEWWINTRACK
|
---|
574 | stub.bShutdownSyncThread = false;
|
---|
575 | stub.hSyncThread = NIL_RTTHREAD;
|
---|
576 | #endif
|
---|
577 |
|
---|
578 | defaultWin = (WindowInfo *) crCalloc(sizeof(WindowInfo));
|
---|
579 | defaultWin->type = CHROMIUM;
|
---|
580 | defaultWin->spuWindow = 0; /* window 0 always exists */
|
---|
581 | #ifdef WINDOWS
|
---|
582 | defaultWin->hVisibleRegion = INVALID_HANDLE_VALUE;
|
---|
583 | #elif defined(GLX)
|
---|
584 | defaultWin->pVisibleRegions = NULL;
|
---|
585 | defaultWin->cVisibleRegions = 0;
|
---|
586 | #endif
|
---|
587 | crHashtableAdd(stub.windowTable, 0, defaultWin);
|
---|
588 |
|
---|
589 | #if 1
|
---|
590 | atexit(stubExitHandler);
|
---|
591 | signal(SIGTERM, stubSignalHandler);
|
---|
592 | signal(SIGINT, stubSignalHandler);
|
---|
593 | #ifndef WINDOWS
|
---|
594 | signal(SIGPIPE, SIG_IGN); /* the networking code should catch this */
|
---|
595 | #endif
|
---|
596 | #else
|
---|
597 | (void) stubExitHandler;
|
---|
598 | (void) stubSignalHandler;
|
---|
599 | #endif
|
---|
600 | }
|
---|
601 |
|
---|
602 |
|
---|
603 | /**
|
---|
604 | * Return a free port number for the mothership to use, or -1 if we
|
---|
605 | * can't find one.
|
---|
606 | */
|
---|
607 | static int
|
---|
608 | GenerateMothershipPort(void)
|
---|
609 | {
|
---|
610 | const int MAX_PORT = 10100;
|
---|
611 | unsigned short port;
|
---|
612 |
|
---|
613 | /* generate initial port number randomly */
|
---|
614 | crRandAutoSeed();
|
---|
615 | port = (unsigned short) crRandInt(10001, MAX_PORT);
|
---|
616 |
|
---|
617 | #ifdef WINDOWS
|
---|
618 | /* XXX should implement a free port check here */
|
---|
619 | return port;
|
---|
620 | #else
|
---|
621 | /*
|
---|
622 | * See if this port number really is free, try another if needed.
|
---|
623 | */
|
---|
624 | {
|
---|
625 | struct sockaddr_in servaddr;
|
---|
626 | int so_reuseaddr = 1;
|
---|
627 | int sock, k;
|
---|
628 |
|
---|
629 | /* create socket */
|
---|
630 | sock = socket(AF_INET, SOCK_STREAM, 0);
|
---|
631 | CRASSERT(sock > 2);
|
---|
632 |
|
---|
633 | /* deallocate socket/port when we exit */
|
---|
634 | k = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
|
---|
635 | (char *) &so_reuseaddr, sizeof(so_reuseaddr));
|
---|
636 | CRASSERT(k == 0);
|
---|
637 |
|
---|
638 | /* initialize the servaddr struct */
|
---|
639 | crMemset(&servaddr, 0, sizeof(servaddr) );
|
---|
640 | servaddr.sin_family = AF_INET;
|
---|
641 | servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
---|
642 |
|
---|
643 | while (port < MAX_PORT) {
|
---|
644 | /* Bind to the given port number, return -1 if we fail */
|
---|
645 | servaddr.sin_port = htons((unsigned short) port);
|
---|
646 | k = bind(sock, (struct sockaddr *) &servaddr, sizeof(servaddr));
|
---|
647 | if (k) {
|
---|
648 | /* failed to create port. try next one. */
|
---|
649 | port++;
|
---|
650 | }
|
---|
651 | else {
|
---|
652 | /* free the socket/port now so mothership can make it */
|
---|
653 | close(sock);
|
---|
654 | return port;
|
---|
655 | }
|
---|
656 | }
|
---|
657 | }
|
---|
658 | #endif /* WINDOWS */
|
---|
659 | return -1;
|
---|
660 | }
|
---|
661 |
|
---|
662 |
|
---|
663 | /**
|
---|
664 | * Try to determine which mothership configuration to use for this program.
|
---|
665 | */
|
---|
666 | static char **
|
---|
667 | LookupMothershipConfig(const char *procName)
|
---|
668 | {
|
---|
669 | const int procNameLen = crStrlen(procName);
|
---|
670 | FILE *f;
|
---|
671 | const char *home;
|
---|
672 | char configPath[1000];
|
---|
673 |
|
---|
674 | /* first, check if the CR_CONFIG env var is set */
|
---|
675 | {
|
---|
676 | const char *conf = crGetenv("CR_CONFIG");
|
---|
677 | if (conf && crStrlen(conf) > 0)
|
---|
678 | return crStrSplit(conf, " ");
|
---|
679 | }
|
---|
680 |
|
---|
681 | /* second, look up config name from config file */
|
---|
682 | home = crGetenv("HOME");
|
---|
683 | if (home)
|
---|
684 | sprintf(configPath, "%s/%s", home, CONFIG_LOOKUP_FILE);
|
---|
685 | else
|
---|
686 | crStrcpy(configPath, CONFIG_LOOKUP_FILE); /* from current dir */
|
---|
687 | /* Check if the CR_CONFIG_PATH env var is set. */
|
---|
688 | {
|
---|
689 | const char *conf = crGetenv("CR_CONFIG_PATH");
|
---|
690 | if (conf)
|
---|
691 | crStrcpy(configPath, conf); /* from env var */
|
---|
692 | }
|
---|
693 |
|
---|
694 | f = fopen(configPath, "r");
|
---|
695 | if (!f) {
|
---|
696 | return NULL;
|
---|
697 | }
|
---|
698 |
|
---|
699 | while (!feof(f)) {
|
---|
700 | char line[1000];
|
---|
701 | char **args;
|
---|
702 | fgets(line, 999, f);
|
---|
703 | line[crStrlen(line) - 1] = 0; /* remove trailing newline */
|
---|
704 | if (crStrncmp(line, procName, procNameLen) == 0 &&
|
---|
705 | (line[procNameLen] == ' ' || line[procNameLen] == '\t'))
|
---|
706 | {
|
---|
707 | crWarning("Using Chromium configuration for %s from %s",
|
---|
708 | procName, configPath);
|
---|
709 | args = crStrSplit(line + procNameLen + 1, " ");
|
---|
710 | return args;
|
---|
711 | }
|
---|
712 | }
|
---|
713 | fclose(f);
|
---|
714 | return NULL;
|
---|
715 | }
|
---|
716 |
|
---|
717 |
|
---|
718 | static int Mothership_Awake = 0;
|
---|
719 |
|
---|
720 |
|
---|
721 | /**
|
---|
722 | * Signal handler to determine when mothership is ready.
|
---|
723 | */
|
---|
724 | static void
|
---|
725 | MothershipPhoneHome(int signo)
|
---|
726 | {
|
---|
727 | crDebug("Got signal %d: mothership is awake!", signo);
|
---|
728 | Mothership_Awake = 1;
|
---|
729 | }
|
---|
730 |
|
---|
731 | void stubSetDefaultConfigurationOptions(void)
|
---|
732 | {
|
---|
733 | unsigned char key[16]= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
---|
734 |
|
---|
735 | stub.appDrawCursor = 0;
|
---|
736 | stub.minChromiumWindowWidth = 0;
|
---|
737 | stub.minChromiumWindowHeight = 0;
|
---|
738 | stub.maxChromiumWindowWidth = 0;
|
---|
739 | stub.maxChromiumWindowHeight = 0;
|
---|
740 | stub.matchChromiumWindowID = NULL;
|
---|
741 | stub.numIgnoreWindowID = 0;
|
---|
742 | stub.matchWindowTitle = NULL;
|
---|
743 | stub.ignoreFreeglutMenus = 0;
|
---|
744 | stub.trackWindowSize = 1;
|
---|
745 | stub.trackWindowPos = 1;
|
---|
746 | stub.trackWindowVisibility = 1;
|
---|
747 | stub.trackWindowVisibleRgn = 1;
|
---|
748 | stub.matchChromiumWindowCount = 0;
|
---|
749 | stub.spu_dir = NULL;
|
---|
750 | crNetSetRank(0);
|
---|
751 | crNetSetContextRange(32, 35);
|
---|
752 | crNetSetNodeRange("iam0", "iamvis20");
|
---|
753 | crNetSetKey(key,sizeof(key));
|
---|
754 | stub.force_pbuffers = 0;
|
---|
755 | stub.viewportHack = 0;
|
---|
756 |
|
---|
757 | #ifdef WINDOWS
|
---|
758 | {
|
---|
759 | char name[1000];
|
---|
760 | int i;
|
---|
761 |
|
---|
762 | # ifdef VBOX_WITH_WDDM
|
---|
763 | stub.bRunningUnderWDDM = false;
|
---|
764 | # endif
|
---|
765 | /* Apply viewport hack only if we're running under wine */
|
---|
766 | if (NULL!=GetModuleHandle("wined3d.dll") || NULL != GetModuleHandle("wined3dwddm.dll"))
|
---|
767 | {
|
---|
768 | crGetProcName(name, 1000);
|
---|
769 | for (i=0; gsViewportHackApps[i]; ++i)
|
---|
770 | {
|
---|
771 | if (!stricmp(name, gsViewportHackApps[i]))
|
---|
772 | {
|
---|
773 | stub.viewportHack = 1;
|
---|
774 | break;
|
---|
775 | }
|
---|
776 | }
|
---|
777 | }
|
---|
778 | }
|
---|
779 | #endif
|
---|
780 | }
|
---|
781 |
|
---|
782 | #ifdef CR_NEWWINTRACK
|
---|
783 | # ifdef VBOX_WITH_WDDM
|
---|
784 | static stubDispatchVisibleRegions(WindowInfo *pWindow)
|
---|
785 | {
|
---|
786 | DWORD dwCount;
|
---|
787 | LPRGNDATA lpRgnData;
|
---|
788 |
|
---|
789 | dwCount = GetRegionData(pWindow->hVisibleRegion, 0, NULL);
|
---|
790 | lpRgnData = crAlloc(dwCount);
|
---|
791 |
|
---|
792 | if (lpRgnData)
|
---|
793 | {
|
---|
794 | GetRegionData(pWindow->hVisibleRegion, dwCount, lpRgnData);
|
---|
795 | crDebug("Dispatched WindowVisibleRegion (%i, cRects=%i)", pWindow->spuWindow, lpRgnData->rdh.nCount);
|
---|
796 | stub.spuDispatch.WindowVisibleRegion(pWindow->spuWindow, lpRgnData->rdh.nCount, (GLint*) lpRgnData->Buffer);
|
---|
797 | crFree(lpRgnData);
|
---|
798 | }
|
---|
799 | else crWarning("GetRegionData failed, VisibleRegions update failed");
|
---|
800 | }
|
---|
801 |
|
---|
802 | static HRGN stubMakeRegionFromRects(PVBOXVIDEOCM_CMD_RECTS pRegions, uint32_t start)
|
---|
803 | {
|
---|
804 | HRGN hRgn, hTmpRgn;
|
---|
805 | uint32_t i;
|
---|
806 |
|
---|
807 | if (pRegions->RectsInfo.cRects<=start)
|
---|
808 | {
|
---|
809 | return INVALID_HANDLE_VALUE;
|
---|
810 | }
|
---|
811 |
|
---|
812 | hRgn = CreateRectRgn(0, 0, 0, 0);
|
---|
813 | for (i=start; i<pRegions->RectsInfo.cRects; ++i)
|
---|
814 | {
|
---|
815 | hTmpRgn = CreateRectRgnIndirect(&pRegions->RectsInfo.aRects[i]);
|
---|
816 | CombineRgn(hRgn, hRgn, hTmpRgn, RGN_OR);
|
---|
817 | DeleteObject(hTmpRgn);
|
---|
818 | }
|
---|
819 | return hRgn;
|
---|
820 | }
|
---|
821 |
|
---|
822 | typedef struct VBOXCR_UPDATEWNDCB
|
---|
823 | {
|
---|
824 | VBOXDISPMP_REGIONS Regions;
|
---|
825 | bool fSendUpdateMsg;
|
---|
826 | } VBOXCR_UPDATEWNDCB, *PVBOXCR_UPDATEWNDCB;
|
---|
827 |
|
---|
828 | static void stubSyncTrUpdateWindowCB(unsigned long key, void *data1, void *data2)
|
---|
829 | {
|
---|
830 | WindowInfo *pWindow = (WindowInfo *) data1;
|
---|
831 | PVBOXCR_UPDATEWNDCB pCbData = (PVBOXCR_UPDATEWNDCB) data2;
|
---|
832 | VBOXDISPMP_REGIONS *pRegions = &pCbData->Regions;
|
---|
833 | bool bChanged = false;
|
---|
834 | HRGN hNewRgn = INVALID_HANDLE_VALUE;
|
---|
835 |
|
---|
836 | if (pRegions->hWnd != pWindow->hWnd)
|
---|
837 | {
|
---|
838 | return;
|
---|
839 | }
|
---|
840 |
|
---|
841 | stub.spu->dispatch_table.VBoxPackSetInjectID(pWindow->u32ClientID);
|
---|
842 |
|
---|
843 | if (!stubSystemWindowExist(pWindow))
|
---|
844 | {
|
---|
845 | crWindowDestroy((GLint)pWindow->hWnd);
|
---|
846 | return;
|
---|
847 | }
|
---|
848 |
|
---|
849 | if (!pWindow->mapped)
|
---|
850 | {
|
---|
851 | pWindow->mapped = GL_TRUE;
|
---|
852 | bChanged = true;
|
---|
853 | crDebug("Dispatched: WindowShow(%i, %i)", pWindow->spuWindow, pWindow->mapped);
|
---|
854 | stub.spu->dispatch_table.WindowShow(pWindow->spuWindow, pWindow->mapped);
|
---|
855 | }
|
---|
856 |
|
---|
857 | if (pRegions->pRegions->fFlags.bAddVisibleRects || pRegions->pRegions->fFlags.bSetViewRect)
|
---|
858 | {
|
---|
859 | /* ensure data integrity */
|
---|
860 | Assert(!pRegions->pRegions->fFlags.bAddHiddenRects);
|
---|
861 |
|
---|
862 | if (pRegions->pRegions->fFlags.bSetViewRect)
|
---|
863 | {
|
---|
864 | int winX, winY;
|
---|
865 | unsigned int winW, winH;
|
---|
866 | BOOL bRc;
|
---|
867 |
|
---|
868 | winX = pRegions->pRegions->RectsInfo.aRects[0].left;
|
---|
869 | winY = pRegions->pRegions->RectsInfo.aRects[0].top;
|
---|
870 | winW = pRegions->pRegions->RectsInfo.aRects[0].right - winX;
|
---|
871 | winH = pRegions->pRegions->RectsInfo.aRects[0].bottom - winY;
|
---|
872 |
|
---|
873 | if (stub.trackWindowPos && (winX!=pWindow->x || winY!=pWindow->y))
|
---|
874 | {
|
---|
875 | crDebug("Dispatched WindowPosition (%i)", pWindow->spuWindow);
|
---|
876 | stub.spuDispatch.WindowPosition(pWindow->spuWindow, winX, winY);
|
---|
877 | pWindow->x = winX;
|
---|
878 | pWindow->y = winY;
|
---|
879 | bChanged = true;
|
---|
880 | }
|
---|
881 |
|
---|
882 | if (stub.trackWindowSize && (winW!=pWindow->width || winH!=pWindow->height))
|
---|
883 | {
|
---|
884 | crDebug("Dispatched WindowSize (%i)", pWindow->spuWindow);
|
---|
885 | stub.spuDispatch.WindowSize(pWindow->spuWindow, winW, winH);
|
---|
886 | pWindow->width = winW;
|
---|
887 | pWindow->height = winH;
|
---|
888 | bChanged = true;
|
---|
889 | }
|
---|
890 |
|
---|
891 | bRc = MoveWindow(pRegions->hWnd, winX, winY, winW, winH, FALSE /*BOOL bRepaint*/);
|
---|
892 | if (!bRc)
|
---|
893 | {
|
---|
894 | DWORD winEr = GetLastError();
|
---|
895 | crWarning("stubSyncTrUpdateWindowCB: MoveWindow failed winEr(%d)", winEr);
|
---|
896 | }
|
---|
897 | }
|
---|
898 |
|
---|
899 | if (pRegions->pRegions->fFlags.bAddVisibleRects)
|
---|
900 | {
|
---|
901 | hNewRgn = stubMakeRegionFromRects(pRegions->pRegions, pRegions->pRegions->fFlags.bSetViewRect ? 1 : 0);
|
---|
902 | }
|
---|
903 | }
|
---|
904 | else if (!pRegions->pRegions->fFlags.bHide)
|
---|
905 | {
|
---|
906 | Assert(pRegions->pRegions->fFlags.bAddHiddenRects);
|
---|
907 | hNewRgn = stubMakeRegionFromRects(pRegions->pRegions, 0);
|
---|
908 | }
|
---|
909 | else
|
---|
910 | {
|
---|
911 | Assert(pRegions->pRegions->fFlags.bAddHiddenRects);
|
---|
912 | hNewRgn = CreateRectRgn(pWindow->x, pWindow->y, pWindow->x + pWindow->width, pWindow->y + pWindow->height);
|
---|
913 | }
|
---|
914 |
|
---|
915 | if (hNewRgn!=INVALID_HANDLE_VALUE)
|
---|
916 | {
|
---|
917 | if (pRegions->pRegions->fFlags.bAddVisibleRects)
|
---|
918 | {
|
---|
919 | HRGN hEmptyRgn = CreateRectRgn(0, 0, 0, 0);
|
---|
920 |
|
---|
921 | if (hEmptyRgn!=INVALID_HANDLE_VALUE)
|
---|
922 | {
|
---|
923 | if (pWindow->hVisibleRegion==INVALID_HANDLE_VALUE || EqualRgn(pWindow->hVisibleRegion, hEmptyRgn))
|
---|
924 | {
|
---|
925 | pCbData->fSendUpdateMsg = true;
|
---|
926 | }
|
---|
927 |
|
---|
928 | DeleteObject(hEmptyRgn);
|
---|
929 | }
|
---|
930 | else
|
---|
931 | {
|
---|
932 | crWarning("Failed to created empty region!");
|
---|
933 | }
|
---|
934 | }
|
---|
935 |
|
---|
936 | OffsetRgn(hNewRgn, -pWindow->x, -pWindow->y);
|
---|
937 |
|
---|
938 | if (pWindow->hVisibleRegion!=INVALID_HANDLE_VALUE)
|
---|
939 | {
|
---|
940 | CombineRgn(hNewRgn, pWindow->hVisibleRegion, hNewRgn,
|
---|
941 | pRegions->pRegions->fFlags.bAddHiddenRects ? RGN_DIFF:RGN_OR);
|
---|
942 |
|
---|
943 | if (!EqualRgn(pWindow->hVisibleRegion, hNewRgn))
|
---|
944 | {
|
---|
945 | DeleteObject(pWindow->hVisibleRegion);
|
---|
946 | pWindow->hVisibleRegion = hNewRgn;
|
---|
947 | stubDispatchVisibleRegions(pWindow);
|
---|
948 | bChanged = true;
|
---|
949 | }
|
---|
950 | else
|
---|
951 | {
|
---|
952 | DeleteObject(hNewRgn);
|
---|
953 | }
|
---|
954 | }
|
---|
955 | else
|
---|
956 | {
|
---|
957 | if (pRegions->pRegions->fFlags.bAddVisibleRects)
|
---|
958 | {
|
---|
959 | pWindow->hVisibleRegion = hNewRgn;
|
---|
960 | stubDispatchVisibleRegions(pWindow);
|
---|
961 | bChanged = true;
|
---|
962 | }
|
---|
963 | }
|
---|
964 | }
|
---|
965 |
|
---|
966 | if (bChanged)
|
---|
967 | {
|
---|
968 | stub.spu->dispatch_table.Flush();
|
---|
969 | }
|
---|
970 | }
|
---|
971 | # endif
|
---|
972 |
|
---|
973 | static void stubSyncTrCheckWindowsCB(unsigned long key, void *data1, void *data2)
|
---|
974 | {
|
---|
975 | WindowInfo *pWindow = (WindowInfo *) data1;
|
---|
976 | (void) data2;
|
---|
977 |
|
---|
978 | if (pWindow->type!=CHROMIUM || pWindow->spuWindow==0)
|
---|
979 | {
|
---|
980 | return;
|
---|
981 | }
|
---|
982 |
|
---|
983 | stub.spu->dispatch_table.VBoxPackSetInjectID(pWindow->u32ClientID);
|
---|
984 |
|
---|
985 | if (!stubSystemWindowExist(pWindow))
|
---|
986 | {
|
---|
987 | #ifdef WINDOWS
|
---|
988 | crWindowDestroy((GLint)pWindow->hWnd);
|
---|
989 | #else
|
---|
990 | crWindowDestroy((GLint)pWindow->drawable);
|
---|
991 | #endif
|
---|
992 | /*No need to flush here as crWindowDestroy does it*/
|
---|
993 | return;
|
---|
994 | }
|
---|
995 |
|
---|
996 | #if defined(WINDOWS) && defined(VBOX_WITH_WDDM)
|
---|
997 | if (stub.bRunningUnderWDDM)
|
---|
998 | return;
|
---|
999 | #endif
|
---|
1000 | stubCheckWindowState(pWindow, GL_TRUE);
|
---|
1001 | }
|
---|
1002 |
|
---|
1003 | static DECLCALLBACK(int) stubSyncThreadProc(RTTHREAD ThreadSelf, void *pvUser)
|
---|
1004 | {
|
---|
1005 | #ifdef WINDOWS
|
---|
1006 | MSG msg;
|
---|
1007 | # ifdef VBOX_WITH_WDDM
|
---|
1008 | static VBOXDISPMP_CALLBACKS VBoxDispMpTstCallbacks = {NULL, NULL, NULL};
|
---|
1009 | HMODULE hVBoxD3D = NULL;
|
---|
1010 | VBOXCR_UPDATEWNDCB RegionsData;
|
---|
1011 | HRESULT hr;
|
---|
1012 | # endif
|
---|
1013 | #endif
|
---|
1014 |
|
---|
1015 | (void) pvUser;
|
---|
1016 |
|
---|
1017 | crDebug("Sync thread started");
|
---|
1018 | #ifdef WINDOWS
|
---|
1019 | PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
|
---|
1020 | # ifdef VBOX_WITH_WDDM
|
---|
1021 | hVBoxD3D = GetModuleHandle("VBoxDispD3D");
|
---|
1022 | if (hVBoxD3D)
|
---|
1023 | {
|
---|
1024 | hVBoxD3D = LoadLibrary("VBoxDispD3D");
|
---|
1025 | }
|
---|
1026 |
|
---|
1027 | if (hVBoxD3D)
|
---|
1028 | {
|
---|
1029 | PFNVBOXDISPMP_GETCALLBACKS pfnVBoxDispMpGetCallbacks;
|
---|
1030 | pfnVBoxDispMpGetCallbacks = (PFNVBOXDISPMP_GETCALLBACKS)GetProcAddress(hVBoxD3D, TEXT("VBoxDispMpGetCallbacks"));
|
---|
1031 | if (pfnVBoxDispMpGetCallbacks)
|
---|
1032 | {
|
---|
1033 | hr = pfnVBoxDispMpGetCallbacks(VBOXDISPMP_VERSION, &VBoxDispMpTstCallbacks);
|
---|
1034 | if (S_OK==hr)
|
---|
1035 | {
|
---|
1036 | CRASSERT(VBoxDispMpTstCallbacks.pfnEnableEvents);
|
---|
1037 | CRASSERT(VBoxDispMpTstCallbacks.pfnDisableEvents);
|
---|
1038 | CRASSERT(VBoxDispMpTstCallbacks.pfnGetRegions);
|
---|
1039 |
|
---|
1040 | hr = VBoxDispMpTstCallbacks.pfnEnableEvents();
|
---|
1041 | if (hr != S_OK)
|
---|
1042 | {
|
---|
1043 | crWarning("VBoxDispMpTstCallbacks.pfnEnableEvents failed");
|
---|
1044 | }
|
---|
1045 | else
|
---|
1046 | {
|
---|
1047 | crDebug("running with VBoxDispD3D");
|
---|
1048 | stub.trackWindowVisibleRgn = 0;
|
---|
1049 | stub.bRunningUnderWDDM = true;
|
---|
1050 | }
|
---|
1051 | }
|
---|
1052 | else
|
---|
1053 | {
|
---|
1054 | crWarning("VBoxDispMpGetCallbacks failed");
|
---|
1055 | }
|
---|
1056 | }
|
---|
1057 | }
|
---|
1058 | # endif
|
---|
1059 | #endif
|
---|
1060 |
|
---|
1061 | crLockMutex(&stub.mutex);
|
---|
1062 | stub.spu->dispatch_table.VBoxPackSetInjectThread();
|
---|
1063 | crUnlockMutex(&stub.mutex);
|
---|
1064 |
|
---|
1065 | RTThreadUserSignal(ThreadSelf);
|
---|
1066 |
|
---|
1067 | while(!stub.bShutdownSyncThread)
|
---|
1068 | {
|
---|
1069 | #ifdef WINDOWS
|
---|
1070 | if (!PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
|
---|
1071 | {
|
---|
1072 | # ifdef VBOX_WITH_WDDM
|
---|
1073 | if (VBoxDispMpTstCallbacks.pfnGetRegions)
|
---|
1074 | {
|
---|
1075 | hr = VBoxDispMpTstCallbacks.pfnGetRegions(&RegionsData.Regions, 50);
|
---|
1076 | if (S_OK==hr)
|
---|
1077 | {
|
---|
1078 | RegionsData.fSendUpdateMsg = false;
|
---|
1079 | # if 0
|
---|
1080 | uint32_t i;
|
---|
1081 | crDebug(">>>Regions for HWND(0x%x)>>>", RegionsData.Regions.hWnd);
|
---|
1082 | crDebug("Flags(0x%x)", RegionsData.Regions.pRegions->fFlags.Value);
|
---|
1083 | for (i = 0; i < RegionsData.Regions.pRegions->RectsInfo.cRects; ++i)
|
---|
1084 | {
|
---|
1085 | RECT *pRect = &RegionsData.Regions.pRegions->RectsInfo.aRects[i];
|
---|
1086 | crDebug("Rect(%d): left(%d), top(%d), right(%d), bottom(%d)", i, pRect->left, pRect->top, pRect->right, pRect->bottom);
|
---|
1087 | }
|
---|
1088 | crDebug("<<<<<");
|
---|
1089 | # endif
|
---|
1090 | /*hacky way to make sure window wouldn't be deleted in another thread as we hold hashtable lock here*/
|
---|
1091 | crHashtableWalk(stub.windowTable, stubSyncTrUpdateWindowCB, &RegionsData);
|
---|
1092 | if (RegionsData.fSendUpdateMsg)
|
---|
1093 | {
|
---|
1094 | SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0, SMTO_NORMAL, 1000, NULL);
|
---|
1095 | }
|
---|
1096 | }
|
---|
1097 | else
|
---|
1098 | {
|
---|
1099 | if (WAIT_TIMEOUT!=hr)
|
---|
1100 | {
|
---|
1101 | crWarning("VBoxDispMpTstCallbacks.pfnGetRegions failed with 0x%x", hr);
|
---|
1102 | }
|
---|
1103 | crHashtableWalk(stub.windowTable, stubSyncTrCheckWindowsCB, NULL);
|
---|
1104 | }
|
---|
1105 | }
|
---|
1106 | else
|
---|
1107 | # endif
|
---|
1108 | {
|
---|
1109 | crHashtableWalk(stub.windowTable, stubSyncTrCheckWindowsCB, NULL);
|
---|
1110 | RTThreadSleep(50);
|
---|
1111 | }
|
---|
1112 | }
|
---|
1113 | else
|
---|
1114 | {
|
---|
1115 | if (WM_QUIT==msg.message)
|
---|
1116 | {
|
---|
1117 | crDebug("Sync thread got WM_QUIT");
|
---|
1118 | break;
|
---|
1119 | }
|
---|
1120 | else
|
---|
1121 | {
|
---|
1122 | TranslateMessage(&msg);
|
---|
1123 | DispatchMessage(&msg);
|
---|
1124 | }
|
---|
1125 | }
|
---|
1126 | #else
|
---|
1127 | crLockMutex(&stub.mutex);
|
---|
1128 | crHashtableWalk(stub.windowTable, stubSyncTrCheckWindowsCB, NULL);
|
---|
1129 | crUnlockMutex(&stub.mutex);
|
---|
1130 | RTThreadSleep(50);
|
---|
1131 | #endif
|
---|
1132 | }
|
---|
1133 |
|
---|
1134 | #ifdef VBOX_WITH_WDDM
|
---|
1135 | if (VBoxDispMpTstCallbacks.pfnDisableEvents)
|
---|
1136 | {
|
---|
1137 | VBoxDispMpTstCallbacks.pfnDisableEvents();
|
---|
1138 | }
|
---|
1139 | if (hVBoxD3D)
|
---|
1140 | {
|
---|
1141 | FreeLibrary(hVBoxD3D);
|
---|
1142 | }
|
---|
1143 | #endif
|
---|
1144 | crDebug("Sync thread stopped");
|
---|
1145 | return 0;
|
---|
1146 | }
|
---|
1147 | #endif
|
---|
1148 |
|
---|
1149 | /**
|
---|
1150 | * Do one-time initializations for the faker.
|
---|
1151 | * Returns TRUE on success, FALSE otherwise.
|
---|
1152 | */
|
---|
1153 | static bool
|
---|
1154 | stubInitLocked(void)
|
---|
1155 | {
|
---|
1156 | /* Here is where we contact the mothership to find out what we're supposed
|
---|
1157 | * to be doing. Networking code in a DLL initializer. I sure hope this
|
---|
1158 | * works :)
|
---|
1159 | *
|
---|
1160 | * HOW can I pass the mothership address to this if I already know it?
|
---|
1161 | */
|
---|
1162 |
|
---|
1163 | CRConnection *conn = NULL;
|
---|
1164 | char response[1024];
|
---|
1165 | char **spuchain;
|
---|
1166 | int num_spus;
|
---|
1167 | int *spu_ids;
|
---|
1168 | char **spu_names;
|
---|
1169 | const char *app_id;
|
---|
1170 | int i;
|
---|
1171 | int disable_sync = 0;
|
---|
1172 |
|
---|
1173 | stubInitVars();
|
---|
1174 |
|
---|
1175 | crGetProcName(response, 1024);
|
---|
1176 | crDebug("Stub launched for %s", response);
|
---|
1177 |
|
---|
1178 | #if defined(CR_NEWWINTRACK) && !defined(WINDOWS)
|
---|
1179 | /*@todo when vm boots with compiz turned on, new code causes hang in xcb_wait_for_reply in the sync thread
|
---|
1180 | * as at the start compiz runs our code under XGrabServer.
|
---|
1181 | */
|
---|
1182 | if (!crStrcmp(response, "compiz") || !crStrcmp(response, "compiz_real") || !crStrcmp(response, "compiz.real")
|
---|
1183 | || !crStrcmp(response, "compiz-bin"))
|
---|
1184 | {
|
---|
1185 | disable_sync = 1;
|
---|
1186 | }
|
---|
1187 | #endif
|
---|
1188 |
|
---|
1189 | /* @todo check if it'd be of any use on other than guests, no use for windows */
|
---|
1190 | app_id = crGetenv( "CR_APPLICATION_ID_NUMBER" );
|
---|
1191 |
|
---|
1192 | crNetInit( NULL, NULL );
|
---|
1193 |
|
---|
1194 | #ifndef WINDOWS
|
---|
1195 | {
|
---|
1196 | CRNetServer ns;
|
---|
1197 |
|
---|
1198 | ns.name = "vboxhgcm://host:0";
|
---|
1199 | ns.buffer_size = 1024;
|
---|
1200 | crNetServerConnect(&ns);
|
---|
1201 | if (!ns.conn)
|
---|
1202 | {
|
---|
1203 | crWarning("Failed to connect to host. Make sure 3D acceleration is enabled for this VM.");
|
---|
1204 | return false;
|
---|
1205 | }
|
---|
1206 | else
|
---|
1207 | {
|
---|
1208 | crNetFreeConnection(ns.conn);
|
---|
1209 | }
|
---|
1210 | #if 0 && defined(CR_NEWWINTRACK)
|
---|
1211 | {
|
---|
1212 | Status st = XInitThreads();
|
---|
1213 | if (st==0)
|
---|
1214 | {
|
---|
1215 | crWarning("XInitThreads returned %i", (int)st);
|
---|
1216 | }
|
---|
1217 | }
|
---|
1218 | #endif
|
---|
1219 | }
|
---|
1220 | #endif
|
---|
1221 |
|
---|
1222 | strcpy(response, "2 0 feedback 1 pack");
|
---|
1223 | spuchain = crStrSplit( response, " " );
|
---|
1224 | num_spus = crStrToInt( spuchain[0] );
|
---|
1225 | spu_ids = (int *) crAlloc( num_spus * sizeof( *spu_ids ) );
|
---|
1226 | spu_names = (char **) crAlloc( num_spus * sizeof( *spu_names ) );
|
---|
1227 | for (i = 0 ; i < num_spus ; i++)
|
---|
1228 | {
|
---|
1229 | spu_ids[i] = crStrToInt( spuchain[2*i+1] );
|
---|
1230 | spu_names[i] = crStrdup( spuchain[2*i+2] );
|
---|
1231 | crDebug( "SPU %d/%d: (%d) \"%s\"", i+1, num_spus, spu_ids[i], spu_names[i] );
|
---|
1232 | }
|
---|
1233 |
|
---|
1234 | stubSetDefaultConfigurationOptions();
|
---|
1235 |
|
---|
1236 | stub.spu = crSPULoadChain( num_spus, spu_ids, spu_names, stub.spu_dir, NULL );
|
---|
1237 |
|
---|
1238 | crFree( spuchain );
|
---|
1239 | crFree( spu_ids );
|
---|
1240 | for (i = 0; i < num_spus; ++i)
|
---|
1241 | crFree(spu_names[i]);
|
---|
1242 | crFree( spu_names );
|
---|
1243 |
|
---|
1244 | // spu chain load failed somewhere
|
---|
1245 | if (!stub.spu) {
|
---|
1246 | return false;
|
---|
1247 | }
|
---|
1248 |
|
---|
1249 | crSPUInitDispatchTable( &glim );
|
---|
1250 |
|
---|
1251 | /* This is unlikely to change -- We still want to initialize our dispatch
|
---|
1252 | * table with the functions of the first SPU in the chain. */
|
---|
1253 | stubInitSPUDispatch( stub.spu );
|
---|
1254 |
|
---|
1255 | /* we need to plug one special stub function into the dispatch table */
|
---|
1256 | glim.GetChromiumParametervCR = stub_GetChromiumParametervCR;
|
---|
1257 |
|
---|
1258 | #if !defined(VBOX_NO_NATIVEGL)
|
---|
1259 | /* Load pointers to native OpenGL functions into stub.nativeDispatch */
|
---|
1260 | stubInitNativeDispatch();
|
---|
1261 | #endif
|
---|
1262 |
|
---|
1263 | /*crDebug("stub init");
|
---|
1264 | raise(SIGINT);*/
|
---|
1265 |
|
---|
1266 | #ifdef WINDOWS
|
---|
1267 | # ifndef CR_NEWWINTRACK
|
---|
1268 | stubInstallWindowMessageHook();
|
---|
1269 | # endif
|
---|
1270 | #endif
|
---|
1271 |
|
---|
1272 | #ifdef CR_NEWWINTRACK
|
---|
1273 | {
|
---|
1274 | int rc;
|
---|
1275 |
|
---|
1276 | RTR3InitDll(0);
|
---|
1277 |
|
---|
1278 | if (!disable_sync)
|
---|
1279 | {
|
---|
1280 | crDebug("Starting sync thread");
|
---|
1281 |
|
---|
1282 | rc = RTThreadCreate(&stub.hSyncThread, stubSyncThreadProc, NULL, 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "Sync");
|
---|
1283 | if (RT_FAILURE(rc))
|
---|
1284 | {
|
---|
1285 | crError("Failed to start sync thread! (%x)", rc);
|
---|
1286 | }
|
---|
1287 | RTThreadUserWait(stub.hSyncThread, 60 * 1000);
|
---|
1288 | RTThreadUserReset(stub.hSyncThread);
|
---|
1289 |
|
---|
1290 | crDebug("Going on");
|
---|
1291 | }
|
---|
1292 | }
|
---|
1293 | #endif
|
---|
1294 |
|
---|
1295 | #ifdef GLX
|
---|
1296 | stub.xshmSI.shmid = -1;
|
---|
1297 | stub.bShmInitFailed = GL_FALSE;
|
---|
1298 | stub.pGLXPixmapsHash = crAllocHashtable();
|
---|
1299 |
|
---|
1300 | stub.bXExtensionsChecked = GL_FALSE;
|
---|
1301 | stub.bHaveXComposite = GL_FALSE;
|
---|
1302 | stub.bHaveXFixes = GL_FALSE;
|
---|
1303 | #endif
|
---|
1304 |
|
---|
1305 | return true;
|
---|
1306 | }
|
---|
1307 |
|
---|
1308 | /**
|
---|
1309 | * Do one-time initializations for the faker.
|
---|
1310 | * Returns TRUE on success, FALSE otherwise.
|
---|
1311 | */
|
---|
1312 | bool
|
---|
1313 | stubInit(void)
|
---|
1314 | {
|
---|
1315 | bool bRc = true;
|
---|
1316 | /* we need to serialize the initialization, otherwise racing is possible
|
---|
1317 | * for XPDM-based d3d when a d3d switcher is testing the gl lib in two or more threads
|
---|
1318 | * NOTE: the STUB_INIT_LOCK/UNLOCK is a NOP for non-win currently */
|
---|
1319 | STUB_INIT_LOCK();
|
---|
1320 | if (!stub_initialized)
|
---|
1321 | bRc = stub_initialized = stubInitLocked();
|
---|
1322 | STUB_INIT_UNLOCK();
|
---|
1323 | return bRc;
|
---|
1324 | }
|
---|
1325 |
|
---|
1326 | /* Sigh -- we can't do initialization at load time, since Windows forbids
|
---|
1327 | * the loading of other libraries from DLLMain. */
|
---|
1328 |
|
---|
1329 | #ifdef LINUX
|
---|
1330 | /* GCC crap
|
---|
1331 | *void (*stub_init_ptr)(void) __attribute__((section(".ctors"))) = __stubInit; */
|
---|
1332 | #endif
|
---|
1333 |
|
---|
1334 | #ifdef WINDOWS
|
---|
1335 | #define WIN32_LEAN_AND_MEAN
|
---|
1336 | #include <windows.h>
|
---|
1337 |
|
---|
1338 | #ifdef DEBUG_misha
|
---|
1339 | /* debugging: this is to be able to catch first-chance notifications
|
---|
1340 | * for exceptions other than EXCEPTION_BREAKPOINT in kernel debugger */
|
---|
1341 | # define VDBG_VEHANDLER
|
---|
1342 | #endif
|
---|
1343 |
|
---|
1344 | #ifdef VDBG_VEHANDLER
|
---|
1345 | static PVOID g_VBoxWDbgVEHandler = NULL;
|
---|
1346 | LONG WINAPI vboxVDbgVectoredHandler(struct _EXCEPTION_POINTERS *pExceptionInfo)
|
---|
1347 | {
|
---|
1348 | PEXCEPTION_RECORD pExceptionRecord = pExceptionInfo->ExceptionRecord;
|
---|
1349 | PCONTEXT pContextRecord = pExceptionInfo->ContextRecord;
|
---|
1350 | switch (pExceptionRecord->ExceptionCode)
|
---|
1351 | {
|
---|
1352 | case EXCEPTION_BREAKPOINT:
|
---|
1353 | case EXCEPTION_ACCESS_VIOLATION:
|
---|
1354 | case EXCEPTION_STACK_OVERFLOW:
|
---|
1355 | case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
|
---|
1356 | case EXCEPTION_FLT_DIVIDE_BY_ZERO:
|
---|
1357 | case EXCEPTION_FLT_INVALID_OPERATION:
|
---|
1358 | case EXCEPTION_INT_DIVIDE_BY_ZERO:
|
---|
1359 | case EXCEPTION_ILLEGAL_INSTRUCTION:
|
---|
1360 | CRASSERT(0);
|
---|
1361 | break;
|
---|
1362 | default:
|
---|
1363 | break;
|
---|
1364 | }
|
---|
1365 | return EXCEPTION_CONTINUE_SEARCH;
|
---|
1366 | }
|
---|
1367 |
|
---|
1368 | void vboxVDbgVEHandlerRegister()
|
---|
1369 | {
|
---|
1370 | CRASSERT(!g_VBoxWDbgVEHandler);
|
---|
1371 | g_VBoxWDbgVEHandler = AddVectoredExceptionHandler(1,vboxVDbgVectoredHandler);
|
---|
1372 | CRASSERT(g_VBoxWDbgVEHandler);
|
---|
1373 | }
|
---|
1374 |
|
---|
1375 | void vboxVDbgVEHandlerUnregister()
|
---|
1376 | {
|
---|
1377 | ULONG uResult;
|
---|
1378 | if (g_VBoxWDbgVEHandler)
|
---|
1379 | {
|
---|
1380 | uResult = RemoveVectoredExceptionHandler(g_VBoxWDbgVEHandler);
|
---|
1381 | CRASSERT(uResult);
|
---|
1382 | g_VBoxWDbgVEHandler = NULL;
|
---|
1383 | }
|
---|
1384 | }
|
---|
1385 | #endif
|
---|
1386 |
|
---|
1387 | /* Windows crap */
|
---|
1388 | BOOL WINAPI DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved)
|
---|
1389 | {
|
---|
1390 | (void) lpvReserved;
|
---|
1391 |
|
---|
1392 | switch (fdwReason)
|
---|
1393 | {
|
---|
1394 | case DLL_PROCESS_ATTACH:
|
---|
1395 | {
|
---|
1396 | CRNetServer ns;
|
---|
1397 |
|
---|
1398 | #ifdef CHROMIUM_THREADSAFE
|
---|
1399 | crInitTSD(&g_stubCurrentContextTSD);
|
---|
1400 | #endif
|
---|
1401 |
|
---|
1402 | crInitMutex(&stub_init_mutex);
|
---|
1403 |
|
---|
1404 | #ifdef VDBG_VEHANDLER
|
---|
1405 | vboxVDbgVEHandlerRegister();
|
---|
1406 | #endif
|
---|
1407 |
|
---|
1408 | crNetInit(NULL, NULL);
|
---|
1409 | ns.name = "vboxhgcm://host:0";
|
---|
1410 | ns.buffer_size = 1024;
|
---|
1411 | crNetServerConnect(&ns);
|
---|
1412 | if (!ns.conn)
|
---|
1413 | {
|
---|
1414 | crDebug("Failed to connect to host (is guest 3d acceleration enabled?), aborting ICD load.");
|
---|
1415 | #ifdef VDBG_VEHANDLER
|
---|
1416 | vboxVDbgVEHandlerUnregister();
|
---|
1417 | #endif
|
---|
1418 | return FALSE;
|
---|
1419 | }
|
---|
1420 | else
|
---|
1421 | crNetFreeConnection(ns.conn);
|
---|
1422 |
|
---|
1423 | break;
|
---|
1424 | }
|
---|
1425 |
|
---|
1426 | case DLL_PROCESS_DETACH:
|
---|
1427 | {
|
---|
1428 | /* do exactly the same thing as for DLL_THREAD_DETACH since
|
---|
1429 | * DLL_THREAD_DETACH is not called for the thread doing DLL_PROCESS_DETACH according to msdn docs */
|
---|
1430 | stubSetCurrentContext(NULL);
|
---|
1431 | if (stub_initialized)
|
---|
1432 | {
|
---|
1433 | CRASSERT(stub.spu);
|
---|
1434 | stub.spu->dispatch_table.VBoxDetachThread();
|
---|
1435 | }
|
---|
1436 |
|
---|
1437 | stubSPUSafeTearDown();
|
---|
1438 |
|
---|
1439 | #ifdef CHROMIUM_THREADSAFE
|
---|
1440 | crFreeTSD(&g_stubCurrentContextTSD);
|
---|
1441 | #endif
|
---|
1442 |
|
---|
1443 | #ifdef VDBG_VEHANDLER
|
---|
1444 | vboxVDbgVEHandlerUnregister();
|
---|
1445 | #endif
|
---|
1446 | break;
|
---|
1447 | }
|
---|
1448 |
|
---|
1449 | case DLL_THREAD_ATTACH:
|
---|
1450 | {
|
---|
1451 | if (stub_initialized)
|
---|
1452 | {
|
---|
1453 | CRASSERT(stub.spu);
|
---|
1454 | stub.spu->dispatch_table.VBoxAttachThread();
|
---|
1455 | }
|
---|
1456 | break;
|
---|
1457 | }
|
---|
1458 |
|
---|
1459 | case DLL_THREAD_DETACH:
|
---|
1460 | {
|
---|
1461 | stubSetCurrentContext(NULL);
|
---|
1462 | if (stub_initialized)
|
---|
1463 | {
|
---|
1464 | CRASSERT(stub.spu);
|
---|
1465 | stub.spu->dispatch_table.VBoxDetachThread();
|
---|
1466 | }
|
---|
1467 | break;
|
---|
1468 | }
|
---|
1469 |
|
---|
1470 | default:
|
---|
1471 | break;
|
---|
1472 | }
|
---|
1473 |
|
---|
1474 | return TRUE;
|
---|
1475 | }
|
---|
1476 | #endif
|
---|