Skip to content

Commit 9adf205

Browse files
committed
bmd_status: use module prefix
to be able to identify capture vs playback This may or may not be important - if cap/disp is on single device, the status is global so it doesn't matter there. But those can be 2 separate DeckLinks and then there will be hard to differntiate. Also, both devices will get the same notifications so this makes at least clear that the duplicate has some reason. (Maybe it will be useful to figure out how to print just once?) Note that BMD_CHECK still uses the blackmagic_common.cpp MOD_NMAE ("[DeckLink] ").
1 parent 5f67a06 commit 9adf205

File tree

4 files changed

+39
-22
lines changed

4 files changed

+39
-22
lines changed

src/blackmagic_common.cpp

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,8 @@ static const struct status_property {
13841384
true, LOG_LEVEL_INFO },
13851385
};
13861386
static void
1387-
print_status_item(IDeckLinkStatus *deckLinkStatus, BMDDeckLinkStatusID prop)
1387+
print_status_item(IDeckLinkStatus *deckLinkStatus, BMDDeckLinkStatusID prop,
1388+
const char *log_prefix)
13881389
{
13891390
const struct status_property *s_prop = nullptr;
13901391

@@ -1408,8 +1409,10 @@ print_status_item(IDeckLinkStatus *deckLinkStatus, BMDDeckLinkStatusID prop)
14081409
: deckLinkStatus->GetInt(s_prop->prop, &int_val);
14091410
if (!SUCCEEDED(rc)) {
14101411
if (FAILED(rc) && rc != E_NOTIMPL) {
1411-
MSG(WARNING, "Obtain property 0x%08x value: %s\n",
1412-
(unsigned) prop, bmd_hresult_to_string(rc).c_str());
1412+
log_msg(LOG_LEVEL_WARNING,
1413+
"%sObtain property 0x%08x value: %s\n",
1414+
log_prefix, (unsigned) prop,
1415+
bmd_hresult_to_string(rc).c_str());
14131416
}
14141417
return;
14151418
}
@@ -1418,13 +1421,15 @@ print_status_item(IDeckLinkStatus *deckLinkStatus, BMDDeckLinkStatusID prop)
14181421
case ST_STRING: {
14191422
string str = get_str_from_bmd_api_str(string_val);
14201423
release_bmd_api_str(string_val);
1421-
MSG(INFO, "%s: %s\n", s_prop->prop_name, str.c_str());
1424+
log_msg(LOG_LEVEL_INFO, "%s%s: %s\n", log_prefix,
1425+
s_prop->prop_name, str.c_str());
14221426
break;
14231427
}
14241428
case ST_INT: {
14251429
char buf[STR_LEN];
14261430
snprintf_ch(buf, s_prop->type_data.int_fmt_str, int_val);
1427-
MSG(INFO, "%s: %s\n", s_prop->prop_name, buf);
1431+
log_msg(LOG_LEVEL_INFO, "%s%s: %s\n",
1432+
log_prefix, s_prop->prop_name, buf);
14281433
break;
14291434
}
14301435
case ST_BIT_FIELD: {
@@ -1443,7 +1448,8 @@ print_status_item(IDeckLinkStatus *deckLinkStatus, BMDDeckLinkStatusID prop)
14431448
snprintf_ch(val, "%s", s_prop->type_data.map[0].name);
14441449
}
14451450

1446-
MSG(INFO, "%s: %s\n", s_prop->prop_name, val);
1451+
log_msg(LOG_LEVEL_INFO, "%s%s: %s\n", log_prefix,
1452+
s_prop->prop_name, val);
14471453
break;
14481454
}
14491455
case ST_ENUM: {
@@ -1456,7 +1462,8 @@ print_status_item(IDeckLinkStatus *deckLinkStatus, BMDDeckLinkStatusID prop)
14561462
}
14571463
}
14581464

1459-
MSG(INFO, "%s: %s\n", s_prop->prop_name, val);
1465+
log_msg(LOG_LEVEL_INFO, "%s%s: %s\n", log_prefix,
1466+
s_prop->prop_name, val);
14601467
break;
14611468
}
14621469
}
@@ -1468,9 +1475,10 @@ class BMDNotificationCallback : public IDeckLinkNotificationCallback
14681475
public:
14691476
explicit BMDNotificationCallback(
14701477
IDeckLinkStatus *deckLinkStatus,
1471-
IDeckLinkNotification *deckLinkNotification)
1478+
IDeckLinkNotification *deckLinkNotification, const char *log_prefix)
14721479
: m_deckLinkStatus(deckLinkStatus),
1473-
m_deckLinkNotification(deckLinkNotification), m_refCount(1)
1480+
m_deckLinkNotification(deckLinkNotification),
1481+
m_logPrefix(log_prefix), m_refCount(1)
14741482

14751483
{
14761484
m_deckLinkStatus->AddRef();
@@ -1489,7 +1497,8 @@ class BMDNotificationCallback : public IDeckLinkNotificationCallback
14891497

14901498
// Print the updated status value
14911499
auto statusId = (BMDDeckLinkStatusID) param1;
1492-
print_status_item(m_deckLinkStatus, statusId);
1500+
print_status_item(m_deckLinkStatus, statusId,
1501+
m_logPrefix.c_str());
14931502

14941503
return S_OK;
14951504
}
@@ -1517,6 +1526,7 @@ class BMDNotificationCallback : public IDeckLinkNotificationCallback
15171526
private:
15181527
IDeckLinkStatus *m_deckLinkStatus;
15191528
IDeckLinkNotification *m_deckLinkNotification;
1529+
string m_logPrefix;
15201530
std::atomic<ULONG> m_refCount;
15211531

