Changeset 70644 in vbox
- Timestamp:
- Jan 19, 2018 12:20:33 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 120374
- Location:
- trunk/src/VBox/Main
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/AudioDriver.h
r70579 r70644 31 31 struct AudioDriverCfg 32 32 { 33 AudioDriverCfg(Utf8Str a_strDev = "", unsigned a_uInst = 0, Utf8Str a_strName = "")33 AudioDriverCfg(Utf8Str a_strDev = "", unsigned a_uInst = 0, unsigned a_uLUN = 0, Utf8Str a_strName = "") 34 34 : strDev(a_strDev) 35 35 , uInst(a_uInst) 36 , uLUN(a_uLUN) 36 37 , strName(a_strName) { } 37 38 … … 40 41 this->strDev = that.strDev; 41 42 this->uInst = that.uInst; 43 this->uLUN = that.uLUN; 42 44 this->strName = that.strName; 43 45 … … 49 51 /** The device instance. */ 50 52 unsigned uInst; 53 /** The LUN the driver is attached to. 54 * Set the UINT8_MAX if not attached. */ 55 unsigned uLUN; 51 56 /** The driver name. */ 52 57 Utf8Str strName; … … 86 91 /** 87 92 * Optional (virtual) function to give the derived audio driver 88 * class the ability to add more driver configuration entries when89 * setting up.93 * class the ability to add (or change) the driver configuration 94 * entries when setting up. 90 95 * 91 * @param pLunCfg CFGM configuration node of the driver. 96 * @return VBox status code. 97 * @param pLunCfg CFGM configuration node of the driver. 92 98 */ 93 virtual void configureDriver(PCFGMNODE pLunCfg) { RT_NOREF(pLunCfg); } 94 95 unsigned getFreeLUN(void); 99 virtual int configureDriver(PCFGMNODE pLunCfg) { RT_NOREF(pLunCfg); return VINF_SUCCESS; } 96 100 97 101 protected: … … 103 107 /** Whether the driver is attached or not. */ 104 108 bool mfAttached; 105 /** The LUN the driver is attached to.106 * Set the UINT8_MAX if not attached. */107 unsigned muLUN;108 109 }; 109 110 -
trunk/src/VBox/Main/include/DrvAudioVRDE.h
r70553 r70644 62 62 private: 63 63 64 voidconfigureDriver(PCFGMNODE pLunCfg);64 int configureDriver(PCFGMNODE pLunCfg); 65 65 66 66 /** Pointer to the associated VRDE audio driver. */ -
trunk/src/VBox/Main/include/DrvAudioVideoRec.h
r70563 r70644 50 50 private: 51 51 52 voidconfigureDriver(PCFGMNODE pLunCfg);52 int configureDriver(PCFGMNODE pLunCfg); 53 53 54 54 /** Pointer to the associated video recording audio driver. */ -
trunk/src/VBox/Main/src-client/AudioDriver.cpp
r70626 r70644 35 35 : mpConsole(pConsole) 36 36 , mfAttached(false) 37 , muLUN(UINT8_MAX)38 37 { 39 38 } … … 43 42 } 44 43 45 /**46 * Returns the next free LUN of the audio device driver47 * chain.48 *49 * @return unsigned Next free LUN in audio device driver chain.50 */51 unsigned AudioDriver::getFreeLUN(void)52 {53 Console::SafeVMPtrQuiet ptrVM(mpConsole);54 Assert(ptrVM.isOk());55 56 PUVM pUVM = ptrVM.rawUVM();57 AssertPtr(pUVM);58 59 unsigned uLUN = 0;60 61 PCFGMNODE pDevLUN;62 for (;;)63 {64 pDevLUN = CFGMR3GetChildF(CFGMR3GetRootU(pUVM), "Devices/%s/%u/LUN#%u/", mCfg.strDev.c_str(), mCfg.uInst, uLUN);65 if (!pDevLUN)66 break;67 uLUN++;68 }69 70 return uLUN;71 }72 73 44 74 45 /** 75 46 * Initializes the audio driver with a certain (device) configuration. 76 *77 * @note The driver's LUN will be determined on runtime when attaching the78 * driver to the audio driver chain.79 47 * 80 48 * @returns VBox status code. … … 84 52 { 85 53 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 54 55 /* Sanity. */ 56 AssertReturn(pCfg->strDev.isNotEmpty(), VERR_INVALID_PARAMETER); 57 AssertReturn(pCfg->uLUN != UINT8_MAX, VERR_INVALID_PARAMETER); 58 AssertReturn(pCfg->strName.isNotEmpty(), VERR_INVALID_PARAMETER); 86 59 87 60 /* Apply configuration. */ … … 142 115 Assert(ptrVM.isOk()); 143 116 144 145 117 if (pThis->mfAttached) /* Already attached? Bail out. */ 146 118 { … … 151 123 AudioDriverCfg *pCfg = &pThis->mCfg; 152 124 153 unsigned uLUN = pThis->muLUN;154 if (uLUN == UINT8_MAX) /* No LUN assigned / configured yet? Retrieve it. */155 uLUN = pThis->getFreeLUN();156 157 125 LogFunc(("strName=%s, strDevice=%s, uInst=%u, uLUN=%u\n", 158 pCfg->strName.c_str(), pCfg->strDev.c_str(), pCfg->uInst, uLUN)); 159 160 int vrc = pThis->configure(uLUN, true /* Attach */); 161 if (RT_SUCCESS(vrc)) 162 vrc = PDMR3DeviceAttach(ptrVM.rawUVM(), pCfg->strDev.c_str(), pCfg->uInst, uLUN, 0 /* fFlags */, 163 NULL /* ppBase */); 164 if (RT_SUCCESS(vrc)) 165 { 166 pThis->muLUN = uLUN; 126 pCfg->strName.c_str(), pCfg->strDev.c_str(), pCfg->uInst, pCfg->uLUN)); 127 128 int rc = pThis->configure(pCfg->uLUN, true /* Attach */); 129 if (RT_SUCCESS(rc)) 130 rc = PDMR3DriverAttach(ptrVM.rawUVM(), pCfg->strDev.c_str(), pCfg->uInst, pCfg->uLUN, 0 /* fFlags */, 131 NULL /* ppBase */); 132 if (RT_SUCCESS(rc)) 133 { 167 134 pThis->mfAttached = true; 168 169 LogRel2(("%s: Driver attached (LUN #%u)\n", pCfg->strName.c_str(), pThis->muLUN)); 135 LogRel2(("%s: Driver attached (LUN #%u)\n", pCfg->strName.c_str(), pCfg->uLUN)); 170 136 } 171 137 else 172 LogRel(("%s: Failed to attach audio driver, rc=%Rrc\n", pCfg->strName.c_str(), vrc)); 173 174 return vrc; 138 LogRel(("%s: Failed to attach audio driver, rc=%Rrc\n", pCfg->strName.c_str(), rc)); 139 140 LogFunc(("Returning %Rrc\n", rc)); 141 return rc; 175 142 } 176 143 … … 232 199 Assert(ptrVM.isOk()); 233 200 234 Assert(pThis->muLUN != UINT8_MAX);235 236 201 AudioDriverCfg *pCfg = &pThis->mCfg; 237 202 203 Assert(pCfg->uLUN != UINT8_MAX); 204 238 205 LogFunc(("strName=%s, strDevice=%s, uInst=%u, uLUN=%u\n", 239 pCfg->strName.c_str(), pCfg->strDev.c_str(), pCfg->uInst, pThis->muLUN)); 240 241 int vrc = PDMR3DriverDetach(ptrVM.rawUVM(), pCfg->strDev.c_str(), pCfg->uInst, pThis->muLUN, "AUDIO", 242 0 /* iOccurrence */, 0 /* fFlags */); 243 if (RT_SUCCESS(vrc)) 244 vrc = pThis->configure(pThis->muLUN, false /* Detach */); 245 246 if (RT_SUCCESS(vrc)) 247 { 248 pThis->muLUN = UINT8_MAX; 206 pCfg->strName.c_str(), pCfg->strDev.c_str(), pCfg->uInst, pCfg->uLUN)); 207 208 int rc = PDMR3DeviceDetach(ptrVM.rawUVM(), pCfg->strDev.c_str(), pCfg->uInst, pCfg->uLUN, 0 /* fFlags */); 209 if (RT_SUCCESS(rc)) 210 rc = pThis->configure(pCfg->uLUN, false /* Detach */); 211 212 if (RT_SUCCESS(rc)) 213 { 249 214 pThis->mfAttached = false; 250 251 215 LogRel2(("%s: Driver detached\n", pCfg->strName.c_str())); 252 216 } 253 217 else 254 LogRel(("%s: Failed to detach audio driver, rc=%Rrc\n", pCfg->strName.c_str(), vrc)); 255 256 return vrc; 218 LogRel(("%s: Failed to detach audio driver, rc=%Rrc\n", pCfg->strName.c_str(), rc)); 219 220 LogFunc(("Returning %Rrc\n", rc)); 221 return rc; 257 222 } 258 223 … … 268 233 int AudioDriver::configure(unsigned uLUN, bool fAttach) 269 234 { 270 int rc = VINF_SUCCESS;271 272 235 Console::SafeVMPtrQuiet ptrVM(mpConsole); 273 236 Assert(ptrVM.isOk()); … … 276 239 AssertPtr(pUVM); 277 240 278 PCFGMNODE pRoot 241 PCFGMNODE pRoot = CFGMR3GetRootU(pUVM); 279 242 AssertPtr(pRoot); 280 PCFGMNODE pDev0 243 PCFGMNODE pDev0 = CFGMR3GetChildF(pRoot, "Devices/%s/%u/", mCfg.strDev.c_str(), mCfg.uInst); 281 244 282 245 if (!pDev0) /* No audio device configured? Bail out. */ … … 286 249 } 287 250 251 int rc = VINF_SUCCESS; 252 288 253 PCFGMNODE pDevLun = CFGMR3GetChildF(pDev0, "LUN#%u/", uLUN); 289 254 290 255 if (fAttach) 291 256 { 292 AssertMsg(uLUN != UINT8_MAX, ("%s: LUN is undefined when it must not\n", mCfg.strName.c_str())); 293 294 if (!pDevLun) 257 do 295 258 { 296 LogRel2(("%s: Configuring audio driver (to LUN #%RU8)\n", mCfg.strName.c_str(), uLUN)); 297 298 PCFGMNODE pLunL0; 299 CFGMR3InsertNodeF(pDev0, &pLunL0, "LUN#%RU8", uLUN); 300 CFGMR3InsertString(pLunL0, "Driver", "AUDIO"); 301 302 PCFGMNODE pLunCfg; 303 CFGMR3InsertNode(pLunL0, "Config", &pLunCfg); 304 CFGMR3InsertStringF(pLunCfg, "DriverName", "%s", mCfg.strName.c_str()); 305 CFGMR3InsertInteger(pLunCfg, "InputEnabled", 0); /* Play safe by default. */ 306 CFGMR3InsertInteger(pLunCfg, "OutputEnabled", 1); 307 308 PCFGMNODE pLunL1; 309 CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); 310 CFGMR3InsertStringF(pLunL1, "Driver", "%s", mCfg.strName.c_str()); 311 312 CFGMR3InsertNode(pLunL1, "Config", &pLunCfg); 259 AssertMsgBreakStmt(pDevLun, ("%s: Device LUN #%u not found\n", mCfg.strName.c_str(), uLUN), rc = VERR_NOT_FOUND); 260 261 LogRel2(("%s: Configuring audio driver (to LUN #%u)\n", mCfg.strName.c_str(), uLUN)); 262 263 PCFGMNODE pLunCfg = CFGMR3GetChild(pDevLun, "Config"); 264 AssertBreakStmt(pLunCfg, rc = VERR_NOT_FOUND); 265 266 rc = CFGMR3InsertStringF(pLunCfg, "DriverName", "%s", mCfg.strName.c_str()); AssertRCBreak(rc); 267 268 rc = CFGMR3InsertInteger(pLunCfg, "InputEnabled", 0); /* Play safe by default. */ AssertRCBreak(rc); 269 rc = CFGMR3InsertInteger(pLunCfg, "OutputEnabled", 1); AssertRCBreak(rc); 270 271 PCFGMNODE pAttachedDriver, pAttachedDriverCfg; 272 rc = CFGMR3InsertNode(pDevLun, "AttachedDriver", &pAttachedDriver); AssertRCBreak(rc); 273 rc = CFGMR3InsertStringF(pAttachedDriver, "Driver", "%s", mCfg.strName.c_str()); AssertRCBreak(rc); 274 rc = CFGMR3InsertNode(pAttachedDriver, "Config", &pAttachedDriverCfg); AssertRCBreak(rc); 313 275 314 276 /* Call the (virtual) method for driver-specific configuration. */ 315 configureDriver(pLunCfg); 316 } 317 else 318 rc = VERR_ALREADY_EXISTS; 277 rc = configureDriver(pAttachedDriverCfg); AssertRCBreak(rc); 278 279 } while (0); 319 280 } 320 281 else /* Detach */ … … 323 284 { 324 285 LogRel2(("%s: Unconfiguring audio driver\n", mCfg.strName.c_str())); 325 CFGMR3RemoveNode(pDevLun); 286 287 PCFGMNODE pLunCfg = CFGMR3GetChild(pDevLun, "Config"); 288 if (pLunCfg) 289 CFGMR3RemoveNode(pLunCfg); 290 291 rc = CFGMR3InsertNode(pDevLun, "Config", &pLunCfg); 292 293 PCFGMNODE pLunAttachedDriver = CFGMR3GetChild(pDevLun, "AttachedDriver"); 294 if (pLunAttachedDriver) 295 CFGMR3RemoveNode(pLunAttachedDriver); 326 296 } 327 else 328 rc = VERR_NOT_FOUND; 329 } 330 331 #ifdef DEBUG_andy 332 CFGMR3Dump(pDev0); 333 #endif 297 } 334 298 335 299 if (RT_FAILURE(rc)) … … 337 301 mCfg.strName.c_str(), fAttach ? "Configuring" : "Unconfiguring", rc)); 338 302 303 LogFunc(("Returning %Rrc\n", rc)); 339 304 return rc; 340 305 } -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r70579 r70644 9840 9840 AssertComRCReturnVoid(rc); 9841 9841 9842 if (fVRDEEnabled) 9842 if ( fVRDEEnabled 9843 && pConsole->mAudioVRDE) 9843 9844 pConsole->mAudioVRDE->doAttachDriverViaEmt(pConsole->mpUVM, &alock); 9844 9845 } … … 9848 9849 pConsole->i_consoleVRDPServer()->EnableConnections(); 9849 9850 9850 #ifdef VBOX_WITH_AUDIO_VIDEOREC9851 9851 Display *pDisplay = pConsole->i_getDisplay(); 9852 9852 AssertPtr(pDisplay); … … 9855 9855 pDisplay->i_videoRecInvalidate(); 9856 9856 9857 /* If video recording fails for whatever reason here, this is 9858 * non-critical and should not be returned at this point -- otherwise 9859 * the display driver construction fails completely. */ 9860 int vrc2 = VINF_SUCCESS; 9861 9862 #ifdef VBOX_WITH_AUDIO_VIDEOREC 9857 9863 /* Attach the video recording audio driver if required. */ 9858 if ( pDisplay->i_videoRecGetEnabled() & VIDEORECFEATURE_AUDIO)9859 pConsole->mAudioVideoRec->doAttachDriverViaEmt(pConsole->mpUVM, &alock);9860 }9864 if ( pDisplay->i_videoRecGetEnabled() & VIDEORECFEATURE_AUDIO 9865 && pConsole->mAudioVideoRec) 9866 vrc2 = pConsole->mAudioVideoRec->doAttachDriverViaEmt(pConsole->mpUVM, &alock); 9861 9867 #endif 9868 if ( RT_SUCCESS(vrc2) 9869 && pDisplay->i_videoRecGetEnabled()) /* Any video recording (audio and/or video) feature enabled? */ 9870 { 9871 vrc2 = pDisplay->i_videoRecStart(); 9872 if (RT_SUCCESS(vrc2)) 9873 fireVideoCaptureChangedEvent(pConsole->i_getEventSource()); 9874 } 9875 } 9876 9862 9877 if (RT_SUCCESS(vrc)) 9863 9878 { -
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r70628 r70644 2979 2979 2980 2980 #ifdef VBOX_WITH_AUDIO_VRDE 2981 AudioDriverCfg DrvCfgVRDE(strAudioDevice, 0 /* Instance */, "AudioVRDE"); 2981 /* Insert dummy audio driver to have the LUN configured. */ 2982 CFGMR3InsertNodeF(pInst, &pLunL0, "LUN#%RU8", uAudioLUN); 2983 InsertConfigString(pLunL0, "Driver", "AUDIO"); 2984 AudioDriverCfg DrvCfgVRDE(strAudioDevice, 0 /* Instance */, uAudioLUN, "AudioVRDE"); 2982 2985 rc = mAudioVRDE->InitializeConfig(&DrvCfgVRDE); 2983 AssertRC(rc); 2986 if (RT_SUCCESS(rc)) 2987 uAudioLUN++; 2984 2988 #endif /* VBOX_WITH_AUDIO_VRDE */ 2985 2989 2986 2990 #ifdef VBOX_WITH_AUDIO_VIDEOREC 2987 AudioDriverCfg DrvCfgVideoRec(strAudioDevice, 0 /* Instance */, "AudioVideoRec"); 2991 /* Insert dummy audio driver to have the LUN configured. */ 2992 CFGMR3InsertNodeF(pInst, &pLunL0, "LUN#%RU8", uAudioLUN); 2993 InsertConfigString(pLunL0, "Driver", "AUDIO"); 2994 AudioDriverCfg DrvCfgVideoRec(strAudioDevice, 0 /* Instance */, uAudioLUN, "AudioVideoRec"); 2988 2995 rc = mAudioVideoRec->InitializeConfig(&DrvCfgVideoRec); 2989 AssertRC(rc); 2996 if (RT_SUCCESS(rc)) 2997 uAudioLUN++; 2990 2998 #endif /* VBOX_WITH_AUDIO_VIDEOREC */ 2991 2999 -
trunk/src/VBox/Main/src-client/DisplayImpl.cpp
r70596 r70644 4569 4569 #endif 4570 4570 4571 #ifdef VBOX_WITH_VIDEOREC4572 if (pDisplay->i_videoRecGetEnabled())4573 {4574 int rc2 = pDisplay->i_videoRecStart();4575 if (RT_SUCCESS(rc2))4576 fireVideoCaptureChangedEvent(pDisplay->mParent->i_getEventSource());4577 4578 /* If video recording fails for whatever reason here, this is4579 * non-critical and should not be returned at this point -- otherwise4580 * the display driver construction fails completely. */4581 }4582 #endif4583 4584 4571 return rc; 4585 4572 } -
trunk/src/VBox/Main/src-client/DrvAudioVRDE.cpp
r70553 r70644 586 586 587 587 588 void AudioVRDE::configureDriver(PCFGMNODE pLunCfg) 588 /** 589 * @copydoc AudioDriver::configureDriver 590 */ 591 int AudioVRDE::configureDriver(PCFGMNODE pLunCfg) 589 592 { 590 593 CFGMR3InsertInteger(pLunCfg, "Object", (uintptr_t)this); 591 594 CFGMR3InsertInteger(pLunCfg, "ObjectVRDPServer", (uintptr_t)mpConsole->i_consoleVRDPServer()); 592 } 595 596 return VINF_SUCCESS; 597 } 598 593 599 594 600 int AudioVRDE::onVRDEControl(bool fEnable, uint32_t uFlags) -
trunk/src/VBox/Main/src-client/DrvAudioVideoRec.cpp
r70563 r70644 1032 1032 1033 1033 1034 void AudioVideoRec::configureDriver(PCFGMNODE pLunCfg) 1034 /** 1035 * @copydoc AudioDriver::configureDriver 1036 */ 1037 int AudioVideoRec::configureDriver(PCFGMNODE pLunCfg) 1035 1038 { 1036 1039 CFGMR3InsertInteger(pLunCfg, "Object", (uintptr_t)mpConsole->i_getAudioVideoRec()); 1037 1040 CFGMR3InsertInteger(pLunCfg, "ObjectConsole", (uintptr_t)mpConsole); 1041 1042 return VINF_SUCCESS; 1038 1043 } 1039 1044
Note:
See TracChangeset
for help on using the changeset viewer.