VirtualBox

Changeset 56088 in vbox


Ignore:
Timestamp:
May 27, 2015 8:55:54 AM (10 years ago)
Author:
vboxsync
Message:

pr6522. First part: added logic which allows to read\save audio properties in form key=value in VM xml setting file

Location:
trunk
Files:
6 edited

Legend:

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

    r56035 r56088  
    705705                     && (controllerType  == a.controllerType)
    706706                     && (driverType      == a.driverType)
     707                     && (properties      == a.properties)
    707708                   );
    708709    }
     
    711712    AudioControllerType_T   controllerType;
    712713    AudioDriverType_T       driverType;
     714    std::map<com::Utf8Str, com::Utf8Str> properties;
    713715};
    714716
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r56035 r56088  
    1839718397      </desc>
    1839818398    </attribute>
     18399    <attribute name="propertiesList" type="wstring" readonly="yes" safearray="yes">
     18400      <desc>
     18401        Array of names of tunable properties, which can be supported by audio driver.
     18402      </desc>
     18403    </attribute>
     18404
     18405    <method name="setProperty">
     18406      <desc>
     18407        Sets an audio specific property string.
     18408
     18409        If you pass @c null or empty string as a key @a value, the given @a key
     18410        will be deleted.
     18411
     18412      </desc>
     18413      <param name="key" type="wstring" dir="in">
     18414        <desc>Name of the key to set.</desc>
     18415      </param>
     18416      <param name="value" type="wstring" dir="in">
     18417        <desc>Value to assign to the key.</desc>
     18418      </param>
     18419    </method>
     18420
     18421    <method name="getProperty" const="yes">
     18422      <desc>
     18423        Returns an audio specific property string.
     18424
     18425        If the requested data @a key does not exist, this function will
     18426        succeed and return an empty string in the @a value argument.
     18427
     18428      </desc>
     18429      <param name="key" type="wstring" dir="in">
     18430        <desc>Name of the key to get.</desc>
     18431      </param>
     18432      <param name="value" type="wstring" dir="return">
     18433        <desc>Value of the requested key.</desc>
     18434      </param>
     18435    </method>
     18436
    1839918437  </interface>
    1840018438
  • trunk/src/VBox/Main/include/AudioAdapterImpl.h

    r55528 r56088  
    6565    HRESULT getAudioController(AudioControllerType_T *aAudioController);
    6666    HRESULT setAudioController(AudioControllerType_T aAudioController);
     67    HRESULT getPropertiesList(std::vector<com::Utf8Str>& aProperties);
     68    HRESULT getProperty(const com::Utf8Str &aKey, com::Utf8Str &aValue);
     69    HRESULT setProperty(const com::Utf8Str &aKey, const com::Utf8Str &aValue);
    6770
    6871    Machine * const     mParent;
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r56085 r56088  
    27362736                    InsertConfigNode(pInst,    "Config", &pCfg);
    27372737                }
     2738            }
     2739
     2740            PCFGMNODE pCfgAudioSettings = NULL;
     2741            InsertConfigNode(pInst, "AudioConfig", &pCfgAudioSettings);
     2742            SafeArray<BSTR> audioProps;
     2743            hrc = audioAdapter->COMGETTER(PropertiesList)(ComSafeArrayAsOutParam(audioProps));  H();
     2744
     2745            std::list<Utf8Str> audioPropertyNamesList;
     2746            std::map<Utf8Str, Utf8Str> audioProperties;
     2747            for (size_t i = 0; i < audioProps.size(); ++i)
     2748            {
     2749                Bstr bstrValue;
     2750                audioPropertyNamesList.push_back(Utf8Str(audioProps[i]));
     2751                hrc = audioAdapter->GetProperty(audioProps[i], bstrValue.asOutParam());
     2752                Utf8Str strKey(audioProps[i]);
     2753                audioProperties[strKey] = Utf8Str(bstrValue);
     2754                InsertConfigString(pCfgAudioSettings, strKey.c_str(), bstrValue);
    27382755            }
    27392756
  • trunk/src/VBox/Main/src-server/AudioAdapterImpl.cpp

    r55548 r56088  
    3939    AudioDriverType_T mAudioDriver;
    4040    AudioControllerType_T mAudioController;
     41    std::map<com::Utf8Str, com::Utf8Str>  properties;
    4142};
    4243
     
    347348}
    348349
     350HRESULT AudioAdapter::getPropertiesList(std::vector<com::Utf8Str>& aProperties)
     351{
     352    using namespace settings;
     353
     354    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     355
     356    aProperties.resize(0);
     357    StringsMap::const_iterator cit = mData->m->properties.begin();
     358    while(cit!=mData->m->properties.end())
     359    {
     360        Utf8Str key = cit->first;
     361        aProperties.push_back(cit->first);
     362        ++cit;
     363    }
     364
     365    return S_OK;
     366}
     367
     368HRESULT AudioAdapter::getProperty(const com::Utf8Str &aKey, com::Utf8Str &aValue)
     369{
     370    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     371
     372    settings::StringsMap::const_iterator cit = mData->m->properties.find(aKey);
     373    if (cit != mData->m->properties.end())
     374        aValue = cit->second;
     375
     376    return S_OK;
     377}
     378
     379HRESULT AudioAdapter::setProperty(const com::Utf8Str &aKey, const com::Utf8Str &aValue)
     380{
     381    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     382
     383    /* Generic properties processing.
     384     * Look up the old value first; if nothing's changed then do nothing.
     385     */
     386    Utf8Str strOldValue;
     387
     388    settings::StringsMap::const_iterator cit = mData->m->properties.find(aKey);
     389    if (cit != mData->m->properties.end())
     390        strOldValue = cit->second;
     391
     392    if (strOldValue != aValue)
     393    {
     394        if (aValue.isEmpty())
     395            mData->m->properties.erase(aKey);
     396        else
     397            mData->m->properties[aKey] = aValue;
     398    }
     399
     400    alock.release();
     401
     402    return S_OK;
     403}
     404
    349405// IAudioAdapter methods
    350406/////////////////////////////////////////////////////////////////////////////
     
    383439    mData->m->mAudioDriver = data.driverType;
    384440
     441    std::map<com::Utf8Str, com::Utf8Str>::const_iterator cit = data.properties.begin();
     442    while(cit!=data.properties.end())
     443    {
     444        mData->m->properties[cit->first] = cit->second;
     445        ++cit;
     446    }
     447
    385448    return S_OK;
    386449}
     
    403466    data.controllerType = mData->m->mAudioController;
    404467    data.driverType = mData->m->mAudioDriver;
     468
     469    std::map<com::Utf8Str, com::Utf8Str>::const_iterator cit = mData->m->properties.begin();
     470    while(cit!=mData->m->properties.end())
     471    {
     472        data.properties[cit->first] = cit->second;
     473        ++cit;
     474    }
     475
    405476    return S_OK;
    406477}
  • trunk/src/VBox/Main/xml/Settings.cpp

    r56035 r56088  
    26222622                                         AudioAdapter &aa)
    26232623{
     2624
     2625    // get all properties
     2626    xml::NodesLoop nl1(elmAudioAdapter, "Property");
     2627    const xml::ElementNode *pelmModeChild;
     2628    while ((pelmModeChild = nl1.forAllNodes()))
     2629    {
     2630        Utf8Str strPropName, strPropValue;
     2631        if (   pelmModeChild->getAttributeValue("name", strPropName)
     2632            && pelmModeChild->getAttributeValue("value", strPropValue) )
     2633            aa.properties[strPropName] = strPropValue;
     2634        else
     2635            throw ConfigFileError(this, pelmModeChild, N_("Required AudioAdapter/Property/@name or @value attribute "
     2636                                                          "is missing"));
     2637    }
     2638
    26242639    elmAudioAdapter.getAttributeValue("enabled", aa.fEnabled);
    26252640
     
    47304745
    47314746    pelmAudio->setAttribute("enabled", hw.audioAdapter.fEnabled);
     4747
     4748    if (hw.audioAdapter.properties.size() > 0)
     4749    {
     4750        for (StringsMap::const_iterator it = hw.audioAdapter.properties.begin();
     4751             it != hw.audioAdapter.properties.end();
     4752             ++it)
     4753        {
     4754            const Utf8Str &strName = it->first;
     4755            const Utf8Str &strValue = it->second;
     4756            xml::ElementNode *pelm = pelmAudio->createChild("Property");
     4757            pelm->setAttribute("name", strName);
     4758            pelm->setAttribute("value", strValue);
     4759        }
     4760    }
    47324761
    47334762    xml::ElementNode *pelmSharedFolders = pelmHardware->createChild("SharedFolders");
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