Skip to content

Commit 32322f2

Browse files
committed
bmd status: print temperature in verbose
since the temperature changes quite often, rate limit it to one minute
1 parent 9adf205 commit 32322f2

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/blackmagic_common.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
#include "blackmagic_common.hpp"
6464
#include "debug.h"
6565
#include "host.h"
66+
#include "tv.h"
6667
#include "utils/color_out.h"
6768
#include "utils/macros.h"
6869
#include "utils/windows.h"
@@ -1346,6 +1347,10 @@ static const struct status_property {
13461347
"PCIe Link Speed", ST_INT,
13471348
{ .int_fmt_str = "Gen. %" PRIu64 },
13481349
false, LOG_LEVEL_VERBOSE },
1350+
{ bmdDeckLinkStatusDeviceTemperature,
1351+
"Temperature", ST_INT,
1352+
{ .int_fmt_str = "%" PRIu64 " °C" },
1353+
false, LOG_LEVEL_VERBOSE }, // temperature info is rate-limited
13491354
{ bmdDeckLinkStatusDetectedVideoInputColorspace,
13501355
"Video Colorspace", ST_ENUM,
13511356
{ .map = bmd_cs_map },
@@ -1497,6 +1502,10 @@ class BMDNotificationCallback : public IDeckLinkNotificationCallback
14971502

14981503
// Print the updated status value
14991504
auto statusId = (BMDDeckLinkStatusID) param1;
1505+
if (statusId == bmdDeckLinkStatusDeviceTemperature) {
1506+
HandleTemperature();
1507+
return S_OK;
1508+
}
15001509
print_status_item(m_deckLinkStatus, statusId,
15011510
m_logPrefix.c_str());
15021511

@@ -1523,12 +1532,26 @@ class BMDNotificationCallback : public IDeckLinkNotificationCallback
15231532
return newRefValue;
15241533
}
15251534

1535+
void HandleTemperature() {
1536+
const time_ns_t now = get_time_in_ns();
1537+
if (now - m_tempLastShown < m_tempShowInt) {
1538+
return;
1539+
}
1540+
print_status_item(m_deckLinkStatus,
1541+
bmdDeckLinkStatusDeviceTemperature,
1542+
m_logPrefix.c_str());
1543+
m_tempLastShown = now;
1544+
}
1545+
15261546
private:
15271547
IDeckLinkStatus *m_deckLinkStatus;
15281548
IDeckLinkNotification *m_deckLinkNotification;
15291549
string m_logPrefix;
15301550
std::atomic<ULONG> m_refCount;
15311551

1552+
static constexpr time_ns_t m_tempShowInt = SEC_TO_NS(60);
1553+
time_ns_t m_tempLastShown = 0;
1554+
15321555
virtual ~BMDNotificationCallback()
15331556
{
15341557
BMD_CHECK(

0 commit comments

Comments
 (0)