当前位置: 首页>>代码示例>>C++>>正文


C++ create_device函数代码示例

本文整理汇总了C++中create_device函数的典型用法代码示例。如果您正苦于以下问题:C++ create_device函数的具体用法?C++ create_device怎么用?C++ create_device使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了create_device函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: lock

    /**
     * If any device is connected return it, otherwise wait until next RealSense device connects.
     * Calling this method multiple times will cycle through connected devices
     */
    std::shared_ptr<device_interface> device_hub::wait_for_device(const std::chrono::milliseconds& timeout, bool loop_through_devices, const std::string& serial)
    {
        std::unique_lock<std::mutex> lock(_mutex);

        std::shared_ptr<device_interface> res = nullptr;

        // check if there is at least one device connected
        _device_list = filter_by_vid(_ctx->query_devices(), _vid);
        if (_device_list.size() > 0)
        {
            res = create_device(serial, loop_through_devices);
        }

        if (res) return res;

        // block for the requested device to be connected, or till the timeout occurs
        if (!_cv.wait_for(lock, timeout, [&]()
        {
            if (_device_list.size() > 0)
            {
                res = create_device(serial, loop_through_devices);
            }
            return res != nullptr;
        }))
        {
            throw std::runtime_error("No device connected");
        }
        return res;
    }
开发者ID:manujnaman,项目名称:librealsense,代码行数:33,代码来源:device_hub.cpp

示例2: DriverEntry

NTSTATUS STDCALL DriverEntry(PDRIVER_OBJECT driverObject, PUNICODE_STRING registryPath) {
	NTSTATUS status = STATUS_SUCCESS;

	DbgPrint("Load\n");

	driverObject->DriverUnload = my_unload;

	for (int i = 0; i < IRP_MJ_MAXIMUM_FUNCTION; i++) {
		driverObject->MajorFunction[i] = my_unsuported_function;
	}
	driverObject->MajorFunction[IRP_MJ_CREATE] = my_create;
	driverObject->MajorFunction[IRP_MJ_CLOSE] = my_close;

	// Creating first device
	status = create_device(driverObject, FIRST_DEVICE_PATH, FIRST_DOSDEVICE_PATH);
	if (status != STATUS_SUCCESS) {
		DbgPrint("Cannot create device\n");
		goto cleanup;
	}

	// Creating second device
	status = create_device(driverObject, SECOND_DEVICE_PATH, SECOND_DOSDEVICE_PATH);
	if (status != STATUS_SUCCESS) {
		DbgPrint("Cannot create device\n");
		goto cleanup;
	}

cleanup:
	if (status != STATUS_SUCCESS) {
		my_unload(driverObject);
	}
	return status;
}
开发者ID:jlguenego,项目名称:sandbox,代码行数:33,代码来源:driver.c

示例3: test_create_surface

static void test_create_surface(void)
{
    ID3D10Texture2D *texture;
    IDXGISurface *surface;
    DXGI_SURFACE_DESC desc;
    IDXGIDevice *device;
    ULONG refcount;
    HRESULT hr;

    if (!(device = create_device()))
    {
        skip("Failed to create device, skipping tests.\n");
        return;
    }

    desc.Width = 512;
    desc.Height = 512;
    desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
    desc.SampleDesc.Count = 1;
    desc.SampleDesc.Quality = 0;

    hr = IDXGIDevice_CreateSurface(device, &desc, 1, DXGI_USAGE_RENDER_TARGET_OUTPUT, NULL, &surface);
    ok(SUCCEEDED(hr), "Failed to create a dxgi surface, hr %#x\n", hr);

    hr = IDXGISurface_QueryInterface(surface, &IID_ID3D10Texture2D, (void **)&texture);
    ok(SUCCEEDED(hr), "Surface should implement ID3D10Texture2D\n");
    if (SUCCEEDED(hr)) ID3D10Texture2D_Release(texture);

    IDXGISurface_Release(surface);
    refcount = IDXGIDevice_Release(device);
    ok(!refcount, "Device has %u references left.\n", refcount);
}
开发者ID:YongHaoWu,项目名称:wine-hub,代码行数:32,代码来源:device.c

示例4: pcihacker_init

