VirtualBox

Changeset 82192 in vbox for trunk/src


Ignore:
Timestamp:
Nov 25, 2019 6:08:10 PM (5 years ago)
Author:
vboxsync
Message:

Main/RecordingSettings: move monitor count query to place before taking the object lock (the recording settings one is much higher lock order than the Machine one)

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

Legend:

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

    r78068 r82192  
    6767
    6868    void i_reset(void);
    69     int i_syncToMachineDisplays(void);
     69    int i_syncToMachineDisplays(uint32_t cMonitors);
    7070    int i_createScreenObj(RecordScreenSettingsMap &screenSettingsMap, uint32_t uScreenId, const settings::RecordingScreenSettings &data);
    7171    int i_destroyScreenObj(RecordScreenSettingsMap &screenSettingsMap, uint32_t uScreenId);
  • trunk/src/VBox/Main/src-server/RecordingSettingsImpl.cpp

    r81971 r82192  
    259259    LogFlowThisFuncEnter();
    260260
    261     i_syncToMachineDisplays();
     261    AssertPtr(m->pMachine);
     262    ComPtr<IGraphicsAdapter> pGraphicsAdapter;
     263    m->pMachine->COMGETTER(GraphicsAdapter)(pGraphicsAdapter.asOutParam());
     264    ULONG cMonitors = 0;
     265    if (!pGraphicsAdapter.isNull())
     266        pGraphicsAdapter->COMGETTER(MonitorCount)(&cMonitors);
     267
     268    i_syncToMachineDisplays(cMonitors);
    262269
    263270    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    285292    LogFlowThisFuncEnter();
    286293
    287     i_syncToMachineDisplays();
     294    AssertPtr(m->pMachine);
     295    ComPtr<IGraphicsAdapter> pGraphicsAdapter;
     296    m->pMachine->COMGETTER(GraphicsAdapter)(pGraphicsAdapter.asOutParam());
     297    ULONG cMonitors = 0;
     298    if (!pGraphicsAdapter.isNull())
     299        pGraphicsAdapter->COMGETTER(MonitorCount)(&cMonitors);
     300
     301    i_syncToMachineDisplays(cMonitors);
    288302
    289303    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    484498    AssertComRCReturnRC(autoCaller.rc());
    485499
    486     int rc2 = i_syncToMachineDisplays();
     500    AssertPtr(m->pMachine);
     501    ComPtr<IGraphicsAdapter> pGraphicsAdapter;
     502    m->pMachine->COMGETTER(GraphicsAdapter)(pGraphicsAdapter.asOutParam());
     503    ULONG cMonitors = 0;
     504    if (!pGraphicsAdapter.isNull())
     505        pGraphicsAdapter->COMGETTER(MonitorCount)(&cMonitors);
     506
     507    int rc2 = i_syncToMachineDisplays(cMonitors);
    487508    AssertRC(rc2);
    488509
     
    566587    AssertComRCReturnVoid(autoCaller.rc());
    567588
    568     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    569 
    570     /* Initialize default capturing settings here. */
    571     m->bd->fEnabled = false;
    572 
    573     /* First, do a reset so that all internal screen settings objects are destroyed. */
    574     i_reset();
    575     /* Second, sync (again) to configured machine displays to (re-)create screen settings objects. */
    576     i_syncToMachineDisplays();
    577 }
    578 
    579 /**
    580  * Returns the full path to the default video capture file.
    581  */
    582 int RecordingSettings::i_getDefaultFilename(Utf8Str &strFile, bool fWithFileExtension)
    583 {
    584     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    585 
    586     strFile = m->pMachine->i_getSettingsFileFull(); // path/to/machinesfolder/vmname/vmname.vbox
    587     strFile.stripSuffix();                          // path/to/machinesfolder/vmname/vmname
    588     if (fWithFileExtension)
    589         strFile.append(".webm");                    // path/to/machinesfolder/vmname/vmname.webm
    590 
    591     return VINF_SUCCESS;
    592 }
    593 
    594 /**
    595  * Determines whether the recording settings currently can be changed or not.
    596  *
    597  * @returns \c true if the settings can be changed, \c false if not.
    598  */
    599 bool RecordingSettings::i_canChangeSettings(void)
    600 {
    601     AutoAnyStateDependency adep(m->pMachine);
    602     if (FAILED(adep.rc()))
    603         return false;
    604 
    605     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    606 
    607     /* Only allow settings to be changed when recording is disabled when the machine is running. */
    608     if (   Global::IsOnline(adep.machineState())
    609         && m->bd->fEnabled)
    610     {
    611         return false;
    612     }
    613 
    614     return true;
    615 }
    616 
    617 /**
    618  * Gets called when the machine object needs to know that the recording settings
    619  * have been changed.
    620  */
    621 void RecordingSettings::i_onSettingsChanged(void)
    622 {
    623     LogFlowThisFuncEnter();
    624 
    625     AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
    626     m->pMachine->i_setModified(Machine::IsModified_Recording);
    627     mlock.release();
    628 
    629     LogFlowThisFuncLeave();
    630 }
    631 
    632 /**
    633  * Synchronizes the screen settings (COM) objects and configuration data
    634  * to the number of the machine's configured displays.
    635  */
    636 int RecordingSettings::i_syncToMachineDisplays(void)
    637 {
    638589    AssertPtr(m->pMachine);
    639590    ComPtr<IGraphicsAdapter> pGraphicsAdapter;
     
    643594        pGraphicsAdapter->COMGETTER(MonitorCount)(&cMonitors);
    644595
     596    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     597
     598    /* Initialize default capturing settings here. */
     599    m->bd->fEnabled = false;
     600
     601    /* First, do a reset so that all internal screen settings objects are destroyed. */
     602    i_reset();
     603    /* Second, sync (again) to configured machine displays to (re-)create screen settings objects. */
     604    i_syncToMachineDisplays(cMonitors);
     605}
     606
     607/**
     608 * Returns the full path to the default video capture file.
     609 */
     610int RecordingSettings::i_getDefaultFilename(Utf8Str &strFile, bool fWithFileExtension)
     611{
     612    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     613
     614    strFile = m->pMachine->i_getSettingsFileFull(); // path/to/machinesfolder/vmname/vmname.vbox
     615    strFile.stripSuffix();                          // path/to/machinesfolder/vmname/vmname
     616    if (fWithFileExtension)
     617        strFile.append(".webm");                    // path/to/machinesfolder/vmname/vmname.webm
     618
     619    return VINF_SUCCESS;
     620}
     621
     622/**
     623 * Determines whether the recording settings currently can be changed or not.
     624 *
     625 * @returns \c true if the settings can be changed, \c false if not.
     626 */
     627bool RecordingSettings::i_canChangeSettings(void)
     628{
     629    AutoAnyStateDependency adep(m->pMachine);
     630    if (FAILED(adep.rc()))
     631        return false;
     632
     633    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     634
     635    /* Only allow settings to be changed when recording is disabled when the machine is running. */
     636    if (   Global::IsOnline(adep.machineState())
     637        && m->bd->fEnabled)
     638    {
     639        return false;
     640    }
     641
     642    return true;
     643}
     644
     645/**
     646 * Gets called when the machine object needs to know that the recording settings
     647 * have been changed.
     648 */
     649void RecordingSettings::i_onSettingsChanged(void)
     650{
     651    LogFlowThisFuncEnter();
     652
     653    AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);
     654    m->pMachine->i_setModified(Machine::IsModified_Recording);
     655    mlock.release();
     656
     657    LogFlowThisFuncLeave();
     658}
     659
     660/**
     661 * Synchronizes the screen settings (COM) objects and configuration data
     662 * to the number of the machine's configured displays.
     663 */
     664int RecordingSettings::i_syncToMachineDisplays(uint32_t cMonitors)
     665{
    645666    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    646667
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