Skip to content

Commit 20a3ed6

Browse files
committed
BMDNotificationCallback: watch overheating
soft warning >= 77 °C, hard over 82
1 parent 9ab3738 commit 20a3ed6

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

src/blackmagic_common.cpp

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,8 +1533,34 @@ class BMDNotificationCallback : public IDeckLinkNotificationCallback
15331533
}
15341534

15351535
void HandleTemperature() {
1536+
int64_t cur_temp = 0;
1537+
m_deckLinkStatus->GetInt(bmdDeckLinkStatusDeviceTemperature,
1538+
&cur_temp);
1539+
// check overheating
1540+
if (cur_temp >= m_tempThresholdErr) {
1541+
log_msg(LOG_LEVEL_ERROR,
1542+
"%sDevice is overheating! The temperature is "
1543+
"%" PRId64 " °C.\n",
1544+
m_logPrefix.c_str(), cur_temp);
1545+
return;
1546+
}
1547+
if (cur_temp < m_tempThresholdWarn &&
1548+
log_level < LOG_LEVEL_VERBOSE) {
1549+
return;
1550+
}
15361551
const time_ns_t now = get_time_in_ns();
1537-
if (now - m_tempLastShown < m_tempShowInt) {
1552+
if (cur_temp >= m_tempThresholdWarn &&
1553+
now - m_tempWarnLastShown > m_tempShowIntervalWarn) {
1554+
log_msg(
1555+
LOG_LEVEL_WARNING,
1556+
"%sDevice temperature is %" PRId64 " °C (>= %d °C).\n",
1557+
m_logPrefix.c_str(), cur_temp, m_tempThresholdWarn);
1558+
m_tempWarnLastShown = now;
1559+
return;
1560+
}
1561+
1562+
// normal behavior - print once a minute in verbose
1563+
if (now - m_tempLastShown < m_tempShowInterval) {
15381564
return;
15391565
}
15401566
print_status_item(m_deckLinkStatus,
@@ -1549,8 +1575,13 @@ class BMDNotificationCallback : public IDeckLinkNotificationCallback
15491575
string m_logPrefix;
15501576
std::atomic<ULONG> m_refCount;
15511577

1552-
static constexpr time_ns_t m_tempShowInt = SEC_TO_NS(60);
1553-
time_ns_t m_tempLastShown = 0;
1578+
// temperature check
1579+
static constexpr time_ns_t m_tempShowInterval = SEC_TO_NS(60);
1580+
static constexpr time_ns_t m_tempShowIntervalWarn = SEC_TO_NS(20);
1581+
static constexpr int m_tempThresholdWarn = 77;
1582+
static constexpr int m_tempThresholdErr = 82;
1583+
time_ns_t m_tempLastShown = 0;
1584+
time_ns_t m_tempWarnLastShown = 0;
15541585

15551586
virtual ~BMDNotificationCallback()
15561587
{

0 commit comments

Comments
 (0)