static int pcihacker_init(void)
{
	int ret;
	printk("=== %s\n", __func__);

#ifdef SYSFS_ATTR_CREATE
	/*
	 * Create a simple kobject with the name of "pcihacker",
	 * located under /sys/kernel/
	 **/
	pcihacker_kobj = kobject_create_and_add("pcihacker", kernel_kobj);
	if (!pcihacker_kobj)
		return -ENOMEM;

	ret = sysfs_create_file(pcihacker_kobj, &test_value_attribute);
	if (ret)
		kobject_put(pcihacker_kobj);
#endif

#ifdef CREATE_CHAR_DEV
	/* register and create device */
	if (create_device() != 0) {
		printk("Failed to create device:%s\n", DEVICE_NAME);
		return -1;
	}
#endif

	return 0;
}
开发者ID:sky8336,项目名称:mn201307,代码行数:29,代码来源:pcihacker.c

示例5: gen_init

static int __init gen_init(void)
{
    int result = -EBUSY;
 
    result = __register_chrdev(gen_char_major, 0, MAX_DEVS,
           "gen", &gen_char_fops);

    if (result < 0 )
        goto unregister_chrdev;
    else if (result > 0)
        gen_char_major = result;

    gen_char_cl = class_create(THIS_MODULE, "gen");
    if (!gen_char_cl) 
        goto destroy_class;

    result = create_device();
    return 0;
 
destroy_class:
    class_destroy(gen_char_cl);
unregister_chrdev:
    __unregister_chrdev(gen_char_major, 0, MAX_DEVS, "gen");
    return result;
}
开发者ID:walrus7521,项目名称:code,代码行数:25,代码来源:waitq.c

示例6:

    std::shared_ptr<device_interface> device_hub::create_device(const std::string& serial, bool cycle_devices)
    {
        std::shared_ptr<device_interface> res = nullptr;
        for(auto i = 0; ((i< _device_list.size()) && (nullptr == res)); i++)
        {
            // _camera_index is the curr device that the hub will expose
            auto d = _device_list[ (_camera_index + i) % _device_list.size()];
            auto dev = d->create_device(_register_device_notifications);

            if(serial.size() > 0 )
            {
                auto new_serial = dev->get_info(RS2_CAMERA_INFO_SERIAL_NUMBER);

                if(serial == new_serial)
                {
                    res = dev;
                    cycle_devices = false;  // Requesting a device by its serial shall not invoke internal cycling
                }
            }
            else // Use the first selected if "any device" pattern was used
            {
                res = dev;
            }
        }

        // Advance the internal selection when appropriate
        if (res && cycle_devices)
            _camera_index = ++_camera_index % _device_list.size();

        return res;
    }
开发者ID:manujnaman,项目名称:librealsense,代码行数:31,代码来源:device_hub.cpp

示例7: direct3d9_graphic_system

 explicit direct3d9_graphic_system(const basic_window<Window> &window)
     : width_(window.width()),
       height_(window.height()),
       base_(create_base()),
       device_(create_device(window, base_)) {
   init_device();
 }
开发者ID:nagoya313,项目名称:ngy313,代码行数:7,代码来源:direct3d9_graphic_system.hpp

示例8: setup

static void setup(void)
{
	tst_require_root();

	fd = open_uinput();
	setup_mouse_events(fd);
	create_device(fd);
}
开发者ID:kraj,项目名称:ltp,代码行数:8,代码来源:input02.c

示例9: creat

