VirtualBox

Changeset 103395 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Feb 16, 2024 9:18:42 AM (12 months ago)
Author:
vboxsync
Message:

Main/Audio: Added mutable state dependency checks for audio adapter settings. bugref:10600

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

Legend:

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

    r98103 r103395  
    6565    // public methods only for internal purposes
    6666    bool     i_canChangeSettings(void);
     67    Machine *i_getMachine(void);
    6768    void     i_onAdapterChanged(IAudioAdapter *pAdapter);
    6869    void     i_onHostDeviceChanged(IHostAudioDevice *pDevice, bool fIsNew, AudioDeviceState_T enmState, IVirtualBoxErrorInfo *pErrInfo);
  • trunk/src/VBox/Main/src-server/AudioAdapterImpl.cpp

    r101313 r103395  
    234234    if (FAILED(autoCaller.hrc())) return autoCaller.hrc();
    235235
     236    /* the machine needs to be mutable */
     237    AutoMutableStateDependency adep(m->pParent->i_getMachine());
     238    if (FAILED(adep.hrc())) return adep.hrc();
     239
    236240    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    237241
     
    242246        alock.release();
    243247
    244         m->pParent->i_onSettingsChanged(); // mParent is const, needs no locking
     248        m->pParent->i_onSettingsChanged(); // m->pParent is const, needs no locking
    245249        m->pParent->i_onAdapterChanged(this);
    246250    }
     
    265269    AutoCaller autoCaller(this);
    266270    if (FAILED(autoCaller.hrc())) return autoCaller.hrc();
     271
     272    /* the machine needs to be mutable */
     273    AutoMutableOrSavedOrRunningStateDependency adep(m->pParent->i_getMachine());
     274    if (FAILED(adep.hrc())) return adep.hrc();
    267275
    268276    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    275283        alock.release();
    276284
    277         m->pParent->i_onSettingsChanged(); // mParent is const, needs no locking
     285        m->pParent->i_onSettingsChanged(); // m->pParent is const, needs no locking
    278286        m->pParent->i_onAdapterChanged(this);
    279287    }
     
    298306    AutoCaller autoCaller(this);
    299307    if (FAILED(autoCaller.hrc())) return autoCaller.hrc();
     308
     309    /* the machine needs to be mutable */
     310    AutoMutableOrSavedOrRunningStateDependency adep(m->pParent->i_getMachine());
     311    if (FAILED(adep.hrc())) return adep.hrc();
    300312
    301313    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    308320        alock.release();
    309321
    310         m->pParent->i_onSettingsChanged(); // mParent is const, needs no locking
     322        m->pParent->i_onSettingsChanged(); // m->pParent is const, needs no locking
    311323        m->pParent->i_onAdapterChanged(this);
    312324    }
     
    331343    AutoCaller autoCaller(this);
    332344    if (FAILED(autoCaller.hrc())) return autoCaller.hrc();
     345
     346    /* the machine needs to be mutable */
     347    AutoMutableOrSavedStateDependency adep(m->pParent->i_getMachine());
     348    if (FAILED(adep.hrc())) return adep.hrc();
    333349
    334350    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    345361            alock.release();
    346362
    347             m->pParent->i_onSettingsChanged(); // mParent is const, needs no locking
     363            m->pParent->i_onSettingsChanged(); // m->pParent is const, needs no locking
    348364        }
    349365        else
     
    373389    AutoCaller autoCaller(this);
    374390    if (FAILED(autoCaller.hrc())) return autoCaller.hrc();
     391
     392    /* the machine needs to be mutable */
     393    AutoMutableStateDependency adep(m->pParent->i_getMachine());
     394    if (FAILED(adep.hrc())) return adep.hrc();
    375395
    376396    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    415435            alock.release();
    416436
    417             m->pParent->i_onSettingsChanged(); // mParent is const, needs no locking
     437            m->pParent->i_onSettingsChanged(); // m->pParent is const, needs no locking
    418438        }
    419439    }
     
    438458    AutoCaller autoCaller(this);
    439459    if (FAILED(autoCaller.hrc())) return autoCaller.hrc();
     460
     461    /* the machine needs to be mutable */
     462    AutoMutableStateDependency adep(m->pParent->i_getMachine());
     463    if (FAILED(adep.hrc())) return adep.hrc();
    440464
    441465    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    494518        alock.release();
    495519
    496         m->pParent->i_onSettingsChanged(); // mParent is const, needs no locking
     520        m->pParent->i_onSettingsChanged(); // m->pParent is const, needs no locking
    497521    }
    498522
     
    539563    AutoCaller autoCaller(this);
    540564    if (FAILED(autoCaller.hrc())) return autoCaller.hrc();
     565
     566    /* the machine needs to be mutable */
     567    AutoMutableStateDependency adep(m->pParent->i_getMachine());
     568    if (FAILED(adep.hrc())) return adep.hrc();
    541569
    542570    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
  • trunk/src/VBox/Main/src-server/AudioSettingsImpl.cpp

    r98288 r103395  
    247247}
    248248
     249Machine *AudioSettings::i_getMachine(void)
     250{
     251    return m->pMachine; // m->pMachine is const, needs no locking
     252}
     253
    249254/**
    250255 * Gets called when the machine object needs to know that audio adapter settings
     
    256261{
    257262    AssertPtrReturnVoid(pAdapter);
    258     m->pMachine->i_onAudioAdapterChange(pAdapter); // mParent is const, needs no locking
     263    m->pMachine->i_onAudioAdapterChange(pAdapter); // m->pMachine is const, needs no locking
    259264}
    260265
     
    272277{
    273278    AssertPtrReturnVoid(pDevice);
    274     m->pMachine->i_onHostAudioDeviceChange(pDevice, fIsNew, enmState, pErrInfo); // mParent is const, needs no locking
     279    m->pMachine->i_onHostAudioDeviceChange(pDevice, fIsNew, enmState, pErrInfo); // m->pMachine is const, needs no locking
    275280}
    276281
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