Ejemplo n.º 1
0
IAESink *CAESinkFactory::TrySink(std::string &driver, std::string &device, AEAudioFormat &format)
{
  IAESink *sink = NULL;

  if (driver == "NULL")
    sink = new CAESinkNULL();
  else
  {
#if defined(TARGET_WINDOWS)
    if (driver == "WASAPI")
      sink = new CAESinkWASAPI();
    if (driver == "DIRECTSOUND")
      sink = new CAESinkDirectSound();
#elif defined(TARGET_ANDROID)
    sink = new CAESinkAUDIOTRACK();
#elif defined(TARGET_RASPBERRY_PI)
  if (driver == "PI")
    sink = new CAESinkPi();
  #if defined(HAS_ALSA)
  if (driver == "ALSA")
    sink = new CAESinkALSA();
  #endif
#elif defined(TARGET_DARWIN_IOS)
    sink = new CAESinkDARWINIOS();
#elif defined(TARGET_DARWIN_OSX)
    sink = new CAESinkDARWINOSX();
#elif defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
 #if defined(HAS_PULSEAUDIO)
    if (driver == "PULSE")
      sink = new CAESinkPULSE();
 #endif
 #if defined(HAS_ALSA)
    if (driver == "ALSA")
      sink = new CAESinkALSA();
 #endif
    if (driver == "OSS")
      sink = new CAESinkOSS();
#endif
  }

  if (!sink)
    return NULL;

  if (sink->Initialize(format, device))
  {
    // do some sanity checks
    if (format.m_sampleRate == 0)
      CLog::Log(LOGERROR, "Sink %s:%s returned invalid sample rate", driver.c_str(), device.c_str());
    else if (format.m_channelLayout.Count() == 0)
      CLog::Log(LOGERROR, "Sink %s:%s returned invalid channel layout", driver.c_str(), device.c_str());
    else if (format.m_frames < 256)
      CLog::Log(LOGERROR, "Sink %s:%s returned invalid buffer size: %d", driver.c_str(), device.c_str(), format.m_frames);
    else
      return sink;
  }
  sink->Deinitialize();
  delete sink;
  return NULL;
}
Ejemplo n.º 2
0
IAESink* CAESinkWASAPI::Create(std::string &device, AEAudioFormat &desiredFormat)
{
  IAESink *sink = new CAESinkWASAPI();
  if (sink->Initialize(desiredFormat, device))
    return sink;

  delete sink;
  return nullptr;
}