VirtualBox

Changeset 76893 in vbox


Ignore:
Timestamp:
Jan 18, 2019 1:51:30 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
128261
Message:

Recording/Main: Use lock() and unlock() in more places.

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/Recording.h

    r76760 r76893  
    3535
    3636/**
    37  * Class for managing a capturing context.
     37 * Class for managing a recording context.
    3838 */
    3939class RecordingContext
     
    5252
    5353    int Create(const settings::RecordingSettings &a_Settings);
    54     int Destroy(void);
     54    void Destroy(void);
    5555
    5656    int Start(void);
     
    6565
    6666    bool IsFeatureEnabled(RecordingFeature_T enmFeature);
    67     bool IsReady(void) const;
     67    bool IsReady(void);
    6868    bool IsReady(uint32_t uScreen, uint64_t msTimestamp);
    6969    bool IsStarted(void);
     
    7979    int stopInternal(void);
    8080
    81     int destroyInternal(void);
     81    void destroyInternal(void);
    8282
    8383    RecordingStream *getStreamInternal(unsigned uScreen) const;
  • trunk/src/VBox/Main/src-client/Recording.cpp

    r76553 r76893  
    217217
    218218    if (RT_FAILURE(rc))
    219     {
    220         int rc2 = destroyInternal();
    221         AssertRC(rc2);
    222     }
     219        destroyInternal();
    223220
    224221    return rc;
     
    274271        rc = RTThreadWait(this->Thread, 30 * 1000 /* 10s timeout */, NULL);
    275272
     273    lock();
     274
    276275    if (RT_SUCCESS(rc))
    277276    {
     
    282281        Log(("Recording: Failed to stop (%Rrc)\n", rc));
    283282
     283    unlock();
     284
    284285    LogFlowThisFunc(("%Rrc\n", rc));
    285286    return rc;
     
    289290 * Destroys a recording context, internal version.
    290291 */
    291 int RecordingContext::destroyInternal(void)
    292 {
     292void RecordingContext::destroyInternal(void)
     293{
     294    if (this->enmState == RECORDINGSTS_UNINITIALIZED)
     295        return;
     296
    293297    int rc = stopInternal();
    294     if (RT_FAILURE(rc))
    295         return rc;
     298    AssertRCReturnVoid(rc);
     299
     300    lock();
    296301
    297302    rc = RTSemEventDestroy(this->WaitEvent);
    298     AssertRC(rc);
     303    AssertRCReturnVoid(rc);
    299304
    300305    this->WaitEvent = NIL_RTSEMEVENT;
    301306
    302     rc = RTCritSectEnter(&this->CritSect);
    303     if (RT_SUCCESS(rc))
    304     {
    305         RecordingStreams::iterator it = this->vecStreams.begin();
    306         while (it != this->vecStreams.end())
    307         {
    308             RecordingStream *pStream = (*it);
    309 
    310             int rc2 = pStream->Uninit();
    311             if (RT_SUCCESS(rc))
    312                 rc = rc2;
    313 
    314             delete pStream;
    315             pStream = NULL;
    316 
    317             this->vecStreams.erase(it);
    318             it = this->vecStreams.begin();
    319 
    320             delete pStream;
    321             pStream = NULL;
    322         }
    323 
    324         /* Sanity. */
    325         Assert(this->vecStreams.empty());
    326         Assert(this->mapBlocksCommon.size() == 0);
    327 
    328         int rc2 = RTCritSectLeave(&this->CritSect);
    329         AssertRC(rc2);
    330 
     307    RecordingStreams::iterator it = this->vecStreams.begin();
     308    while (it != this->vecStreams.end())
     309    {
     310        RecordingStream *pStream = (*it);
     311
     312        rc = pStream->Uninit();
     313        AssertRC(rc);
     314
     315        delete pStream;
     316        pStream = NULL;
     317
     318        this->vecStreams.erase(it);
     319        it = this->vecStreams.begin();
     320    }
     321
     322    /* Sanity. */
     323    Assert(this->vecStreams.empty());
     324    Assert(this->mapBlocksCommon.size() == 0);
     325
     326    unlock();
     327
     328    if (RTCritSectIsInitialized(&this->CritSect))
     329    {
     330        Assert(RTCritSectGetWaiters(&this->CritSect) == -1);
    331331        RTCritSectDelete(&this->CritSect);
    332332    }
    333333
    334     LogFlowThisFunc(("%Rrc\n", rc));
    335     return rc;
     334    this->enmState = RECORDINGSTS_UNINITIALIZED;
    336335}
    337336
     
    418417 * Destroys a recording context.
    419418 */
    420 int RecordingContext::Destroy(void)
    421 {
    422     return destroyInternal();
     419void RecordingContext::Destroy(void)
     420{
     421    destroyInternal();
    423422}
    424423
     
    474473 * @returns @c true if recording context is ready, @c false if not.
    475474 */
    476 bool RecordingContext::IsReady(void) const
    477 {
    478     return (this->enmState >= RECORDINGSTS_CREATED);
     475bool RecordingContext::IsReady(void)
     476{
     477    lock();
     478
     479    const bool fIsReady = this->enmState >= RECORDINGSTS_CREATED;
     480
     481    unlock();
     482
     483    return fIsReady;
    479484}
    480485
     
    624629    pBlock->msTimestamp = msTimestamp;
    625630
    626     int rc = RTCritSectEnter(&this->CritSect);
    627     if (RT_FAILURE(rc))
    628         return rc;
     631    lock();
     632
     633    int rc;
    629634
    630635    try
     
    640645        else
    641646            itBlocks->second->List.push_back(pBlock);
     647
     648        rc = VINF_SUCCESS;
    642649    }
    643650    catch (const std::exception &ex)
     
    647654    }
    648655
    649     int rc2 = RTCritSectLeave(&this->CritSect);
    650     AssertRC(rc2);
     656    unlock();
    651657
    652658    if (RT_SUCCESS(rc))
     
    687693    AssertReturn(puSrcData,  VERR_INVALID_POINTER);
    688694
    689     int rc = RTCritSectEnter(&this->CritSect);
    690     AssertRC(rc);
     695    lock();
    691696
    692697    RecordingStream *pStream = GetStream(uScreen);
    693698    if (!pStream)
    694699    {
    695         rc = RTCritSectLeave(&this->CritSect);
    696         AssertRC(rc);
     700        unlock();
    697701
    698702        AssertFailed();
     
    700704    }
    701705
    702     rc = pStream->SendVideoFrame(x, y, uPixelFormat, uBPP, uBytesPerLine, uSrcWidth, uSrcHeight, puSrcData, msTimestamp);
    703 
    704     int rc2 = RTCritSectLeave(&this->CritSect);
    705     AssertRC(rc2);
     706    int rc = pStream->SendVideoFrame(x, y, uPixelFormat, uBPP, uBytesPerLine, uSrcWidth, uSrcHeight, puSrcData, msTimestamp);
     707
     708    unlock();
    706709
    707710    if (   RT_SUCCESS(rc)
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette