VirtualBox

Changeset 75307 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Nov 7, 2018 1:56:14 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
126417
Message:

Recording: Bugfixes for Main and FE/Qt.

Location:
trunk/src/VBox/Main/src-client
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r75287 r75307  
    56165616    if (pDisplay)
    56175617    {
    5618         const bool fEnabled =    Capture.mpVideoRecCtx
    5619                               && Capture.mpVideoRecCtx->IsStarted();
    5620 
    5621         if (RT_BOOL(fEnable) != fEnabled)
     5618        const bool fIsEnabled =    Capture.mpVideoRecCtx
     5619                                && Capture.mpVideoRecCtx->IsStarted();
     5620
     5621        if (RT_BOOL(fEnable) != fIsEnabled)
    56225622        {
    56235623            LogRel(("VideoRec: %s\n", fEnable ? "Enabling" : "Disabling"));
     
    56285628            {
    56295629                vrc = i_videoRecCreate();
     5630                if (RT_SUCCESS(vrc))
     5631                    vrc = i_videoRecStart();
     5632
    56305633                if (RT_SUCCESS(vrc))
    56315634                {
     
    69046907    AssertComRCReturn(hrc, VERR_INVALID_PARAMETER);
    69056908
    6906     Settings.mapScreens.clear();
     6909    Settings.applyDefaults();
    69076910
    69086911    for (unsigned long i = 0; i < (unsigned long)paCaptureScreens.size(); ++i)
     
    69346937    }
    69356938
     6939    Assert(Settings.mapScreens.size() == paCaptureScreens.size());
     6940
    69366941    return VINF_SUCCESS;
    69376942}
     
    69616966    }
    69626967
     6968    settings::CaptureSettings Settings;
     6969    rc = i_videoRecGetSettings(Settings);
     6970    if (RT_SUCCESS(rc))
     6971    {
     6972        AssertPtr(Capture.mpVideoRecCtx);
     6973        rc = Capture.mpVideoRecCtx->Create(Settings);
     6974    }
     6975
     6976    LogFlowFuncLeaveRC(rc);
    69636977    return rc;
    69646978}
     
    69706984{
    69716985    if (Capture.mpVideoRecCtx)
     6986    {
    69726987        delete Capture.mpVideoRecCtx;
     6988        Capture.mpVideoRecCtx = NULL;
     6989    }
     6990
     6991    LogFlowThisFuncLeave();
    69736992}
    69746993
     
    69877006    LogRel(("VideoRec: Starting ...\n"));
    69887007
    6989     settings::CaptureSettings Settings;
    6990     int rc = i_videoRecGetSettings(Settings);
    6991     if (RT_SUCCESS(rc))
    6992     {
    6993         rc = Capture.mpVideoRecCtx->Create(Settings);
    6994         if (RT_SUCCESS(rc))
    6995         {
    6996             for (unsigned uScreen = 0; uScreen < Capture.mpVideoRecCtx->GetStreamCount(); uScreen++)
    6997                 mDisplay->i_videoRecScreenChanged(uScreen);
    6998         }
    6999     }
     7008    int rc = VINF_SUCCESS;
     7009
     7010    for (unsigned uScreen = 0; uScreen < Capture.mpVideoRecCtx->GetStreamCount(); uScreen++)
     7011        mDisplay->i_videoRecScreenChanged(uScreen);
    70007012
    70017013    if (RT_FAILURE(rc))
    70027014        LogRel(("VideoRec: Failed to start video recording (%Rrc)\n", rc));
    70037015
     7016    LogFlowFuncLeaveRC(rc);
    70047017    return rc;
    70057018}
     
    70107023int Console::i_videoRecStop(void)
    70117024{
    7012     AssertPtrReturn(Capture.mpVideoRecCtx, VERR_WRONG_ORDER);
    7013 
    7014     if (!Capture.mpVideoRecCtx->IsStarted())
     7025    if (   !Capture.mpVideoRecCtx
     7026        || !Capture.mpVideoRecCtx->IsStarted())
    70157027        return VINF_SUCCESS;
    70167028
     
    70207032    for (unsigned uScreen = 0; uScreen < cStreams; ++uScreen)
    70217033        mDisplay->i_videoRecScreenChanged(uScreen);
    7022 
    7023     delete Capture.mpVideoRecCtx;
    7024     Capture.mpVideoRecCtx = NULL;
    70257034
    70267035    ComPtr<ICaptureSettings> pCaptureSettings;
     
    70327041    LogRel(("VideoRec: Stopped\n"));
    70337042
     7043    LogFlowFuncLeaveRC(VINF_SUCCESS);
    70347044    return VINF_SUCCESS;
    70357045}
  • trunk/src/VBox/Main/src-client/VideoRec.cpp

    r75254 r75307  
    5858
    5959/**
    60  * Enumeration for a video recording state.
     60 * Enumeration for a recording state.
    6161 */
    6262enum VIDEORECSTS
     
    6464    /** Not initialized. */
    6565    VIDEORECSTS_UNINITIALIZED = 0,
    66     /** Initialized. */
    67     VIDEORECSTS_INITIALIZED   = 1,
     66    /** Created. */
     67    VIDEORECSTS_CREATED       = 1,
     68    /** Started. */
     69    VIDEORECSTS_STARTED       = 2,
    6870    /** The usual 32-bit hack. */
    6971    VIDEORECSTS_32BIT_HACK    = 0x7fffffff
     
    105107
    106108CaptureContext::CaptureContext(Console *a_pConsole)
    107     : pConsole(a_pConsole) { }
     109    : pConsole(a_pConsole)
     110    , enmState(VIDEORECSTS_UNINITIALIZED) { }
    108111
    109112CaptureContext::CaptureContext(Console *a_pConsole, const settings::CaptureSettings &a_Settings)
    110113    : pConsole(a_pConsole)
     114    , enmState(VIDEORECSTS_UNINITIALIZED)
    111115{
    112116    int rc = CaptureContext::createInternal(a_Settings);
     
    214218    {
    215219        this->tsStartMs = RTTimeMilliTS();
    216         this->enmState  = VIDEORECSTS_UNINITIALIZED;
     220        this->enmState  = VIDEORECSTS_CREATED;
    217221        this->fStarted  = false;
    218222        this->fShutdown = false;
     
    223227        rc = RTSemEventCreate(&this->WaitEvent);
    224228        AssertRCReturn(rc, rc);
    225 
    226         rc = RTThreadCreate(&this->Thread, CaptureContext::threadMain, (void *)this, 0,
    227                             RTTHREADTYPE_MAIN_WORKER, RTTHREADFLAGS_WAITABLE, "VideoRec");
    228 
    229         if (RT_SUCCESS(rc)) /* Wait for the thread to start. */
    230             rc = RTThreadUserWait(this->Thread, 30 * RT_MS_1SEC /* 30s timeout */);
    231 
    232         if (RT_SUCCESS(rc))
    233         {
    234             this->enmState = VIDEORECSTS_INITIALIZED;
    235             this->fStarted = true;
    236         }
    237229    }
    238230
     
    246238}
    247239
     240int CaptureContext::startInternal(void)
     241{
     242    if (this->enmState == VIDEORECSTS_STARTED)
     243        return VINF_SUCCESS;
     244
     245    Assert(this->enmState == VIDEORECSTS_CREATED);
     246
     247    int rc = RTThreadCreate(&this->Thread, CaptureContext::threadMain, (void *)this, 0,
     248                            RTTHREADTYPE_MAIN_WORKER, RTTHREADFLAGS_WAITABLE, "VideoRec");
     249
     250    if (RT_SUCCESS(rc)) /* Wait for the thread to start. */
     251        rc = RTThreadUserWait(this->Thread, 30 * RT_MS_1SEC /* 30s timeout */);
     252
     253    if (RT_SUCCESS(rc))
     254    {
     255        this->enmState = VIDEORECSTS_STARTED;
     256        this->fStarted = true;
     257    }
     258
     259    return rc;
     260}
     261
     262int CaptureContext::stopInternal(void)
     263{
     264    if (this->enmState != VIDEORECSTS_STARTED)
     265        return VINF_SUCCESS;
     266
     267    LogFunc(("Shutting down thread ...\n"));
     268
     269    /* Set shutdown indicator. */
     270    ASMAtomicWriteBool(&this->fShutdown, true);
     271
     272    /* Signal the thread and wait for it to shut down. */
     273    int rc = threadNotify();
     274    if (RT_SUCCESS(rc))
     275        rc = RTThreadWait(this->Thread, 30 * 1000 /* 10s timeout */, NULL);
     276
     277    return rc;
     278}
     279
    248280/**
    249281 * Destroys a video recording context.
     
    253285    int rc = VINF_SUCCESS;
    254286
    255     if (this->enmState == VIDEORECSTS_INITIALIZED)
    256     {
    257         LogFunc(("Shutting down thread ...\n"));
    258 
    259         /* Set shutdown indicator. */
    260         ASMAtomicWriteBool(&this->fShutdown, true);
    261 
    262         /* Signal the thread and wait for it to shut down. */
    263         rc = threadNotify();
    264         if (RT_SUCCESS(rc))
    265             rc = RTThreadWait(this->Thread, 30 * 1000 /* 10s timeout */, NULL);
    266 
     287    if (this->enmState == VIDEORECSTS_STARTED)
     288    {
     289        rc = stopInternal();
    267290        if (RT_SUCCESS(rc))
    268291        {
     
    365388}
    366389
     390int CaptureContext::Start(void)
     391{
     392    return startInternal();
     393}
     394
     395int CaptureContext::Stop(void)
     396{
     397    return stopInternal();
     398}
     399
    367400bool CaptureContext::IsFeatureEnabled(CaptureFeature_T enmFeature) const
    368401{
     
    394427    RT_NOREF(uTimeStampMs);
    395428
    396     if (this->enmState != VIDEORECSTS_INITIALIZED)
     429    if (this->enmState != VIDEORECSTS_STARTED)
    397430        return false;
    398431
  • trunk/src/VBox/Main/src-client/VideoRecStream.cpp

    r75256 r75307  
    4545    : tsStartMs(0)
    4646{
     47    File.pWEBM = NULL;
     48    File.hFile = NIL_RTFILE;
    4749}
    4850
     
    5052    : tsStartMs(0)
    5153{
     54    File.pWEBM = NULL;
     55    File.hFile = NIL_RTFILE;
     56
    5257    int rc2 = initInternal(uScreen, Settings);
    5358    if (RT_FAILURE(rc2))
     
    6671 * @returns IPRT status code.
    6772 */
    68 int CaptureStream::open(void)
    69 {
    70     Assert(ScreenSettings.enmDest == CaptureDestination_None);
     73int CaptureStream::open(const settings::CaptureScreenSettings &Settings)
     74{
     75    /* Sanity. */
     76    Assert(Settings.enmDest != CaptureDestination_None);
    7177
    7278    int rc;
    7379
    74     switch (ScreenSettings.enmDest)
     80    switch (Settings.enmDest)
    7581    {
    7682        case CaptureDestination_File:
    7783        {
    78             Assert(ScreenSettings.File.strName.isNotEmpty());
    79 
    80             char *pszAbsPath = RTPathAbsDup(ScreenSettings.File.strName.c_str());
     84            Assert(Settings.File.strName.isNotEmpty());
     85
     86            char *pszAbsPath = RTPathAbsDup(Settings.File.strName.c_str());
    8187            AssertPtrReturn(pszAbsPath, VERR_NO_MEMORY);
    8288
     
    132138                    if (RT_SUCCESS(rc))
    133139                        rc = RTFileOpen(&hFile, pszFile, fOpen);
     140                }
     141
     142                try
     143                {
     144                    Assert(File.pWEBM == NULL);
     145                    File.pWEBM = new WebMWriter();
     146                }
     147                catch (std::bad_alloc &)
     148               {
     149                    rc = VERR_NO_MEMORY;
    134150                }
    135151
     
    656672        return rc;
    657673
    658     rc = open();
     674    rc = open(Settings);
    659675    if (RT_FAILURE(rc))
    660676        return rc;
     
    675691            const char *pszFile = this->ScreenSettings.File.strName.c_str();
    676692
     693            AssertPtr(File.pWEBM);
    677694            rc = File.pWEBM->OpenEx(pszFile, &this->File.hFile,
    678695#ifdef VBOX_WITH_AUDIO_VIDEOREC
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