调整判断无纸状态出现奔溃

This commit is contained in:
13038267101 2022-11-18 16:05:39 +08:00
parent 83e1c026a8
commit b6065a4a3d
5 changed files with 34 additions and 25 deletions

View File

@ -1271,7 +1271,8 @@ void hg_scanner_239::thread_handle_usb_read(void)
}
if (status_ == SCANNER_ERR_DEVICE_STOPPED)
{
status_ = ret = get_scanner_paperon();
SANE_Bool b = false;
status_ = ret = get_scanner_paperon(&b);
}
VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "USB thread exit with code: %s, status = %s\n", hg_scanner_err_name(ret), hg_scanner_err_name(status_));
}

View File

@ -95,7 +95,7 @@ public:
virtual int set_sleep_time(int setsleepime); //设置功耗模式(休眠)
virtual int get_dogear_distance(void); //获取折角检测最小距离阈值
virtual int set_dogear_distance(void); //设置折角检测最小距离阈值
virtual int get_scanner_paperon(SANE_Bool* paperon = NULL);//获取设备有无纸张
virtual int get_scanner_paperon(SANE_Bool* paperon);//获取设备有无纸张
virtual int set_scan_when_paper_on(void); //获取是否为检测到进纸盘上有纸即开始扫描
virtual int get_scan_when_paper_on(void); //设置是否为检测到进纸盘上有纸即开始扫描
virtual int get_scan_with_hole(void); //获取是否为带孔扫描

View File

@ -112,7 +112,6 @@ using namespace std;
#define __stdcall
#endif
static int num=0;
#define SAFE_DELETE(p){ \
if (NULL != (p)) {delete []p; \
(p) = NULL; \

View File

@ -280,8 +280,17 @@ namespace local_utility
return unk;
}
int ui_cb(scanner_handle dev, int code, void* data, unsigned int* len, void* unused)
{
sane_callback cb_ui = NULL;
void* cb_ui_parm = NULL;
SANE_Auth_Callback cb_auth = NULL;
{
std::lock_guard<std::mutex> lck(cb_lock_);
cb_ui = cb_ui_;
cb_ui_parm = cb_ui_parm_;
cb_auth_ = cb_auth;
}
if (SANE_EVENT_SUPPORT_ASYNC_IO == code)
return cb_ui_ ? SCANNER_ERR_OK : SCANNER_ERR_DEVICE_NOT_SUPPORT;
@ -290,14 +299,14 @@ namespace local_utility
// VLOG_MINI_1(LOG_LEVEL_ALL, "sane callback invoked of event %s\n", sane_event((SANE_Event)code).c_str());
if (cb_ui_)
if (cb_ui)
{
return cb_ui_(h, code, data, len, cb_ui_parm_);
return cb_ui(h, code, data, len, cb_ui_parm);
}
else if (cb_auth_ && code == SANE_EVENT_NEED_AUTH)
else if (cb_auth && code == SANE_EVENT_NEED_AUTH)
{
SANEAUTH* auth = (SANEAUTH*)data;
cb_auth_(auth->resource, auth->name, auth->pwd);
cb_auth(auth->resource, auth->name, auth->pwd);
}
return 0;