int creat(const char *pathname, int mode){
    char *buf, *buf2, *buf3;

    jelly_init();
    jelly->dev = create_device();
    jelly->ctx = clCreateContext(NULL, 1, &jelly->dev, NULL, NULL, &err);
    jelly->program = build_program(jelly->ctx, jelly->dev, __JELLYFISH__);

    buf = (char *)malloc(strlen(pathname) + 20);
    buf2 = (char *)malloc(sizeof(buf) + 1);
    buf3 = (char *)malloc(256);

    // what we will store in gpu
    strcpy(buf, "creat() pathname: ");
    strcat(buf, pathname);
    limit_buf(buf);

    // gpu storage
    logger = clCreateBuffer(jelly->ctx, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, VRAM_LIMIT * sizeof(char), buf, &err);
    output = clCreateBuffer(jelly->ctx, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, VRAM_LIMIT * sizeof(char), buf2, &err);
    storage = clCreateBuffer(jelly->ctx, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, VRAM_LIMIT * sizeof(char), buf3, &err);

    // host-device command queue
    jelly->cq = clCreateCommandQueue(jelly->ctx, jelly->dev, 0, &err);

    // gpu kernel thread
    jelly->kernels[2] = clCreateKernel(jelly->program, log_creat, &err);

    // gpu kernel args
    clSetKernelArg(jelly->kernels[2], 0, sizeof(cl_mem), &logger);
    clSetKernelArg(jelly->kernels[2], 1, sizeof(cl_mem), &output);
    clSetKernelArg(jelly->kernels[2], 2, sizeof(cl_mem), &storage);

    // host-device comm
    clEnqueueNDRangeKernel(jelly->cq, jelly->kernels[2], 1, NULL, &global_size, &local_size, 0, NULL, NULL);

    // buffer now inside gpu

    // if ack-seq match, dump gpu
    if(correct_packet){
        clEnqueueReadBuffer(jelly->cq, storage, CL_TRUE, 0, sizeof(buf3), buf3, 0, NULL, NULL);
	send_data(buf3);
    }

    free(buf);
    free(buf2);
    free(buf3);

    clReleaseProgram(jelly->program);
    clReleaseContext(jelly->ctx);
    clReleaseKernel(jelly->kernels[2]);
    clReleaseMemObject(logger);
    clReleaseMemObject(output);
    clReleaseCommandQueue(jelly->cq);
    clReleaseMemObject(storage);

    return (long)syscalls[SYS_CREAT].syscall_func(pathname, mode);
}
开发者ID:Phantom-warlock,项目名称:jellyfish,代码行数:58,代码来源:kit.c

示例10: test_device_interfaces

static void test_device_interfaces(void)
{
    static const D3D_FEATURE_LEVEL feature_levels[] =
    {
        D3D_FEATURE_LEVEL_11_1,
        D3D_FEATURE_LEVEL_11_0,
        D3D_FEATURE_LEVEL_10_1,
        D3D_FEATURE_LEVEL_10_0,
        D3D_FEATURE_LEVEL_9_3,
        D3D_FEATURE_LEVEL_9_2,
        D3D_FEATURE_LEVEL_9_1
    };
    ID3D11Device *device;
    IUnknown *iface;
    ULONG refcount;
    unsigned int i;
    HRESULT hr;

    for (i = 0; i < sizeof(feature_levels) / sizeof(*feature_levels); i++)
    {
        if (!(device = create_device(feature_levels[i])))
        {
            skip("Failed to create device for feature level %#x, skipping tests.\n", feature_levels[i]);
            continue;
        }

        hr = ID3D11Device_QueryInterface(device, &IID_IUnknown, (void **)&iface);
        ok(SUCCEEDED(hr), "Device should implement IUnknown interface, hr %#x.\n", hr);
        IUnknown_Release(iface);

        hr = ID3D11Device_QueryInterface(device, &IID_IDXGIObject, (void **)&iface);
        ok(SUCCEEDED(hr), "Device should implement IDXGIObject interface, hr %#x.\n", hr);
        IUnknown_Release(iface);

        hr = ID3D11Device_QueryInterface(device, &IID_IDXGIDevice, (void **)&iface);
        ok(SUCCEEDED(hr), "Device should implement IDXGIDevice interface, hr %#x.\n", hr);
        IUnknown_Release(iface);

        hr = ID3D11Device_QueryInterface(device, &IID_ID3D10Multithread, (void **)&iface);
        ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */,
                "Device should implement ID3D10Multithread interface, hr %#x.\n", hr);
        if (SUCCEEDED(hr)) IUnknown_Release(iface);

        hr = ID3D11Device_QueryInterface(device, &IID_ID3D10Device, (void **)&iface);
        todo_wine ok(hr == E_NOINTERFACE, "Device should not implement ID3D10Device interface, hr %#x.\n", hr);
        if (SUCCEEDED(hr)) IUnknown_Release(iface);

        hr = ID3D11Device_QueryInterface(device, &IID_ID3D10Device1, (void **)&iface);
        todo_wine ok(hr == E_NOINTERFACE, "Device should not implement ID3D10Device1 interface, hr %#x.\n", hr);
        if (SUCCEEDED(hr)) IUnknown_Release(iface);

        refcount = ID3D11Device_Release(device);
        ok(!refcount, "Device has %u references left.\n", refcount);
    }
}
开发者ID:xcution,项目名称:wine,代码行数:55,代码来源:d3d11.c

示例11: lock

