Changeset 74765 in vbox
- Timestamp:
- Oct 11, 2018 11:42:31 AM (6 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
-
include/ConsoleImpl.h (modified) (1 diff)
-
src-client/ConsoleImpl.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/ConsoleImpl.h
r73258 r74765 200 200 #ifdef VBOX_WITH_USB_CARDREADER 201 201 UsbCardReader *i_getUsbCardReader() { return mUsbCardReader; } 202 #endif 203 204 #ifdef VBOX_WITH_VIDEOREC 205 int i_videoCaptureEnable(BOOL fEnable, util::AutoWriteLock *pAutoLock); 202 206 #endif 203 207 -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r73005 r74765 5602 5602 } 5603 5603 5604 HRESULT Console::i_onVideoCaptureChange()5605 {5606 AutoCaller autoCaller(this);5607 AssertComRCReturnRC(autoCaller.rc());5608 5609 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);5610 5611 HRESULT rc = S_OK;5612 5613 5604 #ifdef VBOX_WITH_VIDEOREC 5614 /* Don't trigger video capture changes if the VM isn't running. */ 5615 SafeVMPtrQuiet ptrVM(this); 5616 if (ptrVM.isOk()) 5617 { 5618 if (mDisplay) 5619 { 5620 Display *pDisplay = mDisplay; 5621 AssertPtr(pDisplay); 5605 /** 5606 * Enables or disables video (audio) capturing of a VM. 5607 * 5608 * @returns IPRT status code. Will return VERR_NO_CHANGE if the capturing state has not been changed. 5609 * @param fEnable Whether to enable or disable the capturing. 5610 * @param pAutoLock Pointer to auto write lock to use for attaching/detaching required driver(s) at runtime. 5611 */ 5612 int Console::i_videoCaptureEnable(BOOL fEnable, util::AutoWriteLock *pAutoLock) 5613 { 5614 AssertPtrReturn(pAutoLock, VERR_INVALID_POINTER); 5615 5616 int vrc = VINF_SUCCESS; 5617 5618 Display *pDisplay = i_getDisplay(); 5619 if (pDisplay) 5620 { 5621 if (RT_BOOL(fEnable) != pDisplay->i_videoRecStarted()) 5622 { 5623 LogRel(("VideoRec: %s\n", fEnable ? "Enabling" : "Disabling")); 5622 5624 5623 5625 pDisplay->i_videoRecInvalidate(); 5624 5626 5625 BOOL fEnabled; 5626 rc = mMachine->COMGETTER(VideoCaptureEnabled)(&fEnabled); 5627 AssertComRCReturnRC(rc); 5628 5629 int vrc; 5630 5631 if (fEnabled) 5627 if (fEnable) 5632 5628 { 5633 5629 # ifdef VBOX_WITH_AUDIO_VIDEOREC 5634 5630 /* Attach the video recording audio driver if required. */ 5635 if (mDisplay->i_videoRecGetFeatures() & VIDEORECFEATURE_AUDIO) 5636 mAudioVideoRec->doAttachDriverViaEmt(mpUVM, &alock); 5631 if ( pDisplay->i_videoRecGetFeatures() & VIDEORECFEATURE_AUDIO 5632 && mAudioVideoRec) 5633 vrc = mAudioVideoRec->doAttachDriverViaEmt(mpUVM, pAutoLock); 5637 5634 # endif 5638 vrc = mDisplay->i_videoRecStart(); 5639 if (RT_FAILURE(vrc)) 5640 rc = setErrorBoth(E_FAIL, vrc, tr("Unable to start video capturing (%Rrc)"), vrc); 5635 if ( RT_SUCCESS(vrc) 5636 && pDisplay->i_videoRecGetFeatures()) /* Any video recording (audio and/or video) feature enabled? */ 5637 { 5638 vrc = pDisplay->i_videoRecStart(); 5639 } 5641 5640 } 5642 5641 else … … 5644 5643 mDisplay->i_videoRecStop(); 5645 5644 # ifdef VBOX_WITH_AUDIO_VIDEOREC 5646 mAudioVideoRec->doDetachDriverViaEmt(mpUVM, &alock);5645 mAudioVideoRec->doDetachDriverViaEmt(mpUVM, pAutoLock); 5647 5646 # endif 5648 5647 } 5648 5649 if (RT_FAILURE(vrc)) 5650 LogRel(("VideoRec: %s failed with %Rrc\n", fEnable ? "Enabling" : "Disabling", vrc)); 5651 } 5652 else /* Should not happen. */ 5653 vrc = VERR_NO_CHANGE; 5654 } 5655 5656 return vrc; 5657 } 5658 #endif /* VBOX_WITH_VIDEOREC */ 5659 5660 HRESULT Console::i_onVideoCaptureChange() 5661 { 5662 AutoCaller autoCaller(this); 5663 AssertComRCReturnRC(autoCaller.rc()); 5664 5665 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 5666 5667 HRESULT rc = S_OK; 5668 #ifdef VBOX_WITH_VIDEOREC 5669 /* Don't trigger video capture changes if the VM isn't running. */ 5670 SafeVMPtrQuiet ptrVM(this); 5671 if (ptrVM.isOk()) 5672 { 5673 BOOL fEnabled; 5674 rc = mMachine->COMGETTER(VideoCaptureEnabled)(&fEnabled); 5675 AssertComRCReturnRC(rc); 5676 5677 int vrc = i_videoCaptureEnable(fEnabled, &alock); 5678 if (RT_SUCCESS(vrc)) 5679 { 5680 alock.release(); 5681 fireVideoCaptureChangedEvent(mEventSource); 5649 5682 } 5650 5683 … … 5652 5685 } 5653 5686 #endif /* VBOX_WITH_VIDEOREC */ 5654 5655 /* Notify console callbacks on success. */5656 if (SUCCEEDED(rc))5657 {5658 alock.release();5659 fireVideoCaptureChangedEvent(mEventSource);5660 }5661 5687 5662 5688 return rc; … … 9925 9951 9926 9952 #ifdef VBOX_WITH_VIDEOREC 9927 Display *pDisplay = pConsole->i_getDisplay(); 9928 AssertPtr(pDisplay); 9929 if (pDisplay) 9930 { 9931 BOOL fVideoRecEnabled = FALSE; 9932 rc = pConsole->mMachine->COMGETTER(VideoCaptureEnabled)(&fVideoRecEnabled); 9933 AssertComRCReturnVoid(rc); 9934 9935 if (fVideoRecEnabled) 9953 BOOL fVideoRecEnabled = FALSE; 9954 rc = pConsole->mMachine->COMGETTER(VideoCaptureEnabled)(&fVideoRecEnabled); 9955 AssertComRCReturnVoid(rc); 9956 9957 if (fVideoRecEnabled) 9958 { 9959 int vrc2 = pConsole->i_videoCaptureEnable(fVideoRecEnabled, &alock); 9960 if (RT_SUCCESS(vrc2)) 9936 9961 { 9937 pDisplay->i_videoRecInvalidate(); 9938 9939 /* If video recording fails for whatever reason here, this is 9940 * non-critical and should not be returned at this point -- otherwise 9941 * the display driver construction fails completely. */ 9942 int vrc2 = VINF_SUCCESS; 9943 9944 #ifdef VBOX_WITH_AUDIO_VIDEOREC 9945 /* Attach the video recording audio driver if required. */ 9946 if ( pDisplay->i_videoRecGetFeatures() & VIDEORECFEATURE_AUDIO 9947 && pConsole->mAudioVideoRec) 9948 vrc2 = pConsole->mAudioVideoRec->doAttachDriverViaEmt(pConsole->mpUVM, &alock); 9949 #endif 9950 if ( RT_SUCCESS(vrc2) 9951 && pDisplay->i_videoRecGetFeatures()) /* Any video recording (audio and/or video) feature enabled? */ 9952 { 9953 vrc2 = pDisplay->i_videoRecStart(); 9954 if (RT_SUCCESS(vrc2)) 9955 fireVideoCaptureChangedEvent(pConsole->i_getEventSource()); 9956 } 9962 fireVideoCaptureChangedEvent(pConsole->mEventSource); 9957 9963 } 9964 else 9965 LogRel(("VideoRec: Failed with %Rrc on VM power up\n", vrc2)); 9966 9967 /** Note: Do not use vrc here, as starting the video recording isn't critical to 9968 * powering up the VM. */ 9958 9969 } 9959 9970 #endif
Note:
See TracChangeset
for help on using the changeset viewer.

