if (card->QueryInterface(IID_IDeckLinkInput, (void**)&input) != S_OK) {
fprintf(stderr, "Card %d has no inputs\n", card_index);
- exit(1);
+ abort();
}
IDeckLinkAttributes *attr;
if (card->QueryInterface(IID_IDeckLinkAttributes, (void**)&attr) != S_OK) {
fprintf(stderr, "Card %d has no attributes\n", card_index);
- exit(1);
+ abort();
}
// Get the list of available video inputs.
int64_t video_input_mask;
if (attr->GetInt(BMDDeckLinkVideoInputConnections, &video_input_mask) != S_OK) {
fprintf(stderr, "Failed to enumerate video inputs for card %d\n", card_index);
- exit(1);
+ abort();
}
const vector<pair<BMDVideoConnection, string>> video_input_types = {
{ bmdVideoConnectionSDI, "SDI" },
int64_t audio_input_mask;
if (attr->GetInt(BMDDeckLinkAudioInputConnections, &audio_input_mask) != S_OK) {
fprintf(stderr, "Failed to enumerate audio inputs for card %d\n", card_index);
- exit(1);
+ abort();
}
const vector<pair<BMDAudioConnection, string>> audio_input_types = {
{ bmdAudioConnectionEmbedded, "Embedded" },
/* Set up the video and audio sources. */
if (card->QueryInterface(IID_IDeckLinkConfiguration, (void**)&config) != S_OK) {
fprintf(stderr, "Failed to get configuration interface for card %d\n", card_index);
- exit(1);
+ abort();
}
BMDVideoConnection connection = pick_default_video_connection(card, BMDDeckLinkVideoInputConnections, card_index);
IDeckLinkDisplayModeIterator *mode_it;
if (input->GetDisplayModeIterator(&mode_it) != S_OK) {
fprintf(stderr, "Failed to enumerate display modes for card %d\n", card_index);
- exit(1);
+ abort();
}
video_modes = summarize_video_modes(mode_it, card_index);
}
if (display_mode->GetFrameRate(&frame_duration, &time_scale) != S_OK) {
fprintf(stderr, "Could not get new frame rate\n");
- exit(1);
+ abort();
}
field_dominance = display_mode->GetFieldDominance();
return S_OK;
if (current_audio_frame.data != nullptr) {
const uint8_t *src;
audio_frame->GetBytes((void **)&src);
- current_audio_frame.len = sizeof(int32_t) * 2 * num_samples;
+ current_audio_frame.len = sizeof(int32_t) * 8 * num_samples;
memcpy(current_audio_frame.data, src, current_audio_frame.len);
audio_format.bits_per_sample = 32;
- audio_format.num_channels = 2;
+ audio_format.num_channels = 8;
}
}
}
if (input->EnableVideoInput(current_video_mode, pixel_format_to_bmd(current_pixel_format), supports_autodetect ? bmdVideoInputEnableFormatDetection : 0) != S_OK) {
fprintf(stderr, "Failed to set video mode 0x%04x for card %d\n", current_video_mode, card_index);
- exit(1);
+ abort();
}
- if (input->EnableAudioInput(48000, bmdAudioSampleType32bitInteger, 2) != S_OK) {
+ if (input->EnableAudioInput(48000, bmdAudioSampleType32bitInteger, 8) != S_OK) {
fprintf(stderr, "Failed to enable audio input for card %d\n", card_index);
- exit(1);
+ abort();
}
if (input->StartStreams() != S_OK) {
fprintf(stderr, "StartStreams failed\n");
- exit(1);
+ abort();
}
running = true;
}
HRESULT result = input->StopStreams();
if (result != S_OK) {
fprintf(stderr, "StopStreams failed with error 0x%x\n", result);
- exit(1);
+ abort();
}
// We could call DisableVideoInput() and DisableAudioInput() here,
// but they seem to be taking a really long time, and we only do this
- // during shutdown anyway, so StopStreams() will suffice.
+ // during shutdown anyway (except when switching to output mode,
+ // where DeckLinkOutput does the disabling), so StopStreams() will suffice.
running = false;
}
if (running) {
if (input->PauseStreams() != S_OK) {
fprintf(stderr, "PauseStreams failed\n");
- exit(1);
+ abort();
}
if (input->FlushStreams() != S_OK) {
fprintf(stderr, "FlushStreams failed\n");
- exit(1);
+ abort();
}
}
if (running) {
if (input->StartStreams() != S_OK) {
fprintf(stderr, "StartStreams failed\n");
- exit(1);
+ abort();
}
}
}
IDeckLinkDisplayMode *display_mode;
if (input->DoesSupportVideoMode(video_mode_id, pixel_format_to_bmd(current_pixel_format), /*flags=*/0, &support, &display_mode)) {
fprintf(stderr, "Failed to query display mode for card %d\n", card_index);
- exit(1);
+ abort();
}
if (support == bmdDisplayModeNotSupported) {
fprintf(stderr, "Card %d does not support display mode\n", card_index);
- exit(1);
+ abort();
}
if (display_mode->GetFrameRate(&frame_duration, &time_scale) != S_OK) {
fprintf(stderr, "Could not get frame rate for card %d\n", card_index);
- exit(1);
+ abort();
}
field_dominance = display_mode->GetFieldDominance();
if (running) {
if (input->EnableVideoInput(video_mode_id, pixel_format_to_bmd(current_pixel_format), supports_autodetect ? bmdVideoInputEnableFormatDetection : 0) != S_OK) {
fprintf(stderr, "Failed to set video mode 0x%04x for card %d\n", video_mode_id, card_index);
- exit(1);
+ abort();
}
}
{
if (config->SetInt(bmdDeckLinkConfigVideoInputConnection, video_input_id) != S_OK) {
fprintf(stderr, "Failed to set video input connection for card %d\n", card_index);
- exit(1);
+ abort();
}
current_video_input = video_input_id;
{
if (config->SetInt(bmdDeckLinkConfigAudioInputConnection, audio_input_id) != S_OK) {
fprintf(stderr, "Failed to set audio input connection for card %d\n", card_index);
- exit(1);
+ abort();
}
current_audio_input = audio_input_id;