Changeset 95645 in vbox
- Timestamp:
- Jul 14, 2022 10:33:14 AM (2 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/ConsoleImpl.h
r95639 r95645 174 174 AudioVideoRec *i_recordingGetAudioDrv(void) const { return mRecording.mAudioRec; } 175 175 # endif 176 RecordingContext *i_recordingGetContext(void) const { return mRecording.mpCtx; }176 RecordingContext *i_recordingGetContext(void) { return &mRecording.mCtx; } 177 177 # ifdef VBOX_WITH_AUDIO_RECORDING 178 178 HRESULT i_recordingSendAudio(const void *pvData, size_t cbData, uint64_t uDurationMs); … … 1156 1156 { 1157 1157 Recording() 1158 : mpCtx(NULL)1159 1158 # ifdef VBOX_WITH_AUDIO_RECORDING 1160 ,mAudioRec(NULL)1159 : mAudioRec(NULL) 1161 1160 # endif 1162 1161 { } 1163 1162 1164 1163 /** The recording context. */ 1165 RecordingContext *mpCtx;1164 RecordingContext mCtx; 1166 1165 # ifdef VBOX_WITH_AUDIO_RECORDING 1167 1166 /** Pointer to capturing audio backend. */ -
trunk/src/VBox/Main/include/Recording.h
r93115 r95645 36 36 public: 37 37 38 RecordingContext(Console *pConsole, const settings::RecordingSettings &a_Settings); 38 RecordingContext(); 39 40 RecordingContext(Console *ptrConsole, const settings::RecordingSettings &settings); 39 41 40 42 virtual ~RecordingContext(void); … … 46 48 size_t GetStreamCount(void) const; 47 49 48 int Create( const settings::RecordingSettings &a_Settings);50 int Create(Console *pConsole, const settings::RecordingSettings &settings); 49 51 void Destroy(void); 50 52 … … 70 72 protected: 71 73 72 int createInternal( const settings::RecordingSettings &a_Settings);74 int createInternal(Console *ptrConsole, const settings::RecordingSettings &settings); 73 75 int startInternal(void); 74 76 int stopInternal(void); -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r95639 r95645 5887 5887 if (pDisplay) 5888 5888 { 5889 const bool fIsEnabled = mRecording.mpCtx 5890 && mRecording.mpCtx->IsStarted(); 5889 bool const fIsEnabled = mRecording.mCtx.IsStarted(); 5891 5890 5892 5891 if (RT_BOOL(fEnable) != fIsEnabled) … … 5904 5903 # ifdef VBOX_WITH_AUDIO_RECORDING 5905 5904 /* Attach the video recording audio driver if required. */ 5906 if ( mRecording.m pCtx->IsFeatureEnabled(RecordingFeature_Audio)5905 if ( mRecording.mCtx.IsFeatureEnabled(RecordingFeature_Audio) 5907 5906 && mRecording.mAudioRec) 5908 5907 { 5909 vrc = mRecording.mAudioRec->applyConfiguration(mRecording.m pCtx->GetConfig());5908 vrc = mRecording.mAudioRec->applyConfiguration(mRecording.mCtx.GetConfig()); 5910 5909 if (RT_SUCCESS(vrc)) 5911 5910 vrc = mRecording.mAudioRec->doAttachDriverViaEmt(ptrVM.rawUVM(), ptrVM.vtable(), pAutoLock); … … 5913 5912 # endif 5914 5913 if ( RT_SUCCESS(vrc) 5915 && mRecording.m pCtx->IsReady()) /* Any video recording (audio and/or video) feature enabled? */5914 && mRecording.mCtx.IsReady()) /* Any video recording (audio and/or video) feature enabled? */ 5916 5915 { 5917 5916 vrc = pDisplay->i_recordingInvalidate(); … … 7235 7234 HRESULT Console::i_recordingSendAudio(const void *pvData, size_t cbData, uint64_t uTimestampMs) 7236 7235 { 7237 if (!mRecording.mpCtx) 7238 return S_OK; 7239 7240 if ( mRecording.mpCtx->IsStarted() 7241 && mRecording.mpCtx->IsFeatureEnabled(RecordingFeature_Audio)) 7242 return mRecording.mpCtx->SendAudioFrame(pvData, cbData, uTimestampMs); 7236 if ( mRecording.mCtx.IsStarted() 7237 && mRecording.mCtx.IsFeatureEnabled(RecordingFeature_Audio)) 7238 return mRecording.mCtx.SendAudioFrame(pvData, cbData, uTimestampMs); 7243 7239 7244 7240 return S_OK; … … 7310 7306 int Console::i_recordingCreate(void) 7311 7307 { 7312 AssertReturn(mRecording.mpCtx == NULL, VERR_WRONG_ORDER);7313 7314 7308 settings::RecordingSettings recordingSettings; 7315 int rc = i_recordingGetSettings(recordingSettings); 7316 if (RT_SUCCESS(rc)) 7317 { 7318 try 7319 { 7320 mRecording.mpCtx = new RecordingContext(this /* pConsole */, recordingSettings); 7321 } 7322 catch (std::bad_alloc &) 7323 { 7324 return VERR_NO_MEMORY; 7325 } 7326 catch (int &rc2) 7327 { 7328 return rc2; 7329 } 7330 } 7331 7332 LogFlowFuncLeaveRC(rc); 7333 return rc; 7309 int vrc = i_recordingGetSettings(recordingSettings); 7310 if (RT_SUCCESS(vrc)) 7311 vrc = mRecording.mCtx.Create(this, recordingSettings); 7312 7313 LogFlowFuncLeaveRC(vrc); 7314 return vrc; 7334 7315 } 7335 7316 … … 7339 7320 void Console::i_recordingDestroy(void) 7340 7321 { 7341 if (mRecording.mpCtx) 7342 { 7343 delete mRecording.mpCtx; 7344 mRecording.mpCtx = NULL; 7345 } 7346 7347 LogFlowThisFuncLeave(); 7322 mRecording.mCtx.Destroy(); 7348 7323 } 7349 7324 … … 7356 7331 { 7357 7332 RT_NOREF(pAutoLock); 7358 AssertPtrReturn(mRecording.mpCtx, VERR_WRONG_ORDER); 7359 7360 if (mRecording.mpCtx->IsStarted()) 7333 7334 if (mRecording.mCtx.IsStarted()) 7361 7335 return VINF_SUCCESS; 7362 7336 7363 7337 LogRel(("Recording: Starting ...\n")); 7364 7338 7365 int rc = mRecording.mpCtx->Start();7366 if (RT_SUCCESS( rc))7367 { 7368 for (unsigned uScreen = 0; uScreen < mRecording.m pCtx->GetStreamCount(); uScreen++)7339 int vrc = mRecording.mCtx.Start(); 7340 if (RT_SUCCESS(vrc)) 7341 { 7342 for (unsigned uScreen = 0; uScreen < mRecording.mCtx.GetStreamCount(); uScreen++) 7369 7343 mDisplay->i_recordingScreenChanged(uScreen); 7370 7344 } 7371 7345 7372 LogFlowFuncLeaveRC( rc);7373 return rc;7346 LogFlowFuncLeaveRC(vrc); 7347 return vrc; 7374 7348 } 7375 7349 … … 7379 7353 int Console::i_recordingStop(util::AutoWriteLock *pAutoLock /* = NULL */) 7380 7354 { 7381 if ( !mRecording.mpCtx 7382 || !mRecording.mpCtx->IsStarted()) 7355 if (!mRecording.mCtx.IsStarted()) 7383 7356 return VINF_SUCCESS; 7384 7357 7385 7358 LogRel(("Recording: Stopping ...\n")); 7386 7359 7387 int rc = mRecording.mpCtx->Stop();7388 if (RT_SUCCESS( rc))7389 { 7390 const size_t cStreams = mRecording.m pCtx->GetStreamCount();7360 int vrc = mRecording.mCtx.Stop(); 7361 if (RT_SUCCESS(vrc)) 7362 { 7363 const size_t cStreams = mRecording.mCtx.GetStreamCount(); 7391 7364 for (unsigned uScreen = 0; uScreen < cStreams; ++uScreen) 7392 7365 mDisplay->i_recordingScreenChanged(uScreen); … … 7405 7378 } 7406 7379 7407 LogFlowFuncLeaveRC( rc);7408 return rc;7380 LogFlowFuncLeaveRC(vrc); 7381 return vrc; 7409 7382 } 7410 7383 -
trunk/src/VBox/Main/src-client/Recording.cpp
r95639 r95645 58 58 59 59 60 RecordingContext::RecordingContext(Console *a_pConsole, const settings::RecordingSettings &a_Settings) 61 : pConsole(a_pConsole) 60 /** 61 * Recording context constructor. 62 * 63 * @note Will throw when unable to create. 64 */ 65 RecordingContext::RecordingContext(void) 66 : pConsole(NULL) 62 67 , enmState(RECORDINGSTS_UNINITIALIZED) 63 68 , cStreamsEnabled(0) 64 69 { 65 int vrc = R ecordingContext::createInternal(a_Settings);70 int vrc = RTCritSectInit(&this->CritSect); 66 71 if (RT_FAILURE(vrc)) 67 72 throw vrc; 68 73 } 69 74 75 /** 76 * Recording context constructor. 77 * 78 * @param ptrConsole Pointer to console object this context is bound to (weak pointer). 79 * @param settings Reference to recording settings to use for creation. 80 * 81 * @note Will throw when unable to create. 82 */ 83 RecordingContext::RecordingContext(Console *ptrConsole, const settings::RecordingSettings &settings) 84 : pConsole(NULL) 85 , enmState(RECORDINGSTS_UNINITIALIZED) 86 , cStreamsEnabled(0) 87 { 88 int vrc = RTCritSectInit(&this->CritSect); 89 if (RT_FAILURE(vrc)) 90 throw vrc; 91 92 vrc = RecordingContext::createInternal(ptrConsole, settings); 93 if (RT_FAILURE(vrc)) 94 throw vrc; 95 } 96 70 97 RecordingContext::~RecordingContext(void) 71 98 { 72 99 destroyInternal(); 100 101 if (RTCritSectIsInitialized(&this->CritSect)) 102 RTCritSectDelete(&this->CritSect); 73 103 } 74 104 … … 143 173 * 144 174 * @returns IPRT status code. 145 * @param a_Settings Recording settings to use for context creation. 146 */ 147 int RecordingContext::createInternal(const settings::RecordingSettings &a_Settings) 148 { 149 int vrc = RTCritSectInit(&this->CritSect); 150 if (RT_FAILURE(vrc)) 151 return vrc; 152 153 settings::RecordingScreenSettingsMap::const_iterator itScreen = a_Settings.mapScreens.begin(); 154 while (itScreen != a_Settings.mapScreens.end()) 175 * @param ptrConsole Pointer to console object this context is bound to (weak pointer). 176 * @param settings Reference to recording settings to use for creation. 177 */ 178 int RecordingContext::createInternal(Console *ptrConsole, const settings::RecordingSettings &settings) 179 { 180 int vrc = VINF_SUCCESS; 181 182 this->pConsole = ptrConsole; 183 184 settings::RecordingScreenSettingsMap::const_iterator itScreen = settings.mapScreens.begin(); 185 while (itScreen != settings.mapScreens.end()) 155 186 { 156 187 RecordingStream *pStream = NULL; … … 178 209 179 210 /* Copy the settings to our context. */ 180 this->Settings = a_Settings;211 this->Settings = settings; 181 212 182 213 vrc = RTSemEventCreate(&this->WaitEvent); … … 260 291 void RecordingContext::destroyInternal(void) 261 292 { 293 lock(); 294 262 295 if (this->enmState == RECORDINGSTS_UNINITIALIZED) 296 { 297 unlock(); 263 298 return; 299 } 264 300 265 301 int vrc = stopInternal(); 266 302 AssertRCReturnVoid(vrc); 267 268 lock();269 303 270 304 vrc = RTSemEventDestroy(this->WaitEvent); … … 292 326 Assert(this->mapBlocksCommon.size() == 0); 293 327 294 unlock();295 296 if (RTCritSectIsInitialized(&this->CritSect))297 RTCritSectDelete(&this->CritSect);298 299 328 this->enmState = RECORDINGSTS_UNINITIALIZED; 329 330 unlock(); 300 331 } 301 332 … … 371 402 * 372 403 * @returns IPRT status code. 373 * @param a_Settings Recording settings to use for creation.374 * 375 */ 376 int RecordingContext::Create( const settings::RecordingSettings &a_Settings)377 { 378 return createInternal( a_Settings);404 * @param ptrConsole Pointer to console object this context is bound to (weak pointer). 405 * @param settings Reference to recording settings to use for creation. 406 */ 407 int RecordingContext::Create(Console *ptrConsole, const settings::RecordingSettings &settings) 408 { 409 return createInternal(ptrConsole, settings); 379 410 } 380 411
Note:
See TracChangeset
for help on using the changeset viewer.