Changeset 98028 in vbox for trunk/src/VBox/Main/src-server/AudioSettingsImpl.cpp
- Timestamp:
- Jan 9, 2023 9:46:16 AM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 155122
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/AudioSettingsImpl.cpp
r96407 r98028 48 48 { 49 49 Data() 50 : p Parent(NULL)50 : pMachine(NULL) 51 51 { } 52 52 53 Machine * const p Parent;53 Machine * const pMachine; 54 54 const ComObjPtr<AudioAdapter> pAdapter; 55 55 const ComObjPtr<AudioSettings> pPeer; … … 76 76 * Initializes the audio settings object. 77 77 * 78 * @param aParent Handle of the parent object. 78 * @returns HRESULT 79 * @param aParent Pointer of the parent object. 79 80 */ 80 81 HRESULT AudioSettings::init(Machine *aParent) 81 82 { 82 LogFlowThisFunc(("aParent=%p\n", aParent));83 84 83 ComAssertRet(aParent, E_INVALIDARG); 85 84 … … 91 90 92 91 /* share the parent weakly */ 93 unconst(m->p Parent) = aParent;92 unconst(m->pMachine) = aParent; 94 93 95 94 /* create the audio adapter object (always present, default is disabled) */ … … 109 108 * 110 109 * @note This object must be destroyed before the original object 111 * it shares data with is destroyed.110 * it shares data with is destroyed. 112 111 * 113 112 * @note Locks @a aThat object for reading. 113 * 114 * @returns HRESULT 115 * @param aParent Pointer of the parent object. 116 * @param aThat Pointer to audio adapter to use settings from. 114 117 */ 115 118 HRESULT AudioSettings::init(Machine *aParent, AudioSettings *aThat) 116 119 { 117 LogFlowThisFuncEnter();118 LogFlowThisFunc(("aParent: %p, aThat: %p\n", aParent, aThat));119 120 120 ComAssertRet(aParent && aThat, E_INVALIDARG); 121 121 … … 126 126 m = new Data(); 127 127 128 unconst(m->p Parent) = aParent;129 unconst(m->pPeer) = aThat;128 unconst(m->pMachine) = aParent; 129 unconst(m->pPeer) = aThat; 130 130 131 131 AutoCaller thatCaller(aThat); … … 134 134 AutoReadLock thatlock(aThat COMMA_LOCKVAL_SRC_POS); 135 135 136 unconst(m->pAdapter) = aThat->m->pAdapter; 136 HRESULT hrc = unconst(m->pAdapter).createObject(); 137 ComAssertComRCRet(hrc, hrc); 138 hrc = m->pAdapter->init(this, aThat->m->pAdapter); 139 ComAssertComRCRet(hrc, hrc); 137 140 138 141 autoInitSpan.setSucceeded(); 139 142 140 LogFlowThisFuncLeave();141 143 return S_OK; 142 144 } … … 148 150 * 149 151 * @note Locks @a aThat object for reading. 152 * 153 * @returns HRESULT 154 * @param aParent Pointer of the parent object. 155 * @param aThat Pointer to audio adapter to use settings from. 150 156 */ 151 157 HRESULT AudioSettings::initCopy(Machine *aParent, AudioSettings *aThat) 152 158 { 153 LogFlowThisFuncEnter();154 LogFlowThisFunc(("aParent: %p, aThat: %p\n", aParent, aThat));155 156 159 ComAssertRet(aParent && aThat, E_INVALIDARG); 157 160 … … 162 165 m = new Data(); 163 166 164 unconst(m->p Parent) = aParent;167 unconst(m->pMachine) = aParent; 165 168 // pPeer is left null 166 169 … … 175 178 autoInitSpan.setSucceeded(); 176 179 177 LogFlowThisFuncLeave();178 180 return S_OK; 179 181 } … … 185 187 void AudioSettings::uninit(void) 186 188 { 187 LogFlowThisFunc(("\n"));188 189 189 /* Enclose the state transition Ready->InUninit->NotReady */ 190 190 AutoUninitSpan autoUninitSpan(this); … … 192 192 return; 193 193 194 unconst(m->pPeer) = NULL; 195 unconst(m->pMachine) = NULL; 196 194 197 delete m; 195 198 m = NULL; … … 230 233 231 234 /** 232 * Returns the parent object as a weak pointer.233 */234 Machine* AudioSettings::i_getParent(void)235 {236 AutoCaller autoCaller(this);237 AssertComRCReturn(autoCaller.rc(), NULL);238 239 AssertPtrReturn(m, NULL);240 return m->pParent;241 }242 243 /**244 235 * Determines whether the audio settings currently can be changed or not. 245 236 * … … 248 239 bool AudioSettings::i_canChangeSettings(void) 249 240 { 250 AutoAnyStateDependency adep(m->p Parent);241 AutoAnyStateDependency adep(m->pMachine); 251 242 if (FAILED(adep.rc())) 252 243 return false; … … 259 250 * Gets called when the machine object needs to know that audio adapter settings 260 251 * have been changed. 252 * 253 * @param pAdapter Pointer to audio adapter which has changed. 261 254 */ 262 255 void AudioSettings::i_onAdapterChanged(IAudioAdapter *pAdapter) 263 256 { 264 LogFlowThisFuncEnter();265 266 257 AssertPtrReturnVoid(pAdapter); 267 268 m->pParent->i_onAudioAdapterChange(pAdapter); // mParent is const, needs no locking 269 270 LogFlowThisFuncLeave(); 258 m->pMachine->i_onAudioAdapterChange(pAdapter); // mParent is const, needs no locking 271 259 } 272 260 … … 274 262 * Gets called when the machine object needs to know that a host audio device 275 263 * has been changed. 264 * 265 * @param pDevice Host audio device which has changed. 266 * @param fIsNew Set to \c true if this is a new device (i.e. has not been present before), \c false if not. 267 * @param enmState The current state of the device. 268 * @param pErrInfo Additional error information in case of error(s). 276 269 */ 277 270 void AudioSettings::i_onHostDeviceChanged(IHostAudioDevice *pDevice, 278 271 bool fIsNew, AudioDeviceState_T enmState, IVirtualBoxErrorInfo *pErrInfo) 279 272 { 280 LogFlowThisFuncEnter();281 282 273 AssertPtrReturnVoid(pDevice); 283 284 m->pParent->i_onHostAudioDeviceChange(pDevice, fIsNew, enmState, pErrInfo); // mParent is const, needs no locking 285 286 LogFlowThisFuncLeave(); 274 m->pMachine->i_onHostAudioDeviceChange(pDevice, fIsNew, enmState, pErrInfo); // mParent is const, needs no locking 287 275 } 288 276 … … 293 281 void AudioSettings::i_onSettingsChanged(void) 294 282 { 295 LogFlowThisFuncEnter(); 296 297 AutoWriteLock mlock(m->pParent COMMA_LOCKVAL_SRC_POS); 298 m->pParent->i_setModified(Machine::IsModified_AudioSettings); 283 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 284 m->pMachine->i_setModified(Machine::IsModified_AudioSettings); 299 285 mlock.release(); 300 301 LogFlowThisFuncLeave();302 286 } 303 287 … … 306 290 * May be called once right after this object creation. 307 291 * 308 * @param data Configuration settings. 292 * @returns HRESULT 293 * @param data Audio adapter configuration settings to load from. 309 294 * 310 295 * @note Locks this object for writing. … … 324 309 325 310 /** 326 * Saves settings to the given node. 327 * 328 * @param data Configuration settings. 311 * Saves audio settings to the given machine node. 312 * 313 * @returns HRESULT 314 * @param data Audio configuration settings to save to. 329 315 * 330 316 * @note Locks this object for reading. … … 344 330 345 331 /** 332 * Copies settings from a given audio settings object. 333 * 334 * This object makes a private copy of data of the original object passed as 335 * an argument. 336 * 346 337 * @note Locks this object for writing, together with the peer object 347 * represented by @a aThat (locked for reading). 338 * represented by @a aThat (locked for reading). 339 * 340 * @param aThat Audio settings to load from. 348 341 */ 349 342 void AudioSettings::i_copyFrom(AudioSettings *aThat) … … 406 399 407 400 /** 401 * Rolls back the current configuration to a former state. 402 * 408 403 * @note Locks this object for writing. 409 404 */ … … 422 417 423 418 /** 419 * Commits the current settings and propagates those to a peer (if assigned). 420 * 424 421 * @note Locks this object for writing, together with the peer object (also 425 * for writing) if there is one.422 * for writing) if there is one. 426 423 */ 427 424 void AudioSettings::i_commit(void)
Note:
See TracChangeset
for help on using the changeset viewer.