VirtualBox

Changeset 75313 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Nov 7, 2018 5:13:56 PM (6 years ago)
Author:
vboxsync
Message:

Recording: More bugfixes for Main and FE/Qt.

Location:
trunk/src/VBox
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp

    r75307 r75313  
    886886        CCaptureSettings captureSettings = machine.GetCaptureSettings();
    887887        Assert(captureSettings.isOk());
    888         /* For now all screens have the same config: */
    889         CCaptureScreenSettings captureScreen0Settings = captureSettings.GetScreenSettings(0);
    890         Assert(captureScreen0Settings.isOk());
    891         if (!captureScreen0Settings.GetEnabled())
     888        if (!captureSettings.GetEnabled())
    892889            setState(UIIndicatorStateRecording_Disabled);
    893890        else if (!fMachinePaused)
     
    919916                else if (m_eRecordingMode & UIIndicatorStateRecordingMode_Video)
    920917                    strToolTip = "Video capture file";
     918
     919                /* For now all screens have the same config: */
     920                CCaptureScreenSettings captureScreen0Settings = captureSettings.GetScreenSettings(0);
     921                Assert(captureScreen0Settings.isOk());
    921922
    922923                strFullData += s_strTableRow2 /** @todo r=andy Refine this tooltip (audio and/or video). */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp

    r75307 r75313  
    15871587                        fSuccess = recordingScreenSettings.isOk();
    15881588                    }
     1589                    /* Save recording options: */
     1590                    if (fSuccess && newDisplayData.m_strRecordingVideoOptions != oldDisplayData.m_strRecordingVideoOptions)
     1591                    {
     1592                        recordingScreenSettings.SetOptions(newDisplayData.m_strRecordingVideoOptions);
     1593                        fSuccess = recordingScreenSettings.isOk();
     1594                    }
    15891595                    /* Save recording screens: */
    15901596                    if (fSuccess && newDisplayData.m_vecRecordingScreens != oldDisplayData.m_vecRecordingScreens)
    15911597                    {
    15921598                        recordingScreenSettings.SetEnabled(newDisplayData.m_vecRecordingScreens[iScreenIndex]);
    1593                         fSuccess = recordingScreenSettings.isOk();
    1594                     }
    1595                     /* Save recording options: */
    1596                     if (fSuccess && newDisplayData.m_strRecordingVideoOptions != oldDisplayData.m_strRecordingVideoOptions)
    1597                     {
    1598                         recordingScreenSettings.SetOptions(newDisplayData.m_strRecordingVideoOptions);
    15991599                        fSuccess = recordingScreenSettings.isOk();
    16001600                    }
  • trunk/src/VBox/Main/include/CaptureScreenSettingsImpl.h

    r75307 r75313  
    102102
    103103    // internal methods
    104     bool i_canChangeSettings();
    105104    int  i_getDefaultFileName(Utf8Str &strFile);
    106105    int  i_initInternal();
  • trunk/src/VBox/Main/include/VideoRec.h

    r75307 r75313  
    2929#include "VideoRecInternals.h"
    3030#include "VideoRecStream.h"
    31 
    32 #if 0
    33 /**
    34  * Enumeration for definining a video / audio
    35  * profile setting.
    36  */
    37 typedef enum VIDEORECPROFILE
    38 {
    39     VIDEORECPROFILE_NONE   = 0,
    40     VIDEORECPROFILE_LOW,
    41     VIDEORECPROFILE_MEDIUM,
    42     VIDEORECPROFILE_HIGH,
    43     VIDEORECPROFILE_BEST,
    44     VIDEORECPROFILE_REALTIME
    45 } VIDEORECPROFILE;
    46 
    47 /** Stores video recording features. */
    48 typedef uint32_t VIDEORECFEATURES;
    49 
    50 /** Video recording is disabled completely. */
    51 #define VIDEORECFEATURE_NONE        0
    52 /** Capturing video is enabled. */
    53 #define VIDEORECFEATURE_VIDEO       RT_BIT(0)
    54 /** Capturing audio is enabled. */
    55 #define VIDEORECFEATURE_AUDIO       RT_BIT(1)
    56 
    57 /**
    58  * Structure for keeping a screen recording configuration.
    59  */
    60 typedef struct VIDEORECSCREENCFG
    61 {
    62     VIDEORECSCREENCFG(void)
    63         : enmDst(VIDEORECDEST_INVALID)
    64         , uMaxTimeS(0)
    65     {
    66 #ifdef VBOX_WITH_AUDIO_VIDEOREC
    67         RT_ZERO(Audio);
    68 #endif
    69         RT_ZERO(Video);
    70     }
    71 
    72     VIDEORECSCREENCFG& operator=(const VIDEORECSCREENCFG &that)
    73     {
    74         enmDst          = that.enmDst;
    75 
    76         File.strName    = that.File.strName;
    77         File.uMaxSizeMB = that.File.uMaxSizeMB;
    78 #ifdef VBOX_WITH_AUDIO_VIDEOREC
    79         Audio           = that.Audio;
    80 #endif
    81         Video           = that.Video;
    82         uMaxTimeS       = that.uMaxTimeS;
    83         return *this;
    84     }
    85 
    86     unsigned long           uScreenId;
    87     /** Destination where to write the stream to. */
    88     VIDEORECDEST            enmDst;
    89 
    90     /**
    91      * Structure for keeping recording parameters if
    92      * destination is a file.
    93      */
    94     struct
    95     {
    96         /** File name (as absolute path). */
    97         com::Bstr       strName;
    98         /** Maximum file size (in MB) to record. */
    99         uint32_t        uMaxSizeMB;
    100     } File;
    101 
    102 #ifdef VBOX_WITH_AUDIO_VIDEOREC
    103     /**
    104      * Structure for keeping the audio recording parameters.
    105      */
    106     struct
    107     {
    108         /** Whether audio recording is enabled or not. */
    109         bool                fEnabled;
    110         /** The device LUN the audio driver is attached / configured to. */
    111         unsigned            uLUN;
    112         /** Hertz (Hz) rate. */
    113         uint16_t            uHz;
    114         /** Bits per sample. */
    115         uint8_t             cBits;
    116         /** Number of audio channels. */
    117         uint8_t             cChannels;
    118         /** Audio profile which is being used. */
    119         VIDEORECPROFILE     enmProfile;
    120     } Audio;
    121 #endif
    122 
    123     /**
    124      * Structure for keeping the video recording parameters.
    125      */
    126     struct
    127     {
    128         /** Whether video recording is enabled or not. */
    129         bool                fEnabled;
    130         /** Target width (in pixels). */
    131         uint32_t            uWidth;
    132         /** Target height (in pixels). */
    133         uint32_t            uHeight;
    134         /** Target encoding rate. */
    135         uint32_t            uRate;
    136         /** Target FPS. */
    137         uint32_t            uFPS;
    138 
    139 #ifdef VBOX_WITH_LIBVPX
    140         union
    141         {
    142             struct
    143             {
    144                 /** Encoder deadline. */
    145                 unsigned int uEncoderDeadline;
    146             } VPX;
    147         } Codec;
    148 #endif
    149 
    150     } Video;
    151 
    152     /** Maximum time (in s) to record.
    153      *  Specify 0 to disable this check. */
    154     uint32_t                uMaxTimeS;
    155 } VIDEORECSCREENCFG, *PVIDEORECSCREENCFG;
    156 #endif
    15731
    15832class Console;
     
    21286protected:
    21387
     88    /**
     89     * Enumeration for a recording context state.
     90     */
     91    enum VIDEORECSTS
     92    {
     93        /** Context not initialized. */
     94        VIDEORECSTS_UNINITIALIZED = 0,
     95        /** Context was created. */
     96        VIDEORECSTS_CREATED       = 1,
     97        /** Context was started. */
     98        VIDEORECSTS_STARTED       = 2,
     99        /** The usual 32-bit hack. */
     100        VIDEORECSTS_32BIT_HACK    = 0x7fffffff
     101    };
     102
    214103    /** Pointer to the console object. */
    215104    Console                  *pConsole;
     
    217106    settings::CaptureSettings Settings;
    218107    /** The current state. */
    219     uint32_t                  enmState;
     108    VIDEORECSTS               enmState;
    220109    /** Critical section to serialize access. */
    221110    RTCRITSECT                CritSect;
    222111    /** Semaphore to signal the encoding worker thread. */
    223112    RTSEMEVENT                WaitEvent;
    224     /** Whether this context is in started state or not. */
    225     bool                      fStarted;
    226113    /** Shutdown indicator. */
    227114    bool                      fShutdown;
  • trunk/src/VBox/Main/include/VideoRecStream.h

    r75307 r75313  
    109109public:
    110110
    111     CaptureStream(void);
    112 
    113     CaptureStream(uint32_t uScreen, const settings::CaptureScreenSettings &Settings);
     111    CaptureStream(CaptureContext *pCtx);
     112
     113    CaptureStream(CaptureContext *pCtx, uint32_t uScreen, const settings::CaptureScreenSettings &Settings);
    114114
    115115    virtual ~CaptureStream(void);
     
    117117public:
    118118
    119     int Init(uint32_t uScreen, const settings::CaptureScreenSettings &Settings);
     119    int Init(CaptureContext *pCtx, uint32_t uScreen, const settings::CaptureScreenSettings &Settings);
    120120    int Uninit(void);
    121121
     
    133133    int close(void);
    134134
    135     int initInternal(uint32_t uScreen, const settings::CaptureScreenSettings &Settings);
     135    int initInternal(CaptureContext *pCtx, uint32_t uScreen, const settings::CaptureScreenSettings &Settings);
    136136    int uninitInternal(void);
    137137
     
    153153protected:
    154154
     155    /**
     156     * Enumeration for a recording stream state.
     157     */
     158    enum RECORDINGSTREAMSTATE
     159    {
     160        /** Stream not initialized. */
     161        RECORDINGSTREAMSTATE_UNINITIALIZED = 0,
     162        /** Stream was initialized. */
     163        RECORDINGSTREAMSTATE_INITIALIZED   = 1,
     164        /** The usual 32-bit hack. */
     165        RECORDINGSTREAMSTATE_32BIT_HACK    = 0x7fffffff
     166    };
     167
    155168    /** Recording context this stream is associated to. */
    156     CaptureContext             *pCtx;
     169    CaptureContext         *pCtx;
     170    /** The current state. */
     171    RECORDINGSTREAMSTATE    enmState;
    157172    struct
    158173    {
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r75307 r75313  
    56295629                vrc = i_videoRecCreate();
    56305630                if (RT_SUCCESS(vrc))
    5631                     vrc = i_videoRecStart();
    5632 
    5633                 if (RT_SUCCESS(vrc))
    56345631                {
    56355632# ifdef VBOX_WITH_AUDIO_VIDEOREC
     
    68996896    Assert(mMachine.isNotNull());
    69006897
     6898    Settings.applyDefaults();
     6899
    69016900    ComPtr<ICaptureSettings> pCaptureSettings;
    69026901    HRESULT hrc = mMachine->COMGETTER(CaptureSettings)(pCaptureSettings.asOutParam());
    69036902    AssertComRCReturn(hrc, VERR_INVALID_PARAMETER);
    69046903
     6904    BOOL fTemp;
     6905    hrc = pCaptureSettings->COMGETTER(Enabled)(&fTemp);
     6906    AssertComRCReturn(hrc, VERR_INVALID_PARAMETER);
     6907    Settings.fEnabled = RT_BOOL(fTemp);
     6908
    69056909    SafeIfaceArray<ICaptureScreenSettings> paCaptureScreens;
    69066910    hrc = pCaptureSettings->COMGETTER(Screens)(ComSafeArrayAsOutParam(paCaptureScreens));
    69076911    AssertComRCReturn(hrc, VERR_INVALID_PARAMETER);
    69086912
    6909     Settings.applyDefaults();
    6910 
    69116913    for (unsigned long i = 0; i < (unsigned long)paCaptureScreens.size(); ++i)
    69126914    {
     
    69146916        ComPtr<ICaptureScreenSettings> pCaptureScreenSettings = paCaptureScreens[i];
    69156917
     6918        hrc = pCaptureScreenSettings->COMGETTER(Enabled)(&fTemp);
     6919        AssertComRCReturn(hrc, VERR_INVALID_PARAMETER);
     6920        CaptureScreenSettings.fEnabled = RT_BOOL(fTemp);
    69166921        hrc = pCaptureScreenSettings->COMGETTER(MaxTime)((ULONG *)&CaptureScreenSettings.ulMaxTimeS);
    69176922        AssertComRCReturn(hrc, VERR_INVALID_PARAMETER);
     
    70067011    LogRel(("VideoRec: Starting ...\n"));
    70077012
    7008     int rc = VINF_SUCCESS;
    7009 
    7010     for (unsigned uScreen = 0; uScreen < Capture.mpVideoRecCtx->GetStreamCount(); uScreen++)
    7011         mDisplay->i_videoRecScreenChanged(uScreen);
     7013    int rc = Capture.mpVideoRecCtx->Start();
     7014    if (RT_SUCCESS(rc))
     7015    {
     7016        for (unsigned uScreen = 0; uScreen < Capture.mpVideoRecCtx->GetStreamCount(); uScreen++)
     7017            mDisplay->i_videoRecScreenChanged(uScreen);
     7018    }
    70127019
    70137020    if (RT_FAILURE(rc))
     
    70297036    LogRel(("VideoRec: Stopping ...\n"));
    70307037
    7031     const size_t cStreams = Capture.mpVideoRecCtx->GetStreamCount();
    7032     for (unsigned uScreen = 0; uScreen < cStreams; ++uScreen)
    7033         mDisplay->i_videoRecScreenChanged(uScreen);
    7034 
    7035     ComPtr<ICaptureSettings> pCaptureSettings;
    7036     HRESULT hrc = mMachine->COMGETTER(CaptureSettings)(pCaptureSettings.asOutParam());
    7037     ComAssertComRC(hrc);
    7038     hrc = pCaptureSettings->COMSETTER(Enabled)(false);
    7039     ComAssertComRC(hrc);
    7040 
    7041     LogRel(("VideoRec: Stopped\n"));
    7042 
    7043     LogFlowFuncLeaveRC(VINF_SUCCESS);
    7044     return VINF_SUCCESS;
     7038    int rc = Capture.mpVideoRecCtx->Stop();
     7039    if (RT_SUCCESS(rc))
     7040    {
     7041        const size_t cStreams = Capture.mpVideoRecCtx->GetStreamCount();
     7042        for (unsigned uScreen = 0; uScreen < cStreams; ++uScreen)
     7043            mDisplay->i_videoRecScreenChanged(uScreen);
     7044
     7045        ComPtr<ICaptureSettings> pCaptureSettings;
     7046        HRESULT hrc = mMachine->COMGETTER(CaptureSettings)(pCaptureSettings.asOutParam());
     7047        ComAssertComRC(hrc);
     7048        hrc = pCaptureSettings->COMSETTER(Enabled)(false);
     7049        ComAssertComRC(hrc);
     7050
     7051        LogRel(("VideoRec: Stopped\n"));
     7052    }
     7053    else
     7054        LogRel(("VideoRec: Failed to stop video recording (%Rrc)\n", rc));
     7055
     7056    LogFlowFuncLeaveRC(rc);
     7057    return rc;
    70457058}
    70467059#endif /* VBOX_WITH_VIDEOREC */
  • trunk/src/VBox/Main/src-client/VideoRec.cpp

    r75307 r75313  
    5656//# define VBOX_VIDEOREC_DUMP
    5757#endif
    58 
    59 /**
    60  * Enumeration for a recording state.
    61  */
    62 enum VIDEORECSTS
    63 {
    64     /** Not initialized. */
    65     VIDEORECSTS_UNINITIALIZED = 0,
    66     /** Created. */
    67     VIDEORECSTS_CREATED       = 1,
    68     /** Started. */
    69     VIDEORECSTS_STARTED       = 2,
    70     /** The usual 32-bit hack. */
    71     VIDEORECSTS_32BIT_HACK    = 0x7fffffff
    72 };
    73 
    7458
    7559#ifdef VBOX_VIDEOREC_DUMP
     
    205189        try
    206190        {
    207             pStream = new CaptureStream(itScreen->first /* Screen ID */, itScreen->second);
     191            pStream = new CaptureStream(this, itScreen->first /* Screen ID */, itScreen->second);
    208192            this->vecStreams.push_back(pStream);
    209193        }
     
    213197            break;
    214198        }
     199
     200        ++itScreen;
    215201    }
    216202
     
    219205        this->tsStartMs = RTTimeMilliTS();
    220206        this->enmState  = VIDEORECSTS_CREATED;
    221         this->fStarted  = false;
    222207        this->fShutdown = false;
    223208
     
    246231
    247232    int rc = RTThreadCreate(&this->Thread, CaptureContext::threadMain, (void *)this, 0,
    248                             RTTHREADTYPE_MAIN_WORKER, RTTHREADFLAGS_WAITABLE, "VideoRec");
     233                            RTTHREADTYPE_MAIN_WORKER, RTTHREADFLAGS_WAITABLE, "Record");
    249234
    250235    if (RT_SUCCESS(rc)) /* Wait for the thread to start. */
     
    254239    {
    255240        this->enmState = VIDEORECSTS_STARTED;
    256         this->fStarted = true;
    257241    }
    258242
     
    265249        return VINF_SUCCESS;
    266250
    267     LogFunc(("Shutting down thread ...\n"));
     251    LogThisFunc(("Shutting down thread ...\n"));
    268252
    269253    /* Set shutdown indicator. */
     
    275259        rc = RTThreadWait(this->Thread, 30 * 1000 /* 10s timeout */, NULL);
    276260
     261    if (RT_SUCCESS(rc))
     262    {
     263        this->enmState = VIDEORECSTS_CREATED;
     264    }
     265
     266    LogFlowThisFunc(("%Rrc\n", rc));
    277267    return rc;
    278268}
     
    283273int CaptureContext::destroyInternal(void)
    284274{
    285     int rc = VINF_SUCCESS;
    286 
    287     if (this->enmState == VIDEORECSTS_STARTED)
    288     {
    289         rc = stopInternal();
    290         if (RT_SUCCESS(rc))
    291         {
    292             /* Disable the context. */
    293             ASMAtomicWriteBool(&this->fStarted, false);
    294 
    295             int rc2 = RTSemEventDestroy(this->WaitEvent);
    296             AssertRC(rc2);
    297 
    298             this->WaitEvent = NIL_RTSEMEVENT;
    299         }
    300     }
    301 
     275    int rc = stopInternal();
    302276    if (RT_FAILURE(rc))
    303     {
    304         AssertRC(rc);
    305277        return rc;
    306     }
     278
     279    rc = RTSemEventDestroy(this->WaitEvent);
     280    AssertRC(rc);
     281
     282    this->WaitEvent = NIL_RTSEMEVENT;
    307283
    308284    rc = RTCritSectEnter(&this->CritSect);
     
    338314    }
    339315
     316    LogFlowThisFunc(("%Rrc\n", rc));
    340317    return rc;
    341318}
     
    411388}
    412389
     390/**
     391 * Returns if this recording context is ready to start recording.
     392 *
     393 * @returns @c true if recording context is ready, @c false if not.
     394 */
    413395bool CaptureContext::IsReady(void) const
    414396{
    415     return this->fStarted;
    416 }
    417 
    418 /**
    419  * Checks if recording engine is ready to accept new recording data for a given screen.
    420  *
    421  * @returns true if recording engine is ready, false if not.
     397    return (this->enmState >= VIDEORECSTS_CREATED);
     398}
     399
     400/**
     401 * Returns if this recording context is ready to accept new recording data for a given screen.
     402 *
     403 * @returns @c true if the specified screen is ready, @c false if not.
    422404 * @param   uScreen             Screen ID.
    423405 * @param   uTimeStampMs        Current time stamp (in ms). Currently not being used.
     
    450432bool CaptureContext::IsStarted(void) const
    451433{
    452     return this->fStarted;
     434    return (this->enmState == VIDEORECSTS_STARTED);
    453435}
    454436
  • trunk/src/VBox/Main/src-client/VideoRecStream.cpp

    r75307 r75313  
    4242
    4343
    44 CaptureStream::CaptureStream(void)
    45     : tsStartMs(0)
     44CaptureStream::CaptureStream(CaptureContext *a_pCtx)
     45    : pCtx(a_pCtx)
     46    , enmState(RECORDINGSTREAMSTATE_UNINITIALIZED)
     47    , tsStartMs(0)
    4648{
    4749    File.pWEBM = NULL;
     
    4951}
    5052
    51 CaptureStream::CaptureStream(uint32_t uScreen, const settings::CaptureScreenSettings &Settings)
    52     : tsStartMs(0)
     53CaptureStream::CaptureStream(CaptureContext *a_pCtx, uint32_t uScreen, const settings::CaptureScreenSettings &Settings)
     54    : enmState(RECORDINGSTREAMSTATE_UNINITIALIZED)
     55    , tsStartMs(0)
    5356{
    5457    File.pWEBM = NULL;
    5558    File.hFile = NIL_RTFILE;
    5659
    57     int rc2 = initInternal(uScreen, Settings);
     60    int rc2 = initInternal(a_pCtx, uScreen, Settings);
    5861    if (RT_FAILURE(rc2))
    5962        throw rc2;
     
    645648        VideoRecVideoFrameFree(pFrame);
    646649
    647     lock();
     650    unlock();
    648651
    649652    return rc;
    650653}
    651654
    652 int CaptureStream::Init(uint32_t uScreen, const settings::CaptureScreenSettings &Settings)
    653 {
    654     return initInternal(uScreen, Settings);
    655 }
    656 
    657655/**
    658656 * Initializes a recording stream.
    659657 *
    660658 * @returns IPRT status code.
     659 * @param   a_pCtx              Pointer to recording context.
    661660 * @param   uScreen             Screen number to use for this recording stream.
    662661 * @param   Settings            Capturing configuration to use for initialization.
    663662 */
    664 int CaptureStream::initInternal(uint32_t uScreen, const settings::CaptureScreenSettings &Settings)
     663int CaptureStream::Init(CaptureContext *a_pCtx, uint32_t uScreen, const settings::CaptureScreenSettings &Settings)
     664{
     665    return initInternal(a_pCtx, uScreen, Settings);
     666}
     667
     668/**
     669 * Initializes a recording stream, internal version.
     670 *
     671 * @returns IPRT status code.
     672 * @param   a_pCtx              Pointer to recording context.
     673 * @param   uScreen             Screen number to use for this recording stream.
     674 * @param   Settings            Capturing configuration to use for initialization.
     675 */
     676int CaptureStream::initInternal(CaptureContext *a_pCtx, uint32_t uScreen, const settings::CaptureScreenSettings &Settings)
    665677{
    666678    int rc = parseOptionsString(Settings.strOptions);
     
    770782    if (RT_SUCCESS(rc))
    771783    {
     784        this->pCtx           = a_pCtx;
     785        this->enmState       = RECORDINGSTREAMSTATE_INITIALIZED;
    772786        this->fEnabled       = true;
    773787        this->uScreenID      = uScreen;
     
    870884int CaptureStream::uninitInternal(void)
    871885{
     886    if (this->enmState != RECORDINGSTREAMSTATE_INITIALIZED)
     887        return VINF_SUCCESS;
     888
    872889    int rc = close();
    873890    if (RT_FAILURE(rc))
     
    883900    RTCritSectDelete(&this->CritSect);
    884901
     902    this->enmState = RECORDINGSTREAMSTATE_UNINITIALIZED;
    885903    this->fEnabled = false;
    886904
     
    911929int CaptureStream::uninitVideoVPX(void)
    912930{
    913     vpx_img_free(&this->Video.Codec.VPX.RawImage);
     931    PVIDEORECVIDEOCODEC pCodec = &this->Video.Codec;
     932    vpx_img_free(&pCodec->VPX.RawImage);
     933    pCodec->VPX.pu8YuvBuf = NULL; /* Was pointing to VPX.RawImage. */
     934
    914935    vpx_codec_err_t rcv = vpx_codec_destroy(&this->Video.Codec.VPX.Ctx);
    915936    Assert(rcv == VPX_CODEC_OK); RT_NOREF(rcv);
  • trunk/src/VBox/Main/src-server/CaptureScreenSettingsImpl.cpp

    r75307 r75313  
    292292HRESULT CaptureScreenSettings::setFeatures(ULONG aFeatures)
    293293{
    294     if (!i_canChangeSettings())
     294    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     295
     296    if (m->bd->fEnabled)
    295297        return setError(E_INVALIDARG, tr("Cannot change features while capturing is enabled"));
    296 
    297     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    298298
    299299    m->bd.backup();
     
    325325HRESULT CaptureScreenSettings::setDestination(CaptureDestination_T aDestination)
    326326{
    327     if (!i_canChangeSettings())
     327    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     328
     329    if (m->bd->fEnabled)
    328330        return setError(E_INVALIDARG, tr("Cannot change destination type while capturing is enabled"));
    329331
    330     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    331 
    332332    m->bd.backup();
    333333    m->bd->enmDest = aDestination;
     
    353353HRESULT CaptureScreenSettings::setFileName(const com::Utf8Str &aFileName)
    354354{
    355     if (!i_canChangeSettings())
     355    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     356
     357    if (m->bd->fEnabled)
    356358        return setError(E_INVALIDARG, tr("Cannot change file name while capturing is enabled"));
    357 
    358     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    359359
    360360    Utf8Str strFile(aFileName);
     
    388388    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    389389
    390     if (!i_canChangeSettings())
     390    if (m->bd->fEnabled)
    391391        return setError(E_INVALIDARG, tr("Cannot change maximum time while capturing is enabled"));
    392392
     
    414414    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    415415
    416     if (!i_canChangeSettings())
     416    if (m->bd->fEnabled)
    417417        return setError(E_INVALIDARG, tr("Cannot change maximum file size while capturing is enabled"));
    418418
     
    440440    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    441441
    442     if (!i_canChangeSettings())
    443         return setError(E_INVALIDARG, tr("Cannot change options string while capturing is enabled"));
     442    if (m->bd->fEnabled)
     443        return setError(E_INVALIDARG, tr("Cannot change options while capturing is enabled"));
    444444
    445445    m->bd.backup();
    446446    m->bd->strOptions = aOptions;
    447447
    448     AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
    449     m->pMachine->i_setModified(Machine::IsModified_Capture);
    450     mlock.release();
     448    alock.release();
     449    AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
     450    m->pMachine->i_setModified(Machine::IsModified_Capture);
    451451
    452452    return S_OK;
     
    466466    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    467467
    468     if (!i_canChangeSettings())
     468    if (m->bd->fEnabled)
    469469        return setError(E_INVALIDARG, tr("Cannot change audio codec while capturing is enabled"));
    470470
     
    492492    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    493493
    494     if (!i_canChangeSettings())
     494    if (m->bd->fEnabled)
    495495        return setError(E_INVALIDARG, tr("Cannot change audio Hertz rate while capturing is enabled"));
    496496
     
    518518    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    519519
    520     if (!i_canChangeSettings())
     520    if (m->bd->fEnabled)
    521521        return setError(E_INVALIDARG, tr("Cannot change audio bits while capturing is enabled"));
    522522
     
    544544    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    545545
    546     if (!i_canChangeSettings())
     546    if (m->bd->fEnabled)
    547547        return setError(E_INVALIDARG, tr("Cannot change audio channels while capturing is enabled"));
    548548
     
    570570    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    571571
    572     if (!i_canChangeSettings())
     572    if (m->bd->fEnabled)
    573573        return setError(E_INVALIDARG, tr("Cannot change video codec while capturing is enabled"));
    574574
     
    596596    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    597597
    598     if (!i_canChangeSettings())
     598    if (m->bd->fEnabled)
    599599        return setError(E_INVALIDARG, tr("Cannot change video width while capturing is enabled"));
    600600
     
    622622    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    623623
    624     if (!i_canChangeSettings())
     624    if (m->bd->fEnabled)
    625625        return setError(E_INVALIDARG, tr("Cannot change video height while capturing is enabled"));
    626626
     
    648648    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    649649
    650     if (!i_canChangeSettings())
     650    if (m->bd->fEnabled)
    651651        return setError(E_INVALIDARG, tr("Cannot change video rate while capturing is enabled"));
    652652
     
    674674    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    675675
    676     if (!i_canChangeSettings())
     676    if (m->bd->fEnabled)
    677677        return setError(E_INVALIDARG, tr("Cannot change video rate control mode while capturing is enabled"));
    678678
     
    696696    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    697697
    698     if (!i_canChangeSettings())
     698    if (m->bd->fEnabled)
    699699        return setError(E_INVALIDARG, tr("Cannot change video FPS while capturing is enabled"));
    700700
     
    722722    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    723723
    724     if (!i_canChangeSettings())
     724    if (m->bd->fEnabled)
    725725        return setError(E_INVALIDARG, tr("Cannot change video rate scaling method while capturing is enabled"));
    726726
     
    729729
    730730    return E_NOTIMPL;
    731 }
    732 
    733 bool CaptureScreenSettings::i_canChangeSettings(void)
    734 {
    735     AutoAnyStateDependency adep(m->pMachine);
    736     AssertComRCReturn(adep.rc(), false);
    737 
    738     if (   Global::IsOnline(adep.machineState())
    739         && m->bd->fEnabled)
    740         return false;
    741 
    742     return true;
    743731}
    744732
  • trunk/src/VBox/Main/xml/Settings.cpp

    r75307 r75313  
    24832483        /* Always add screen 0 to the default configuration. */
    24842484        CaptureScreenSettings screenSettings; /* Apply default settings for screen 0. */
     2485        screenSettings.fEnabled = true;       /* Enabled by default. */
    24852486        mapScreens[0] = screenSettings;
    24862487    }
Note: See TracChangeset for help on using the changeset viewer.

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