Skip to content

Commit

Permalink
Avoid repeatd error messages in HidIoGlobalOutputReportFifo::sendNext…
Browse files Browse the repository at this point in the history
…ReportDataset() when hid_write() fails.
  • Loading branch information
daschuer committed Oct 6, 2024
1 parent d6eeb45 commit 5b0f2a8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/controllers/hid/hidioglobaloutputreportfifo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ constexpr size_t kSizeOfFifoInReports = 32;
} // namespace

HidIoGlobalOutputReportFifo::HidIoGlobalOutputReportFifo()
: m_fifoQueue(kSizeOfFifoInReports) {
: m_fifoQueue(kSizeOfFifoInReports),
m_hidWriteErrorLogged(false) {
}

void HidIoGlobalOutputReportFifo::addReportDatasetToFifo(const quint8 reportId,
Expand Down Expand Up @@ -69,10 +70,16 @@ bool HidIoGlobalOutputReportFifo::sendNextReportDataset(QMutex* pHidDeviceAndPol
reinterpret_cast<const unsigned char*>(reportToSend.constData()),
reportToSend.size());
if (result == -1) {
qCWarning(logOutput) << "Unable to send data to" << deviceInfo.formatName() << ":"
<< mixxx::convertWCStringToQString(
hid_error(pHidDevice),
kMaxHidErrorMessageSize);
if (!m_hidWriteErrorLogged) {
qCWarning(logOutput) << "Unable to send data to" << deviceInfo.formatName() << ":"
<< mixxx::convertWCStringToQString(
hid_error(pHidDevice),
kMaxHidErrorMessageSize);
// Stop logging error messages if every hid_write() fails to avoid large log files
m_hidWriteErrorLogged = true;
}
} else {
m_hidWriteErrorLogged = false;
}

hidDeviceLock.unlock();
Expand Down
1 change: 1 addition & 0 deletions src/controllers/hid/hidioglobaloutputreportfifo.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ class HidIoGlobalOutputReportFifo {
private:
// Lockless FIFO queue
rigtorp::SPSCQueue<QByteArray> m_fifoQueue;
bool m_hidWriteErrorLogged;
};

0 comments on commit 5b0f2a8

Please sign in to comment.