Skip to content

Commit

Permalink
settings: migrate old audiooutput.channellayout setting to audiooutpu…
Browse files Browse the repository at this point in the history
…t.channels and reset audiooutput.audiodevice if necessary
  • Loading branch information
Montellese committed Nov 22, 2012
1 parent 938ea02 commit 6b99d90
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions xbmc/settings/GUISettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1354,10 +1354,35 @@ void CGUISettings::GetSettingsGroup(CSettingsCategory* cat, vecSettings &setting

void CGUISettings::LoadXML(TiXmlElement *pRootElement, bool hideSettings /* = false */)
{ // load our stuff...
bool updated = false;

for (mapIter it = settingsMap.begin(); it != settingsMap.end(); it++)
{
LoadFromXML(pRootElement, it, hideSettings);
}

// check if we are updating to Frodo and need to update from
// audiooutput.channellayout to audiooutput.channels
TiXmlNode *channelNode = pRootElement->FirstChild("audiooutput");
if (channelNode != NULL)
{
channelNode = channelNode->FirstChild("channellayout");
CSettingInt* channels = (CSettingInt*)GetSetting("audiooutput.channels");
if (channelNode != NULL && channelNode->FirstChild() != NULL && channels != NULL)
{
channels->FromString(channelNode->FirstChild()->ValueStr());
if (channels->GetData() < AE_CH_LAYOUT_MAX - 1)
channels->SetData(channels->GetData() + 1);

// let's just reset the audiodevice settings as well
std::string audiodevice = GetString("audiooutput.audiodevice");
CAEFactory::VerifyOutputDevice(audiodevice, false);
SetString("audiooutput.audiodevice", audiodevice.c_str());

updated = true;
}
}

// Get hardware based stuff...
CLog::Log(LOGNOTICE, "Getting hardware information now...");
// FIXME: Check if the hardware supports it (if possible ;)
Expand Down Expand Up @@ -1401,6 +1426,7 @@ void CGUISettings::LoadXML(TiXmlElement *pRootElement, bool hideSettings /* = fa
{
timezone = g_timezone.GetOSConfiguredTimezone();
SetString("locale.timezone", timezone);
updated = true;
}
g_timezone.SetTimezone(timezone);
}
Expand All @@ -1417,6 +1443,9 @@ void CGUISettings::LoadXML(TiXmlElement *pRootElement, bool hideSettings /* = fa
g_langInfo.SetSubtitleLanguage(streamLanguage);
else
g_langInfo.SetSubtitleLanguage("");

if (updated)
g_settings.Save();
}

void CGUISettings::LoadFromXML(TiXmlElement *pRootElement, mapIter &it, bool advanced /* = false */)
Expand Down

0 comments on commit 6b99d90

Please sign in to comment.