VirtualBox

Changeset 95835 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jul 26, 2022 4:06:37 PM (2 years ago)
Author:
vboxsync
Message:

Audio/Settings: Keep settings >= 1.19 compatible with older VBox versions (on a best effort basis, of course). So use a dedicated attribute for the new "Default" audio driver type, which did not exist prior settings 1.19 (VBox 7.0) and explicitly set the driver type to something older VBox versions know about. ​bugref:10051

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/xml/Settings.cpp

    r95796 r95835  
    47424742        // settings before 1.3 used lower case so make sure this is case-insensitive
    47434743        strTemp.toUpper();
    4744         if (strTemp == "DEFAULT")
     4744        if (strTemp == "DEFAULT") /* Keep this to be backwards compatible for settings < r152556. */
    47454745            aa.driverType = AudioDriverType_Default;
    47464746        else if (strTemp == "NULL")
     
    47664766        else
    47674767            throw ConfigFileError(this, &elmAudioAdapter, N_("Invalid value '%s' in AudioAdapter/@driver attribute"), strTemp.c_str());
     4768
     4769        /* When loading settings >= 1.19 (VBox 7.0), the attribute "useDefault" will determine if the VM should use
     4770         * the OS' default audio driver or not. This additional attribute is necessary in order to be backwards compatible
     4771         * with older VBox versions. */
     4772        bool fUseDefault = false;
     4773        if (   elmAudioAdapter.getAttributeValue("useDefault", &fUseDefault) /* Overrides "driver" above (if set). */
     4774            && fUseDefault)
     4775            aa.driverType = AudioDriverType_Default;
    47684776
    47694777        // now check if this is actually supported on the current host platform;
     
    74857493            pelmAudio->setAttribute("codec", pcszCodec);
    74867494
    7487         const char *pcszDriver;
    7488         switch (hw.audioAdapter.driverType)
    7489         {
    7490             case AudioDriverType_Default: pcszDriver = "Default"; break;
    7491             case AudioDriverType_WinMM: pcszDriver = "WinMM"; break;
    7492             case AudioDriverType_DirectSound: pcszDriver = "DirectSound"; break;
    7493             case AudioDriverType_WAS: pcszDriver = "WAS"; break;
    7494             case AudioDriverType_ALSA: pcszDriver = "ALSA"; break;
    7495             case AudioDriverType_OSS: pcszDriver = "OSS"; break;
    7496             case AudioDriverType_Pulse: pcszDriver = "Pulse"; break;
    7497             case AudioDriverType_CoreAudio: pcszDriver = "CoreAudio"; break;
    7498             case AudioDriverType_SolAudio: pcszDriver = "SolAudio"; break;
    7499             case AudioDriverType_MMPM: pcszDriver = "MMPM"; break;
    7500             default: /*case AudioDriverType_Null:*/ pcszDriver = "Null"; break;
    7501         }
     7495        /*
     7496         * Keep settings >= 1.19 compatible with older VBox versions (on a best effort basis, of course).
     7497         * So use a dedicated attribute for the new "Default" audio driver type, which did not exist prior
     7498         * settings 1.19 (VBox 7.0) and explicitly set the driver type to something older VBox versions
     7499         * know about.
     7500         */
     7501        AudioDriverType_T driverType = hw.audioAdapter.driverType;
     7502
     7503        if (driverType == AudioDriverType_Default)
     7504        {
     7505            /* Only recognized by VBox >= 7.0. */
     7506            pelmAudio->setAttribute("useDefault", true);
     7507
     7508            /* Make sure to set the actual driver type to the OS' default driver type.
     7509             * This is required for VBox < 7.0. */
     7510            driverType = getHostDefaultAudioDriver();
     7511        }
     7512
     7513        const char *pcszDriver = NULL;
     7514        switch (driverType)
     7515        {
     7516            case AudioDriverType_Default: /* Handled above. */                  break;
     7517            case AudioDriverType_WinMM:             pcszDriver = "WinMM";       break;
     7518            case AudioDriverType_DirectSound:       pcszDriver = "DirectSound"; break;
     7519            case AudioDriverType_WAS:               pcszDriver = "WAS";         break;
     7520            case AudioDriverType_ALSA:              pcszDriver = "ALSA";        break;
     7521            case AudioDriverType_OSS:               pcszDriver = "OSS";         break;
     7522            case AudioDriverType_Pulse:             pcszDriver = "Pulse";       break;
     7523            case AudioDriverType_CoreAudio:         pcszDriver = "CoreAudio";   break;
     7524            case AudioDriverType_SolAudio:          pcszDriver = "SolAudio";    break;
     7525            case AudioDriverType_MMPM:              pcszDriver = "MMPM";        break;
     7526            default: /*case AudioDriverType_Null:*/ pcszDriver = "Null";        break;
     7527        }
     7528
    75027529        /* Deliberately have the audio driver explicitly in the config file,
    75037530         * otherwise an unwritten default driver triggers auto-detection. */
     7531        AssertStmt(pcszDriver != NULL, pcszDriver = "Null");
    75047532        pelmAudio->setAttribute("driver", pcszDriver);
    75057533
     
    85618589            RT_FALL_THROUGH();
    85628590        case AudioDriverType_Null:
     8591            return true; /* Default and Null audio are always allowed. */
    85638592#ifdef RT_OS_WINDOWS
    85648593        case AudioDriverType_WAS:
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