free device queue in scanner_manager

This commit is contained in:
gb 2023-08-25 15:03:10 +08:00
parent f04e66afa7
commit 133225aaa8
1 changed files with 9 additions and 2 deletions

View File

@ -160,6 +160,13 @@ hg_scanner_mgr::hg_scanner_mgr() : same_ind_(1), user_(""), pwd_(""), cf_name(""
} }
hg_scanner_mgr::~hg_scanner_mgr() hg_scanner_mgr::~hg_scanner_mgr()
{ {
{
std::lock_guard<std::mutex> lock(mutex_dev_);
for (auto& v : online_devices_)
libusb_unref_device(v.dev);
online_devices_.clear();
}
usb_manager::clear(); usb_manager::clear();
} }
@ -366,7 +373,7 @@ void hg_scanner_mgr::on_hgscanner_pnp(usb_event ev, libusb_device* device, int v
int index = -1; int index = -1;
for (int i = 0; i < _countof(g_supporting_devices); ++i) for (int i = 0; i < _countof(g_supporting_devices); ++i)
{ {
// 064B 澶氬彴璁惧浣跨敤杩欎釜vid锛屾墍浠ュ姞杞芥椂涓嶄細娓呮瑕佹墦寮€鍝竴鍙拌澶囷紝鍙湁閫氳繃澶栭儴杩涜鍔犺浇鏀瑰彉瀹炰緥 // 064B 婢舵艾褰寸拋鎯ь槵娴法鏁ゆ潻娆庨嚋vid閿涘本澧嶆禒銉ュ<EFBFBD>鏉炶姤妞傛稉宥勭窗濞撳懏顨熺憰浣瑰ⅵ瀵<EFBFBD>偓閸濐亙绔撮崣鎷岊啎婢跺浄绱濋崣顏呮箒闁<EFBFBD>俺绻冩径鏍<EFBFBD>劥鏉╂稖顢戦崝鐘烘祰閺€鐟板綁鐎圭偘绶?
if (g_supporting_devices[i].vid == vid && g_supporting_devices[i].pid == pid) if (g_supporting_devices[i].vid == vid && g_supporting_devices[i].pid == pid)
{ {
index = i; index = i;
@ -401,7 +408,7 @@ void hg_scanner_mgr::on_hgscanner_pnp(usb_event ev, libusb_device* device, int v
break; break;
} }
} }
if (add) // 澶勭悊瀵硅薄鈥渄evice鈥濇敼鍙樼殑鎯呮櫙 if (add) // 婢跺嫮鎮婄€电<EFBFBD>钖勯垾娓別vice閳ユ繃鏁奸崣妯兼畱閹<EFBFBD>懏娅?
{ {
i = 0; i = 0;
for (auto& v : online_devices_) for (auto& v : online_devices_)