儲存庫 vbox 的更動 30934
圖例:
- 未更動
- 新增
- 刪除
-
trunk/include/VBox/settings.h
r30764 r30934 883 883 std::list<xml::ElementNode*> *pllElementsWithUuidAttributes); 884 884 885 static bool isAudioDriverAllowedOnThisHost(AudioDriverType_T drv); 886 static AudioDriverType_T getHostDefaultAudioDriver(); 887 885 888 private: 886 889 void readNetworkAdapters(const xml::ElementNode &elmHardware, NetworkAdaptersList &ll); … … 890 893 void readSerialPorts(const xml::ElementNode &elmUART, SerialPortsList &ll); 891 894 void readParallelPorts(const xml::ElementNode &elmLPT, ParallelPortsList &ll); 895 void readAudioAdapter(const xml::ElementNode &elmAudioAdapter, AudioAdapter &aa); 892 896 void readGuestProperties(const xml::ElementNode &elmGuestProperties, Hardware &hw); 893 897 void readStorageControllerAttributes(const xml::ElementNode &elmStorageController, StorageController &sctl); -
trunk/src/VBox/Main/AudioAdapterImpl.cpp
r28800 r30934 246 246 if (mData->mAudioDriver != aAudioDriver) 247 247 { 248 /* 249 * which audio driver type are we supposed to use? 250 */ 251 switch (aAudioDriver) 248 if (settings::MachineConfigFile::isAudioDriverAllowedOnThisHost(aAudioDriver)) 252 249 { 253 case AudioDriverType_Null: 254 #ifdef RT_OS_WINDOWS 255 # ifdef VBOX_WITH_WINMM 256 case AudioDriverType_WinMM: 257 # endif 258 case AudioDriverType_DirectSound: 259 #endif /* RT_OS_WINDOWS */ 260 #ifdef RT_OS_SOLARIS 261 case AudioDriverType_SolAudio: 262 #endif 263 #ifdef RT_OS_LINUX 264 # ifdef VBOX_WITH_ALSA 265 case AudioDriverType_ALSA: 266 # endif 267 # ifdef VBOX_WITH_PULSE 268 case AudioDriverType_Pulse: 269 # endif 270 #endif /* RT_OS_LINUX */ 271 #if defined (RT_OS_LINUX) || defined (RT_OS_FREEBSD) || defined(VBOX_WITH_SOLARIS_OSS) 272 case AudioDriverType_OSS: 273 #endif 274 #ifdef RT_OS_FREEBSD 275 # ifdef VBOX_WITH_PULSE 276 case AudioDriverType_Pulse: 277 # endif 278 #endif 279 #ifdef RT_OS_DARWIN 280 case AudioDriverType_CoreAudio: 281 #endif 282 #ifdef RT_OS_OS2 283 case AudioDriverType_MMPM: 284 #endif 285 { 286 mData.backup(); 287 mData->mAudioDriver = aAudioDriver; 288 289 alock.release(); 290 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking 291 mParent->setModified(Machine::IsModified_AudioAdapter); 292 break; 293 } 294 295 default: 296 { 297 AssertMsgFailed (("Wrong audio driver type %d\n", 298 aAudioDriver)); 299 rc = E_FAIL; 300 } 250 mData.backup(); 251 mData->mAudioDriver = aAudioDriver; 252 253 alock.release(); 254 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking 255 mParent->setModified(Machine::IsModified_AudioAdapter); 256 } 257 else 258 { 259 AssertMsgFailed(("Wrong audio driver type %d\n", aAudioDriver)); 260 rc = E_FAIL; 301 261 } 302 262 } -
trunk/src/VBox/Main/MachineImpl.cpp
r30931 r30934 367 367 * Initializes a new instance with data from machine XML (formerly Init_Registered). 368 368 * Gets called in two modes: 369 * 369 370 * -- from VirtualBox::initMachines() during VirtualBox startup; in that case, the 370 371 * UUID is specified and we mark the machine as "registered"; 372 * 371 373 * -- from the public VirtualBox::OpenMachine() API, in which case the UUID is NULL 372 374 * and the machine remains unregistered until RegisterMachine() is called. … … 458 460 /** 459 461 * Initializes a new instance from a machine config that is already in memory 460 * (import OVF importcase). Since we are importing, the UUID in the machine462 * (import OVF case). Since we are importing, the UUID in the machine 461 463 * config is ignored and we always generate a fresh one. 462 464 * -
trunk/src/VBox/Main/SystemPropertiesImpl.cpp
r30842 r30934 29 29 #include <iprt/path.h> 30 30 #include <iprt/dir.h> 31 #include <iprt/process.h>32 #include <iprt/ldr.h>33 31 #include <iprt/cpp/utils.h> 34 32 … … 117 115 } 118 116 } 119 120 /* Driver defaults which are OS specific */121 #if defined(RT_OS_WINDOWS)122 # ifdef VBOX_WITH_WINMM123 mDefaultAudioDriver = AudioDriverType_WinMM;124 # else /* VBOX_WITH_WINMM */125 mDefaultAudioDriver = AudioDriverType_DirectSound;126 # endif /* !VBOX_WITH_WINMM */127 #elif defined(RT_OS_SOLARIS)128 mDefaultAudioDriver = AudioDriverType_SolAudio;129 #elif defined(RT_OS_LINUX)130 # if defined(VBOX_WITH_PULSE)131 /* Check for the pulse library & that the pulse audio daemon is running. */132 if (RTProcIsRunningByName("pulseaudio") &&133 RTLdrIsLoadable("libpulse.so.0"))134 mDefaultAudioDriver = AudioDriverType_Pulse;135 else136 # endif /* VBOX_WITH_PULSE */137 # if defined(VBOX_WITH_ALSA)138 /* Check if we can load the ALSA library */139 if (RTLdrIsLoadable("libasound.so.2"))140 mDefaultAudioDriver = AudioDriverType_ALSA;141 else142 # endif /* VBOX_WITH_ALSA */143 mDefaultAudioDriver = AudioDriverType_OSS;144 #elif defined(RT_OS_DARWIN)145 mDefaultAudioDriver = AudioDriverType_CoreAudio;146 #elif defined(RT_OS_OS2)147 mDefaultAudioDriver = AudioDriverType_MMP;148 #elif defined(RT_OS_FREEBSD)149 mDefaultAudioDriver = AudioDriverType_OSS;150 #else151 mDefaultAudioDriver = AudioDriverType_Null;152 #endif153 117 154 118 /* Confirm a successful initialization */ … … 805 769 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 806 770 807 *aAudioDriver = mDefaultAudioDriver;771 *aAudioDriver = settings::MachineConfigFile::getHostDefaultAudioDriver(); 808 772 809 773 return S_OK; -
trunk/src/VBox/Main/include/SystemPropertiesImpl.h
r30764 r30934 136 136 Utf8Str m_strWebServiceAuthLibrary; 137 137 ULONG mLogHistoryCount; 138 AudioDriverType_T mDefaultAudioDriver;139 138 140 139 friend class VirtualBox; -
trunk/src/VBox/Main/xml/Settings.cpp
r30286 r30934 60 60 #include <iprt/ctype.h> 61 61 #include <iprt/file.h> 62 #include <iprt/process.h> 63 #include <iprt/ldr.h> 64 #include <iprt/cpp/lock.h> 62 65 63 66 // generated header … … 2026 2029 2027 2030 /** 2031 * Called from MachineConfigFile::readHardware() to read audio adapter information 2032 * and maybe fix driver information depending on the current host hardware. 2033 * 2034 * @param elmAudioAdapter "AudioAdapter" XML element. 2035 * @param hw 2036 */ 2037 void MachineConfigFile::readAudioAdapter(const xml::ElementNode &elmAudioAdapter, 2038 AudioAdapter &aa) 2039 { 2040 elmAudioAdapter.getAttributeValue("enabled", aa.fEnabled); 2041 2042 Utf8Str strTemp; 2043 if (elmAudioAdapter.getAttributeValue("controller", strTemp)) 2044 { 2045 if (strTemp == "SB16") 2046 aa.controllerType = AudioControllerType_SB16; 2047 else if (strTemp == "AC97") 2048 aa.controllerType = AudioControllerType_AC97; 2049 else 2050 throw ConfigFileError(this, &elmAudioAdapter, N_("Invalid value '%s' in AudioAdapter/@controller attribute"), strTemp.c_str()); 2051 } 2052 2053 if (elmAudioAdapter.getAttributeValue("driver", strTemp)) 2054 { 2055 // settings before 1.3 used lower case so make sure this is case-insensitive 2056 strTemp.toUpper(); 2057 if (strTemp == "NULL") 2058 aa.driverType = AudioDriverType_Null; 2059 else if (strTemp == "WINMM") 2060 aa.driverType = AudioDriverType_WinMM; 2061 else if ( (strTemp == "DIRECTSOUND") || (strTemp == "DSOUND") ) 2062 aa.driverType = AudioDriverType_DirectSound; 2063 else if (strTemp == "SOLAUDIO") 2064 aa.driverType = AudioDriverType_SolAudio; 2065 else if (strTemp == "ALSA") 2066 aa.driverType = AudioDriverType_ALSA; 2067 else if (strTemp == "PULSE") 2068 aa.driverType = AudioDriverType_Pulse; 2069 else if (strTemp == "OSS") 2070 aa.driverType = AudioDriverType_OSS; 2071 else if (strTemp == "COREAUDIO") 2072 aa.driverType = AudioDriverType_CoreAudio; 2073 else if (strTemp == "MMPM") 2074 aa.driverType = AudioDriverType_MMPM; 2075 else 2076 throw ConfigFileError(this, &elmAudioAdapter, N_("Invalid value '%s' in AudioAdapter/@driver attribute"), strTemp.c_str()); 2077 2078 // now check if this is actually supported on the current host platform; 2079 // people might be opening a file created on a Windows host, and that 2080 // VM should still start on a Linux host 2081 if (!isAudioDriverAllowedOnThisHost(aa.driverType)) 2082 aa.driverType = getHostDefaultAudioDriver(); 2083 } 2084 } 2085 2086 /** 2028 2087 * Called from MachineConfigFile::readHardware() to read guest property information. 2029 2088 * @param elmGuestProperties … … 2415 2474 readParallelPorts(*pelmHwChild, hw.llParallelPorts); 2416 2475 else if (pelmHwChild->nameEquals("AudioAdapter")) 2417 { 2418 pelmHwChild->getAttributeValue("enabled", hw.audioAdapter.fEnabled); 2419 2420 Utf8Str strTemp; 2421 if (pelmHwChild->getAttributeValue("controller", strTemp)) 2422 { 2423 if (strTemp == "SB16") 2424 hw.audioAdapter.controllerType = AudioControllerType_SB16; 2425 else if (strTemp == "AC97") 2426 hw.audioAdapter.controllerType = AudioControllerType_AC97; 2427 else 2428 throw ConfigFileError(this, pelmHwChild, N_("Invalid value '%s' in AudioAdapter/@controller attribute"), strTemp.c_str()); 2429 } 2430 if (pelmHwChild->getAttributeValue("driver", strTemp)) 2431 { 2432 // settings before 1.3 used lower case so make sure this is case-insensitive 2433 strTemp.toUpper(); 2434 if (strTemp == "NULL") 2435 hw.audioAdapter.driverType = AudioDriverType_Null; 2436 else if (strTemp == "WINMM") 2437 hw.audioAdapter.driverType = AudioDriverType_WinMM; 2438 else if ( (strTemp == "DIRECTSOUND") || (strTemp == "DSOUND") ) 2439 hw.audioAdapter.driverType = AudioDriverType_DirectSound; 2440 else if (strTemp == "SOLAUDIO") 2441 hw.audioAdapter.driverType = AudioDriverType_SolAudio; 2442 else if (strTemp == "ALSA") 2443 hw.audioAdapter.driverType = AudioDriverType_ALSA; 2444 else if (strTemp == "PULSE") 2445 hw.audioAdapter.driverType = AudioDriverType_Pulse; 2446 else if (strTemp == "OSS") 2447 hw.audioAdapter.driverType = AudioDriverType_OSS; 2448 else if (strTemp == "COREAUDIO") 2449 hw.audioAdapter.driverType = AudioDriverType_CoreAudio; 2450 else if (strTemp == "MMPM") 2451 hw.audioAdapter.driverType = AudioDriverType_MMPM; 2452 else 2453 throw ConfigFileError(this, pelmHwChild, N_("Invalid value '%s' in AudioAdapter/@driver attribute"), strTemp.c_str()); 2454 } 2455 } 2476 readAudioAdapter(*pelmHwChild, hw.audioAdapter); 2456 2477 else if (pelmHwChild->nameEquals("SharedFolders")) 2457 2478 { … … 3906 3927 3907 3928 /** 3929 * Returns true only if the given AudioDriverType is supported on 3930 * the current host platform. For example, this would return false 3931 * for AudioDriverType_DirectSound when compiled on a Linux host. 3932 * @param drv AudioDriverType_* enum to test. 3933 * @return true only if the current host supports that driver. 3934 */ 3935 /*static*/ 3936 bool MachineConfigFile::isAudioDriverAllowedOnThisHost(AudioDriverType_T drv) 3937 { 3938 switch (drv) 3939 { 3940 case AudioDriverType_Null: 3941 #ifdef RT_OS_WINDOWS 3942 # ifdef VBOX_WITH_WINMM 3943 case AudioDriverType_WinMM: 3944 # endif 3945 case AudioDriverType_DirectSound: 3946 #endif /* RT_OS_WINDOWS */ 3947 #ifdef RT_OS_SOLARIS 3948 case AudioDriverType_SolAudio: 3949 #endif 3950 #ifdef RT_OS_LINUX 3951 # ifdef VBOX_WITH_ALSA 3952 case AudioDriverType_ALSA: 3953 # endif 3954 # ifdef VBOX_WITH_PULSE 3955 case AudioDriverType_Pulse: 3956 # endif 3957 #endif /* RT_OS_LINUX */ 3958 #if defined (RT_OS_LINUX) || defined (RT_OS_FREEBSD) || defined(VBOX_WITH_SOLARIS_OSS) 3959 case AudioDriverType_OSS: 3960 #endif 3961 #ifdef RT_OS_FREEBSD 3962 # ifdef VBOX_WITH_PULSE 3963 case AudioDriverType_Pulse: 3964 # endif 3965 #endif 3966 #ifdef RT_OS_DARWIN 3967 case AudioDriverType_CoreAudio: 3968 #endif 3969 #ifdef RT_OS_OS2 3970 case AudioDriverType_MMPM: 3971 #endif 3972 return true; 3973 } 3974 3975 return false; 3976 } 3977 3978 /** 3979 * Returns the AudioDriverType_* which should be used by default on this 3980 * host platform. On Linux, this will check at runtime whether PulseAudio 3981 * or ALSA are actually supported on the first call. 3982 * @return 3983 */ 3984 /*static*/ 3985 AudioDriverType_T MachineConfigFile::getHostDefaultAudioDriver() 3986 { 3987 #if defined(RT_OS_WINDOWS) 3988 # ifdef VBOX_WITH_WINMM 3989 return AudioDriverType_WinMM; 3990 # else /* VBOX_WITH_WINMM */ 3991 return AudioDriverType_DirectSound; 3992 # endif /* !VBOX_WITH_WINMM */ 3993 #elif defined(RT_OS_SOLARIS) 3994 return AudioDriverType_SolAudio; 3995 #elif defined(RT_OS_LINUX) 3996 // on Linux, we need to check at runtime what's actually supported... 3997 static RTLockMtx s_mtx; 3998 static AudioDriverType_T s_linuxDriver = -1; 3999 RTLock lock(s_mtx); 4000 if (s_linuxDriver == (AudioDriverType_T)-1) 4001 { 4002 # if defined(VBOX_WITH_PULSE) 4003 /* Check for the pulse library & that the pulse audio daemon is running. */ 4004 if (RTProcIsRunningByName("pulseaudio") && 4005 RTLdrIsLoadable("libpulse.so.0")) 4006 s_linuxDriver = AudioDriverType_Pulse; 4007 else 4008 # endif /* VBOX_WITH_PULSE */ 4009 # if defined(VBOX_WITH_ALSA) 4010 /* Check if we can load the ALSA library */ 4011 if (RTLdrIsLoadable("libasound.so.2")) 4012 s_linuxDriver = AudioDriverType_ALSA; 4013 else 4014 # endif /* VBOX_WITH_ALSA */ 4015 s_linuxDriver = AudioDriverType_OSS; 4016 } 4017 return s_linuxDriver; 4018 // end elif defined(RT_OS_LINUX) 4019 #elif defined(RT_OS_DARWIN) 4020 return AudioDriverType_CoreAudio; 4021 #elif defined(RT_OS_OS2) 4022 return AudioDriverType_MMP; 4023 #elif defined(RT_OS_FREEBSD) 4024 return AudioDriverType_OSS; 4025 #else 4026 return AudioDriverType_Null; 4027 #endif 4028 } 4029 4030 /** 3908 4031 * Called from write() before calling ConfigFileBase::createStubDocument(). 3909 4032 * This adjusts the settings version in m->sv if incompatible settings require … … 3959 4082 { 3960 4083 // we can only write the StorageController/@Instance attribute with v1.9 3961 if (sctl.ulInstance != 0) 4084 if (sctl.ulInstance != 0) 3962 4085 { 3963 4086 if (m->sv < SettingsVersion_v1_9)
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器