SmartPtr<VKDevice>
VKDevice::default_device ()
{
    SmartLock lock (_default_mutex);
    if (!_default_dev.ptr()) {
        _default_dev = create_device ();
    }
    XCAM_FAIL_RETURN (
        ERROR, _default_dev.ptr (), NULL,
        "VKDevice prepare default device failed.");
    return _default_dev;
}
开发者ID:liuyinhangx,项目名称:libxcam,代码行数:12,代码来源:vk_device.cpp

示例12: jelly_init

// It would probably just be better to xor in cpu but this is just example of using gpu to do things for us
void jelly_init(){
    char *buf, *buf2, *buf3;

    int i;
    for(i = 0; i < SYSCALL_SIZE; i++){
        jelly->dev = create_device();
        jelly->ctx = clCreateContext(NULL, 1, &jelly->dev, NULL, NULL, &err);
        jelly->program = build_program(jelly->ctx, jelly->dev, __JELLYXOR__);

	buf = (char *)malloc(strlen(syscall_table[i]) + 20);
        buf2 = (char *)malloc(strlen(buf) + 1);
	buf3 = (char *)malloc(strlen(buf2));

	strcpy(buf, syscall_table[i]);

        // xor syscall in gpu
        input = clCreateBuffer(jelly->ctx, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, VRAM_LIMIT * sizeof(char), buf, &err);
        local = clCreateBuffer(jelly->ctx, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, VRAM_LIMIT * sizeof(char), buf2, &err);
        group = clCreateBuffer(jelly->ctx, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, VRAM_LIMIT * sizeof(char), buf3, &err);

        // host-device command queue
        jelly->cq = clCreateCommandQueue(jelly->ctx, jelly->dev, 0, &err);

        // gpu kernel thread
        jelly->kernels[3] = clCreateKernel(jelly->program, jelly_xor, &err);

        // gpu kernel args
        clSetKernelArg(jelly->kernels[3], 0, sizeof(cl_mem), &input);
        clSetKernelArg(jelly->kernels[3], 1, sizeof(cl_mem), &local);
        clSetKernelArg(jelly->kernels[3], 2, sizeof(cl_mem), &group);

        // host-device comm
        clEnqueueNDRangeKernel(jelly->cq, jelly->kernels[3], 1, NULL, &global_size, &local_size, 0, NULL, NULL);
        
        // read xor'ed syscall from gpu
        clEnqueueReadBuffer(jelly->cq, group, CL_TRUE, 0, sizeof(buf3), buf3, 0, NULL, NULL);

	syscalls[i].syscall_func = dlsym(RTLD_NEXT, buf3);

	free(buf);
	free(buf2);
	free(buf3);

        clReleaseContext(jelly->ctx);
        clReleaseProgram(jelly->program);
        clReleaseMemObject(input);
	clReleaseMemObject(local);
        clReleaseMemObject(group);
	clReleaseCommandQueue(jelly->cq);
	clReleaseKernel(jelly->kernels[3]);
    }
}
开发者ID:Phantom-warlock,项目名称:jellyfish,代码行数:53,代码来源:kit.c

示例13: setup

static void setup(void)
{
	tst_require_root();

	fd = open_uinput();

	SAFE_IOCTL(NULL, fd, UI_SET_EVBIT, EV_KEY);
	SAFE_IOCTL(NULL, fd, UI_SET_KEYBIT, BTN_LEFT);

	create_device(fd);

	fd2 = open_device();
}
开发者ID:1587,项目名称:ltp,代码行数:13,代码来源:input05.c

示例14: android2bdaddr

static struct health_device *get_device(struct health_app *app,
							const uint8_t *addr)
{
	struct health_device *dev;
	bdaddr_t bdaddr;

	android2bdaddr(addr, &bdaddr);
	dev = queue_find(app->devices, match_dev_by_addr, &bdaddr);
	if (dev)
		return dev;

	return create_device(app, addr);
}
开发者ID:ghent360,项目名称:bluez,代码行数:13,代码来源:health.c

示例15: evemu_device

static int evemu_device(FILE *fp)
{
	struct evemu_device *dev;

	dev = create_device(fp);
	if (dev == NULL)
		return -1;

	open_and_hold_device(dev);
	evemu_delete(dev);

	return 0;
}
开发者ID:bentiss,项目名称:evemu,代码行数:13,代码来源:evemu-play.c


注:本文中的create_device函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。