15221532
virtual ~BMDNotificationCallback()
@@ -1547,7 +1557,8 @@ class BMDNotificationCallback : public IDeckLinkNotificationCallback
15471557
* destroy with bmd_unsubscribe_notify()
15481558
*/
15491559
BMDNotificationCallback *
1550-
bmd_print_status_subscribe_notify(IDeckLink *deckLink, bool capture)
1560+
bmd_print_status_subscribe_notify(IDeckLink *deckLink, const char *log_prefix,
1561+
bool capture)
15511562
{
15521563
IDeckLinkProfileAttributes *deckLinkAttributes = nullptr;
15531564
HRESULT result = deckLink->QueryInterface(
@@ -1558,13 +1569,15 @@ bmd_print_status_subscribe_notify(IDeckLink *deckLink, bool capture)
15581569
BMDDeckLinkEthernetMACAddress, &string_val))) {
15591570
string mac_addr = get_str_from_bmd_api_str(string_val);
15601571
release_bmd_api_str(string_val);
1561-
MSG(INFO, "Ethernet MAC address: %s\n",
1562-
mac_addr.c_str());
1572+
log_msg(LOG_LEVEL_INFO, "%sEthernet MAC address: %s\n",
1573+
log_prefix, mac_addr.c_str());
15631574
}
15641575
deckLinkAttributes->Release();
15651576
} else {
1566-
MSG(ERROR, "Cannot obtain IID_IDeckLinkProfileAttributes from "
1567-
"DeckLink!\n");
1577+
log_msg(LOG_LEVEL_ERROR,
1578+
"%sCannot obtain IID_IDeckLinkProfileAttributes from "
1579+
"DeckLink: %s\n",
1580+
log_prefix, bmd_hresult_to_string(result).c_str());
15681581
}
15691582

15701583
IDeckLinkStatus *deckLinkStatus = nullptr;
@@ -1577,7 +1590,8 @@ bmd_print_status_subscribe_notify(IDeckLink *deckLink, bool capture)
15771590
if (capture && status_map[u].playback_only) {
15781591
continue;
15791592
}
1580-
print_status_item(deckLinkStatus, status_map[u].prop);
1593+
print_status_item(deckLinkStatus, status_map[u].prop,
1594+
log_prefix);
15811595
}
15821596

15831597
// Obtain the notification interface
@@ -1588,8 +1602,8 @@ bmd_print_status_subscribe_notify(IDeckLink *deckLink, bool capture)
15881602
deckLinkStatus->Release();
15891603
return nullptr);
15901604

1591-
auto *notificationCallback =
1592-
new BMDNotificationCallback(deckLinkStatus, deckLinkNotification);
1605+
auto *notificationCallback = new BMDNotificationCallback(
1606+
deckLinkStatus, deckLinkNotification, log_prefix);
15931607
assert(notificationCallback != nullptr);
15941608

15951609
BMD_CHECK(deckLinkNotification->Subscribe(bmdStatusChanged,

src/blackmagic_common.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,9 @@ std::vector<bmd_dev> bmd_get_sorted_devices(bool *com_initialized,
192192
bool verbose = true,
193193
bool natural_sort = false);
194194
class BMDNotificationCallback;
195-
BMDNotificationCallback *bmd_print_status_subscribe_notify(IDeckLink *deckLink,
196-
bool capture);
195+
BMDNotificationCallback *
196+
bmd_print_status_subscribe_notify(IDeckLink *deckLink, const char *log_prefix,
197+
bool capture);
197198
void bmd_unsubscribe_notify(BMDNotificationCallback *notificationCallback);
198199

199200
#endif // defined BLACKMAGIC_COMMON_HPP

src/video_capture/decklink.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1420,7 +1420,8 @@ bool device_state::init(struct vidcap_decklink_state *s, struct tile *t, BMDAudi
14201420
displayModeIterator->Release();
14211421
displayModeIterator = NULL;
14221422

1423-
notificationCallback = bmd_print_status_subscribe_notify(deckLink, true);
1423+
notificationCallback =
1424+
bmd_print_status_subscribe_notify(deckLink, MOD_NAME, true);
14241425

14251426
return true;
14261427
}

src/video_display/decklink.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1576,7 +1576,8 @@ static void *display_decklink_init(struct module *parent, const char *fmt, unsig
15761576
s->delegate.SetDecklinkOutput(s->deckLinkOutput);
15771577
}
15781578
// s->state.at(i).deckLinkOutput->DisableAudioOutput();
1579-
s->notificationCallback = bmd_print_status_subscribe_notify(s->deckLink, false);
1579+
s->notificationCallback =
1580+
bmd_print_status_subscribe_notify(s->deckLink, MOD_NAME, false);
15801581

15811582
return (void *)s;
15821583
}

0 commit comments

Comments
 (0)