Skip to content

Commit

Permalink
remove vid (pipeline used default, 0, meaning any)
Browse files Browse the repository at this point in the history
  • Loading branch information
maloel committed Oct 4, 2023
1 parent 99c9420 commit d714cfa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 42 deletions.
45 changes: 5 additions & 40 deletions src/device_hub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,57 +6,22 @@
#include "core/processing.h"
#include "proc/synthetic-stream.h"
#include "device_hub.h"
#include "platform/platform-device-info.h"

namespace librealsense
{
typedef rs2::devices_changed_callback<std::function<void(rs2::event_information& info)>> hub_devices_changed_callback;

std::vector< std::shared_ptr< device_info > >
filter_by_vid( std::vector< std::shared_ptr< device_info > > const & devices, int vid )
{
std::vector<std::shared_ptr<device_info>> result;
for (auto & dev : devices)
{
auto pdev = std::dynamic_pointer_cast< platform::platform_device_info >( dev );
if( ! pdev )
{
if( vid == 0 )
result.push_back( dev );
continue;
}
auto & data = pdev->get_group();
for (const auto& usb : data.usb_devices)
{
if (usb.vid == vid || vid == 0)
{
result.push_back(dev);
break;
}
}
for (const auto& uvc : data.uvc_devices)
{
if (uvc.vid == vid || vid == 0)
{
result.push_back(dev);
break;
}
}
}
return result;
}

device_hub::device_hub(std::shared_ptr<librealsense::context> ctx, int mask, int vid)
: _ctx(ctx), _vid(vid),
device_hub::device_hub(std::shared_ptr<librealsense::context> ctx, int mask)
: _ctx(ctx),
_device_changes_callback_id(0)
{
_device_list = filter_by_vid(_ctx->query_devices(mask), _vid);
_device_list = _ctx->query_devices(mask);

auto cb = new hub_devices_changed_callback([&,mask](rs2::event_information&)
{
std::unique_lock<std::mutex> lock(_mutex);

_device_list = filter_by_vid(_ctx->query_devices(mask), _vid);
_device_list = _ctx->query_devices(mask);

// Current device will point to the first available device
_camera_index = 0;
Expand Down Expand Up @@ -126,7 +91,7 @@ namespace librealsense
std::shared_ptr<device_interface> res = nullptr;

// check if there is at least one device connected
_device_list = filter_by_vid(_ctx->query_devices(RS2_PRODUCT_LINE_ANY), _vid);
_device_list = _ctx->query_devices(RS2_PRODUCT_LINE_ANY);
if (_device_list.size() > 0)
{
res = create_device(serial, loop_through_devices);
Expand Down
3 changes: 1 addition & 2 deletions src/device_hub.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace librealsense
class device_hub
{
public:
explicit device_hub(std::shared_ptr<librealsense::context> ctx, int mask = RS2_PRODUCT_LINE_ANY, int vid = 0);
explicit device_hub(std::shared_ptr<librealsense::context> ctx, int mask = RS2_PRODUCT_LINE_ANY);

~device_hub();

Expand Down Expand Up @@ -52,7 +52,6 @@ namespace librealsense
std::condition_variable _cv;
std::vector<std::shared_ptr<device_info>> _device_list;
int _camera_index = 0;
int _vid = 0;
uint64_t _device_changes_callback_id;
};
}

0 comments on commit d714cfa

Please sign in to comment.