Ejemplo n.º 1
0
bool AsyncPluginImpl::Stop() {
  if (m_scan_timeout != ola::thread::INVALID_TIMEOUT) {
    m_plugin_adaptor->RemoveTimeout(m_scan_timeout);
    m_scan_timeout = ola::thread::INVALID_TIMEOUT;
  }

  // The shutdown sequence is:
  //  - suppress hotplug events so we don't add any new devices
  //  - remove all existing devices
  //  - stop the usb_thread (if using hotplug, otherwise this is a noop).
  {
    ola::thread::MutexLocker locker(&m_mutex);
    m_suppress_hotplug_events = true;
  }

  USBDeviceToFactoryMap::iterator iter = m_device_factory_map.begin();
  for (; iter != m_device_factory_map.end(); ++iter) {
    iter->second->DeviceRemoved(this, iter->first);
  }
  m_device_factory_map.clear();

  m_usb_thread->Shutdown();

  m_usb_thread.reset();
  m_usb_adaptor.reset();
  STLDeleteElements(&m_widget_factories);

  libusb_exit(m_context);
  m_context = NULL;
  return true;
}
Ejemplo n.º 2
0
/**
 * Delete all entries from this store
 */
void SLPStore::Reset() {
  for (ServiceMap::iterator iter = m_services.begin();
        iter != m_services.end(); ++iter) {
    STLDeleteElements(&(iter->second->services));
    delete iter->second;
  }
}
Ejemplo n.º 3
0
bool AsyncPluginImpl::Start() {
  if (libusb_init(&m_context)) {
    OLA_WARN << "Failed to init libusb";
    return false;
  }

  OLA_DEBUG << "libusb debug level set to " << m_debug_level;
  libusb_set_debug(m_context, m_debug_level);

  m_use_hotplug = HotplugSupported();
  OLA_INFO << "HotplugSupported returned " << m_use_hotplug;
  if (m_use_hotplug) {
#ifdef HAVE_LIBUSB_HOTPLUG_API
    m_usb_thread.reset(new LibUsbHotplugThread(
          m_context, hotplug_callback, this));
#else
    OLA_FATAL << "Mismatch between m_use_hotplug and "
      " HAVE_LIBUSB_HOTPLUG_API";
    return false;
#endif
  } else {
    m_usb_thread.reset(new LibUsbSimpleThread(m_context));
  }
  m_usb_adaptor.reset(new AsyncronousLibUsbAdaptor(m_usb_thread.get()));

  // Setup the factories.
  m_widget_factories.push_back(new AnymauDMXFactory(m_usb_adaptor.get()));
  m_widget_factories.push_back(
      new EuroliteProFactory(m_usb_adaptor.get()));
  m_widget_factories.push_back(
      new JaRuleFactory(m_plugin_adaptor, m_usb_adaptor.get()));
  m_widget_factories.push_back(
      new ScanlimeFadecandyFactory(m_usb_adaptor.get()));
  m_widget_factories.push_back(new SunliteFactory(m_usb_adaptor.get()));
  m_widget_factories.push_back(new VellemanK8062Factory(m_usb_adaptor.get()));

  // If we're using hotplug, this starts the hotplug thread.
  if (!m_usb_thread->Init()) {
    STLDeleteElements(&m_widget_factories);
    m_usb_adaptor.reset();
    m_usb_thread.reset();
    return false;
  }

  if (!m_use_hotplug) {
    // Either we don't support hotplug or the setup failed.
    // As poor man's hotplug, we call libusb_get_device_list periodically to
    // check for new devices.
    m_scan_timeout = m_plugin_adaptor->RegisterRepeatingTimeout(
        TimeInterval(5, 0),
        NewCallback(this, &AsyncPluginImpl::ScanUSBDevices));

    // Call it immediately now.
    ScanUSBDevices();
  }

  return true;
}
Ejemplo n.º 4
0
/*
 * Start this device
 */
bool SPIDevice::StartHook() {
  if (!m_backend->Init()) {
    STLDeleteElements(&m_spi_ports);
    return false;
  }

  SPIPorts::iterator iter = m_spi_ports.begin();
  for (uint8_t i = 0; iter != m_spi_ports.end(); iter++, i++) {
    uint8_t personality;
    if (StringToInt(m_preferences->GetValue(PersonalityKey(i)),
                    &personality)) {
      (*iter)->SetPersonality(personality);
    }

    uint16_t dmx_address;
    if (StringToInt(m_preferences->GetValue(StartAddressKey(i)),
                                            &dmx_address)) {
      (*iter)->SetStartAddress(dmx_address);
    }

    AddPort(*iter);
  }
  return true;
}
Ejemplo n.º 5
0
DraggedTabView::~DraggedTabView()
{
    parent()->RemoveChildView(this);
    container_->CloseNow();
    STLDeleteElements(&renderers_);
}
Ejemplo n.º 6
0
void StatusTray::RemoveAllIcons()
{
    STLDeleteElements(&status_icons_);
}
LsiRewriteDriverFactory::~LsiRewriteDriverFactory()
{
    ShutDown();
    m_pSharedCircularBuffer = NULL;
    STLDeleteElements(&uninitialized_server_contexts_);
}
Ejemplo n.º 8
0
 GridLayout::~GridLayout()
 {
     STLDeleteElements(&column_sets_);
     STLDeleteElements(&view_states_);
     STLDeleteElements(&rows_);
 }
Ejemplo n.º 9
0
 ColumnSet::~ColumnSet()
 {
     STLDeleteElements(&columns_);
 }
Ejemplo n.º 10
0
AsyncPluginImpl::~AsyncPluginImpl() {
  STLDeleteElements(&m_widget_factories);
}
Ejemplo n.º 11
0
 virtual ~ImageRepSkia()
 {
     STLDeleteElements(&bitmaps_);
 }