Skip to content

Commit ccbe130

Browse files
committed
deltacast_dvi: improve code flow for HDMI boards
The original sample code uses cascadding if-ladder evaluating Result. The derived code was just slightly derived but it was maybe even worse because the error handling (message) was coupled in one if/else with subsequent API call. This is mostly a refactor but: 1. two-times VHD_DV_SP_REFRESH_RATE removed 2. perhaps fixed misaligned error message prints to wrong calls, eg. when board type was not HDMI, the error was print even though the previous call didn't fail (but continued, anyways)
1 parent 8b6825b commit ccbe130

File tree

1 file changed

+24
-31
lines changed

1 file changed

+24
-31
lines changed

src/video_capture/deltacast_dvi.cpp

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* @author Martin Piatka <[email protected]>
44
* @author Martin Pulec <[email protected]>
55
*
6+
* code is written by DELTACAST's VideoMaster SDK example Sample_RX_DVI
7+
*
68
* @sa deltacast_common.hpp for common DELTACAST information
79
*/
810
/*
@@ -386,49 +388,40 @@ static bool wait_for_channel_locked(struct vidcap_deltacast_dvi_state *s, bool h
386388
VHD_DV_CS InputCS;
387389
ULONG PxlClk = 0;
388390
/* Get auto-detected resolution */
389-
Result = VHD_GetStreamProperty(s->StreamHandle,VHD_DV_SP_ACTIVE_WIDTH,&Width);
390-
if(Result == VHDERR_NOERROR)
391-
Result = VHD_GetStreamProperty(s->StreamHandle,VHD_DV_SP_ACTIVE_HEIGHT,&Height);
392-
else
391+
if ((Result = VHD_GetStreamProperty(s->StreamHandle,VHD_DV_SP_ACTIVE_WIDTH,&Width)) != VHDERR_NOERROR) {
393392
printf("ERROR : Cannot detect incoming active width from RX0. "
394393
"Result = 0x%08" PRIX_ULONG "\n", Result);
395-
if(Result == VHDERR_NOERROR)
396-
Result = VHD_GetStreamProperty(s->StreamHandle,VHD_DV_SP_INTERLACED,(ULONG*)&Interlaced_B);
397-
else
394+
return false;
395+
}
396+
if ((Result = VHD_GetStreamProperty(s->StreamHandle,VHD_DV_SP_ACTIVE_HEIGHT,&Height)) != VHDERR_NOERROR) {
398397
printf("ERROR : Cannot detect incoming active height from RX0. "
399398
"Result = 0x%08" PRIX_ULONG "\n", Result);
400-
if(Result == VHDERR_NOERROR)
401-
Result = VHD_GetStreamProperty(s->StreamHandle,VHD_DV_SP_REFRESH_RATE,&RefreshRate);
402-
else
399+
return false;
400+
}
401+
if ((Result = VHD_GetStreamProperty(s->StreamHandle,VHD_DV_SP_INTERLACED,(ULONG*)&Interlaced_B)) != VHDERR_NOERROR) {
403402
printf("ERROR : Cannot detect if incoming stream from RX0 is "
404403
"interlaced or progressive. Result = 0x%08" PRIX_ULONG "\n", Result);
405-
406-
if (Result == VHDERR_NOERROR) {
407-
Result = VHD_GetStreamProperty(s->StreamHandle,VHD_DV_SP_REFRESH_RATE,&RefreshRate);
408-
if(s->BoardType == VHD_BOARDTYPE_HDMI)
409-
Result = VHD_GetStreamProperty(s->StreamHandle,VHD_DV_SP_INPUT_CS,(ULONG*)&InputCS);
410-
else
411-
printf("ERROR : Cannot detect incoming color space from RX0. Result = 0x%08" PRIX_ULONG " (%s)\n", Result,
412-
delta_get_error_description(Result));
404+
return false;
405+
}
406+
if ((Result = VHD_GetStreamProperty(s->StreamHandle,VHD_DV_SP_REFRESH_RATE,&RefreshRate)) != VHDERR_NOERROR) {
407+
printf("ERROR : Cannot detect incoming refresh rate from RX0. Result = 0x%08" PRIX_ULONG "\n",Result);
408+
return false;
413409
}
414410

415-
if (Result == VHDERR_NOERROR) {
416-
if (s->BoardType == VHD_BOARDTYPE_HDMI)
417-
Result = VHD_GetStreamProperty(s->StreamHandle,VHD_DV_SP_PIXEL_CLOCK,&PxlClk);
418-
else
411+
if (s->BoardType == VHD_BOARDTYPE_HDMI) {
412+
if ((Result = VHD_GetStreamProperty(s->StreamHandle,VHD_DV_SP_INPUT_CS,(ULONG*)&InputCS)) != VHDERR_NOERROR) {
413+
printf("ERROR : Cannot detect incoming color space from RX0. Result = 0x%08" PRIX_ULONG " (%s)\n", Result,
414+
delta_get_error_description(Result));
415+
return false;
416+
}
417+
if ((Result = VHD_GetStreamProperty(s->StreamHandle,VHD_DV_SP_PIXEL_CLOCK,&PxlClk)) != VHDERR_NOERROR) {
419418
printf("ERROR : Cannot detect incoming pixel clock from RX0. Result = 0x%08" PRIX_ULONG " (%s)\n", Result,
420419
delta_get_error_description(Result));
420+
return false
421+
}
421422
}
422423

423-
if(Result == VHDERR_NOERROR)
424-
printf("\nIncoming graphic resolution : %" PRIu_ULONG "x%" PRIu_ULONG " @%" PRIu_ULONG "Hz (%s)\n", Width, Height, RefreshRate, Interlaced_B ? "Interlaced" : "Progressive");
425-
else
426-
printf("ERROR : Cannot detect incoming refresh rate from RX0. "
427-
"Result = 0x%08" PRIX_ULONG "\n", Result);
428-
429-
if(Result != VHDERR_NOERROR) {
430-
return false;
431-
}
424+
printf("\nIncoming graphic resolution : %" PRIu_ULONG "x%" PRIu_ULONG " @%" PRIu_ULONG "Hz (%s)\n", Width, Height, RefreshRate, Interlaced_B ? "Interlaced" : "Progressive");
432425

433426
/* Configure stream. Only VHD_DVI_SP_ACTIVE_WIDTH, VHD_DVI_SP_ACTIVE_HEIGHT and
434427
VHD_DVI_SP_INTERLACED properties are required for HDMI and Component

0 commit comments

Comments
 (0)