VirtualBox

Changeset 95364 in vbox


Ignore:
Timestamp:
Jun 24, 2022 4:51:21 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
151958
Message:

Main/FE: Added new audio driver type "default" to make it possible to move VMs (appliances) between different platforms without the need of changing the audio driver explicitly. When the "default" driver is selected, the best audio backend option for a platform will be used.

While at it, also added the "WAS" (Windows Audio Session) driver type for which we only had a hack so far. This now can be explicitly selected, also by the frontends. bugref:10051

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/settings.h

    r94981 r95364  
    14271427                         std::list<xml::ElementNode*> *pllElementsWithUuidAttributes);
    14281428
    1429     static bool isAudioDriverAllowedOnThisHost(AudioDriverType_T drv);
     1429    static bool isAudioDriverAllowedOnThisHost(AudioDriverType_T enmDrvType);
    14301430    static AudioDriverType_T getHostDefaultAudioDriver();
    14311431
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp

    r95140 r95364  
    21592159            switch (enmDrvType)
    21602160            {
     2161                case AudioDriverType_Default:
     2162                    if (details == VMINFO_MACHINEREADABLE)
     2163                        pszDrv = "default";
     2164                    else
     2165                        pszDrv = Info::tr("Default");
     2166                    break;
    21612167                case AudioDriverType_Null:
    21622168                    if (details == VMINFO_MACHINEREADABLE)
     
    21642170                    else
    21652171                        pszDrv = Info::tr("Null");
    2166                     break;
    2167                 case AudioDriverType_WinMM:
    2168                     if (details == VMINFO_MACHINEREADABLE)
    2169                         pszDrv = "winmm";
    2170                     else
    2171                         pszDrv = "WINMM";
    2172                     break;
    2173                 case AudioDriverType_DirectSound:
    2174                     if (details == VMINFO_MACHINEREADABLE)
    2175                         pszDrv = "dsound";
    2176                     else
    2177                         pszDrv = "DSOUND";
    21782172                    break;
    21792173                case AudioDriverType_OSS:
     
    21942188                    else
    21952189                        pszDrv = "PulseAudio";
     2190                    break;
     2191                case AudioDriverType_WinMM:
     2192                    if (details == VMINFO_MACHINEREADABLE)
     2193                        pszDrv = "winmm";
     2194                    else
     2195                        pszDrv = "WINMM";
     2196                    break;
     2197                case AudioDriverType_DirectSound:
     2198                    if (details == VMINFO_MACHINEREADABLE)
     2199                        pszDrv = "dsound";
     2200                    else
     2201                        pszDrv = "DirectSound";
     2202                    break;
     2203                case AudioDriverType_WAS:
     2204                    if (details == VMINFO_MACHINEREADABLE)
     2205                        pszDrv = "was";
     2206                    else
     2207                        pszDrv = "Windows Audio Session (WAS)";
    21962208                    break;
    21972209                case AudioDriverType_CoreAudio:
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp

    r95178 r95364  
    844844    switch (enmAudio)
    845845    {
    846         case AudioDriverType_Null:          psz = List::tr("Null"); break;
    847         case AudioDriverType_WinMM:         psz = "WinMM";          break;
    848         case AudioDriverType_OSS:           psz = "OSS";            break;
    849         case AudioDriverType_ALSA:          psz = "ALSA";           break;
    850         case AudioDriverType_DirectSound:   psz = "DirectSound";    break;
    851         case AudioDriverType_CoreAudio:     psz = "CoreAudio";      break;
    852         case AudioDriverType_MMPM:          psz = "MMPM";           break;
    853         case AudioDriverType_Pulse:         psz = "Pulse";          break;
    854         case AudioDriverType_SolAudio:      psz = "SolAudio";       break;
     846        case AudioDriverType_Default:       psz = List::tr("Default");     break;
     847        case AudioDriverType_Null:          psz = List::tr("Null");        break;
     848        case AudioDriverType_OSS:           psz = "OSS";                   break;
     849        case AudioDriverType_ALSA:          psz = "ALSA";                  break;
     850        case AudioDriverType_Pulse:         psz = "PulseAudio";            break;
     851        case AudioDriverType_WinMM:         psz = "WinMM";                 break;
     852        case AudioDriverType_DirectSound:   psz = "DirectSound";           break;
     853        case AudioDriverType_WAS:           psz = "Windows Audio Session"; break;
     854        case AudioDriverType_CoreAudio:     psz = "CoreAudio";             break;
     855        case AudioDriverType_SolAudio:      psz = "SolAudio";              break;
     856        case AudioDriverType_MMPM:          psz = "MMPM";                  break;
    855857        default:                            psz = List::tr("Unknown");
    856858    }
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp

    r95140 r95364  
    25762576 * saved state. The GUI also might learn this trick if it doesn't use it
    25772577 * already. */
    2578 
    25792578                /* disable? */
    25802579                if (!RTStrICmp(ValueUnion.psz, "none"))
    25812580                {
    25822581                    CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(false));
     2582                }
     2583                else if (!RTStrICmp(ValueUnion.psz, "default"))
     2584                {
     2585                    CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_Default));
     2586                    CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
    25832587                }
    25842588                else if (!RTStrICmp(ValueUnion.psz, "null"))
     
    25982602                {
    25992603                    CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_DirectSound));
     2604                    CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
     2605                }
     2606                else if (!RTStrICmp(ValueUnion.psz, "was"))
     2607                {
     2608                    CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_was));
    26002609                    CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
    26012610                }
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendCOM.cpp

    r94595 r95364  
    530530    switch (type)
    531531    {
     532        case KAudioDriverType_Default:     return QApplication::translate("UICommon", "Default", "AudioDriverType");
    532533        case KAudioDriverType_Null:        return QApplication::translate("UICommon", "Null Audio", "AudioDriverType");
    533         case KAudioDriverType_WinMM:       return QApplication::translate("UICommon", "Windows Multimedia", "AudioDriverType");
    534534        case KAudioDriverType_OSS:         return QApplication::translate("UICommon", "OSS Audio", "AudioDriverType");
    535535        case KAudioDriverType_ALSA:        return QApplication::translate("UICommon", "ALSA Audio", "AudioDriverType");
     536        case KAudioDriverType_Pulse:       return QApplication::translate("UICommon", "PulseAudio", "AudioDriverType");
     537        case KAudioDriverType_WinMM:       return QApplication::translate("UICommon", "Windows Multimedia", "AudioDriverType");
    536538        case KAudioDriverType_DirectSound: return QApplication::translate("UICommon", "Windows DirectSound", "AudioDriverType");
     539        case KAudioDriverType_WAS:         return QApplication::translate("UICommon", "Windows Audio Session", "AudioDriverType");
    537540        case KAudioDriverType_CoreAudio:   return QApplication::translate("UICommon", "Core Audio", "AudioDriverType");
    538541        // case KAudioDriverType_MMPM:
    539         case KAudioDriverType_Pulse:       return QApplication::translate("UICommon", "PulseAudio", "AudioDriverType");
    540542        case KAudioDriverType_SolAudio:    return QApplication::translate("UICommon", "Solaris Audio", "AudioDriverType");
    541543        default: AssertMsgFailed(("No text for %d", type)); break;
     
    548550{
    549551    QHash<QString, KAudioDriverType> list;
    550     list.insert(QApplication::translate("UICommon", "Null Audio", "AudioDriverType"),          KAudioDriverType_Null);
    551     list.insert(QApplication::translate("UICommon", "Windows Multimedia", "AudioDriverType"),  KAudioDriverType_WinMM);
    552     list.insert(QApplication::translate("UICommon", "OSS Audio", "AudioDriverType"),           KAudioDriverType_OSS);
    553     list.insert(QApplication::translate("UICommon", "ALSA Audio", "AudioDriverType"),          KAudioDriverType_ALSA);
    554     list.insert(QApplication::translate("UICommon", "Windows DirectSound", "AudioDriverType"), KAudioDriverType_DirectSound);
    555     list.insert(QApplication::translate("UICommon", "Core Audio", "AudioDriverType"),          KAudioDriverType_CoreAudio);
     552    list.insert(QApplication::translate("UICommon", "Default", "AudioDriverType"),              KAudioDriverType_Default);
     553    list.insert(QApplication::translate("UICommon", "Null Audio", "AudioDriverType"),            KAudioDriverType_Null);
     554    list.insert(QApplication::translate("UICommon", "OSS Audio", "AudioDriverType"),             KAudioDriverType_OSS);
     555    list.insert(QApplication::translate("UICommon", "ALSA Audio", "AudioDriverType"),            KAudioDriverType_ALSA);
     556    list.insert(QApplication::translate("UICommon", "PulseAudio", "AudioDriverType"),            KAudioDriverType_Pulse);
     557    list.insert(QApplication::translate("UICommon", "Windows Multimedia", "AudioDriverType"),    KAudioDriverType_WinMM);
     558    list.insert(QApplication::translate("UICommon", "Windows DirectSound", "AudioDriverType"),   KAudioDriverType_DirectSound);
     559    list.insert(QApplication::translate("UICommon", "Windows Audio Session", "AudioDriverType"), KAudioDriverType_WAS);
     560    list.insert(QApplication::translate("UICommon", "Core Audio", "AudioDriverType"),            KAudioDriverType_CoreAudio);
    556561    // list.insert(..., KAudioDriverType_MMPM);
    557     list.insert(QApplication::translate("UICommon", "PulseAudio", "AudioDriverType"),          KAudioDriverType_Pulse);
    558     list.insert(QApplication::translate("UICommon", "Solaris Audio", "AudioDriverType"),       KAudioDriverType_SolAudio);
     562    list.insert(QApplication::translate("UICommon", "Solaris Audio", "AudioDriverType"),         KAudioDriverType_SolAudio);
    559563    if (!list.contains(strType))
    560564    {
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r95274 r95364  
    2301423014  <enum
    2301523015    name="AudioDriverType"
    23016     uuid="4bcc3d73-c2fe-40db-b72f-0c2ca9d68496"
     23016    uuid="32b4acfd-79ab-4b7e-9a1c-92e99f4e000b"
    2301723017    >
    2301823018    <desc>
     
    2302023020    </desc>
    2302123021
    23022     <const name="Null"          value="0">
     23022    <const name="Default"       value="0">
     23023      <desc>Use the default audio driver automatically determined for the host
     23024        that this VirtualBox instance is running on.
     23025        Useful for VMs which need to run on different host OSes.
     23026        <note>
     23027          Currently not implemented yet; the Null audio driver will be used instead.
     23028        </note>
     23029      </desc>
     23030    </const>
     23031    <!-- When changing the enum anyway, keep the enum grouped per platforms, starting
     23032         from oldest audio stack to newest one (if possible). -->
     23033    <const name="Null"          value="1">
    2302323034      <desc>Null value, also means "dummy audio driver".</desc>
    23024     </const>
    23025     <const name="WinMM"         value="1">
    23026         <desc>Windows multimedia (Windows hosts only, not supported at the moment).</desc>
    2302723035    </const>
    2302823036    <const name="OSS"           value="2">
     
    2303223040        <desc>Advanced Linux Sound Architecture (Linux hosts only).</desc>
    2303323041    </const>
    23034     <const name="DirectSound"   value="4">
     23042    <const name="Pulse"         value="4">
     23043        <desc>PulseAudio (Linux hosts only).</desc>
     23044    </const>
     23045    <const name="WinMM"         value="5">
     23046        <desc>Windows multimedia (Windows hosts only, not supported at the moment).</desc>
     23047    </const>
     23048    <const name="DirectSound"   value="6">
    2303523049        <desc>DirectSound (Windows hosts only).</desc>
    2303623050    </const>
    23037     <const name="CoreAudio"     value="5">
     23051    <const name="WAS"           value="7">
     23052        <desc>Windows Audio Session (Windows hosts only).</desc>
     23053    </const>
     23054    <const name="CoreAudio"     value="8">
    2303823055        <desc>CoreAudio (Mac hosts only).</desc>
    2303923056    </const>
    23040     <const name="MMPM"          value="6">
     23057    <const name="MMPM"          value="9">
    2304123058        <desc>Reserved for historical reasons.</desc>
    2304223059    </const>
    23043     <const name="Pulse"         value="7">
    23044         <desc>PulseAudio (Linux hosts only).</desc>
    23045     </const>
    23046     <const name="SolAudio"      value="8">
    23047         <desc>Solaris audio (Solaris hosts only, not supported at the moment).</desc>
     23060    <const name="SolAudio"      value="10">
     23061        <desc>Reserved for historical reasons.</desc>
    2304823062    </const>
    2304923063  </enum>
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r95256 r95364  
    7575#include <VBox/err.h>
    7676#include <VBox/param.h>
     77#include <VBox/settings.h> /* For MachineConfigFile::getHostDefaultAudioDriver(). */
    7778#include <VBox/vmm/pdmapi.h> /* For PDMR3DriverAttach/PDMR3DriverDetach. */
    7879#include <VBox/vmm/pdmusb.h> /* For PDMR3UsbCreateEmulatedDevice. */
     
    32003201                AudioDriverType_T enmAudioDriver;
    32013202                hrc = audioAdapter->COMGETTER(AudioDriver)(&enmAudioDriver);                    H();
     3203
     3204                /* The "Default" audio driver needs special treatment, as we need to figure out which driver to use
     3205                 * by default on the current platform. */
     3206                bool const fUseDefaultDrv = enmAudioDriver == AudioDriverType_Default;
     3207
     3208                AudioDriverType_T const enmDefaultAudioDriver = settings::MachineConfigFile::getHostDefaultAudioDriver();
     3209
     3210                if (fUseDefaultDrv)
     3211                {
     3212                    enmAudioDriver = enmDefaultAudioDriver;
     3213                    if (enmAudioDriver == AudioDriverType_Null)
     3214                        LogRel(("Audio: Warning: No default driver detected for current platform -- defaulting to Null audio backend\n"));
     3215                }
     3216
    32023217                switch (enmAudioDriver)
    32033218                {
     3219                    case AudioDriverType_Default: /* Can't happen, but handle it anyway. */
     3220                        RT_FALL_THROUGH();
    32043221                    case AudioDriverType_Null:
    32053222                        pszAudioDriver = "NullAudio";
     
    32123229# endif
    32133230                    case AudioDriverType_DirectSound:
    3214                         /* Use the windows audio session (WAS) API rather than Direct Sound on windows
     3231                        /* Use the Windows Audio Session (WAS) API rather than Direct Sound on Windows
    32153232                           versions we've tested it on (currently W7+).  Since Vista, Direct Sound has
    32163233                           been emulated on top of WAS according to the docs, so better use WAS directly.
    32173234
    3218                            Set extradata value "VBoxInternal2/Audio/WindowsDrv" "dsound" to no use WasAPI. */
    3219                         pszAudioDriver = "DSoundAudio";
     3235                           Set extradata value "VBoxInternal2/Audio/WindowsDrv" "dsound" to no use WasAPI.
     3236
     3237                           Keep this hack for backwards compatibility (introduced < 7.0).
     3238                        */
    32203239                        GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/Audio/WindowsDrv", &strTmp); H();
    3221                         if (   RTSystemGetNtVersion() >= RTSYSTEM_MAKE_NT_VERSION(6,1,0)
     3240                        if (   enmDefaultAudioDriver == AudioDriverType_WAS
    32223241                            && (   strTmp.isEmpty()
    32233242                                || strTmp.equalsIgnoreCase("was")
    32243243                                || strTmp.equalsIgnoreCase("wasapi")) )
     3244                        {
     3245                            /* Nothing to do here, fall through to WAS driver. */
     3246                        }
     3247                        else
     3248                        {
     3249                            pszAudioDriver = "DSoundAudio";
     3250                            break;
     3251                        }
     3252                        RT_FALL_THROUGH();
     3253                    case AudioDriverType_WAS:
     3254                        if (enmDefaultAudioDriver == AudioDriverType_WAS) /* WAS supported? */
    32253255                            pszAudioDriver = "HostAudioWas";
     3256                        else if (enmDefaultAudioDriver == AudioDriverType_DirectSound)
     3257                        {
     3258                            LogRel(("Audio: Warning: Windows Audio Session (WAS) not supported, defaulting to DirectSound backend\n"));
     3259                            pszAudioDriver = "DSoundAudio";
     3260                        }
    32263261                        break;
    32273262#endif /* RT_OS_WINDOWS */
     
    32303265                        /* Should not happen, as the Solaris Audio backend is not around anymore.
    32313266                         * Remove this sometime later. */
    3232                         LogRel(("Audio: WARNING: Solaris Audio is deprecated, please switch to OSS!\n"));
     3267                        LogRel(("Audio: Warning: Solaris Audio is deprecated, please switch to OSS!\n"));
    32333268                        LogRel(("Audio: Automatically setting host audio backend to OSS\n"));
    32343269
     
    32613296                        AssertFailedBreak();
    32623297                }
     3298
     3299                if (fUseDefaultDrv)
     3300                    LogRel(("Audio: Detected default audio driver type is '%s'\n", pszAudioDriver));
    32633301            }
    32643302
  • trunk/src/VBox/Main/src-server/SystemPropertiesImpl.cpp

    r94714 r95364  
    17931793    static const AudioDriverType_T aAudioDriverTypes[] =
    17941794    {
     1795        AudioDriverType_Default,
    17951796#ifdef RT_OS_WINDOWS
    17961797# if 0 /* deprecated for many years now */
    17971798        AudioDriverType_WinMM,
    17981799# endif
     1800        AudioDriverType_WAS,
    17991801        AudioDriverType_DirectSound,
    18001802#endif
  • trunk/src/VBox/Main/xml/Settings.cpp

    r95338 r95364  
    46054605        // settings before 1.3 used lower case so make sure this is case-insensitive
    46064606        strTemp.toUpper();
    4607         if (strTemp == "NULL")
     4607        if (strTemp == "DEFAULT")
     4608            aa.driverType = AudioDriverType_Default;
     4609        else if (strTemp == "NULL")
    46084610            aa.driverType = AudioDriverType_Null;
     4611        else if (strTemp == "WAS")
     4612            aa.driverType = AudioDriverType_WAS;
    46094613        else if (strTemp == "WINMM")
    46104614            aa.driverType = AudioDriverType_WinMM;
     
    46214625        else if (strTemp == "COREAUDIO")
    46224626            aa.driverType = AudioDriverType_CoreAudio;
    4623         else if (strTemp == "MMPM")
     4627        else if (strTemp == "MMPM") /* Deprecated; only kept for backwards compatibility. */
    46244628            aa.driverType = AudioDriverType_MMPM;
    46254629        else
     
    73147318        switch (hw.audioAdapter.driverType)
    73157319        {
     7320            case AudioDriverType_Default: pcszDriver = "Default"; break;
    73167321            case AudioDriverType_WinMM: pcszDriver = "WinMM"; break;
    73177322            case AudioDriverType_DirectSound: pcszDriver = "DirectSound"; break;
     7323            case AudioDriverType_WAS: pcszDriver = "WAS"; break;
     7324            case AudioDriverType_ALSA: pcszDriver = "ALSA"; break;
     7325            case AudioDriverType_OSS: pcszDriver = "OSS"; break;
     7326            case AudioDriverType_Pulse: pcszDriver = "Pulse"; break;
     7327            case AudioDriverType_CoreAudio: pcszDriver = "CoreAudio"; break;
    73187328            case AudioDriverType_SolAudio: pcszDriver = "SolAudio"; break;
    7319             case AudioDriverType_ALSA: pcszDriver = "ALSA"; break;
    7320             case AudioDriverType_Pulse: pcszDriver = "Pulse"; break;
    7321             case AudioDriverType_OSS: pcszDriver = "OSS"; break;
    7322             case AudioDriverType_CoreAudio: pcszDriver = "CoreAudio"; break;
    73237329            case AudioDriverType_MMPM: pcszDriver = "MMPM"; break;
    73247330            default: /*case AudioDriverType_Null:*/ pcszDriver = "Null"; break;
     
    82368242 * the current host platform. For example, this would return false
    82378243 * for AudioDriverType_DirectSound when compiled on a Linux host.
    8238  * @param drv AudioDriverType_* enum to test.
    8239  * @return true only if the current host supports that driver.
     8244 *
     8245*  @return \c true if the current host supports the driver, \c false if not.
     8246 * @param enmDrvType            AudioDriverType_* enum to test.
    82408247 */
    82418248/*static*/
    8242 bool MachineConfigFile::isAudioDriverAllowedOnThisHost(AudioDriverType_T drv)
    8243 {
    8244     switch (drv)
    8245     {
     8249bool MachineConfigFile::isAudioDriverAllowedOnThisHost(AudioDriverType_T enmDrvType)
     8250{
     8251    switch (enmDrvType)
     8252    {
     8253        case AudioDriverType_Default:
     8254            RT_FALL_THROUGH();
    82468255        case AudioDriverType_Null:
    82478256#ifdef RT_OS_WINDOWS
     8257        case AudioDriverType_WAS:
     8258            /* We only support WAS on systems we tested so far (Vista+). */
     8259            if (RTSystemGetNtVersion() < RTSYSTEM_MAKE_NT_VERSION(6,1,0))
     8260                break;
     8261            RT_FALL_THROUGH();
    82488262        case AudioDriverType_DirectSound:
    82498263#endif
     
    82758289 * or ALSA are actually supported on the first call.
    82768290 *
     8291 * When more than one supported audio stack is available, choose the most suited
     8292 * (probably newest in most cases) one.
     8293 *
    82778294 * @return Default audio driver type for this host platform.
    82788295 */
     
    82818298{
    82828299#if defined(RT_OS_WINDOWS)
     8300    if (RTSystemGetNtVersion() >= RTSYSTEM_MAKE_NT_VERSION(6,1,0))
     8301        return AudioDriverType_WAS;
    82838302    return AudioDriverType_DirectSound;
    82848303
     
    83018320             if (RTLdrIsLoadable("libasound.so.2"))
    83028321                s_enmLinuxDriver = AudioDriverType_ALSA;
    8303         else
    83048322# endif /* VBOX_WITH_AUDIO_ALSA */
    8305             s_enmLinuxDriver = AudioDriverType_OSS;
     8323# ifdef VBOX_WITH_AUDIO_OSS
     8324             else
     8325                s_enmLinuxDriver = AudioDriverType_OSS;
     8326# endif /* VBOX_WITH_AUDIO_OSS */
    83068327    }
    83078328    return s_enmLinuxDriver;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette