Changeset 98728 in vbox
- Timestamp:
- Feb 24, 2023 4:27:05 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 156029
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp
r98727 r98728 47 47 /* COM includes: */ 48 48 #include "CAudioAdapter.h" 49 #include "CAudioSettings.h" 49 50 #include "CBooleanFormValue.h" 50 51 #include "CChoiceFormValue.h" … … 685 686 QApplication::translate("UIMessageCenter", "Graphics adapter failure ..."), 686 687 QApplication::translate("UIMessageCenter", "Failed to acquire graphics adapter parameter.") + 688 UIErrorString::formatErrorInfo(comAdapter)); 689 } 690 691 /* static */ 692 void UINotificationMessage::cannotAcquireAudioSettingsParameter(const CAudioSettings &comSettings) 693 { 694 createMessage( 695 QApplication::translate("UIMessageCenter", "Audio settings failure ..."), 696 QApplication::translate("UIMessageCenter", "Failed to acquire audio settings parameter.") + 697 UIErrorString::formatErrorInfo(comSettings)); 698 } 699 700 /* static */ 701 void UINotificationMessage::cannotAcquireAudioAdapterParameter(const CAudioAdapter &comAdapter) 702 { 703 createMessage( 704 QApplication::translate("UIMessageCenter", "Audio adapter failure ..."), 705 QApplication::translate("UIMessageCenter", "Failed to acquire audio adapter parameter.") + 687 706 UIErrorString::formatErrorInfo(comAdapter)); 688 707 } -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h
r98727 r98728 302 302 * @param comAdapter Brings the object parameter get acquired from. */ 303 303 static void cannotAcquireGraphicsAdapterParameter(const CGraphicsAdapter &comAdapter); 304 /** Notifies about inability to acquire IAudioSettings parameter. 305 * @param comSettings Brings the object parameter get acquired from. */ 306 static void cannotAcquireAudioSettingsParameter(const CAudioSettings &comSettings); 307 /** Notifies about inability to acquire IAudioAdapter parameter. 308 * @param comAdapter Brings the object parameter get acquired from. */ 309 static void cannotAcquireAudioAdapterParameter(const CAudioAdapter &comAdapter); 304 310 /** Notifies about inability to acquire IConsole parameter. 305 311 * @param comConsole Brings the object parameter get acquired from. */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp
r98727 r98728 249 249 { 250 250 /* Make sure Audio adapter is present: */ 251 const CAudioSettings comAudioSettings = uisession()->machine().GetAudioSettings(); 252 AssertMsgReturnVoid(uisession()->machine().isOk() && comAudioSettings.isNotNull(), 253 ("Audio audio settings should NOT be null!\n")); 254 const CAudioAdapter comAdapter = comAudioSettings.GetAdapter(); 255 AssertMsgReturnVoid(comAudioSettings.isOk() && comAdapter.isNotNull(), 256 ("Audio audio adapter should NOT be null!\n")); 251 bool fAdapterPresent = false; 252 acquireWhetherAudioAdapterPresent(fAdapterPresent); 253 AssertMsgReturnVoid(fAdapterPresent, 254 ("Audio adapter can't be null!\n")); 257 255 258 256 /* Check/Uncheck Audio adapter output/input actions depending on features status: */ 257 bool fAudioOutputEnabled = false; 258 bool fAudioInputEnabled = false; 259 acquireWhetherAudioAdapterOutputEnabled(fAudioOutputEnabled); 260 acquireWhetherAudioAdapterInputEnabled(fAudioInputEnabled); 259 261 actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Output)->blockSignals(true); 260 actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Output)->setChecked( comAdapter.GetEnabledOut());262 actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Output)->setChecked(fAudioOutputEnabled); 261 263 actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Output)->blockSignals(false); 262 264 actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Input)->blockSignals(true); 263 actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Input)->setChecked( comAdapter.GetEnabledIn());265 actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Input)->setChecked(fAudioInputEnabled); 264 266 actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Input)->blockSignals(false); 265 267 } … … 375 377 { 376 378 return uisession()->acquireCurrentSnapshotName(strName); 379 } 380 381 bool UIMachine::acquireWhetherAudioAdapterPresent(bool &fPresent) 382 { 383 return uisession()->acquireWhetherAudioAdapterPresent(fPresent); 384 } 385 386 bool UIMachine::acquireWhetherAudioAdapterEnabled(bool &fEnabled) 387 { 388 return uisession()->acquireWhetherAudioAdapterEnabled(fEnabled); 389 } 390 391 bool UIMachine::acquireWhetherAudioAdapterOutputEnabled(bool &fEnabled) 392 { 393 return uisession()->acquireWhetherAudioAdapterOutputEnabled(fEnabled); 394 } 395 396 bool UIMachine::acquireWhetherAudioAdapterInputEnabled(bool &fEnabled) 397 { 398 return uisession()->acquireWhetherAudioAdapterInputEnabled(fEnabled); 399 } 400 401 bool UIMachine::setAudioAdapterOutputEnabled(bool fEnabled) 402 { 403 return uisession()->setAudioAdapterOutputEnabled(fEnabled); 404 } 405 406 bool UIMachine::setAudioAdapterInputEnabled(bool fEnabled) 407 { 408 return uisession()->setAudioAdapterInputEnabled(fEnabled); 377 409 } 378 410 … … 1666 1698 /* Audio stuff: */ 1667 1699 { 1668 /* Check whether audio controller is enabled. */ 1669 const CAudioSettings comAudioSettings = uisession()->machine().GetAudioSettings(); 1670 const CAudioAdapter comAudioAdapter = comAudioSettings.GetAdapter(); 1671 if (comAudioAdapter.isNull() || !comAudioAdapter.GetEnabled()) 1700 /* Check whether audio adapter is present & enabled: */ 1701 bool fAdapterPresent = false; 1702 bool fAdapterEnabled = false; 1703 acquireWhetherAudioAdapterPresent(fAdapterPresent); 1704 acquireWhetherAudioAdapterEnabled(fAdapterEnabled); 1705 if (!fAdapterPresent || !fAdapterEnabled) 1672 1706 restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType) 1673 1707 (restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Audio); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h
r98727 r98728 260 260 /** Acquires current snapshot name. */ 261 261 bool acquireCurrentSnapshotName(QString &strName); 262 /** @} */ 263 264 /** @name Audio stuff. 265 ** @{ */ 266 /** Acquires whether audio adapter is present. */ 267 bool acquireWhetherAudioAdapterPresent(bool &fPresent); 268 /** Acquires whether audio adapter is enabled. */ 269 bool acquireWhetherAudioAdapterEnabled(bool &fEnabled); 270 /** Acquires whether audio adapter output is enabled. */ 271 bool acquireWhetherAudioAdapterOutputEnabled(bool &fEnabled); 272 /** Acquires whether audio adapter input is enabled. */ 273 bool acquireWhetherAudioAdapterInputEnabled(bool &fEnabled); 274 /** Defines whether audio adapter output is enabled. */ 275 bool setAudioAdapterOutputEnabled(bool fEnabled); 276 /** Defines whether audio adapter input is enabled. */ 277 bool setAudioAdapterInputEnabled(bool fEnabled); 262 278 /** @} */ 263 279 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r98727 r98728 2173 2173 return; 2174 2174 2175 /* Access audio adapter: */2176 CAudioSettings const comAudioSettings = machine().GetAudioSettings();2177 CAudioAdapter comAdapter = comAudioSettings.GetAdapter();2178 AssertMsgReturnVoid( machine().isOk() && comAdapter.isNotNull(),2175 /* Make sure audio adapter present: */ 2176 bool fAdapterPresent = false; 2177 uimachine()->acquireWhetherAudioAdapterPresent(fAdapterPresent); 2178 AssertMsgReturnVoid(fAdapterPresent, 2179 2179 ("Audio adapter should NOT be null!\n")); 2180 2180 2181 2181 /* Make sure something had changed: */ 2182 if (comAdapter.GetEnabledOut() == static_cast<BOOL>(fEnabled)) 2183 return; 2184 2185 /* Update audio output state: */ 2186 comAdapter.SetEnabledOut(fEnabled); 2187 if (!comAdapter.isOk()) 2188 { 2189 /* Make sure action is updated: */ 2190 uimachine()->updateStateAudioActions(); 2191 /* Notify about the error: */ 2192 return UINotificationMessage::cannotToggleAudioOutput(comAdapter, machineName(), fEnabled); 2193 } 2194 2195 /* Save machine-settings, make sure action is updated in case of failure: */ 2196 if (!uimachine()->saveSettings()) 2182 bool fAudioOutputEnabled = false; 2183 uimachine()->acquireWhetherAudioAdapterOutputEnabled(fAudioOutputEnabled); 2184 if (fAudioOutputEnabled == fEnabled) 2185 return; 2186 2187 /* Update and save audio adapter output state, 2188 * make sure action is updated in case of failure: */ 2189 if ( !uimachine()->setAudioAdapterOutputEnabled(fEnabled) 2190 || !uimachine()->saveSettings()) 2197 2191 return uimachine()->updateStateAudioActions(); 2198 2192 } … … 2204 2198 return; 2205 2199 2206 /* Access audio adapter: */2207 CAudioSettings const comAudioSettings = machine().GetAudioSettings();2208 CAudioAdapter comAdapter = comAudioSettings.GetAdapter();2209 AssertMsgReturnVoid( machine().isOk() && comAdapter.isNotNull(),2200 /* Make sure audio adapter present: */ 2201 bool fAdapterPresent = false; 2202 uimachine()->acquireWhetherAudioAdapterPresent(fAdapterPresent); 2203 AssertMsgReturnVoid(fAdapterPresent, 2210 2204 ("Audio adapter should NOT be null!\n")); 2211 2205 2212 2206 /* Make sure something had changed: */ 2213 if (comAdapter.GetEnabledIn() == static_cast<BOOL>(fEnabled)) 2214 return; 2215 2216 /* Update audio input state: */ 2217 comAdapter.SetEnabledIn(fEnabled); 2218 if (!comAdapter.isOk()) 2219 { 2220 /* Make sure action is updated: */ 2221 uimachine()->updateStateAudioActions(); 2222 /* Notify about the error: */ 2223 return UINotificationMessage::cannotToggleAudioInput(comAdapter, machineName(), fEnabled); 2224 } 2225 2226 /* Save machine-settings, make sure action is updated in case of failure: */ 2227 if (!uimachine()->saveSettings()) 2207 bool fAudioInputEnabled = false; 2208 uimachine()->acquireWhetherAudioAdapterInputEnabled(fAudioInputEnabled); 2209 if (fAudioInputEnabled == fEnabled) 2210 return; 2211 2212 /* Update and save audio adapter input state, 2213 * make sure action is updated in case of failure: */ 2214 if ( !uimachine()->setAudioAdapterInputEnabled(fEnabled) 2215 || !uimachine()->saveSettings()) 2228 2216 return uimachine()->updateStateAudioActions(); 2229 2217 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r98727 r98728 57 57 58 58 /* COM includes: */ 59 #include "CAudioAdapter.h" 60 #include "CAudioSettings.h" 59 61 #include "CEmulatedUSB.h" 60 62 #include "CGraphicsAdapter.h" … … 674 676 } 675 677 678 bool UISession::acquireWhetherAudioAdapterPresent(bool &fPresent) 679 { 680 CMachine comMachine = machine(); 681 CAudioSettings comSettings = comMachine.GetAudioSettings(); 682 const bool fSuccess = comMachine.isOk(); 683 if (!fSuccess) 684 UINotificationMessage::cannotAcquireMachineParameter(comMachine); 685 else 686 { 687 CAudioAdapter comAdapter = comSettings.GetAdapter(); 688 fPresent = comSettings.isOk() && comAdapter.isNotNull(); 689 } 690 return fSuccess; 691 } 692 693 bool UISession::acquireWhetherAudioAdapterEnabled(bool &fEnabled) 694 { 695 CMachine comMachine = machine(); 696 CAudioSettings comSettings = comMachine.GetAudioSettings(); 697 bool fSuccess = comMachine.isOk(); 698 if (!fSuccess) 699 UINotificationMessage::cannotAcquireMachineParameter(comMachine); 700 else 701 { 702 CAudioAdapter comAdapter = comSettings.GetAdapter(); 703 fSuccess = comSettings.isOk(); 704 if (!fSuccess) 705 UINotificationMessage::cannotAcquireAudioSettingsParameter(comSettings); 706 { 707 const BOOL fAdapterEnabled = comAdapter.GetEnabled(); 708 fSuccess = comAdapter.isOk(); 709 if (!fSuccess) 710 UINotificationMessage::cannotAcquireAudioAdapterParameter(comAdapter); 711 else 712 fEnabled = fAdapterEnabled == TRUE; 713 } 714 } 715 return fSuccess; 716 } 717 718 bool UISession::acquireWhetherAudioAdapterOutputEnabled(bool &fEnabled) 719 { 720 CMachine comMachine = machine(); 721 CAudioSettings comSettings = comMachine.GetAudioSettings(); 722 bool fSuccess = comMachine.isOk(); 723 if (!fSuccess) 724 UINotificationMessage::cannotAcquireMachineParameter(comMachine); 725 else 726 { 727 CAudioAdapter comAdapter = comSettings.GetAdapter(); 728 fSuccess = comSettings.isOk(); 729 if (!fSuccess) 730 UINotificationMessage::cannotAcquireAudioSettingsParameter(comSettings); 731 { 732 const BOOL fOutputEnabled = comAdapter.GetEnabledOut(); 733 fSuccess = comAdapter.isOk(); 734 if (!fSuccess) 735 UINotificationMessage::cannotAcquireAudioAdapterParameter(comAdapter); 736 else 737 fEnabled = fOutputEnabled == TRUE; 738 } 739 } 740 return fSuccess; 741 } 742 743 bool UISession::acquireWhetherAudioAdapterInputEnabled(bool &fEnabled) 744 { 745 CMachine comMachine = machine(); 746 CAudioSettings comSettings = comMachine.GetAudioSettings(); 747 bool fSuccess = comMachine.isOk(); 748 if (!fSuccess) 749 UINotificationMessage::cannotAcquireMachineParameter(comMachine); 750 else 751 { 752 CAudioAdapter comAdapter = comSettings.GetAdapter(); 753 fSuccess = comSettings.isOk(); 754 if (!fSuccess) 755 UINotificationMessage::cannotAcquireAudioSettingsParameter(comSettings); 756 { 757 const BOOL fInputEnabled = comAdapter.GetEnabledIn(); 758 fSuccess = comAdapter.isOk(); 759 if (!fSuccess) 760 UINotificationMessage::cannotAcquireAudioAdapterParameter(comAdapter); 761 else 762 fEnabled = fInputEnabled == TRUE; 763 } 764 } 765 return fSuccess; 766 } 767 768 bool UISession::setAudioAdapterOutputEnabled(bool fEnabled) 769 { 770 CMachine comMachine = machine(); 771 CAudioSettings comSettings = comMachine.GetAudioSettings(); 772 bool fSuccess = comMachine.isOk(); 773 if (!fSuccess) 774 UINotificationMessage::cannotAcquireMachineParameter(comMachine); 775 else 776 { 777 CAudioAdapter comAdapter = comSettings.GetAdapter(); 778 fSuccess = comSettings.isOk(); 779 if (!fSuccess) 780 UINotificationMessage::cannotAcquireAudioSettingsParameter(comSettings); 781 { 782 comAdapter.SetEnabledOut(fEnabled); 783 fSuccess = comAdapter.isOk(); 784 if (!fSuccess) 785 UINotificationMessage::cannotToggleAudioOutput(comAdapter, machineName(), fEnabled); 786 } 787 } 788 return fSuccess; 789 } 790 791 bool UISession::setAudioAdapterInputEnabled(bool fEnabled) 792 { 793 CMachine comMachine = machine(); 794 CAudioSettings comSettings = comMachine.GetAudioSettings(); 795 bool fSuccess = comMachine.isOk(); 796 if (!fSuccess) 797 UINotificationMessage::cannotAcquireMachineParameter(comMachine); 798 else 799 { 800 CAudioAdapter comAdapter = comSettings.GetAdapter(); 801 fSuccess = comSettings.isOk(); 802 if (!fSuccess) 803 UINotificationMessage::cannotAcquireAudioSettingsParameter(comSettings); 804 { 805 comAdapter.SetEnabledIn(fEnabled); 806 fSuccess = comAdapter.isOk(); 807 if (!fSuccess) 808 UINotificationMessage::cannotToggleAudioInput(comAdapter, machineName(), fEnabled); 809 } 810 } 811 return fSuccess; 812 } 813 676 814 UIFrameBuffer *UISession::frameBuffer(ulong uScreenId) const 677 815 { -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r98727 r98728 335 335 /** Returns whether GA can be upgraded. */ 336 336 bool guestAdditionsUpgradable(); 337 /** @} */ 338 339 /** @name Audio stuff. 340 ** @{ */ 341 /** Acquires whether audio adapter is present. */ 342 bool acquireWhetherAudioAdapterPresent(bool &fPresent); 343 /** Acquires whether audio adapter is enabled. */ 344 bool acquireWhetherAudioAdapterEnabled(bool &fEnabled); 345 /** Acquires whether audio adapter output is enabled. */ 346 bool acquireWhetherAudioAdapterOutputEnabled(bool &fEnabled); 347 /** Acquires whether audio adapter input is enabled. */ 348 bool acquireWhetherAudioAdapterInputEnabled(bool &fEnabled); 349 /** Defines whether audio adapter output is enabled. */ 350 bool setAudioAdapterOutputEnabled(bool fEnabled); 351 /** Defines whether audio adapter input is enabled. */ 352 bool setAudioAdapterInputEnabled(bool fEnabled); 337 353 /** @} */ 338 354
Note:
See TracChangeset
for help on using the changeset viewer.