Skip to content
This repository
Browse code

CAEFActory: add VerifyOutputDevice() implementation

  • Loading branch information...
commit 18c1537dcd9a5181d5be0add74a5e6b22beae35b 1 parent 3cab055
Sascha Montellese authored November 22, 2012
26  xbmc/cores/AudioEngine/AEFactory.cpp
@@ -197,6 +197,32 @@ void CAEFactory::EnumerateOutputDevices(AEDeviceList &devices, bool passthrough)
197 197
     AE->EnumerateOutputDevices(devices, passthrough);
198 198
 }
199 199
 
  200
+void CAEFactory::VerifyOutputDevice(std::string &device, bool passthrough)
  201
+{
  202
+  AEDeviceList devices;
  203
+  EnumerateOutputDevices(devices, passthrough);
  204
+  std::string firstDevice;
  205
+
  206
+  for (AEDeviceList::const_iterator deviceIt = devices.begin(); deviceIt != devices.end(); deviceIt++)
  207
+  {
  208
+    std::string currentDevice = deviceIt->second;
  209
+    /* remember the first device so we can default to it if required */
  210
+    if (firstDevice.empty())
  211
+      firstDevice = deviceIt->second;
  212
+
  213
+    if (deviceIt->second == device)
  214
+      return;
  215
+    else if (deviceIt->first == device)
  216
+    {
  217
+      device = deviceIt->second;
  218
+      return;
  219
+    }
  220
+  }
  221
+
  222
+  /* if the device wasnt found, set it to the first viable output */
  223
+  device = firstDevice;
  224
+}
  225
+
200 226
 std::string CAEFactory::GetDefaultDevice(bool passthrough)
201 227
 {
202 228
   if(AE)
1  xbmc/cores/AudioEngine/AEFactory.h
@@ -46,6 +46,7 @@ class CAEFactory
46 46
   static void SetSoundMode(const int mode);
47 47
   static void OnSettingsChange(std::string setting);
48 48
   static void EnumerateOutputDevices(AEDeviceList &devices, bool passthrough);
  49
+  static void VerifyOutputDevice(std::string &device, bool passthrough);
49 50
   static std::string GetDefaultDevice(bool passthrough);
50 51
   static bool SupportsRaw();
51 52
   static void SetMute(const bool enabled);

0 notes on commit 18c1537

Please sign in to comment.
Something went wrong with that request. Please try again.