VirtualBox

Ignore:
Timestamp:
Nov 8, 2018 3:39:50 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
126445
Message:

Recording: More settings bugfixes for Main and FE/Qt.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/CaptureScreenSettingsImpl.cpp

    r75313 r75324  
    1717 */
    1818
     19#define LOG_GROUP LOG_GROUP_MAIN_CAPTURESCREENSETTINGS
     20#include "LoggingNew.h"
     21
    1922#include "CaptureScreenSettingsImpl.h"
     23#include "CaptureSettingsImpl.h"
    2024#include "MachineImpl.h"
    2125
     
    2731#include "AutoCaller.h"
    2832#include "Global.h"
    29 #include "Logging.h"
    3033
    3134////////////////////////////////////////////////////////////////////////////////
     
    3841{
    3942    Data()
    40         : pMachine(NULL)
     43        : pParent(NULL)
    4144    { }
    4245
    43     Machine * const                  pMachine;
     46    CaptureSettings * const          pParent;
    4447    ComObjPtr<CaptureScreenSettings> pPeer;
    4548    uint32_t                         uScreenId;
     
    7376 * @returns COM result indicator
    7477 */
    75 HRESULT CaptureScreenSettings::init(Machine *aParent, uint32_t uScreenId, const settings::CaptureScreenSettings& data)
     78HRESULT CaptureScreenSettings::init(CaptureSettings *aParent, uint32_t uScreenId, const settings::CaptureScreenSettings& data)
    7679{
    7780    LogFlowThisFuncEnter();
     
    8689    m = new Data();
    8790
    88     /* Share the parent weakly. */
    89     unconst(m->pMachine) = aParent;
     91    /* Share the parent & machine weakly. */
     92    unconst(m->pParent) = aParent;
    9093    /* mPeer is left null. */
    9194
     
    120123 *  it shares data with is destroyed.
    121124 */
    122 HRESULT CaptureScreenSettings::init(Machine *aParent, CaptureScreenSettings *that)
     125HRESULT CaptureScreenSettings::init(CaptureSettings *aParent, CaptureScreenSettings *that)
    123126{
    124127    LogFlowThisFuncEnter();
     
    133136    m = new Data();
    134137
    135     unconst(m->pMachine) = aParent;
     138    unconst(m->pParent) = aParent;
    136139    m->pPeer = that;
    137140
     
    163166 *  of the original object passed as an argument.
    164167 */
    165 HRESULT CaptureScreenSettings::initCopy(Machine *aParent, CaptureScreenSettings *that)
     168HRESULT CaptureScreenSettings::initCopy(CaptureSettings *aParent, CaptureScreenSettings *that)
    166169{
    167170    LogFlowThisFuncEnter();
     
    176179    m = new Data();
    177180
    178     unconst(m->pMachine) = aParent;
     181    unconst(m->pParent) = aParent;
    179182    /* mPeer is left null. */
    180183
     
    217220
    218221    unconst(m->pPeer) = NULL;
    219     unconst(m->pMachine) = NULL;
     222    unconst(m->pParent) = NULL;
    220223
    221224    delete m;
     
    227230HRESULT CaptureScreenSettings::isFeatureEnabled(CaptureFeature_T aFeature, BOOL *aEnabled)
    228231{
     232    AutoCaller autoCaller(this);
     233    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     234
     235    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     236
    229237    settings::CaptureFeatureMap::const_iterator itFeature = m->bd->featureMap.find(aFeature);
    230238
     
    237245HRESULT CaptureScreenSettings::getEnabled(BOOL *enabled)
    238246{
     247    AutoCaller autoCaller(this);
     248    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     249
    239250    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    240251
     
    246257HRESULT CaptureScreenSettings::setEnabled(BOOL enabled)
    247258{
     259    AutoCaller autoCaller(this);
     260    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     261
     262    LogFlowThisFunc(("Screen %RU32\n", m->uScreenId));
     263
     264    if (!m->pParent->i_canChangeSettings())
     265        return setError(E_INVALIDARG, tr("Cannot change enabled state of screen while capturing is enabled"));
     266
    248267    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    249268
     
    254273        alock.release();
    255274
    256         AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
    257         m->pMachine->i_setModified(Machine::IsModified_Capture);
    258         mlock.release();
    259 
    260         HRESULT rc = m->pMachine->i_onCaptureChange();
    261         if (FAILED(rc)) return rc;
    262 
    263         /** Save settings if online - @todo why is this required? -- @bugref{6818} */
    264         AutoAnyStateDependency adep(m->pMachine);
    265         AssertComRCReturn(adep.rc(), E_UNEXPECTED);
    266 
    267         if (Global::IsOnline(adep.machineState()))
    268             m->pMachine->i_saveSettings(NULL);
     275        m->pParent->i_onSettingsChanged();
    269276    }
    270277
     278    LogFlowThisFunc(("Screen %RU32\n", m->uScreenId));
    271279    return S_OK;
    272280}
     
    274282HRESULT CaptureScreenSettings::getFeatures(ULONG *aFeatures)
    275283{
     284    AutoCaller autoCaller(this);
     285    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     286
    276287    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    277288
     
    292303HRESULT CaptureScreenSettings::setFeatures(ULONG aFeatures)
    293304{
    294     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    295 
    296     if (m->bd->fEnabled)
     305    AutoCaller autoCaller(this);
     306    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     307
     308    if (!m->pParent->i_canChangeSettings())
    297309        return setError(E_INVALIDARG, tr("Cannot change features while capturing is enabled"));
     310
     311    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    298312
    299313    m->bd.backup();
     
    307321    alock.release();
    308322
    309     AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
    310     m->pMachine->i_setModified(Machine::IsModified_Capture);
    311     mlock.release();
    312 
    313323    return S_OK;
    314324}
     
    316326HRESULT CaptureScreenSettings::getDestination(CaptureDestination_T *aDestination)
    317327{
     328    AutoCaller autoCaller(this);
     329    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     330
    318331    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    319332
     
    325338HRESULT CaptureScreenSettings::setDestination(CaptureDestination_T aDestination)
    326339{
    327     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    328 
    329     if (m->bd->fEnabled)
     340    AutoCaller autoCaller(this);
     341    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     342
     343    if (!m->pParent->i_canChangeSettings())
    330344        return setError(E_INVALIDARG, tr("Cannot change destination type while capturing is enabled"));
    331345
     346    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     347
    332348    m->bd.backup();
    333349    m->bd->enmDest = aDestination;
    334350
    335     alock.release();
    336 
    337     AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
    338     m->pMachine->i_setModified(Machine::IsModified_Capture);
    339     mlock.release();
    340 
    341351    return S_OK;
    342352}
     
    344354HRESULT CaptureScreenSettings::getFileName(com::Utf8Str &aFileName)
    345355{
     356    AutoCaller autoCaller(this);
     357    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     358
    346359    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    347360
     
    353366HRESULT CaptureScreenSettings::setFileName(const com::Utf8Str &aFileName)
    354367{
    355     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    356 
    357     if (m->bd->fEnabled)
     368    AutoCaller autoCaller(this);
     369    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     370
     371    if (!m->pParent->i_canChangeSettings())
    358372        return setError(E_INVALIDARG, tr("Cannot change file name while capturing is enabled"));
     373
     374    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    359375
    360376    Utf8Str strFile(aFileName);
     
    366382    m->bd->File.strName = strFile;
    367383
    368     alock.release();
    369 
    370     AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
    371     m->pMachine->i_setModified(Machine::IsModified_Capture);
    372     mlock.release();
    373 
    374384    return S_OK;
    375385}
     
    377387HRESULT CaptureScreenSettings::getMaxTime(ULONG *aMaxTimeS)
    378388{
     389    AutoCaller autoCaller(this);
     390    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     391
    379392    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    380393
     
    386399HRESULT CaptureScreenSettings::setMaxTime(ULONG aMaxTimeS)
    387400{
    388     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    389 
    390     if (m->bd->fEnabled)
     401    AutoCaller autoCaller(this);
     402    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     403
     404    if (!m->pParent->i_canChangeSettings())
    391405        return setError(E_INVALIDARG, tr("Cannot change maximum time while capturing is enabled"));
    392406
     407    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     408
    393409    m->bd.backup();
    394410    m->bd->ulMaxTimeS = aMaxTimeS;
    395411
    396     AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
    397     m->pMachine->i_setModified(Machine::IsModified_Capture);
    398     mlock.release();
    399 
    400412    return S_OK;
    401413}
     
    403415HRESULT CaptureScreenSettings::getMaxFileSize(ULONG *aMaxFileSizeMB)
    404416{
     417    AutoCaller autoCaller(this);
     418    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     419
    405420    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    406421
     
    412427HRESULT CaptureScreenSettings::setMaxFileSize(ULONG aMaxFileSize)
    413428{
    414     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    415 
    416     if (m->bd->fEnabled)
     429    AutoCaller autoCaller(this);
     430    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     431
     432    if (!m->pParent->i_canChangeSettings())
    417433        return setError(E_INVALIDARG, tr("Cannot change maximum file size while capturing is enabled"));
    418434
     435    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     436
    419437    m->bd.backup();
    420438    m->bd->File.ulMaxSizeMB = aMaxFileSize;
    421439
    422     AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
    423     m->pMachine->i_setModified(Machine::IsModified_Capture);
    424     mlock.release();
    425 
    426440    return S_OK;
    427441}
     
    429443HRESULT CaptureScreenSettings::getOptions(com::Utf8Str &aOptions)
    430444{
     445    AutoCaller autoCaller(this);
     446    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     447
    431448    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    432449
     
    438455HRESULT CaptureScreenSettings::setOptions(const com::Utf8Str &aOptions)
    439456{
    440     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    441 
    442     if (m->bd->fEnabled)
     457    AutoCaller autoCaller(this);
     458    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     459
     460    if (!m->pParent->i_canChangeSettings())
    443461        return setError(E_INVALIDARG, tr("Cannot change options while capturing is enabled"));
    444462
     463    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     464
    445465    m->bd.backup();
    446466    m->bd->strOptions = aOptions;
    447467
    448     alock.release();
    449     AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
    450     m->pMachine->i_setModified(Machine::IsModified_Capture);
    451 
    452468    return S_OK;
    453469}
     
    455471HRESULT CaptureScreenSettings::getAudioCodec(CaptureAudioCodec_T *aCodec)
    456472{
     473    AutoCaller autoCaller(this);
     474    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     475
    457476    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    458477
     
    464483HRESULT CaptureScreenSettings::setAudioCodec(CaptureAudioCodec_T aCodec)
    465484{
    466     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    467 
    468     if (m->bd->fEnabled)
     485    AutoCaller autoCaller(this);
     486    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     487
     488    if (!m->pParent->i_canChangeSettings())
    469489        return setError(E_INVALIDARG, tr("Cannot change audio codec while capturing is enabled"));
    470490
     491    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     492
    471493    m->bd.backup();
    472494    m->bd->Audio.enmAudioCodec = aCodec;
    473495
    474     AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
    475     m->pMachine->i_setModified(Machine::IsModified_Capture);
    476     mlock.release();
    477 
    478496    return S_OK;
    479497}
     
    481499HRESULT CaptureScreenSettings::getAudioHz(ULONG *aHz)
    482500{
     501    AutoCaller autoCaller(this);
     502    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     503
    483504    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    484505
     
    490511HRESULT CaptureScreenSettings::setAudioHz(ULONG aHz)
    491512{
    492     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    493 
    494     if (m->bd->fEnabled)
     513    AutoCaller autoCaller(this);
     514    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     515
     516    if (!m->pParent->i_canChangeSettings())
    495517        return setError(E_INVALIDARG, tr("Cannot change audio Hertz rate while capturing is enabled"));
    496518
     519    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     520
    497521    m->bd.backup();
    498522    m->bd->Audio.uHz = (uint16_t)aHz;
    499523
    500     AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
    501     m->pMachine->i_setModified(Machine::IsModified_Capture);
    502     mlock.release();
    503 
    504524    return S_OK;
    505525}
     
    507527HRESULT CaptureScreenSettings::getAudioBits(ULONG *aBits)
    508528{
     529    AutoCaller autoCaller(this);
     530    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     531
    509532    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    510533
     
    516539HRESULT CaptureScreenSettings::setAudioBits(ULONG aBits)
    517540{
    518     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    519 
    520     if (m->bd->fEnabled)
     541    AutoCaller autoCaller(this);
     542    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     543
     544    if (!m->pParent->i_canChangeSettings())
    521545        return setError(E_INVALIDARG, tr("Cannot change audio bits while capturing is enabled"));
    522546
     547    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     548
    523549    m->bd.backup();
    524550    m->bd->Audio.cBits = (uint8_t)aBits;
    525551
    526     AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
    527     m->pMachine->i_setModified(Machine::IsModified_Capture);
    528     mlock.release();
    529 
    530552    return S_OK;
    531553}
     
    533555HRESULT CaptureScreenSettings::getAudioChannels(ULONG *aChannels)
    534556{
     557    AutoCaller autoCaller(this);
     558    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     559
    535560    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    536561
     
    542567HRESULT CaptureScreenSettings::setAudioChannels(ULONG aChannels)
    543568{
    544     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    545 
    546     if (m->bd->fEnabled)
     569    AutoCaller autoCaller(this);
     570    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     571
     572    if (!m->pParent->i_canChangeSettings())
    547573        return setError(E_INVALIDARG, tr("Cannot change audio channels while capturing is enabled"));
    548574
     575    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     576
    549577    m->bd.backup();
    550578    m->bd->Audio.cChannels = (uint8_t)aChannels;
    551579
    552     AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
    553     m->pMachine->i_setModified(Machine::IsModified_Capture);
    554     mlock.release();
    555 
    556580    return S_OK;
    557581}
     
    559583HRESULT CaptureScreenSettings::getVideoCodec(CaptureVideoCodec_T *aCodec)
    560584{
     585    AutoCaller autoCaller(this);
     586    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     587
    561588    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    562589
     
    568595HRESULT CaptureScreenSettings::setVideoCodec(CaptureVideoCodec_T aCodec)
    569596{
    570     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    571 
    572     if (m->bd->fEnabled)
     597    AutoCaller autoCaller(this);
     598    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     599
     600    if (!m->pParent->i_canChangeSettings())
    573601        return setError(E_INVALIDARG, tr("Cannot change video codec while capturing is enabled"));
    574602
     603    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     604
    575605    m->bd.backup();
    576606    m->bd->Video.enmCodec = aCodec;
    577607
    578     AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
    579     m->pMachine->i_setModified(Machine::IsModified_Capture);
    580     mlock.release();
    581 
    582608    return S_OK;
    583609}
     
    585611HRESULT CaptureScreenSettings::getVideoWidth(ULONG *aVideoWidth)
    586612{
     613    AutoCaller autoCaller(this);
     614    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     615
    587616    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    588617
     
    594623HRESULT CaptureScreenSettings::setVideoWidth(ULONG aVideoWidth)
    595624{
    596     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    597 
    598     if (m->bd->fEnabled)
     625    AutoCaller autoCaller(this);
     626    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     627
     628    if (!m->pParent->i_canChangeSettings())
    599629        return setError(E_INVALIDARG, tr("Cannot change video width while capturing is enabled"));
    600630
     631    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     632
    601633    m->bd.backup();
    602634    m->bd->Video.ulWidth = aVideoWidth;
    603635
    604     AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
    605     m->pMachine->i_setModified(Machine::IsModified_Capture);
    606     mlock.release();
    607 
    608636    return S_OK;
    609637}
     
    611639HRESULT CaptureScreenSettings::getVideoHeight(ULONG *aVideoHeight)
    612640{
     641    AutoCaller autoCaller(this);
     642    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     643
    613644    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    614645
     
    620651HRESULT CaptureScreenSettings::setVideoHeight(ULONG aVideoHeight)
    621652{
    622     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    623 
    624     if (m->bd->fEnabled)
     653    AutoCaller autoCaller(this);
     654    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     655
     656    if (!m->pParent->i_canChangeSettings())
    625657        return setError(E_INVALIDARG, tr("Cannot change video height while capturing is enabled"));
    626658
     659    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     660
    627661    m->bd.backup();
    628662    m->bd->Video.ulHeight = aVideoHeight;
    629663
    630     AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
    631     m->pMachine->i_setModified(Machine::IsModified_Capture);
    632     mlock.release();
    633 
    634664    return S_OK;
    635665}
     
    637667HRESULT CaptureScreenSettings::getVideoRate(ULONG *aVideoRate)
    638668{
     669    AutoCaller autoCaller(this);
     670    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     671
    639672    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    640673
     
    646679HRESULT CaptureScreenSettings::setVideoRate(ULONG aVideoRate)
    647680{
    648     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    649 
    650     if (m->bd->fEnabled)
     681    AutoCaller autoCaller(this);
     682    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     683
     684    if (!m->pParent->i_canChangeSettings())
    651685        return setError(E_INVALIDARG, tr("Cannot change video rate while capturing is enabled"));
    652686
     687    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     688
    653689    m->bd.backup();
    654690    m->bd->Video.ulRate = aVideoRate;
    655691
    656     AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
    657     m->pMachine->i_setModified(Machine::IsModified_Capture);
    658     mlock.release();
    659 
    660692    return S_OK;
    661693}
     
    663695HRESULT CaptureScreenSettings::getVideoRateControlMode(CaptureVideoRateControlMode_T *aMode)
    664696{
     697    AutoCaller autoCaller(this);
     698    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     699
    665700    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    666701
     
    672707HRESULT CaptureScreenSettings::setVideoRateControlMode(CaptureVideoRateControlMode_T aMode)
    673708{
    674     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    675 
    676     if (m->bd->fEnabled)
     709    AutoCaller autoCaller(this);
     710    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     711
     712    if (!m->pParent->i_canChangeSettings())
    677713        return setError(E_INVALIDARG, tr("Cannot change video rate control mode while capturing is enabled"));
     714
     715    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    678716
    679717    /** @todo Implement this. */
     
    685723HRESULT CaptureScreenSettings::getVideoFPS(ULONG *aVideoFPS)
    686724{
     725    AutoCaller autoCaller(this);
     726    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     727
    687728    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    688729
     
    694735HRESULT CaptureScreenSettings::setVideoFPS(ULONG aVideoFPS)
    695736{
    696     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    697 
    698     if (m->bd->fEnabled)
     737    AutoCaller autoCaller(this);
     738    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     739
     740    if (!m->pParent->i_canChangeSettings())
    699741        return setError(E_INVALIDARG, tr("Cannot change video FPS while capturing is enabled"));
    700742
     743    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     744
    701745    m->bd.backup();
    702746    m->bd->Video.ulFPS = aVideoFPS;
    703747
    704     AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
    705     m->pMachine->i_setModified(Machine::IsModified_Capture);
    706     mlock.release();
    707 
    708748    return S_OK;
    709749}
     
    711751HRESULT CaptureScreenSettings::getVideoScalingMethod(CaptureVideoScalingMethod_T *aMode)
    712752{
     753    AutoCaller autoCaller(this);
     754    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     755
    713756    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    714757
     
    720763HRESULT CaptureScreenSettings::setVideoScalingMethod(CaptureVideoScalingMethod_T aMode)
    721764{
    722     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    723 
    724     if (m->bd->fEnabled)
     765    AutoCaller autoCaller(this);
     766    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     767
     768    if (!m->pParent->i_canChangeSettings())
    725769        return setError(E_INVALIDARG, tr("Cannot change video rate scaling method while capturing is enabled"));
     770
     771    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    726772
    727773    /** @todo Implement this. */
     
    729775
    730776    return E_NOTIMPL;
    731 }
    732 
    733 /**
    734  * Returns the full path to the default video capture file.
    735  */
    736 int CaptureScreenSettings::i_getDefaultFileName(Utf8Str &strFile)
    737 {
    738     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    739 
    740     strFile = m->pMachine->i_getSettingsFileFull(); // path/to/machinesfolder/vmname/vmname.vbox
    741     strFile.stripSuffix();                          // path/to/machinesfolder/vmname/vmname
    742     strFile.append(".webm");                        // path/to/machinesfolder/vmname/vmname.webm
    743 
    744     return VINF_SUCCESS;
    745777}
    746778
     
    753785{
    754786    Assert(m);
    755     return i_getDefaultFileName(m->bd->File.strName);
    756 }
    757 
     787
     788    int rc = VINF_SUCCESS;
     789
     790    switch (m->bd->enmDest)
     791    {
     792        case CaptureDestination_File:
     793        {
     794            if (m->bd->File.strName.isEmpty())
     795                rc = m->pParent->i_getDefaultFileName(m->bd->File.strName);
     796            break;
     797        }
     798
     799        default:
     800            break;
     801    }
     802
     803    return rc;
     804}
     805
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