Browse files

[GUISettings] Basic support for AE new enumeration method

  • Loading branch information...
1 parent 672ca92 commit 91bf1e49b5e9e005778c5364e163e5351ed2af94 @Karlson2k committed Oct 18, 2012
View
10 language/English/strings.po
@@ -10816,8 +10816,14 @@ msgctxt "#34110"
msgid "7.1"
msgstr ""
-#34111-34119 reserved for future use
-#empty strings from id 34111 to 34119
+#34111-34118 reserved for future use
+#empty strings from id 34111 to 34118
+
+#. output device; passthrough device
+#: xbmc/settings/GUIWindowSettingsCategory.cpp
+msgctxt "#34119"
+msgid "Error - no devices found"
+msgstr ""
#: xbmc/settings/GUISettings.cpp
msgctxt "#34120"
View
85 xbmc/settings/GUIWindowSettingsCategory.cpp
@@ -1957,14 +1957,14 @@ void CGUIWindowSettingsCategory::OnSettingChanged(CBaseSettingControl *pSettingC
#if defined(TARGET_DARWIN)
g_guiSettings.SetString("audiooutput.audiodevice", pControl->GetCurrentLabel());
#else
- g_guiSettings.SetString("audiooutput.audiodevice", m_AnalogAudioSinkMap[pControl->GetCurrentLabel()]);
+ g_guiSettings.SetString("audiooutput.audiodevice", m_AnalogAudioSinkMap[pControl->GetCurrentLabel()].m_DeviceName.c_str());
#endif
}
#if !defined(TARGET_DARWIN)
else if (strSetting.Equals("audiooutput.passthroughdevice"))
{
CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
- g_guiSettings.SetString("audiooutput.passthroughdevice", m_DigitalAudioSinkMap[pControl->GetCurrentLabel()]);
+ g_guiSettings.SetString("audiooutput.passthroughdevice", m_DigitalAudioSinkMap[pControl->GetCurrentLabel()].m_DeviceName.c_str());
}
#endif
else if (strSetting.Equals("audiooutput.guisoundmode"))
@@ -2860,62 +2860,81 @@ void CGUIWindowSettingsCategory::FillInAudioDevices(CSetting* pSetting, bool Pas
CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(GetSetting(pSetting->GetSetting())->GetID());
pControl->Clear();
- CStdString currentDevice = Passthrough ? g_guiSettings.GetString("audiooutput.passthroughdevice") : g_guiSettings.GetString("audiooutput.audiodevice");
+ std::string currentDevice = Passthrough ? g_guiSettings.GetString("audiooutput.passthroughdevice") : g_guiSettings.GetString("audiooutput.audiodevice");
if (Passthrough)
- {
m_DigitalAudioSinkMap.clear();
- m_DigitalAudioSinkMap["Error - no devices found"] = "null:";
- }
else
- {
m_AnalogAudioSinkMap.clear();
- m_AnalogAudioSinkMap["Error - no devices found"] = "null:";
- }
int numberSinks = 0;
-
int selectedValue = -1;
AEDeviceList sinkList;
- CAEFactory::EnumerateOutputDevices(sinkList, Passthrough);
-#if !defined(TARGET_DARWIN)
- if (sinkList.size()==0)
+ vector<AEDeviceEx> deviceExList;
+ if (CAEFactory::EnumerateOutputDevicesEx(deviceExList, Passthrough) && !deviceExList.empty())
{
- pControl->AddLabel("Error - no devices found", 0);
- numberSinks = 1;
- selectedValue = 0;
+ for(unsigned int i = 0; i < deviceExList.size(); i++)
+ {
+ const AEDeviceEx &dev = deviceExList.at(i);
+ pControl->AddLabel(dev.m_DisplayName, i);
+ if (currentDevice.compare(dev.m_DeviceName) == 0)
+ selectedValue = i;
+
+ if (Passthrough)
+ m_DigitalAudioSinkMap[dev.m_DisplayName] = dev;
+ else
+ m_AnalogAudioSinkMap[dev.m_DisplayName] = dev;
+ }
}
else
{
-#endif
- AEDeviceList::const_iterator iter = sinkList.begin();
- for (int i=0; iter != sinkList.end(); iter++)
+ CAEFactory::EnumerateOutputDevices(sinkList, Passthrough);
+ for (unsigned int i = 0; i < sinkList.size(); i++)
{
- CStdString label = (*iter).first;
- CStdString sink = (*iter).second;
- pControl->AddLabel(label.c_str(), i);
+ AEDeviceEx dev;
+ dev.m_DeviceType = AE_DEVTYPE_UNKNOWN;
+ dev.m_DisplayName = sinkList.at(i).first;
+ dev.m_DeviceName = sinkList.at(i).second;
+ pControl->AddLabel(dev.m_DisplayName, i);
- if (currentDevice.Equals(sink))
+ if (currentDevice.compare(dev.m_DeviceName))
selectedValue = i;
if (Passthrough)
- m_DigitalAudioSinkMap[label] = sink;
+ m_DigitalAudioSinkMap[dev.m_DisplayName] = dev;
else
- m_AnalogAudioSinkMap[label] = sink;
-
- i++;
+ m_AnalogAudioSinkMap[dev.m_DisplayName] = dev;
}
+ }
- numberSinks = sinkList.size();
-#if !defined(TARGET_DARWIN)
+ if ( Passthrough ? (m_DigitalAudioSinkMap.size() == 0) : (m_AnalogAudioSinkMap.size() == 0) )
+ {
+ AEDeviceEx dev;
+ dev.m_DeviceType = AE_DEVTYPE_UNKNOWN;
+ dev.m_DeviceName = "null:";
+ dev.m_DisplayName = g_localizeStrings.Get(34119);
+ if (Passthrough)
+ m_DigitalAudioSinkMap[dev.m_DisplayName] = dev;
+ else
+ m_AnalogAudioSinkMap[dev.m_DisplayName] = dev;
+
+ pControl->AddLabel(dev.m_DisplayName, 0);
+ numberSinks = 1;
+ selectedValue = 0;
}
-#endif
+ else
+ numberSinks = Passthrough ? m_DigitalAudioSinkMap.size() : m_AnalogAudioSinkMap.size();
if (selectedValue < 0)
{
- CLog::Log(LOGWARNING, "Failed to find previously selected audio sink");
- pControl->AddLabel(currentDevice, numberSinks);
- pControl->SetValue(numberSinks);
+ if (currentDevice.empty())
+ pControl->SetValue(0);
+ else
+ {
+ CLog::Log(LOGWARNING, "Failed to find previously selected audio sink");
+ pControl->AddLabel(currentDevice, numberSinks);
+ pControl->SetValue(numberSinks);
+ }
}
else
pControl->SetValue(selectedValue);
View
7 xbmc/settings/GUIWindowSettingsCategory.h
@@ -25,6 +25,8 @@
#include "GUISettings.h"
#include "utils/Stopwatch.h"
+struct AEDeviceEx;
+
class CGUIWindowSettingsCategory :
public CGUIWindow
{
@@ -97,8 +99,9 @@ class CGUIWindowSettingsCategory :
CStdString m_strOldTrackFormat;
CStdString m_strOldTrackFormatRight;
- std::map<CStdString, CStdString> m_AnalogAudioSinkMap;
- std::map<CStdString, CStdString> m_DigitalAudioSinkMap;
+ std::map<std::string, AEDeviceEx> m_AnalogAudioSinkMap;
+ std::map<std::string, AEDeviceEx> m_DigitalAudioSinkMap;
+ typedef std::map<std::string, AEDeviceEx>::iterator AudioSinkMapIterator;
std::map<CStdString, CStdString> m_SkinFontSetIDs;
bool m_returningFromSkinLoad; // true if we are returning from loading the skin

0 comments on commit 91bf1e4

Please sign in to comment.