#include "print_latency.h"
#include "shared/timebase.h"
#include "v210_converter.h"
#include "print_latency.h"
#include "shared/timebase.h"
#include "v210_converter.h"
if (video_modes.empty()) {
fprintf(stderr, "ERROR: No matching output modes for %dx%d found\n", width, height);
if (video_modes.empty()) {
fprintf(stderr, "ERROR: No matching output modes for %dx%d found\n", width, height);
IDeckLinkConfiguration *config = nullptr;
if (output->QueryInterface(IID_IDeckLinkConfiguration, (void**)&config) != S_OK) {
fprintf(stderr, "Failed to get configuration interface for output card\n");
IDeckLinkConfiguration *config = nullptr;
if (output->QueryInterface(IID_IDeckLinkConfiguration, (void**)&config) != S_OK) {
fprintf(stderr, "Failed to get configuration interface for output card\n");
}
if (config->SetFlag(bmdDeckLinkConfigLowLatencyVideoOutput, true) != S_OK) {
fprintf(stderr, "Failed to set low latency output\n");
}
if (config->SetFlag(bmdDeckLinkConfigLowLatencyVideoOutput, true) != S_OK) {
fprintf(stderr, "Failed to set low latency output\n");
}
if (config->SetInt(bmdDeckLinkConfigVideoOutputConnection, video_connection) != S_OK) {
fprintf(stderr, "Failed to set video output connection for card %u\n", card_index);
}
if (config->SetInt(bmdDeckLinkConfigVideoOutputConnection, video_connection) != S_OK) {
fprintf(stderr, "Failed to set video output connection for card %u\n", card_index);
}
if (config->SetFlag(bmdDeckLinkConfigUse1080pNotPsF, true) != S_OK) {
fprintf(stderr, "Failed to set PsF flag for card\n");
}
if (config->SetFlag(bmdDeckLinkConfigUse1080pNotPsF, true) != S_OK) {
fprintf(stderr, "Failed to set PsF flag for card\n");
}
if (config->SetFlag(bmdDeckLinkConfigSMPTELevelAOutput, true) != S_OK) {
// This affects at least some no-name SDI->HDMI converters.
}
if (config->SetFlag(bmdDeckLinkConfigSMPTELevelAOutput, true) != S_OK) {
// This affects at least some no-name SDI->HDMI converters.
if (output->DoesSupportVideoMode(mode, pixel_format, bmdVideoOutputFlagDefault,
&support, &display_mode) != S_OK) {
fprintf(stderr, "Couldn't ask for format support\n");
if (output->DoesSupportVideoMode(mode, pixel_format, bmdVideoOutputFlagDefault,
&support, &display_mode) != S_OK) {
fprintf(stderr, "Couldn't ask for format support\n");
}
if (support == bmdDisplayModeNotSupported) {
fprintf(stderr, "Requested display mode not supported\n");
}
if (support == bmdDisplayModeNotSupported) {
fprintf(stderr, "Requested display mode not supported\n");
BMDTimeScale time_scale;
if (display_mode->GetFrameRate(&time_value, &time_scale) != S_OK) {
fprintf(stderr, "Couldn't get frame rate\n");
BMDTimeScale time_scale;
if (display_mode->GetFrameRate(&time_value, &time_scale) != S_OK) {
fprintf(stderr, "Couldn't get frame rate\n");
HRESULT result = output->EnableVideoOutput(mode, bmdVideoOutputFlagDefault);
if (result != S_OK) {
fprintf(stderr, "Couldn't enable output with error 0x%x\n", result);
HRESULT result = output->EnableVideoOutput(mode, bmdVideoOutputFlagDefault);
if (result != S_OK) {
fprintf(stderr, "Couldn't enable output with error 0x%x\n", result);
}
if (output->SetScheduledFrameCompletionCallback(this) != S_OK) {
fprintf(stderr, "Couldn't set callback\n");
}
if (output->SetScheduledFrameCompletionCallback(this) != S_OK) {
fprintf(stderr, "Couldn't set callback\n");
}
assert(OUTPUT_FREQUENCY == 48000);
if (output->EnableAudioOutput(bmdAudioSampleRate48kHz, bmdAudioSampleType32bitInteger, 2, bmdAudioOutputStreamTimestamped) != S_OK) {
fprintf(stderr, "Couldn't enable audio output\n");
}
assert(OUTPUT_FREQUENCY == 48000);
if (output->EnableAudioOutput(bmdAudioSampleRate48kHz, bmdAudioSampleType32bitInteger, 2, bmdAudioOutputStreamTimestamped) != S_OK) {
fprintf(stderr, "Couldn't enable audio output\n");
}
if (output->BeginAudioPreroll() != S_OK) {
fprintf(stderr, "Couldn't begin audio preroll\n");
}
if (output->BeginAudioPreroll() != S_OK) {
fprintf(stderr, "Couldn't begin audio preroll\n");
if (!make_current(context, this->surface)) {
printf("display=%p surface=%p context=%p curr=%p err=%d\n", eglGetCurrentDisplay(), this->surface, context, eglGetCurrentContext(),
eglGetError());
if (!make_current(context, this->surface)) {
printf("display=%p surface=%p context=%p curr=%p err=%d\n", eglGetCurrentDisplay(), this->surface, context, eglGetCurrentContext(),
eglGetError());
HRESULT result = output->ScheduleAudioSamples(int_samples.get(), samples.size() / 2,
pts, TIMEBASE, &frames_written);
if (result != S_OK) {
HRESULT result = output->ScheduleAudioSamples(int_samples.get(), samples.size() / 2,
pts, TIMEBASE, &frames_written);
if (result != S_OK) {
- fprintf(stderr, "ScheduleAudioSamples(pts=%ld) failed (result=0x%08x)\n", pts, result);
+ fprintf(stderr, "ScheduleAudioSamples(pts=%" PRId64 ") failed (result=0x%08x)\n", pts, result);
- fprintf(stderr, "ScheduleAudioSamples() returned short write (%u/%ld)\n", frames_written, samples.size() / 2);
+ fprintf(stderr, "ScheduleAudioSamples() returned short write (%u/%zu)\n", frames_written, samples.size() / 2);
if (!playback_started) {
if (output->EndAudioPreroll() != S_OK) {
fprintf(stderr, "Could not end audio preroll\n");
if (!playback_started) {
if (output->EndAudioPreroll() != S_OK) {
fprintf(stderr, "Could not end audio preroll\n");
}
if (output->StartScheduledPlayback(base_pts, TIMEBASE, 1.0) != S_OK) {
fprintf(stderr, "Could not start playback\n");
}
if (output->StartScheduledPlayback(base_pts, TIMEBASE, 1.0) != S_OK) {
fprintf(stderr, "Could not start playback\n");
fprintf(stderr, "Consider increasing --output-buffer-frames if this persists.\n");
++metric_decklink_output_completed_frames_late;
break;
case bmdOutputFrameDropped:
fprintf(stderr, "Consider increasing --output-buffer-frames if this persists.\n");
++metric_decklink_output_completed_frames_late;
break;
case bmdOutputFrameDropped:
fprintf(stderr, "Consider increasing --output-buffer-frames if this persists.\n");
++metric_decklink_output_completed_frames_dropped;
break;
case bmdOutputFrameFlushed:
fprintf(stderr, "Consider increasing --output-buffer-frames if this persists.\n");
++metric_decklink_output_completed_frames_dropped;
break;
case bmdOutputFrameFlushed: