コード例 #1
0
ファイル: AEFactory.cpp プロジェクト: nremenda/xbmc
void CAEFactory::SettingOptionsAudioDevicesFillerGeneral(const CSetting *setting, std::vector< std::pair<std::string, std::string> > &list, std::string &current, bool passthrough)
{
  current = ((const CSettingString*)setting)->GetValue();
  std::string firstDevice;

  bool foundValue = false;
  AEDeviceList sinkList;
  EnumerateOutputDevices(sinkList, passthrough);
#if !defined(TARGET_DARWIN)
  if (sinkList.size() == 0)
    list.push_back(std::make_pair("Error - no devices found", "error"));
  else
  {
#endif
    for (AEDeviceList::const_iterator sink = sinkList.begin(); sink != sinkList.end(); sink++)
    {
      if (sink == sinkList.begin())
        firstDevice = sink->second;

#if defined(TARGET_DARWIN)
      list.push_back(std::make_pair(sink->first, sink->first));
#else
      list.push_back(std::make_pair(sink->first, sink->second));
#endif

      if (StringUtils::EqualsNoCase(current, sink->second))
        foundValue = true;
    }
#if !defined(TARGET_DARWIN)
  }
#endif

  if (!foundValue)
    current = firstDevice;
}
コード例 #2
0
ファイル: AEFactory.cpp プロジェクト: AFFLUENTSOCIETY/SPMC
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;
}