Skip to content

Commit

Permalink
Append a note about hid_read() and hid_write() errors are only logged…
Browse files Browse the repository at this point in the history
… once.

Co-authored-by: JoergAtGithub <[email protected]>
  • Loading branch information
daschuer and JoergAtGithub committed Oct 6, 2024
1 parent 5b0f2a8 commit 233445a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
13 changes: 9 additions & 4 deletions src/controllers/hid/hidioglobaloutputreportfifo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,15 @@ bool HidIoGlobalOutputReportFifo::sendNextReportDataset(QMutex* pHidDeviceAndPol
reportToSend.size());
if (result == -1) {
if (!m_hidWriteErrorLogged) {
qCWarning(logOutput) << "Unable to send data to" << deviceInfo.formatName() << ":"
<< mixxx::convertWCStringToQString(
hid_error(pHidDevice),
kMaxHidErrorMessageSize);
qCWarning(logOutput)
<< "Unable to send data to" << deviceInfo.formatName()
<< ":"
<< mixxx::convertWCStringToQString(
hid_error(pHidDevice), kMaxHidErrorMessageSize)
<< "Note that, this message is only logged once and may "
"not appear again until all hid_read errors have "
"disappeared.";

// Stop logging error messages if every hid_write() fails to avoid large log files
m_hidWriteErrorLogged = true;
}
Expand Down
12 changes: 8 additions & 4 deletions src/controllers/hid/hidiooutputreport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,14 @@ bool HidIoOutputReport::sendCachedData(QMutex* pHidDeviceAndPollMutex,
m_lastSentData.size());
if (result == -1) {
if (!m_hidWriteErrorLogged) {
qCWarning(logOutput) << "Unable to send data to device :"
<< mixxx::convertWCStringToQString(
hid_error(pHidDevice),
kMaxHidErrorMessageSize);
qCWarning(logOutput)
<< "Unable to send data to device :"
<< mixxx::convertWCStringToQString(
hid_error(pHidDevice), kMaxHidErrorMessageSize)
<< "Note that, this message is only logged once and may "
"not appear again until all hid_writee errors have "
"disappeared.";

// Stop logging error messages if every hid_write() fails to avoid large log files
m_hidWriteErrorLogged = true;
}
Expand Down
14 changes: 9 additions & 5 deletions src/controllers/hid/hidiothread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,15 @@ void HidIoThread::pollBufferedInputReports() {
// -1 is the only error value according to hidapi documentation.
DEBUG_ASSERT(bytesRead == -1);
if (!m_hidReadErrorLogged) {
qCWarning(m_logOutput) << "Unable to read buffered HID InputReports from"
<< m_deviceInfo.formatName() << ":"
<< mixxx::convertWCStringToQString(
hid_error(m_pHidDevice),
kMaxHidErrorMessageSize);
qCWarning(m_logOutput)
<< "Unable to read buffered HID InputReports from"
<< m_deviceInfo.formatName() << ":"
<< mixxx::convertWCStringToQString(
hid_error(m_pHidDevice),
kMaxHidErrorMessageSize)
<< "Note that, this message is only logged once and "
"may not appear again until all hid_read errors "
"have disappeared.";
// Stop logging error messages if every hid_read() fails to avoid large log files
m_hidReadErrorLogged = true;
}
Expand Down

0 comments on commit 233445a

Please sign in to comment.