Changeset 51677 in vbox for trunk/src/VBox/Frontends/VBoxSDL
- Timestamp:
- Jun 20, 2014 12:58:01 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 94447
- Location:
- trunk/src/VBox/Frontends/VBoxSDL
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxSDL/Framebuffer.cpp
r51670 r51677 74 74 // Constructor / destructor 75 75 // 76 77 VBoxSDLFB::VBoxSDLFB() 78 { 79 } 80 81 HRESULT VBoxSDLFB::FinalConstruct() 82 { 83 return 0; 84 } 85 86 void VBoxSDLFB::FinalRelease() 87 { 88 return; 89 } 76 90 77 91 /** … … 87 101 * @param iFixedHeight fixed SDL height (-1 means not set) 88 102 */ 89 VBoxSDLFB::VBoxSDLFB(uint32_t uScreenId,103 HRESULT VBoxSDLFB::init(uint32_t uScreenId, 90 104 bool fFullscreen, bool fResizable, bool fShowSDLConfig, 91 105 bool fKeepHostRes, uint32_t u32FixedWidth, … … 95 109 int rc; 96 110 LogFlow(("VBoxSDLFB::VBoxSDLFB\n")); 97 98 #if defined (RT_OS_WINDOWS)99 refcnt = 0;100 #endif101 111 102 112 mScreenId = uScreenId; … … 140 150 Assert(mScreen); 141 151 mfInitialized = true; 152 #ifdef RT_OS_WINDOWS 153 HRESULT hr = CoCreateFreeThreadedMarshaler(this, //GetControllingUnknown(), 154 &m_pUnkMarshaler.p); 155 Log(("CoCreateFreeThreadedMarshaler hr %08X\n", hr)); 156 #endif 157 158 return 0; 142 159 } 143 160 -
trunk/src/VBox/Frontends/VBoxSDL/Framebuffer.h
r51670 r51677 42 42 class VBoxSDLFBOverlay; 43 43 44 class VBoxSDLFB : 44 class ATL_NO_VTABLE VBoxSDLFB : 45 public CComObjectRootEx<CComMultiThreadModel>, 45 46 VBOX_SCRIPTABLE_IMPL(IFramebuffer) 46 47 { 47 48 public: 48 VBoxSDLFB(uint32_t uScreenId, 49 bool fFullscreen = false, bool fResizable = true, bool fShowSDLConfig = false, 50 bool fKeepHostRes = false, uint32_t u32FixedWidth = ~(uint32_t)0, 51 uint32_t u32FixedHeight = ~(uint32_t)0, uint32_t u32FixedBPP = ~(uint32_t)0, 52 bool fUpdateImage = false); 53 virtual ~VBoxSDLFB(); 49 VBoxSDLFB(); 50 ~VBoxSDLFB(); 51 52 HRESULT init(uint32_t uScreenId, 53 bool fFullscreen, bool fResizable, bool fShowSDLConfig, 54 bool fKeepHostRes, uint32_t u32FixedWidth, 55 uint32_t u32FixedHeight, uint32_t u32FixedBPP, 56 bool fUpdateImage); 54 57 55 58 static bool init(bool fShowSDLConfig); 56 59 static void uninit(); 57 60 58 #ifdef RT_OS_WINDOWS 59 STDMETHOD_(ULONG, AddRef)() 60 { 61 return ::InterlockedIncrement (&refcnt); 62 } 63 STDMETHOD_(ULONG, Release)() 64 { 65 long cnt = ::InterlockedDecrement (&refcnt); 66 if (cnt == 0) 67 delete this; 68 return cnt; 69 } 70 #endif 71 VBOX_SCRIPTABLE_DISPATCH_IMPL(IFramebuffer) 72 73 NS_DECL_ISUPPORTS 61 DECLARE_NOT_AGGREGATABLE(VBoxSDLFB) 62 63 DECLARE_PROTECT_FINAL_CONSTRUCT() 64 65 BEGIN_COM_MAP(VBoxSDLFB) 66 COM_INTERFACE_ENTRY(IFramebuffer) 67 COM_INTERFACE_ENTRY2(IDispatch,IFramebuffer) 68 COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p) 69 END_COM_MAP() 70 71 HRESULT FinalConstruct(); 72 void FinalRelease(); 74 73 75 74 STDMETHOD(COMGETTER(Width))(ULONG *width); … … 194 193 195 194 #endif 196 #ifdef RT_OS_WINDOWS 197 long refcnt; 198 #endif 195 199 196 SDL_Surface *mSurfVRAM; 200 197 … … 207 204 ComPtr<IDisplaySourceBitmap> mpPendingSourceBitmap; 208 205 bool mfUpdates; 206 207 #ifdef RT_OS_WINDOWS 208 CComPtr <IUnknown> m_pUnkMarshaler; 209 #endif 209 210 }; 210 211 -
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r51547 r51677 5 5 6 6 /* 7 * Copyright (C) 2006-201 3Oracle Corporation7 * Copyright (C) 2006-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 207 207 208 208 static ULONG gcMonitors = 1; 209 static VBoxSDLFB *gpFramebuffer[64];209 static ComObjPtr<VBoxSDLFB> gpFramebuffer[64]; 210 210 static SDL_Cursor *gpDefaultCursor = NULL; 211 211 #ifdef VBOXSDL_WITH_X11 … … 602 602 RTPrintf("Usage:\n" 603 603 " --startvm <uuid|name> Virtual machine to start, either UUID or name\n" 604 " --separate Run a separate VM process or attach to a running VM\n" 604 605 " --hda <file> Set temporary first hard disk to file\n" 605 606 " --fda <file> Set temporary first floppy disk to file\n" … … 823 824 Guid uuidVM; 824 825 char *vmName = NULL; 826 bool fSeparate = false; 825 827 DeviceType_T bootDevice = DeviceType_Null; 826 828 uint32_t memorySize = 0; … … 976 978 } 977 979 } 980 else if ( !strcmp(argv[curArg], "--separate") 981 || !strcmp(argv[curArg], "-separate")) 982 { 983 fSeparate = true; 984 } 978 985 else if ( !strcmp(argv[curArg], "--comment") 979 986 || !strcmp(argv[curArg], "-comment")) … … 1482 1489 } 1483 1490 1484 rc = pMachine->LockMachine(pSession, LockType_VM); 1491 if (fSeparate) 1492 { 1493 MachineState_T machineState = MachineState_Null; 1494 pMachine->COMGETTER(State)(&machineState); 1495 if ( machineState == MachineState_Running 1496 || machineState == MachineState_Teleporting 1497 || machineState == MachineState_LiveSnapshotting 1498 || machineState == MachineState_Paused 1499 || machineState == MachineState_TeleportingPausedVM 1500 ) 1501 { 1502 RTPrintf("VM is already running.\n"); 1503 } 1504 else 1505 { 1506 ComPtr<IProgress> progress; 1507 rc = pMachine->LaunchVMProcess(pSession, Bstr("headless").raw(), NULL, progress.asOutParam()); 1508 if (SUCCEEDED(rc) && !progress.isNull()) 1509 { 1510 RTPrintf("Waiting for VM to power on...\n"); 1511 rc = progress->WaitForCompletion(-1); 1512 if (SUCCEEDED(rc)) 1513 { 1514 BOOL completed = true; 1515 rc = progress->COMGETTER(Completed)(&completed); 1516 if (SUCCEEDED(rc)) 1517 { 1518 LONG iRc; 1519 rc = progress->COMGETTER(ResultCode)(&iRc); 1520 if (SUCCEEDED(rc)) 1521 { 1522 if (FAILED(iRc)) 1523 { 1524 ProgressErrorInfo info(progress); 1525 com::GluePrintErrorInfo(info); 1526 } 1527 else 1528 { 1529 RTPrintf("VM has been successfully started.\n"); 1530 /* LaunchVMProcess obtains a shared lock on the machine. 1531 * Unlock it here, because the lock will be obtained below 1532 * in the common code path as for already running VM. 1533 */ 1534 pSession->UnlockMachine(); 1535 } 1536 } 1537 } 1538 } 1539 } 1540 } 1541 if (FAILED(rc)) 1542 { 1543 RTPrintf("Error: failed to power up VM! No error text available.\n"); 1544 goto leave; 1545 } 1546 1547 rc = pMachine->LockMachine(pSession, LockType_Shared); 1548 } 1549 else 1550 { 1551 rc = pMachine->LockMachine(pSession, LockType_VM); 1552 } 1553 1485 1554 if (FAILED(rc)) 1486 1555 { … … 1509 1578 goto leave; 1510 1579 } 1580 1511 1581 // get the VM console 1512 1582 pSession->COMGETTER(Console)(gpConsole.asOutParam()); … … 1857 1927 { 1858 1928 // create our SDL framebuffer instance 1859 gpFramebuffer[i] = new VBoxSDLFB(i, fFullscreen, fResizable, fShowSDLConfig, false,1860 fixedWidth, fixedHeight, fixedBPP);1861 1862 if ( !gpFramebuffer[i])1929 gpFramebuffer[i].createObject(); 1930 rc = gpFramebuffer[i]->init(i, fFullscreen, fResizable, fShowSDLConfig, false, 1931 fixedWidth, fixedHeight, fixedBPP, fSeparate); 1932 if (FAILED(rc)) 1863 1933 { 1864 1934 RTPrintf("Error: could not create framebuffer object!\n"); … … 1944 2014 goto leave; 1945 2015 } 2016 ULONG dummy; 1946 2017 LONG xOrigin, yOrigin; 1947 rc = gpDisplay->GetScreenResolution(i, NULL, NULL, NULL, &xOrigin, &yOrigin);2018 rc = gpDisplay->GetScreenResolution(i, &dummy, &dummy, &dummy, &xOrigin, &yOrigin); 1948 2019 gpFramebuffer[i]->setOrigin(xOrigin, yOrigin); 1949 2020 } … … 2130 2201 SDL_Event event; 2131 2202 2132 LogFlow(("Powering up the VM...\n")); 2133 rc = gpConsole->PowerUp(gpProgress.asOutParam()); 2134 if (rc != S_OK) 2135 { 2136 com::ErrorInfo info(gpConsole, COM_IIDOF(IConsole)); 2137 if (info.isBasicAvailable()) 2138 PrintError("Failed to power up VM", info.getText().raw()); 2139 else 2140 RTPrintf("Error: failed to power up VM! No error text available.\n"); 2141 goto leave; 2203 if (!fSeparate) 2204 { 2205 LogFlow(("Powering up the VM...\n")); 2206 rc = gpConsole->PowerUp(gpProgress.asOutParam()); 2207 if (rc != S_OK) 2208 { 2209 com::ErrorInfo info(gpConsole, COM_IIDOF(IConsole)); 2210 if (info.isBasicAvailable()) 2211 PrintError("Failed to power up VM", info.getText().raw()); 2212 else 2213 RTPrintf("Error: failed to power up VM! No error text available.\n"); 2214 goto leave; 2215 } 2142 2216 } 2143 2217 … … 2220 2294 gpFramebuffer[event.user.code]->notifyChange(event.user.code); 2221 2295 /* update xOrigin, yOrigin -> mouse */ 2222 rc = gpDisplay->GetScreenResolution(event.user.code, NULL, NULL, NULL, &xOrigin, &yOrigin); 2296 ULONG dummy; 2297 rc = gpDisplay->GetScreenResolution(event.user.code, &dummy, &dummy, &dummy, &xOrigin, &yOrigin); 2223 2298 gpFramebuffer[event.user.code]->setOrigin(xOrigin, yOrigin); 2224 2299 break; … … 2306 2381 RTPrintf("Error: could not get mouse object!\n"); 2307 2382 goto leave; 2383 } 2384 2385 if (fSeparate && gpMouse) 2386 { 2387 LogFlow(("Fetching mouse caps\n")); 2388 2389 /* Fetch current mouse status, etc */ 2390 gpMouse->COMGETTER(AbsoluteSupported)(&gfAbsoluteMouseGuest); 2391 gpMouse->COMGETTER(RelativeSupported)(&gfRelativeMouseGuest); 2392 gpMouse->COMGETTER(NeedsHostCursor)(&gfGuestNeedsHostCursor); 2393 2394 HandleGuestCapsChanged(); 2308 2395 } 2309 2396 … … 2702 2789 gpFramebuffer[event.user.code]->notifyChange(event.user.code); 2703 2790 /* update xOrigin, yOrigin -> mouse */ 2704 rc = gpDisplay->GetScreenResolution(event.user.code, NULL, NULL, NULL, &xOrigin, &yOrigin); 2791 ULONG dummy; 2792 rc = gpDisplay->GetScreenResolution(event.user.code, &dummy, &dummy, &dummy, &xOrigin, &yOrigin); 2705 2793 gpFramebuffer[event.user.code]->setOrigin(xOrigin, yOrigin); 2706 2794 break; … … 2808 2896 machineState = MachineState_Aborted; 2809 2897 2810 /* 2811 * Turn off the VM if it's running 2812 */ 2813 if ( gpConsole 2814 && ( machineState == MachineState_Running 2815 || machineState == MachineState_Teleporting 2816 || machineState == MachineState_LiveSnapshotting 2817 /** @todo power off paused VMs too? */ 2898 if (!fSeparate) 2899 { 2900 /* 2901 * Turn off the VM if it's running 2902 */ 2903 if ( gpConsole 2904 && ( machineState == MachineState_Running 2905 || machineState == MachineState_Teleporting 2906 || machineState == MachineState_LiveSnapshotting 2907 /** @todo power off paused VMs too? */ 2908 ) 2818 2909 ) 2819 )2820 do2821 {2822 pConsoleListener->getWrapped()->ignorePowerOffEvents(true);2823 ComPtr<IProgress> pProgress;2824 CHECK_ERROR_BREAK(gpConsole, PowerDown(pProgress.asOutParam()));2825 CHECK_ERROR_BREAK(pProgress, WaitForCompletion(-1));2826 BOOL completed;2827 CHECK_ERROR_BREAK(pProgress, COMGETTER(Completed)(&completed));2828 ASSERT(completed);2829 LONG hrc;2830 CHECK_ERROR_BREAK(pProgress, COMGETTER(ResultCode)(&hrc));2831 if (FAILED(hrc))2832 {2833 com::ErrorInfo info;2834 if (info.isFullAvailable())2835 PrintError("Failed to power down VM",2836 info.getText().raw(), info.getComponent().raw());2837 else2838 RTPrintf("Failed to power down virtual machine! No error information available (rc = 0x%x).\n", hrc);2839 break;2840 } 2841 } while (0);2910 do 2911 { 2912 pConsoleListener->getWrapped()->ignorePowerOffEvents(true); 2913 ComPtr<IProgress> pProgress; 2914 CHECK_ERROR_BREAK(gpConsole, PowerDown(pProgress.asOutParam())); 2915 CHECK_ERROR_BREAK(pProgress, WaitForCompletion(-1)); 2916 BOOL completed; 2917 CHECK_ERROR_BREAK(pProgress, COMGETTER(Completed)(&completed)); 2918 ASSERT(completed); 2919 LONG hrc; 2920 CHECK_ERROR_BREAK(pProgress, COMGETTER(ResultCode)(&hrc)); 2921 if (FAILED(hrc)) 2922 { 2923 com::ErrorInfo info; 2924 if (info.isFullAvailable()) 2925 PrintError("Failed to power down VM", 2926 info.getText().raw(), info.getComponent().raw()); 2927 else 2928 RTPrintf("Failed to power down virtual machine! No error information available (rc = 0x%x).\n", hrc); 2929 break; 2930 } 2931 } while (0); 2932 } 2842 2933 2843 2934 /* unregister Console listener */ … … 2859 2950 { 2860 2951 rc = gpMachine->DiscardSettings(); 2861 Assert ComRC(rc);2952 AssertMsg(SUCCEEDED(rc), ("DiscardSettings %Rhrc, machineState %d\n", rc, machineState)); 2862 2953 } 2863 2954
Note:
See TracChangeset
for help on using the changeset viewer.