Skip to content

Commit 930c4c5

Browse files
committed
deltacast probes: filter by dev type + better name
- do not return SDI devices with deltacast_dv and vice versa - use better names by delta_get_model_name - vcap/deltacast: early return
1 parent 00da8d2 commit 930c4c5

File tree

5 files changed

+28
-38
lines changed

5 files changed

+28
-38
lines changed

src/deltacast_common.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ get_board_type(ULONG BoardIndex)
8181
return (VHD_BOARDTYPE) BoardType;
8282
}
8383

84-
static const char *
85-
get_model_name(ULONG BoardIndex)
84+
const char *
85+
delta_get_model_name(ULONG BoardIndex)
8686
{
8787
thread_local char buf[128];
8888
#if !defined VHD_MIN_6_00
@@ -306,7 +306,7 @@ static void
306306
print_board_info(int BoardIndex, ULONG DllVersion, bool full)
307307
{
308308
color_printf("\tBoard " TBOLD("%d") ": " TBOLD("%s") "\n", BoardIndex,
309-
get_model_name(BoardIndex));
309+
delta_get_model_name(BoardIndex));
310310

311311
ULONG DriverVersion = 0U;
312312
HANDLE BoardHandle = nullptr;

src/deltacast_common.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ bool delta_chn_type_is_sdi(ULONG ChnType);
202202
void delta_print_slot_stats(HANDLE StreamHandle, ULONG *SlotsDroppedLast,
203203
const char *action);
204204
bool delta_board_type_is_dv(ULONG BoardIndex);
205+
const char *delta_get_model_name(ULONG BoardIndex);
205206

206207
#ifdef HAVE_VHD_STRING
207208
#define DELTA_PRINT_ERROR(error_code, error_message, ...) \

src/video_capture/deltacast.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,21 @@ static void vidcap_deltacast_probe(device_info **available_cards, int *count, vo
144144

145145
ULONG Result,DllVersion,NbBoards;
146146
Result = VHD_GetApiInfo(&DllVersion,&NbBoards);
147-
if (Result == VHDERR_NOERROR) {
148-
*available_cards = (struct device_info *) calloc(NbBoards, sizeof(struct device_info));
149-
*count = NbBoards;
150-
for (ULONG i = 0; i < NbBoards; ++i) {
151-
auto& card = (*available_cards)[i];
152-
snprintf(card.dev, sizeof(card.dev), ":device=%" PRIu_ULONG, i);
153-
snprintf(card.name, sizeof(card.name), "DELTACAST SDI board %" PRIu_ULONG, i);
154-
snprintf(card.extra, sizeof(card.extra), "\"embeddedAudioAvailable\":\"t\"");
147+
if (Result != VHDERR_NOERROR) {
148+
return;
149+
}
150+
*available_cards =
151+
(struct device_info *) calloc(NbBoards, sizeof(struct device_info));
152+
for (ULONG i = 0; i < NbBoards; ++i) {
153+
if (delta_board_type_is_dv(i)) { // skip DVI/HDMI boards
154+
continue;
155155
}
156-
}
156+
auto &card = (*available_cards)[*count];
157+
snprintf_ch(card.dev, ":device=%" PRIu_ULONG, i);
158+
snprintf_ch(card.name, "DELTACAST %s", delta_get_model_name(i));
159+
snprintf_ch(card.extra, "\"embeddedAudioAvailable\":\"t\"");
160+
*count += 1;
161+
}
157162
}
158163

159164
class delta_init_exception {

src/video_capture/deltacast_dvi.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -224,22 +224,14 @@ static void vidcap_deltacast_dvi_probe(device_info **available_cards, int *count
224224
}
225225

226226
*available_cards = (struct device_info *) calloc(NbBoards, sizeof(struct device_info));
227-
*count = NbBoards;
228227
for (ULONG i = 0; i < NbBoards; ++i) {
229-
ULONG BoardType;
230-
HANDLE BoardHandle = NULL;
231-
Result = VHD_OpenBoardHandle(i, &BoardHandle, NULL, 0);
232-
VHD_GetBoardProperty(BoardHandle, VHD_CORE_BP_BOARD_TYPE, &BoardType);
233-
const char *board = "Unknown board type";
234-
if (Result == VHDERR_NOERROR)
235-
{
236-
board = delta_get_board_type_name(BoardType);
228+
if (!delta_board_type_is_dv(i)) { // skip SDI baords
229+
continue;
237230
}
238-
VHD_CloseBoardHandle(BoardHandle);
239-
240-
auto& card = (*available_cards)[i];
231+
auto &card = (*available_cards)[*count];
241232
snprintf(card.dev, sizeof card.dev, ":device=%" PRIu_ULONG, i);
242-
snprintf_ch(card.name, "DELTACAST %s #%" PRIu_ULONG, board, i);
233+
snprintf_ch(card.name, "DELTACAST %s", delta_get_model_name(i));
234+
*count += 1;
243235
}
244236
}
245237

src/video_display/deltacast.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -312,26 +312,18 @@ static void display_deltacast_probe(struct device_info **available_cards, int *c
312312
/* Query DELTA boards information */
313313
for (ULONG i = 0; i < NbBoards; i++)
314314
{
315-
ULONG BoardType;
316-
HANDLE BoardHandle = NULL;
317-
ULONG Result = VHD_OpenBoardHandle(i,&BoardHandle,NULL,0);
318-
VHD_GetBoardProperty(BoardHandle, VHD_CORE_BP_BOARD_TYPE, &BoardType);
319-
315+
if (delta_board_type_is_dv(i)) { // skip DVI/HDMI boards
316+
continue;
317+
}
320318
*count += 1;
321319
*available_cards = (struct device_info *)
322320
realloc(*available_cards, *count * sizeof(struct device_info));
323321
memset(*available_cards + *count - 1, 0, sizeof(struct device_info));
324322
snprintf((*available_cards)[*count - 1].dev, sizeof (*available_cards)[*count - 1].dev, ":device=%d", *count - 1);
325323
snprintf((*available_cards)[*count - 1].extra, sizeof (*available_cards)[*count - 1].extra, R"("embeddedAudioAvailable":"t")");
324+
snprintf_ch((*available_cards)[*count - 1].name, "DELTACAST %s",
325+
delta_get_model_name(i));
326326
(*available_cards)[*count - 1].repeatable = false;
327-
328-
if (Result == VHDERR_NOERROR)
329-
{
330-
const char *board = delta_get_board_type_name(BoardType);
331-
snprintf_ch((*available_cards)[*count - 1].name,
332-
"DELTACAST %s", board);
333-
VHD_CloseBoardHandle(BoardHandle);
334-
}
335327
}
336328

337329
}

0 commit comments

Comments
 (0)