From 2a511d58f5ce23afb9ed19d62e07bbd3a517c67b Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Thu, 7 Oct 2021 14:54:54 +0200 Subject: [PATCH] DeckLink cap.: default audio BPS is 2 (originally 4) When uncompressed it requires less bandwidth and it is more suitable for compression and/or further processing. + fail if audio BPS or sample rate is invalid rather than displaying only a warning + removed unused FRAME_TIMEOUT --- src/video_capture/decklink.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/video_capture/decklink.cpp b/src/video_capture/decklink.cpp index 431fe7e07..18f4b7ad0 100644 --- a/src/video_capture/decklink.cpp +++ b/src/video_capture/decklink.cpp @@ -75,7 +75,7 @@ #include "video.h" #include "video_capture.h" -#define FRAME_TIMEOUT 60000000 // 30000000 // in nanoseconds +constexpr const int DEFAULT_AUDIO_BPS = 2; constexpr const size_t MAX_AUDIO_PACKETS = 10; #define MOD_NAME "[DeckLink capture] " @@ -1088,16 +1088,16 @@ vidcap_decklink_init(struct vidcap_params *params, void **state) fprintf(stderr, "[Decklink capture] Unexpected audio flag encountered.\n"); abort(); } - if (audio_capture_bps == 2) { - s->audio.bps = 2; - } else { - if (audio_capture_bps != 4 && audio_capture_bps != 0) { - log_msg(LOG_LEVEL_WARNING, "[Decklink] Ignoring unsupported Bps!\n"); - } - s->audio.bps = 4; + s->audio.bps = audio_capture_bps == 0 ? DEFAULT_AUDIO_BPS : audio_capture_bps; + if (s->audio.bps != 2 && s->audio.bps != 4) { + LOG(LOG_LEVEL_ERROR) << MOD_NAME << "Unsupported audio Bps " << audio_capture_bps << "! Supported is 2 or 4 bytes only!\n"; + delete s; + return VIDCAP_INIT_FAIL; } if (audio_capture_sample_rate != 0 && audio_capture_sample_rate != 48000) { - log_msg(LOG_LEVEL_WARNING, "[Decklink] Ignoring unsupported sample rate!\n"); + LOG(LOG_LEVEL_ERROR) << MOD_NAME "Unsupported sample rate " << audio_capture_sample_rate << "! Only 48000 is supported.\n"; + delete s; + return VIDCAP_INIT_FAIL; } s->audio.sample_rate = 48000; s->audio.ch_count = audio_capture_channels > 0 ? audio_capture_channels : DEFAULT_AUDIO_CAPTURE_CHANNELS;