Skip to content

Commit

Permalink
DeckLink disp.: set audio chans only on query succ
Browse files Browse the repository at this point in the history
refers to GH-354

It seems that if the query fails, it sets some undefined or invalid
value to the output variable.

\+ print actual used maximal value in verbose mode

\+ print also error message
  • Loading branch information
MartinPulec committed Nov 3, 2023
1 parent 3a3c607 commit 7abe893
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/video_display/decklink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ struct state_decklink {
bool initialized = false;
bool emit_timecode = false;
bool play_audio = false; ///< the BMD device will be used also for output audio
int64_t max_aud_chans = BMD_MAX_AUD_CH;
int max_aud_chans = BMD_MAX_AUD_CH;

BMDPixelFormat pixelFormat{};

Expand Down Expand Up @@ -1257,13 +1257,19 @@ set_audio_props(state_decklink *s,
}
s->play_audio = true;

if (s->deckLinkAttributes->GetInt(
audio_output == DISPLAY_FLAG_AUDIO_EMBEDDED
? BMDDeckLinkMaximumAudioChannels
: BMDDeckLinkMaximumAnalogAudioOutputChannels,
&s->max_aud_chans) != S_OK) {
MSG(WARNING, "Cannot get maximum audio channels!\n");
int64_t max_aud_chans = 0;
HRESULT result = s->deckLinkAttributes->GetInt(
audio_output == DISPLAY_FLAG_AUDIO_EMBEDDED
? BMDDeckLinkMaximumAudioChannels
: BMDDeckLinkMaximumAnalogAudioOutputChannels,
&max_aud_chans);
if (result != S_OK) {
MSG(WARNING, "Cannot get maximum audio channels: %s\n",
bmd_hresult_to_string(result).c_str());
} else {
s->max_aud_chans = (int) max_aud_chans;
}
MSG(VERBOSE, "Using maximum audio channels: %d\n", s->max_aud_chans);

MSG(INFO, "Using audio output: %s\n",
get_audio_conn_flag_name(audio_output));
Expand All @@ -1287,7 +1293,7 @@ set_audio_props(state_decklink *s,
/* .... one exception is a card that has switchable cables between
* AES/EBU and analog. (But this applies only for channels 3 and above.)
*/
HRESULT result = deckLinkConfiguration->SetInt(
result = deckLinkConfiguration->SetInt(
bmdDeckLinkConfigAudioOutputAESAnalogSwitch, audioConnection);
if (result == S_OK) { // has switchable channels
MSG(INFO, "Card with switchable audio channels detected. "
Expand Down

0 comments on commit 7abe893

Please sign in to comment.