Changeset 70563 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- Jan 12, 2018 5:52:10 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 120250
- Location:
- trunk/src/VBox/Main/src-client
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/AudioDriver.cpp
r70547 r70563 35 35 : mpConsole(pConsole) 36 36 , mfAttached(false) 37 , muLUN(UINT8_MAX) 37 38 { 38 39 } … … 58 59 unsigned uLUN = 0; 59 60 60 /* First check if the LUN already exists. */61 61 PCFGMNODE pDevLUN; 62 62 for (;;) … … 71 71 } 72 72 73 int AudioDriver::Initialize(AudioDriverCfg *pCfg) 74 { 75 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 76 77 /* Apply configuration. */ 78 mCfg = *pCfg; 79 80 return VINF_SUCCESS; 81 } 82 73 83 /** 74 84 * Configures the audio driver (to CFGM) and attaches it to the audio chain. … … 77 87 * @returns IPRT status code. 78 88 * @param pThis Audio driver to detach. 79 * @param pCfg Audio driver configuration to use for the audio driver to attach.80 89 */ 81 90 /* static */ 82 DECLCALLBACK(int) AudioDriver::Attach(AudioDriver *pThis , AudioDriverCfg *pCfg)91 DECLCALLBACK(int) AudioDriver::Attach(AudioDriver *pThis) 83 92 { 84 93 AssertPtrReturn(pThis, VERR_INVALID_POINTER); … … 90 99 91 100 if (pThis->mfAttached) /* Already attached? Bail out. */ 101 { 102 LogFunc(("%s: Already attached\n", pThis->mCfg.strName.c_str())); 92 103 return VINF_SUCCESS; 93 94 if (pCfg->uLUN == UINT8_MAX) /* No LUN assigned / configured yet? Retrieve it. */ 95 pCfg->uLUN = pThis->getFreeLUN(); 104 } 105 106 AudioDriverCfg *pCfg = &pThis->mCfg; 107 108 unsigned uLUN = pThis->muLUN; 109 if (uLUN == UINT8_MAX) /* No LUN assigned / configured yet? Retrieve it. */ 110 uLUN = pThis->getFreeLUN(); 96 111 97 112 LogFunc(("strName=%s, strDevice=%s, uInst=%u, uLUN=%u\n", 98 pCfg->strName.c_str(), pCfg->strDev.c_str(), pCfg->uInst, pCfg->uLUN)); 99 100 vrc = pThis->Configure(pCfg, true /* Attach */); 101 if (RT_SUCCESS(vrc)) 102 vrc = PDMR3DriverAttach(ptrVM.rawUVM(), pCfg->strDev.c_str(), pCfg->uInst, pCfg->uLUN, 0 /* fFlags */, NULL /* ppBase */); 103 104 if (RT_SUCCESS(vrc)) 105 { 113 pCfg->strName.c_str(), pCfg->strDev.c_str(), pCfg->uInst, uLUN)); 114 115 vrc = pThis->configure(uLUN, true /* Attach */); 116 if (RT_SUCCESS(vrc)) 117 vrc = PDMR3DeviceAttach(ptrVM.rawUVM(), pCfg->strDev.c_str(), pCfg->uInst, uLUN, 0 /* fFlags */, 118 NULL /* ppBase */); 119 if (RT_SUCCESS(vrc)) 120 { 121 pThis->muLUN = uLUN; 106 122 pThis->mfAttached = true; 123 124 LogRel2(("%s: Driver attached (LUN #%u)\n", pCfg->strName.c_str(), pThis->muLUN)); 107 125 } 108 126 else … … 124 142 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 125 143 144 if (!pThis->mfAttached) /* Not attached? Bail out. */ 145 { 146 LogFunc(("%s: Not attached\n", pThis->mCfg.strName.c_str())); 147 return VINF_SUCCESS; 148 } 149 126 150 Console::SafeVMPtrQuiet ptrVM(pThis->mpConsole); 127 151 Assert(ptrVM.isOk()); 128 152 129 if (!pThis->mfAttached) /* Not attached? Bail out. */ 130 return VINF_SUCCESS; 153 Assert(pThis->muLUN != UINT8_MAX); 131 154 132 155 int vrc = VINF_SUCCESS; … … 135 158 136 159 LogFunc(("strName=%s, strDevice=%s, uInst=%u, uLUN=%u\n", 137 pCfg->strName.c_str(), pCfg->strDev.c_str(), pCfg->uInst, p Cfg->uLUN));138 139 vrc = PDMR3DriverDetach(ptrVM.rawUVM(), pCfg->strDev.c_str(), pCfg->uInst, p Cfg->uLUN, "AUDIO",160 pCfg->strName.c_str(), pCfg->strDev.c_str(), pCfg->uInst, pThis->muLUN)); 161 162 vrc = PDMR3DriverDetach(ptrVM.rawUVM(), pCfg->strDev.c_str(), pCfg->uInst, pThis->muLUN, "AUDIO", 140 163 0 /* iOccurrence */, 0 /* fFlags */); 141 164 if (RT_SUCCESS(vrc)) 142 vrc = pThis->Configure(pCfg, false /* Detach */); 143 144 if (RT_SUCCESS(vrc)) 145 { 146 pCfg->uLUN = UINT8_MAX; 147 165 vrc = pThis->configure(pThis->muLUN, false /* Detach */); 166 167 if (RT_SUCCESS(vrc)) 168 { 169 pThis->muLUN = UINT8_MAX; 148 170 pThis->mfAttached = false; 171 172 LogRel2(("%s: Driver detached\n", pCfg->strName.c_str())); 149 173 } 150 174 else … … 158 182 * 159 183 * @returns VBox status code. 160 * @param pCfg Audio driver configuration to use.184 * @param uLUN LUN to attach driver to. 161 185 * @param fAttach Whether to attach or detach the driver configuration to CFGM. 162 186 * 163 187 * @thread EMT 164 188 */ 165 int AudioDriver::Configure(AudioDriverCfg *pCfg, bool fAttach) 166 { 167 if (pCfg->strDev.isEmpty()) /* No audio device configured. Bail out. */ 168 return VINF_SUCCESS; 169 189 int AudioDriver::configure(unsigned uLUN, bool fAttach) 190 { 170 191 int rc = VINF_SUCCESS; 171 192 172 193 Console::SafeVMPtrQuiet ptrVM(mpConsole); 173 194 Assert(ptrVM.isOk()); 174 175 /* Apply configuration. */176 mCfg = *pCfg;177 195 178 196 PUVM pUVM = ptrVM.rawUVM(); … … 184 202 AssertPtr(pDev0); 185 203 186 PCFGMNODE pDevLun = CFGMR3GetChildF(pDev0, "LUN#%u/", mCfg.uLUN);204 PCFGMNODE pDevLun = CFGMR3GetChildF(pDev0, "LUN#%u/", uLUN); 187 205 188 206 if (fAttach) 189 207 { 208 AssertMsg(uLUN != UINT8_MAX, ("%s: LUN is undefined when it must not\n", mCfg.strName.c_str())); 209 190 210 if (!pDevLun) 191 211 { 192 LogRel2(("%s: Configuring audio driver \n", mCfg.strName.c_str()));212 LogRel2(("%s: Configuring audio driver (to LUN #%RU8)\n", mCfg.strName.c_str(), uLUN)); 193 213 194 214 PCFGMNODE pLunL0; 195 CFGMR3InsertNodeF(pDev0, &pLunL0, "LUN#%RU8", mCfg.uLUN);215 CFGMR3InsertNodeF(pDev0, &pLunL0, "LUN#%RU8", uLUN); 196 216 CFGMR3InsertString(pLunL0, "Driver", "AUDIO"); 197 217 … … 211 231 configureDriver(pLunCfg); 212 232 } 233 else 234 rc = VERR_ALREADY_EXISTS; 213 235 } 214 236 else /* Detach */ … … 219 241 CFGMR3RemoveNode(pDevLun); 220 242 } 221 } 222 223 AssertRC(rc); 243 else 244 rc = VERR_NOT_FOUND; 245 } 246 247 #ifdef DEBUG_andy 248 CFGMR3Dump(pDev0); 249 #endif 250 251 if (RT_FAILURE(rc)) 252 LogRel(("%s: %s audio driver failed with rc=%Rrc\n", 253 mCfg.strName.c_str(), fAttach ? "Configuring" : "Unconfiguring", rc)); 254 224 255 return rc; 225 256 } -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r70535 r70563 5405 5405 mConsoleVRDPServer->Stop(); 5406 5406 5407 int vrc; 5408 #ifdef VBOX_WITH_AUDIO_VRDE 5409 if (!mAudioVRDE->IsAttached()) 5410 { 5411 vrc = VMR3ReqCallWaitU(ptrVM.rawUVM(), VMCPUID_ANY /*idDstCpu*/, 5412 (PFNRT)AudioVRDE::Attach, 2, 5413 mAudioVRDE, mAudioVRDE->GetConfig()); 5414 AssertRC(vrc); 5415 } 5416 #endif 5417 vrc = mConsoleVRDPServer->Launch(); 5407 int vrc = mConsoleVRDPServer->Launch(); 5418 5408 if (vrc != VINF_SUCCESS) 5419 5409 { … … 5422 5412 } 5423 5413 else 5414 { 5415 #ifdef VBOX_WITH_AUDIO_VRDE 5416 alock.acquire(); 5417 5418 PVMREQ pReq; 5419 int vrc2 = VMR3ReqCallU(mpUVM, VMCPUID_ANY, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS, 5420 (PFNRT)AudioVRDE::Attach, 1, 5421 mAudioVRDE); 5422 5423 /* Release the lock before a VMR3* call (EMT might wait for it, @bugref{7648})! */ 5424 alock.release(); 5425 5426 if (vrc2 == VERR_TIMEOUT) 5427 vrc2 = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT); 5428 AssertRC(vrc2); 5429 VMR3ReqFree(pReq); 5430 #endif 5424 5431 mConsoleVRDPServer->EnableConnections(); 5432 } 5425 5433 } 5426 5434 else … … 5428 5436 mConsoleVRDPServer->Stop(); 5429 5437 #ifdef VBOX_WITH_AUDIO_VRDE 5430 if (mAudioVRDE->IsAttached()) 5431 { 5432 int vrc2 = VMR3ReqCallWaitU(ptrVM.rawUVM(), VMCPUID_ANY /*idDstCpu*/, 5433 (PFNRT)AudioVRDE::Detach, 1, 5434 mAudioVRDE); 5435 AssertRC(vrc2); 5436 } 5438 alock.acquire(); 5439 5440 PVMREQ pReq; 5441 int vrc2 = VMR3ReqCallU(mpUVM, VMCPUID_ANY, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS, 5442 (PFNRT)AudioVRDE::Detach, 1, 5443 mAudioVRDE); 5444 5445 /* Release the lock before a VMR3* call (EMT might wait for it, @bugref{7648})! */ 5446 alock.release(); 5447 5448 if (vrc2 == VERR_TIMEOUT) 5449 vrc2 = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT); 5450 AssertRC(vrc2); 5451 VMR3ReqFree(pReq); 5437 5452 #endif 5438 5453 } … … 5529 5544 AssertPtr(pDisplay); 5530 5545 5531 /* Release lock because the call scheduled on EMT may also try to take it. */ 5532 alock.release(); 5533 5534 const PVIDEORECCFG pCfg = pDisplay->i_videoRecGetConfig(); 5546 pDisplay->i_videoRecInvalidate(); 5547 5548 int vrc; 5549 5550 if (!mDisplay->i_videoRecStarted()) 5551 { 5535 5552 # ifdef VBOX_WITH_AUDIO_VIDEOREC 5536 const unsigned uLUN = pCfg->Audio.uLUN; /* Get the currently configured LUN. */ 5537 # else 5538 const unsigned uLUN = 0; 5553 /* Attach the video recording audio driver if required. */ 5554 if (mDisplay->i_videoRecGetEnabled() & VIDEORECFEATURE_AUDIO) 5555 { 5556 PVMREQ pReq; 5557 int vrc2 = VMR3ReqCallU(mpUVM, VMCPUID_ANY, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS, 5558 (PFNRT)AudioVideoRec::Attach, 1, 5559 mAudioVideoRec); 5560 5561 /* Release the lock before a VMR3* call (EMT might wait for it, @bugref{7648})! */ 5562 alock.release(); 5563 5564 if (vrc2 == VERR_TIMEOUT) 5565 vrc2 = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT); 5566 AssertRC(vrc2); 5567 VMR3ReqFree(pReq); 5568 5569 alock.acquire(); 5570 } 5539 5571 # endif 5540 int vrc = VMR3ReqCallWaitU(ptrVM.rawUVM(), VMCPUID_ANY /*idDstCpu*/, 5541 (PFNRT)Display::i_videoRecConfigure, 4, 5542 pDisplay, pCfg, true /* fAttachDetach */, &uLUN); 5543 if (RT_SUCCESS(vrc)) 5544 { 5545 /* Make sure to acquire the lock again after we're done running in EMT. */ 5546 alock.acquire(); 5547 5548 if (!mDisplay->i_videoRecStarted()) 5549 { 5550 vrc = mDisplay->i_videoRecStart(); 5551 if (RT_FAILURE(vrc)) 5552 rc = setError(E_FAIL, tr("Unable to start video capturing (%Rrc)"), vrc); 5553 } 5554 else 5555 mDisplay->i_videoRecStop(); 5572 vrc = mDisplay->i_videoRecStart(); 5573 if (RT_FAILURE(vrc)) 5574 rc = setError(E_FAIL, tr("Unable to start video capturing (%Rrc)"), vrc); 5556 5575 } 5557 5576 else 5558 rc = setError(E_FAIL, tr("Unable to set screens for capturing (%Rrc)"), vrc); 5577 { 5578 mDisplay->i_videoRecStop(); 5579 # ifdef VBOX_WITH_AUDIO_VIDEOREC 5580 PVMREQ pReq; 5581 int vrc2 = VMR3ReqCallU(mpUVM, VMCPUID_ANY, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS, 5582 (PFNRT)AudioVideoRec::Detach, 1, 5583 mAudioVideoRec); 5584 5585 /* Release the lock before a VMR3* call (EMT might wait for it, @bugref{7648})! */ 5586 alock.release(); 5587 5588 if (vrc2 == VERR_TIMEOUT) 5589 vrc2 = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT); 5590 AssertRC(vrc2); 5591 VMR3ReqFree(pReq); 5592 5593 alock.acquire(); 5594 # endif 5595 } 5559 5596 } 5560 5597 … … 9846 9883 static_cast<Console *>(pConsole), 9847 9884 &pVM, NULL); 9848 9849 9885 alock.acquire(); 9850 9886 9851 /* Enable client connections to the server. */ 9887 #ifdef VBOX_WITH_AUDIO_VRDE 9888 /* Attach the VRDE audio driver. */ 9889 IVRDEServer *pVRDEServer = pConsole->i_getVRDEServer(); 9890 if (pVRDEServer) 9891 { 9892 BOOL fVRDEEnabled = FALSE; 9893 rc = pVRDEServer->COMGETTER(Enabled)(&fVRDEEnabled); 9894 AssertComRCReturnVoid(rc); 9895 9896 if (fVRDEEnabled) 9897 { 9898 PVMREQ pReq; 9899 int vrc2 = VMR3ReqCallU(pConsole->mpUVM, VMCPUID_ANY, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS, 9900 (PFNRT)AudioVRDE::Attach, 1, 9901 pConsole->mAudioVRDE); 9902 9903 /* Release the lock before a VMR3* call (EMT might wait for it, @bugref{7648})! */ 9904 alock.release(); 9905 9906 if (vrc2 == VERR_TIMEOUT) 9907 vrc2 = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT); 9908 AssertRC(vrc2); 9909 VMR3ReqFree(pReq); 9910 9911 alock.acquire(); 9912 } 9913 } 9914 #endif 9915 9916 /* Enable client connections to the VRDP server. */ 9852 9917 pConsole->i_consoleVRDPServer()->EnableConnections(); 9853 9918 9919 #ifdef VBOX_WITH_AUDIO_VIDEOREC 9920 Display *pDisplay = pConsole->i_getDisplay(); 9921 AssertPtr(pDisplay); 9922 if (pDisplay) 9923 { 9924 pDisplay->i_videoRecInvalidate(); 9925 9926 /* Attach the video recording audio driver if required. */ 9927 if (pDisplay->i_videoRecGetEnabled() & VIDEORECFEATURE_AUDIO) 9928 { 9929 PVMREQ pReq; 9930 int vrc2 = VMR3ReqCallU(pConsole->mpUVM, VMCPUID_ANY, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS, 9931 (PFNRT)AudioVideoRec::Attach, 1, 9932 pConsole->mAudioVideoRec); 9933 9934 /* Release the lock before a VMR3* call (EMT might wait for it, @bugref{7648})! */ 9935 alock.release(); 9936 9937 if (vrc2 == VERR_TIMEOUT) 9938 vrc2 = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT); 9939 AssertRC(vrc2); 9940 VMR3ReqFree(pReq); 9941 9942 alock.acquire(); 9943 } 9944 } 9945 #endif 9854 9946 if (RT_SUCCESS(vrc)) 9855 9947 { -
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r70544 r70563 124 124 #ifdef VBOX_WITH_AUDIO_VRDE 125 125 # include "DrvAudioVRDE.h" 126 #endif 127 #ifdef VBOX_WITH_AUDIO_VIDEOREC 128 # include "DrvAudioVideoRec.h" 126 129 #endif 127 130 #include "NetworkServiceRunner.h" … … 2967 2970 2968 2971 #ifdef VBOX_WITH_AUDIO_VRDE 2969 BOOL fVRDEEnabled = FALSE; 2970 2971 if (mVRDEServer) 2972 { 2973 hrc = mVRDEServer->COMGETTER(Enabled)(&fVRDEEnabled); 2974 ComAssertComRC(hrc); 2975 } 2976 2977 AudioDriverCfg Cfg(strAudioDevice, 0 /* Instance */, uAudioLUN, "AudioVRDE"); 2978 rc = mAudioVRDE->Configure(&Cfg, RT_BOOL(fVRDEEnabled) /* Attach */); 2979 if ( RT_SUCCESS(rc) 2980 && fVRDEEnabled) /* Successfully configured, use next LUN for drivers below. */ 2981 { 2982 uAudioLUN++; 2983 } 2972 AudioDriverCfg DrvCfgVRDE(strAudioDevice, 0 /* Instance */, "AudioVRDE"); 2973 rc = mAudioVRDE->Initialize(&DrvCfgVRDE); 2974 AssertRC(rc); 2984 2975 #endif /* VBOX_WITH_AUDIO_VRDE */ 2985 2976 2986 2977 #ifdef VBOX_WITH_AUDIO_VIDEOREC 2987 Display *pDisplay = i_getDisplay(); 2988 if (pDisplay) 2989 { 2990 /* Note: Don't do any driver attaching (fAttachDetach) here, as this will 2991 * be done automatically as part of the VM startup process. */ 2992 rc = pDisplay->i_videoRecConfigure(pDisplay, pDisplay->i_videoRecGetConfig(), false /* fAttachDetach */, 2993 &uAudioLUN); 2994 if (RT_SUCCESS(rc)) /* Successfully configured, use next LUN for drivers below. */ 2995 uAudioLUN++; 2996 } 2978 AudioDriverCfg DrvCfgVideoRec(strAudioDevice, 0 /* Instance */, "AudioVideoRec"); 2979 rc = mAudioVideoRec->Initialize(&DrvCfgVideoRec); 2980 AssertRC(rc); 2997 2981 #endif /* VBOX_WITH_AUDIO_VIDEOREC */ 2998 2982 -
trunk/src/VBox/Main/src-client/DisplayImpl.cpp
r70075 r70563 2417 2417 } 2418 2418 2419 #ifdef VBOX_WITH_AUDIO_VIDEOREC2420 2419 /** 2421 * Configures the video recording audio driver in CFGM. 2422 * 2423 * @returns VBox status code. 2424 * @param strDevice The PDM device name. 2425 * @param uInstance The PDM device instance. 2426 * @param uLUN The PDM LUN number of the driver. 2427 * @param fAttach Whether to attach or detach the driver configuration to CFGM. 2428 * 2429 * @thread EMT 2420 * Invalidates the video recording configuration. 2430 2421 */ 2431 int Display::i_videoRecConfigureAudioDriver(const Utf8Str& strDevice, 2432 unsigned uInstance, 2433 unsigned uLUN, 2434 bool fAttach) 2435 { 2436 if (strDevice.isEmpty()) /* No audio device configured. Bail out. */ 2437 return VINF_SUCCESS; 2438 2422 void Display::i_videoRecInvalidate(void) 2423 { 2439 2424 AssertPtr(mParent); 2440 2441 2425 ComPtr<IMachine> pMachine = mParent->i_machine(); 2442 2426 Assert(pMachine.isNotNull()); 2443 2427 2444 Console::SafeVMPtr ptrVM(mParent); 2445 Assert(ptrVM.isOk()); 2446 2447 PUVM pUVM = ptrVM.rawUVM(); 2448 AssertPtr(pUVM); 2449 2450 PCFGMNODE pRoot = CFGMR3GetRootU(pUVM); 2451 AssertPtr(pRoot); 2452 PCFGMNODE pDev0 = CFGMR3GetChildF(pRoot, "Devices/%s/%u/", strDevice.c_str(), uInstance); 2453 AssertPtr(pDev0); 2454 2455 PCFGMNODE pDevLun = CFGMR3GetChildF(pDev0, "LUN#%u/", uLUN); 2456 2457 if (fAttach) 2458 { 2459 if (!pDevLun) 2460 { 2461 LogRel2(("VideoRec: Attaching audio driver\n")); 2462 2463 PCFGMNODE pLunL0; 2464 CFGMR3InsertNodeF(pDev0, &pLunL0, "LUN#%RU8", uLUN); 2465 CFGMR3InsertString(pLunL0, "Driver", "AUDIO"); 2466 2467 PCFGMNODE pCfg; 2468 CFGMR3InsertNode(pLunL0, "Config", &pCfg); 2469 CFGMR3InsertString (pCfg, "DriverName", "AudioVideoRec"); 2470 CFGMR3InsertInteger(pCfg, "InputEnabled", 0); 2471 CFGMR3InsertInteger(pCfg, "OutputEnabled", 1); 2472 2473 PCFGMNODE pLunL1; 2474 CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); 2475 CFGMR3InsertString(pLunL1, "Driver", "AudioVideoRec"); 2476 2477 CFGMR3InsertNode(pLunL1, "Config", &pCfg); 2478 CFGMR3InsertInteger(pCfg, "Object", (uintptr_t)mParent->i_getAudioVideoRec()); 2479 CFGMR3InsertInteger(pCfg, "ObjectConsole", (uintptr_t)mParent /* Console */); 2480 } 2481 } 2482 else /* Detach */ 2483 { 2484 if (pDevLun) 2485 { 2486 LogRel2(("VideoRec: Detaching audio driver\n")); 2487 CFGMR3RemoveNode(pDevLun); 2488 } 2489 } 2490 2491 return VINF_SUCCESS; 2492 } 2493 #endif 2494 2495 /** 2496 * Configures video capturing (via CFGM) and attaches / detaches the associated driver. 2497 * Currently this only is the audio driver (if available). 2498 * 2499 * @returns IPRT status code. 2500 * @param pThis Display instance to configure video capturing for. 2501 * @param pCfg Where to store the configuration into. 2502 * @param fAttachDetach Whether to attach/detach associated drivers or not. 2503 * @param puLUN On input, this defines the LUN to which the audio driver shall be assigned to. 2504 * On output, this returns the LUN the audio driver was assigned to. 2505 */ 2506 /* static */ 2507 DECLCALLBACK(int) Display::i_videoRecConfigure(Display *pThis, PVIDEORECCFG pCfg, bool fAttachDetach, unsigned *puLUN) 2508 { 2509 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 2510 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 2511 AssertPtrReturn(puLUN, VERR_INVALID_POINTER); 2512 2513 AssertPtr(pThis->mParent); 2514 ComPtr<IMachine> pMachine = pThis->mParent->i_machine(); 2515 Assert(pMachine.isNotNull()); 2516 2517 pCfg->enmDst = VIDEORECDEST_FILE; /** @todo Make this configurable once we have more variations. */ 2428 mVideoRecCfg.enmDst = VIDEORECDEST_FILE; /** @todo Make this configurable once we have more variations. */ 2518 2429 2519 2430 /* … … 2521 2432 */ 2522 2433 BOOL fEnabled; 2523 HRESULT rc = pMachine->COMGETTER(VideoCaptureEnabled)(&fEnabled);2524 AssertComRCReturn (rc, VERR_COM_UNEXPECTED);2525 pCfg->fEnabled = RT_BOOL(fEnabled);2434 HRESULT hrc = pMachine->COMGETTER(VideoCaptureEnabled)(&fEnabled); 2435 AssertComRCReturnVoid(hrc); 2436 mVideoRecCfg.fEnabled = RT_BOOL(fEnabled); 2526 2437 2527 2438 com::SafeArray<BOOL> aScreens; 2528 rc = pMachine->COMGETTER(VideoCaptureScreens)(ComSafeArrayAsOutParam(aScreens));2529 AssertComRCReturn (rc, VERR_COM_UNEXPECTED);2530 2531 pCfg->aScreens.resize(aScreens.size());2439 hrc = pMachine->COMGETTER(VideoCaptureScreens)(ComSafeArrayAsOutParam(aScreens)); 2440 AssertComRCReturnVoid(hrc); 2441 2442 mVideoRecCfg.aScreens.resize(aScreens.size()); 2532 2443 for (size_t i = 0; i < aScreens.size(); ++i) 2533 pCfg->aScreens[i] = aScreens[i];2534 2535 rc = pMachine->COMGETTER(VideoCaptureWidth)((ULONG *)&pCfg->Video.uWidth);2536 AssertComRCReturn (rc, VERR_COM_UNEXPECTED);2537 rc = pMachine->COMGETTER(VideoCaptureHeight)((ULONG *)&pCfg->Video.uHeight);2538 AssertComRCReturn (rc, VERR_COM_UNEXPECTED);2539 rc = pMachine->COMGETTER(VideoCaptureRate)((ULONG *)&pCfg->Video.uRate);2540 AssertComRCReturn (rc, VERR_COM_UNEXPECTED);2541 rc = pMachine->COMGETTER(VideoCaptureFPS)((ULONG *)&pCfg->Video.uFPS);2542 AssertComRCReturn (rc, VERR_COM_UNEXPECTED);2543 rc = pMachine->COMGETTER(VideoCaptureFile)(pCfg->File.strName.asOutParam());2544 AssertComRCReturn (rc, VERR_COM_UNEXPECTED);2545 rc = pMachine->COMGETTER(VideoCaptureMaxFileSize)((ULONG *)&pCfg->File.uMaxSizeMB);2546 AssertComRCReturn (rc, VERR_COM_UNEXPECTED);2547 rc = pMachine->COMGETTER(VideoCaptureMaxTime)((ULONG *)&pCfg->uMaxTimeS);2548 AssertComRCReturn (rc, VERR_COM_UNEXPECTED);2444 mVideoRecCfg.aScreens[i] = aScreens[i]; 2445 2446 hrc = pMachine->COMGETTER(VideoCaptureWidth)((ULONG *)&mVideoRecCfg.Video.uWidth); 2447 AssertComRCReturnVoid(hrc); 2448 hrc = pMachine->COMGETTER(VideoCaptureHeight)((ULONG *)&mVideoRecCfg.Video.uHeight); 2449 AssertComRCReturnVoid(hrc); 2450 hrc = pMachine->COMGETTER(VideoCaptureRate)((ULONG *)&mVideoRecCfg.Video.uRate); 2451 AssertComRCReturnVoid(hrc); 2452 hrc = pMachine->COMGETTER(VideoCaptureFPS)((ULONG *)&mVideoRecCfg.Video.uFPS); 2453 AssertComRCReturnVoid(hrc); 2454 hrc = pMachine->COMGETTER(VideoCaptureFile)(mVideoRecCfg.File.strName.asOutParam()); 2455 AssertComRCReturnVoid(hrc); 2456 hrc = pMachine->COMGETTER(VideoCaptureMaxFileSize)((ULONG *)&mVideoRecCfg.File.uMaxSizeMB); 2457 AssertComRCReturnVoid(hrc); 2458 hrc = pMachine->COMGETTER(VideoCaptureMaxTime)((ULONG *)&mVideoRecCfg.uMaxTimeS); 2459 AssertComRCReturnVoid(hrc); 2549 2460 BSTR bstrOptions; 2550 rc = pMachine->COMGETTER(VideoCaptureOptions)(&bstrOptions);2551 AssertComRCReturn (rc, VERR_COM_UNEXPECTED);2461 hrc = pMachine->COMGETTER(VideoCaptureOptions)(&bstrOptions); 2462 AssertComRCReturnVoid(hrc); 2552 2463 2553 2464 /* 2554 2465 * Set sensible defaults. 2555 2466 */ 2556 pCfg->Video.fEnabled = pCfg->fEnabled;2557 2558 if (! pCfg->Video.uFPS) /* Prevent division by zero. */2559 pCfg->Video.uFPS = 15;2467 mVideoRecCfg.Video.fEnabled = mVideoRecCfg.fEnabled; 2468 2469 if (!mVideoRecCfg.Video.uFPS) /* Prevent division by zero. */ 2470 mVideoRecCfg.Video.uFPS = 15; 2560 2471 2561 2472 #ifdef VBOX_WITH_LIBVPX 2562 pCfg->Video.Codec.VPX.uEncoderDeadline = 1000000 / pCfg->Video.uFPS;2473 mVideoRecCfg.Video.Codec.VPX.uEncoderDeadline = 1000000 / mVideoRecCfg.Video.uFPS; 2563 2474 #endif 2564 2475 … … 2566 2477 * There be dragons! */ 2567 2478 #ifdef VBOX_WITH_AUDIO_VIDEOREC 2568 pCfg->Audio.fEnabled = false;2479 mVideoRecCfg.Audio.fEnabled = false; 2569 2480 /* By default we use 48kHz, 16-bit, stereo for the audio track. */ 2570 pCfg->Audio.uHz = 48000;2571 pCfg->Audio.cBits = 16;2572 pCfg->Audio.cChannels = 2;2481 mVideoRecCfg.Audio.uHz = 48000; 2482 mVideoRecCfg.Audio.cBits = 16; 2483 mVideoRecCfg.Audio.cChannels = 2; 2573 2484 #endif 2574 2485 … … 2585 2496 #ifdef VBOX_WITH_LIBVPX 2586 2497 if (value.compare("realtime", Utf8Str::CaseInsensitive) == 0) 2587 pCfg->Video.Codec.VPX.uEncoderDeadline = VPX_DL_REALTIME;2498 mVideoRecCfg.Video.Codec.VPX.uEncoderDeadline = VPX_DL_REALTIME; 2588 2499 else if (value.compare("good", Utf8Str::CaseInsensitive) == 0) 2589 pCfg->Video.Codec.VPX.uEncoderDeadline = 1000000 / pCfg->Video.uFPS;2500 mVideoRecCfg.Video.Codec.VPX.uEncoderDeadline = 1000000 / mVideoRecCfg.Video.uFPS; 2590 2501 else if (value.compare("best", Utf8Str::CaseInsensitive) == 0) 2591 pCfg->Video.Codec.VPX.uEncoderDeadline = VPX_DL_BEST_QUALITY;2502 mVideoRecCfg.Video.Codec.VPX.uEncoderDeadline = VPX_DL_BEST_QUALITY; 2592 2503 else 2593 2504 { 2594 2505 LogRel(("VideoRec: Setting quality deadline to '%s'\n", value.c_str())); 2595 pCfg->Video.Codec.VPX.uEncoderDeadline = value.toUInt32();2506 mVideoRecCfg.Video.Codec.VPX.uEncoderDeadline = value.toUInt32(); 2596 2507 #endif 2597 2508 } … … 2601 2512 if (value.compare("false", Utf8Str::CaseInsensitive) == 0) 2602 2513 { 2603 pCfg->Video.fEnabled = false;2514 mVideoRecCfg.Video.fEnabled = false; 2604 2515 #ifdef VBOX_WITH_AUDIO_VIDEOREC 2605 2516 LogRel(("VideoRec: Only audio will be recorded\n")); … … 2612 2523 if (value.compare("true", Utf8Str::CaseInsensitive) == 0) 2613 2524 { 2614 pCfg->Audio.fEnabled = true;2525 mVideoRecCfg.Audio.fEnabled = true; 2615 2526 2616 2527 } … … 2624 2535 if (value.compare("low", Utf8Str::CaseInsensitive) == 0) 2625 2536 { 2626 pCfg->Audio.uHz = 8000;2627 pCfg->Audio.cBits = 16;2628 pCfg->Audio.cChannels = 1;2537 mVideoRecCfg.Audio.uHz = 8000; 2538 mVideoRecCfg.Audio.cBits = 16; 2539 mVideoRecCfg.Audio.cChannels = 1; 2629 2540 } 2630 2541 else if (value.startsWith("med" /* "med[ium]" */, Utf8Str::CaseInsensitive) == 0) 2631 2542 { 2632 pCfg->Audio.uHz = 22050;2633 pCfg->Audio.cBits = 16;2634 pCfg->Audio.cChannels = 2;2543 mVideoRecCfg.Audio.uHz = 22050; 2544 mVideoRecCfg.Audio.cBits = 16; 2545 mVideoRecCfg.Audio.cChannels = 2; 2635 2546 } 2636 2547 else if (value.compare("high", Utf8Str::CaseInsensitive) == 0) … … 2645 2556 } /* while */ 2646 2557 2647 unsigned uLUN = *puLUN;2648 2649 #ifdef VBOX_WITH_AUDIO_VIDEOREC2650 ComPtr<IAudioAdapter> audioAdapter;2651 rc = pMachine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam());2652 AssertComRC(rc);2653 2654 unsigned uInstance = 0;2655 2656 Utf8Str strAudioDev = pThis->mParent->i_getAudioAdapterDeviceName(audioAdapter);2657 if (!strAudioDev.isEmpty())2658 {2659 Console::SafeVMPtr ptrVM(pThis->mParent);2660 Assert(ptrVM.isOk());2661 2662 /*2663 * Configure + attach audio driver.2664 */2665 int vrc2 = VINF_SUCCESS;2666 2667 LogFunc(("Audio fAttachDetach=%RTbool, fEnabled=%RTbool\n", fAttachDetach, pCfg->Audio.fEnabled));2668 2669 if (pCfg->Audio.fEnabled) /* Enable */2670 {2671 vrc2 = pThis->i_videoRecConfigureAudioDriver(strAudioDev, uInstance, uLUN, true /* fAttach */);2672 if ( RT_SUCCESS(vrc2)2673 && fAttachDetach)2674 {2675 vrc2 = PDMR3DriverAttach(ptrVM.rawUVM(), strAudioDev.c_str(), uInstance, uLUN, 0 /* fFlags */, NULL /* ppBase */);2676 }2677 2678 if (RT_FAILURE(vrc2))2679 LogRel(("VideoRec: Failed to attach audio driver, rc=%Rrc\n", vrc2));2680 }2681 else /* Disable */2682 {2683 if (fAttachDetach)2684 vrc2 = PDMR3DriverDetach(ptrVM.rawUVM(), strAudioDev.c_str(), uInstance, uLUN, "AUDIO",2685 0 /* iOccurrence */, 0 /* fFlags */);2686 2687 if (RT_SUCCESS(vrc2))2688 {2689 vrc2 = pThis->i_videoRecConfigureAudioDriver(strAudioDev, uInstance, uLUN, false /* fAttach */);2690 }2691 2692 if (RT_FAILURE(vrc2))2693 LogRel(("VideoRec: Failed to detach audio driver, rc=%Rrc\n", vrc2));2694 }2695 2696 AssertRC(vrc2);2697 }2698 else2699 LogRel2(("VideoRec: No audio hardware configured, skipping to record audio\n"));2700 #else2701 RT_NOREF(fAttachDetach);2702 #endif2703 2704 2558 /* 2705 2559 * Invalidate screens. 2706 2560 */ 2707 for (unsigned i = 0; i < pCfg->aScreens.size(); i++) 2708 { 2709 bool fChanged = pThis->maVideoRecEnabled[i] != RT_BOOL(pCfg->aScreens[i]); 2710 2711 pThis->maVideoRecEnabled[i] = RT_BOOL(pCfg->aScreens[i]); 2712 2713 if (fChanged && i < pThis->mcMonitors) 2714 pThis->i_videoRecScreenChanged(i); 2715 2716 } 2717 2718 if (puLUN) 2719 *puLUN = uLUN; 2720 2721 return S_OK; 2561 for (unsigned i = 0; i < mVideoRecCfg.aScreens.size(); i++) 2562 { 2563 bool fChanged = maVideoRecEnabled[i] != RT_BOOL(mVideoRecCfg.aScreens[i]); 2564 2565 maVideoRecEnabled[i] = RT_BOOL(mVideoRecCfg.aScreens[i]); 2566 2567 if (fChanged && i < mcMonitors) 2568 i_videoRecScreenChanged(i); 2569 2570 } 2722 2571 } 2723 2572 -
trunk/src/VBox/Main/src-client/DrvAudioVideoRec.cpp
r70038 r70563 1016 1016 1017 1017 AudioVideoRec::AudioVideoRec(Console *pConsole) 1018 : mpDrv(NULL)1019 , mp Console(pConsole)1018 : AudioDriver(pConsole) 1019 , mpDrv(NULL) 1020 1020 { 1021 1021 } … … 1029 1029 mpDrv = NULL; 1030 1030 } 1031 } 1032 1033 1034 void AudioVideoRec::configureDriver(PCFGMNODE pLunCfg) 1035 { 1036 CFGMR3InsertInteger(pLunCfg, "Object", (uintptr_t)mpConsole->i_getAudioVideoRec()); 1037 CFGMR3InsertInteger(pLunCfg, "ObjectConsole", (uintptr_t)mpConsole); 1031 1038 } 1032 1039
Note:
See TracChangeset
for help on using the changeset viewer.