Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

CAEFActory: add VerifyOutputDevice() implementation

  • Loading branch information...
commit 18c1537dcd9a5181d5be0add74a5e6b22beae35b 1 parent 3cab055
@Montellese Montellese authored
View
26 xbmc/cores/AudioEngine/AEFactory.cpp
@@ -197,6 +197,32 @@ void CAEFactory::EnumerateOutputDevices(AEDeviceList &devices, bool passthrough)
AE->EnumerateOutputDevices(devices, passthrough);
}
+void CAEFactory::VerifyOutputDevice(std::string &device, bool passthrough)
+{
+ AEDeviceList devices;
+ EnumerateOutputDevices(devices, passthrough);
+ std::string firstDevice;
+
+ for (AEDeviceList::const_iterator deviceIt = devices.begin(); deviceIt != devices.end(); deviceIt++)
+ {
+ std::string currentDevice = deviceIt->second;
+ /* remember the first device so we can default to it if required */
+ if (firstDevice.empty())
+ firstDevice = deviceIt->second;
+
+ if (deviceIt->second == device)
+ return;
+ else if (deviceIt->first == device)
+ {
+ device = deviceIt->second;
+ return;
+ }
+ }
+
+ /* if the device wasnt found, set it to the first viable output */
+ device = firstDevice;
+}
+
std::string CAEFactory::GetDefaultDevice(bool passthrough)
{
if(AE)
View
1  xbmc/cores/AudioEngine/AEFactory.h
@@ -46,6 +46,7 @@ class CAEFactory
static void SetSoundMode(const int mode);
static void OnSettingsChange(std::string setting);
static void EnumerateOutputDevices(AEDeviceList &devices, bool passthrough);
+ static void VerifyOutputDevice(std::string &device, bool passthrough);
static std::string GetDefaultDevice(bool passthrough);
static bool SupportsRaw();
static void SetMute(const bool enabled);
Please sign in to comment.
Something went wrong with that request. Please try again.