Skip to content

Commit e0ef3fb

Browse files
committed
delta: print_board_info: updates
- board index rn s/i/BoardIndex/; s/board/board_type/ - s/NULL/nullptr/ - use DELTA_PRINT_ERROR - close board handle if returning prematurely - use color_printf instead of col() and LOG->MSG (personal taste)
1 parent 250083a commit e0ef3fb

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

src/deltacast_common.cpp

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -227,56 +227,54 @@ print_avail_channels(HANDLE BoardHandle)
227227
}
228228

229229
static void
230-
print_board_info(int i, ULONG DllVersion, bool full)
230+
print_board_info(int BoardIndex, ULONG DllVersion, bool full)
231231
{
232232
ULONG BoardType = 0U;
233233
ULONG DriverVersion = 0U;
234-
HANDLE BoardHandle = NULL;
235-
ULONG Result = VHD_OpenBoardHandle(i, &BoardHandle, NULL, 0);
234+
HANDLE BoardHandle = nullptr;
235+
ULONG Result =
236+
VHD_OpenBoardHandle(BoardIndex, &BoardHandle, nullptr, 0);
236237
if (Result != VHDERR_NOERROR) {
237-
LOG(LOG_LEVEL_ERROR)
238-
<< "[DELTACAST] Unable to open board " << i << ": "
239-
<< delta_get_error_description(Result) << "\n";
238+
DELTA_PRINT_ERROR(Result, "Unable to open board %d.",
239+
BoardIndex);
240240
return;
241241
}
242242
Result = VHD_GetBoardProperty(BoardHandle, VHD_CORE_BP_BOARD_TYPE,
243243
&BoardType);
244244
if (Result != VHDERR_NOERROR) {
245-
LOG(LOG_LEVEL_ERROR)
246-
<< "[DELTACAST] Unable to get board " << i
247-
<< " type: " << delta_get_error_description(Result) << "\n";
245+
DELTA_PRINT_ERROR(Result, "Unable to get board %d type.",
246+
BoardIndex);
247+
VHD_CloseBoardHandle(BoardHandle);
248248
return;
249249
}
250250
Result = VHD_GetBoardProperty(BoardHandle, VHD_CORE_BP_DRIVER_VERSION,
251251
&DriverVersion);
252252
if (Result != VHDERR_NOERROR) {
253-
LOG(LOG_LEVEL_ERROR)
254-
<< "[DELTACAST] Unable to get board " << i
255-
<< " version: " << delta_get_error_description(Result)
256-
<< "\n";
253+
DELTA_PRINT_ERROR(Result, "Unable to get board %d version.",
254+
BoardIndex);
257255
}
258256

259-
const char *board = delta_get_board_type_name(BoardType);
260-
col() << "\tBoard " << SBOLD(i) << ": " << SBOLD(board)
261-
<< " (driver: " << delta_format_version(DriverVersion, false)
262-
<< ")\n";
257+
const char *board_type = delta_get_board_type_name(BoardType);
258+
color_printf("\tBoard " TBOLD("%d") ": " TBOLD("%s") " (driver: %s)\n",
259+
BoardIndex, board_type,
260+
delta_format_version(DriverVersion, false).c_str());
263261
if (full) {
264262
print_avail_channels(BoardHandle);
265-
266-
ULONG IsBiDir = 2;
267-
VHD_GetBoardProperty(BoardHandle, VHD_CORE_BP_IS_BIDIR,
268-
&IsBiDir);
263+
const char *bidir_status = "ERROR";
264+
ULONG IsBiDir = 0;
265+
if (VHD_GetBoardProperty(BoardHandle, VHD_CORE_BP_IS_BIDIR,
266+
&IsBiDir) == VHDERR_NOERROR) {
267+
bidir_status =
268+
IsBiDir == TRUE ? "supported" : "not supported";
269+
}
269270
printf("\t\tbidirectional (switchable) channels: "
270271
"%s\n",
271-
IsBiDir == 2 ? "ERROR"
272-
: IsBiDir == TRUE ? "supported"
273-
: "not supported");
272+
bidir_status);
274273
}
275274
if ((DllVersion >> 16U) != (DriverVersion >> 16U)) {
276-
LOG(LOG_LEVEL_WARNING)
277-
<< "[DELTACAST] API and driver version mismatch: "
278-
<< delta_format_version(DllVersion, true) << " vs "
279-
<< delta_format_version(DriverVersion, true) << "\n";
275+
MSG(WARNING, "API and driver version mismatch: %s vs %s\n",
276+
delta_format_version(DllVersion, true).c_str(),
277+
delta_format_version(DriverVersion, true).c_str());
280278
}
281279
VHD_CloseBoardHandle(BoardHandle);
282280
}

0 commit comments

Comments
 (0)