Beispiel #1
0
int main(int argc, char *argv[]) {

    if (argc > 1) {
        run(argv[1]);
    }
    else
        device_list();

    return 1;
}
static int open_stack_internal(void)
{
	struct sockaddr_hci addr;
	struct hci_filter flt;
	int fd, opt = 1;

	fd = socket(AF_BLUETOOTH, SOCK_RAW | SOCK_CLOEXEC, BTPROTO_HCI);
	if (fd < 0) {
		perror("Failed to open channel");
		return -1;
	}

	/* Setup filter */
	hci_filter_clear(&flt);
	hci_filter_set_ptype(HCI_EVENT_PKT, &flt);
	hci_filter_set_event(EVT_STACK_INTERNAL, &flt);

	if (setsockopt(fd, SOL_HCI, HCI_FILTER, &flt, sizeof(flt)) < 0) {
		perror("Failed to set HCI filter");
		close(fd);
		return -1;
	}

	if (setsockopt(fd, SOL_HCI, HCI_TIME_STAMP, &opt, sizeof(opt)) < 0) {
		perror("Failed to enable HCI time stamps");
		close(fd);
		return -1;
	}

	memset(&addr, 0, sizeof(addr));
	addr.hci_family = AF_BLUETOOTH;
	addr.hci_dev = HCI_DEV_NONE;
	addr.hci_channel = HCI_CHANNEL_RAW;

	if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
		perror("Failed to bind channel");
		close(fd);
		return -1;
	}

	device_list(fd, HCI_MAX_DEV);

	return fd;
}
Beispiel #3
0
static gboolean
device_get_name (GstOSXVideoSrc * src)
{
  GList *l, *list;
  video_device *dev;
  gboolean ret;

  /* if there is no device set, then attempt to set up with the default,
   * which will also grab the name in the process.
   */
  if (!src->device_id)
    return device_set_default (src);

  /* if we already have a name, free it */
  if (src->device_name) {
    g_free (src->device_name);
    src->device_name = NULL;
  }

  /* obtain the device list */
  list = device_list (src);
  if (!list)
    return FALSE;

  ret = FALSE;

  /* look up the id */
  for (l = list; l != NULL; l = l->next) {
    dev = (video_device *) l->data;
    if (g_str_equal (dev->id, src->device_id)) {
      /* take the string, no need to copy */
      src->device_name = dev->name;
      dev->name = NULL;
      ret = TRUE;
      break;
    }
  }

  g_list_foreach (list, video_device_free_func, NULL);
  g_list_free (list);

  return ret;
}
Beispiel #4
0
std::vector<RAWINPUTDEVICELIST> rawinput_device_list(){
	UINT _num_devices;
    UINT _result;

	if(0 != GetRawInputDeviceList(0, &_num_devices, sizeof(RAWINPUTDEVICELIST))){
		std::cerr << "0 != GetRawInputDeviceList(0, &num_devices, sizeof(RAWINPUTDEVICELIST))" << std::endl;
        return std::vector<RAWINPUTDEVICELIST>();
	}

    std::vector<RAWINPUTDEVICELIST> device_list(_num_devices);
    _result = GetRawInputDeviceList(&device_list[0], &_num_devices, sizeof(RAWINPUTDEVICELIST));
	if(-1 == _result){
		std::cerr << "-1 == _result" << std::endl;
		return std::vector<RAWINPUTDEVICELIST>();
	}
	
    device_list.resize(_result);
	return device_list;
}
Beispiel #5
0
static GValueArray *
probe_get_values (GstPropertyProbe * probe, guint prop_id,
    const GParamSpec * pspec)
{
  GstOSXVideoSrc *src;
  GValueArray *array;
  GValue value = { 0, };
  GList *l, *list;
  video_device *dev;

  if (!g_str_equal (pspec->name, "device")) {
    G_OBJECT_WARN_INVALID_PROPERTY_ID (probe, prop_id, pspec);
    return NULL;
  }

  src = GST_OSX_VIDEO_SRC (probe);

  list = device_list (src);

  if (list == NULL) {
    GST_LOG_OBJECT (probe, "No devices found");
    return NULL;
  }

  array = g_value_array_new (g_list_length (list));
  g_value_init (&value, G_TYPE_STRING);
  for (l = list; l != NULL; l = l->next) {
    dev = (video_device *) l->data;
    GST_LOG_OBJECT (probe, "Found device: %s", dev->id);
    g_value_take_string (&value, dev->id);
    dev->id = NULL;
    video_device_free (dev);
    l->data = NULL;
    g_value_array_append (array, &value);
  }
  g_value_unset (&value);
  g_list_free (list);

  return array;
}
Beispiel #6
0
static gboolean
device_set_default (GstOSXVideoSrc * src)
{
  GList *list;
  video_device *dev;
  gboolean ret;

  /* obtain the device list */
  list = device_list (src);
  if (!list)
    return FALSE;

  ret = FALSE;

  /* the first item is the default */
  if (g_list_length (list) >= 1) {
    dev = (video_device *) list->data;

    /* take the strings, no need to copy */
    src->device_id = dev->id;
    src->device_name = dev->name;
    dev->id = NULL;
    dev->name = NULL;

    /* null out the item */
    video_device_free (dev);
    list->data = NULL;

    ret = TRUE;
  }

  /* clean up */
  g_list_foreach (list, video_device_free_func, NULL);
  g_list_free (list);

  return ret;
}
main (int argc, char *argv[])
{
  device_list(SND_PCM_STREAM_CAPTURE);
  device_list(SND_PCM_STREAM_PLAYBACK);
}
Beispiel #8
0
bool ParticleSystem::initCL(void)
{
  INFO("Initializing OpenCL subsystem");

#if 0
  std::cerr << "this                : " << (void *) this << std::endl;
      
  std::cerr << "&m_shader           : " << (void *) &m_shader << std::endl;
  std::cerr << "&m_particle_geom    : " << (void *) &m_particle_geom << std::endl;
  std::cerr << "&m_cl_ctx           : " << (void *) &m_cl_ctx << std::endl;
  std::cerr << "&m_cl_queue         : " << (void *) &m_cl_queue << std::endl;
  std::cerr << "&m_particle_pos_buf : " << (void *) &m_particle_pos_buf << std::endl;
  std::cerr << "&m_particle_col_buf : " << (void *) &m_particle_col_buf << std::endl;
  std::cerr << "&m_num_particles    : " << (void *) &m_num_particles << std::endl;
  //std::cerr << "&m_volume_min       : " << (void *) &m_volume_min << std::endl;
  //std::cerr << "&m_volume_max       : " << (void *) &m_volume_max << std::endl;
  //
  std::cerr << "m_cl_ctx()          : " << m_cl_ctx() << std::endl;
  std::cerr << "m_cl_queue()        : " << m_cl_queue() << std::endl;
#endif

  /* select appropriate device and platform */
  cl_platform_id platform = nullptr;
  cl_device_id device = nullptr;

  if ((!ocl::selectGLDeviceAndPlatform(&device, &platform)) &&
      (!ocl::selectPlatformAndDevice(&device, &platform)))
  {
    ERROR("Failed to select an appropriate device or platform");
    return false;
  }

  //std::cerr << "m_cl_ctx: " << m_cl_ctx() << std::endl;
  //std::cerr << "m_cl_queue: " << m_cl_queue() << std::endl;

  std::vector<cl::Device> device_list(1, device);

  /* setup context */
  cl_context_properties props[] = {
#if defined(FLUIDSIM_OS_MAC)
    CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE,
    (cl_context_properties) CGLGetShareGroup(CGLGetCurrentContext()),
#elif defined(FLUIDSIM_OS_UNIX)
    CL_GL_CONTEXT_KHR, (cl_context_properties) glXGetCurrentContext(), 
    CL_GLX_DISPLAY_KHR, (cl_context_properties) glXGetCurrentDisplay(), 
    CL_CONTEXT_PLATFORM, (cl_context_properties) platform,
#elif defined(FLUIDSIM_OS_WIN)
    CL_GL_CONTEXT_KHR, (cl_context_properties) wglGetCurrentContext(),
    CL_WGL_HDC_KHR, (cl_context_properties) wglGetCurrentDC(),
    CL_CONTEXT_PLATFORM, (cl_context_properties) platform,
#else
# error "Unsupported OS platform"
#endif
    0
  };

  cl_int err = CL_SUCCESS;
  m_cl_ctx = cl::Context(device_list, props, nullptr, nullptr, &err);
  if (err != CL_SUCCESS)
  {
    ERROR("Failed to create OpenCL context: " << ocl::errorToStr(err));
    return false;
  }

  /* create command queue */
  m_cl_queue = cl::CommandQueue(m_cl_ctx, device, CL_QUEUE_PROFILING_ENABLE, &err);
  if (err != CL_SUCCESS)
  {
    ERROR("Failed to create OpenCL command queue: " << ocl::errorToStr(err));
    return false;
  }

  /* pass the context pointer to OpenGL shared buffers */
  m_particle_pos_buf.setCLContext(m_cl_ctx());
  m_particle_col_buf.setCLContext(m_cl_ctx());

  INFO("Successfully initialized OpenCL context and command queue");

  return true;
}