Changeset 75307 in vbox for trunk/src/VBox/Main/src-server
- Timestamp:
- Nov 7, 2018 1:56:14 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 126417
- Location:
- trunk/src/VBox/Main/src-server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/CaptureScreenSettingsImpl.cpp
r75279 r75307 86 86 m = new Data(); 87 87 88 /* share the parent weakly*/88 /* Share the parent weakly. */ 89 89 unconst(m->pMachine) = aParent; 90 /* mPeer is left null. */ 90 91 91 92 /* Simply copy the settings data. */ … … 94 95 m->bd->operator=(data); 95 96 96 autoInitSpan.setSucceeded(); 97 HRESULT rc = S_OK; 98 99 int vrc = i_initInternal(); 100 if (RT_SUCCESS(vrc)) 101 { 102 autoInitSpan.setSucceeded(); 103 } 104 else 105 { 106 autoInitSpan.setFailed(); 107 rc = E_UNEXPECTED; 108 } 97 109 98 110 LogFlowThisFuncLeave(); 99 return S_OK;111 return rc; 100 112 } 101 113 … … 129 141 m->bd.share(that->m->bd); 130 142 131 autoInitSpan.setSucceeded(); 143 HRESULT rc = S_OK; 144 145 int vrc = i_initInternal(); 146 if (RT_SUCCESS(vrc)) 147 { 148 autoInitSpan.setSucceeded(); 149 } 150 else 151 { 152 autoInitSpan.setFailed(); 153 rc = E_UNEXPECTED; 154 } 132 155 133 156 LogFlowThisFuncLeave(); 134 return S_OK;157 return rc; 135 158 } 136 159 … … 154 177 155 178 unconst(m->pMachine) = aParent; 156 / / mPeer is left null179 /* mPeer is left null. */ 157 180 158 181 AutoWriteLock thatlock(that COMMA_LOCKVAL_SRC_POS); … … 161 184 m->bd.attachCopy(that->m->bd); 162 185 163 autoInitSpan.setSucceeded(); 186 HRESULT rc = S_OK; 187 188 int vrc = i_initInternal(); 189 if (RT_SUCCESS(vrc)) 190 { 191 autoInitSpan.setSucceeded(); 192 } 193 else 194 { 195 autoInitSpan.setFailed(); 196 rc = E_UNEXPECTED; 197 } 164 198 165 199 LogFlowThisFuncLeave(); 166 return S_OK;200 return rc; 167 201 } 168 202 … … 216 250 if (m->bd->fEnabled != RT_BOOL(enabled)) 217 251 { 252 m->bd.backup(); 253 m->bd->fEnabled = RT_BOOL(enabled); 218 254 alock.release(); 255 256 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 257 m->pMachine->i_setModified(Machine::IsModified_Capture); 258 mlock.release(); 219 259 220 260 HRESULT rc = m->pMachine->i_onCaptureChange(); 221 261 if (FAILED(rc)) return rc; 222 223 m->pMachine->i_setModified(Machine::IsModified_Capture);224 225 alock.acquire();226 m->bd->fEnabled = RT_BOOL(enabled);227 alock.release();228 262 229 263 /** Save settings if online - @todo why is this required? -- @bugref{6818} */ … … 263 297 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 264 298 265 m->pMachine->i_setModified(Machine::IsModified_Capture); 266 m->bd.backup(); 267 299 m->bd.backup(); 268 300 m->bd->featureMap.clear(); 269 301 … … 273 305 m->bd->featureMap[CaptureFeature_Video] = true; 274 306 307 alock.release(); 308 309 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 310 m->pMachine->i_setModified(Machine::IsModified_Capture); 311 mlock.release(); 312 275 313 return S_OK; 276 314 } … … 292 330 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 293 331 294 m->pMachine->i_setModified(Machine::IsModified_Capture);295 332 m->bd.backup(); 296 333 m->bd->enmDest = aDestination; 297 334 335 alock.release(); 336 337 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 338 m->pMachine->i_setModified(Machine::IsModified_Capture); 339 mlock.release(); 340 298 341 return S_OK; 299 342 } … … 303 346 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 304 347 305 if (m->bd->File.strName.isEmpty()) 306 i_getDefaultCaptureFile(aFileName); 307 else 308 aFileName = m->bd->File.strName; 348 aFileName = m->bd->File.strName; 309 349 310 350 return S_OK; … … 323 363 return setError(E_INVALIDARG, tr("Capture file name '%s' is not absolute"), strFile.c_str()); 324 364 325 if (!strFile.isEmpty())326 {327 Utf8Str defaultFile;328 i_getDefaultCaptureFile(defaultFile);329 if (!RTPathCompare(strFile.c_str(), defaultFile.c_str()))330 strFile.setNull();331 }332 333 m->pMachine->i_setModified(Machine::IsModified_Capture);334 365 m->bd.backup(); 335 366 m->bd->File.strName = strFile; 336 367 368 alock.release(); 369 370 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 371 m->pMachine->i_setModified(Machine::IsModified_Capture); 372 mlock.release(); 373 337 374 return S_OK; 338 375 } … … 354 391 return setError(E_INVALIDARG, tr("Cannot change maximum time while capturing is enabled")); 355 392 356 m->pMachine->i_setModified(Machine::IsModified_Capture); 357 m->bd.backup(); 358 393 m->bd.backup(); 359 394 m->bd->ulMaxTimeS = aMaxTimeS; 360 395 396 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 397 m->pMachine->i_setModified(Machine::IsModified_Capture); 398 mlock.release(); 399 361 400 return S_OK; 362 401 } … … 378 417 return setError(E_INVALIDARG, tr("Cannot change maximum file size while capturing is enabled")); 379 418 380 m->pMachine->i_setModified(Machine::IsModified_Capture); 381 m->bd.backup(); 382 419 m->bd.backup(); 383 420 m->bd->File.ulMaxSizeMB = aMaxFileSize; 384 421 422 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 423 m->pMachine->i_setModified(Machine::IsModified_Capture); 424 mlock.release(); 425 385 426 return S_OK; 386 427 } … … 402 443 return setError(E_INVALIDARG, tr("Cannot change options string while capturing is enabled")); 403 444 404 m->pMachine->i_setModified(Machine::IsModified_Capture); 405 m->bd.backup(); 406 445 m->bd.backup(); 407 446 m->bd->strOptions = aOptions; 408 447 448 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 449 m->pMachine->i_setModified(Machine::IsModified_Capture); 450 mlock.release(); 451 409 452 return S_OK; 410 453 } … … 426 469 return setError(E_INVALIDARG, tr("Cannot change audio codec while capturing is enabled")); 427 470 428 m->pMachine->i_setModified(Machine::IsModified_Capture); 429 m->bd.backup(); 430 471 m->bd.backup(); 431 472 m->bd->Audio.enmAudioCodec = aCodec; 432 473 474 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 475 m->pMachine->i_setModified(Machine::IsModified_Capture); 476 mlock.release(); 477 433 478 return S_OK; 434 479 } … … 450 495 return setError(E_INVALIDARG, tr("Cannot change audio Hertz rate while capturing is enabled")); 451 496 452 m->pMachine->i_setModified(Machine::IsModified_Capture); 453 m->bd.backup(); 454 497 m->bd.backup(); 455 498 m->bd->Audio.uHz = (uint16_t)aHz; 456 499 500 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 501 m->pMachine->i_setModified(Machine::IsModified_Capture); 502 mlock.release(); 503 457 504 return S_OK; 458 505 } … … 474 521 return setError(E_INVALIDARG, tr("Cannot change audio bits while capturing is enabled")); 475 522 476 m->pMachine->i_setModified(Machine::IsModified_Capture); 477 m->bd.backup(); 478 523 m->bd.backup(); 479 524 m->bd->Audio.cBits = (uint8_t)aBits; 480 525 526 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 527 m->pMachine->i_setModified(Machine::IsModified_Capture); 528 mlock.release(); 529 481 530 return S_OK; 482 531 } … … 498 547 return setError(E_INVALIDARG, tr("Cannot change audio channels while capturing is enabled")); 499 548 500 m->pMachine->i_setModified(Machine::IsModified_Capture); 501 m->bd.backup(); 502 549 m->bd.backup(); 503 550 m->bd->Audio.cChannels = (uint8_t)aChannels; 504 551 552 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 553 m->pMachine->i_setModified(Machine::IsModified_Capture); 554 mlock.release(); 555 505 556 return S_OK; 506 557 } … … 522 573 return setError(E_INVALIDARG, tr("Cannot change video codec while capturing is enabled")); 523 574 524 m->pMachine->i_setModified(Machine::IsModified_Capture); 525 m->bd.backup(); 526 575 m->bd.backup(); 527 576 m->bd->Video.enmCodec = aCodec; 528 577 578 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 579 m->pMachine->i_setModified(Machine::IsModified_Capture); 580 mlock.release(); 581 529 582 return S_OK; 530 583 } … … 546 599 return setError(E_INVALIDARG, tr("Cannot change video width while capturing is enabled")); 547 600 548 m->pMachine->i_setModified(Machine::IsModified_Capture); 549 m->bd.backup(); 550 601 m->bd.backup(); 551 602 m->bd->Video.ulWidth = aVideoWidth; 552 603 604 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 605 m->pMachine->i_setModified(Machine::IsModified_Capture); 606 mlock.release(); 607 553 608 return S_OK; 554 609 } … … 570 625 return setError(E_INVALIDARG, tr("Cannot change video height while capturing is enabled")); 571 626 572 m->pMachine->i_setModified(Machine::IsModified_Capture); 573 m->bd.backup(); 574 627 m->bd.backup(); 575 628 m->bd->Video.ulHeight = aVideoHeight; 576 629 630 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 631 m->pMachine->i_setModified(Machine::IsModified_Capture); 632 mlock.release(); 633 577 634 return S_OK; 578 635 } … … 594 651 return setError(E_INVALIDARG, tr("Cannot change video rate while capturing is enabled")); 595 652 596 m->pMachine->i_setModified(Machine::IsModified_Capture); 597 m->bd.backup(); 598 653 m->bd.backup(); 599 654 m->bd->Video.ulRate = aVideoRate; 655 656 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 657 m->pMachine->i_setModified(Machine::IsModified_Capture); 658 mlock.release(); 600 659 601 660 return S_OK; … … 640 699 return setError(E_INVALIDARG, tr("Cannot change video FPS while capturing is enabled")); 641 700 642 m->pMachine->i_setModified(Machine::IsModified_Capture); 643 m->bd.backup(); 644 701 m->bd.backup(); 645 702 m->bd->Video.ulFPS = aVideoFPS; 703 704 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 705 m->pMachine->i_setModified(Machine::IsModified_Capture); 706 mlock.release(); 646 707 647 708 return S_OK; … … 685 746 * Returns the full path to the default video capture file. 686 747 */ 687 int CaptureScreenSettings::i_getDefault CaptureFile(Utf8Str &strFile)748 int CaptureScreenSettings::i_getDefaultFileName(Utf8Str &strFile) 688 749 { 689 750 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); … … 696 757 } 697 758 759 /** 760 * Initializes data, internal version. 761 * 762 * @returns IPRT status code. 763 */ 764 int CaptureScreenSettings::i_initInternal(void) 765 { 766 Assert(m); 767 return i_getDefaultFileName(m->bd->File.strName); 768 } 769 -
trunk/src/VBox/Main/src-server/CaptureSettingsImpl.cpp
r75287 r75307 44 44 ComObjPtr<CaptureSettings> pPeer; 45 45 CaptureScreenSettingsMap mapScreenSettings; 46 bool fHasMachineLock; 46 47 47 48 // use the XML settings structure in the members for simplicity … … 84 85 85 86 m->bd.allocate(); 87 m->fHasMachineLock = false; 86 88 87 89 autoInitSpan.setSucceeded(); … … 119 121 m->bd.share(that->m->bd); 120 122 m->mapScreenSettings = that->m->mapScreenSettings; 123 m->fHasMachineLock = false; 121 124 122 125 autoInitSpan.setSucceeded(); … … 151 154 m->bd.attachCopy(that->m->bd); 152 155 m->mapScreenSettings = that->m->mapScreenSettings; 156 m->fHasMachineLock = false; 153 157 154 158 autoInitSpan.setSucceeded(); … … 196 200 HRESULT CaptureSettings::setEnabled(BOOL enable) 197 201 { 198 /* the machine needs to be mutable */199 AutoMutableStateDependency adep(m->pMachine);200 if (FAILED(adep.rc())) return adep.rc();201 202 202 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 203 203 … … 216 216 { 217 217 /* 218 * Normally we would do the actual change _after_ i_on VideoCaptureChange() succeeded.219 * We cannot do this because that function uses Machine::GetVideoCaptureEnabled to218 * Normally we would do the actual change _after_ i_onCaptureChange() succeeded. 219 * We cannot do this because that function uses CaptureSettings::GetEnabled to 220 220 * determine if it should start or stop capturing. Therefore we need to manually 221 221 * undo change. … … 230 230 m->pMachine->i_setModified(Machine::IsModified_Capture); 231 231 232 /* We need to indicate here that we just took the machine lock, as Machine::i_saveSettings() will 233 * call i_commit(), which in turn also wants to lock the machine for writing. */ 234 m->fHasMachineLock = true; 235 232 236 /** Save settings if online - @todo why is this required? -- @bugref{6818} */ 233 if (Global::IsOnline(adep.machineState())) 234 m->pMachine->i_saveSettings(NULL); 237 if (Global::IsOnline(m->pMachine->i_getMachineState())) 238 rc = m->pMachine->i_saveSettings(NULL); 239 240 m->fHasMachineLock = false; 235 241 } 236 242 } … … 251 257 { 252 258 itScreenSettings->second.queryInterfaceTo(aCaptureScreenSettings[i].asOutParam()); 259 Assert(aCaptureScreenSettings[i].isNotNull()); 253 260 ++i; 254 261 ++itScreenSettings; 255 262 } 256 263 264 Assert(aCaptureScreenSettings.size() == m->mapScreenSettings.size()); 265 257 266 return S_OK; 258 267 } … … 280 289 281 290 /** 291 * Adds a screen settings object to the recording settings. 292 * 293 * @returns IPRT status code. VERR_ALREADY_EXISTS if the object in question already exists. 294 * @param uScreenId Screen ID to add settings for. 295 * @param data Recording screen settings to use for that screen. 296 */ 297 int CaptureSettings::i_addScreen(uint32_t uScreenId, const settings::CaptureScreenSettings &data) 298 { 299 if (m->mapScreenSettings.find(uScreenId) != m->mapScreenSettings.end()) 300 { 301 AssertFailed(); 302 return VERR_ALREADY_EXISTS; 303 } 304 305 int vrc = VINF_SUCCESS; 306 307 ComObjPtr<CaptureScreenSettings> captureScreenSettings; 308 HRESULT rc = captureScreenSettings.createObject(); 309 if (SUCCEEDED(rc)) 310 { 311 rc = captureScreenSettings->init(m->pMachine, uScreenId, data); 312 if (SUCCEEDED(rc)) 313 { 314 try 315 { 316 m->mapScreenSettings[uScreenId] = captureScreenSettings; 317 } 318 catch (std::bad_alloc &) 319 { 320 vrc = VERR_NO_MEMORY; 321 } 322 } 323 } 324 325 return vrc; 326 } 327 328 /** 282 329 * Loads settings from the given settings. 283 330 * May be called once right after this object creation. … … 301 348 while (itScreen != data.mapScreens.end()) 302 349 { 303 ComObjPtr<CaptureScreenSettings> captureScreenSettings; 304 rc = captureScreenSettings.createObject(); 305 if (FAILED(rc)) 350 int vrc = i_addScreen(itScreen->first /* uScreenId */, itScreen->second /* Settings */); 351 if (RT_FAILURE(vrc)) 352 { 353 rc = E_OUTOFMEMORY; 306 354 break; 307 308 rc = captureScreenSettings->init(m->pMachine, itScreen->first /* uScreenId */, itScreen->second /* Settings */); 309 if (FAILED(rc)) 310 break; 311 312 m->mapScreenSettings[itScreen->first] = captureScreenSettings; 355 } 313 356 314 357 ++itScreen; 315 358 } 359 360 if (FAILED(rc)) 361 return rc; 316 362 317 363 ComAssertComRC(rc); … … 378 424 { 379 425 /* attach new data to the peer and reshare it */ 380 AutoWriteLock peerlock(m->pPeer COMMA_LOCKVAL_SRC_POS); 426 AutoWriteLock peerlock(RT_SRC_POS); 427 if (!m->fHasMachineLock) 428 peerlock.attach(m->pPeer); 381 429 m->pPeer->m->bd.attach(m->bd); 382 430 }
Note:
See TracChangeset
for help on using the changeset viewer.