#include <movit/effect_util.h>
#include <movit/util.h>
#include <movit/resource_pool.h> // Must be above the Xlib includes.
+#include <pthread.h>
#include <epoxy/egl.h>
}
mode_it->Release();
+
+ // HDMI or SDI generally mean “both HDMI and SDI at the same time” on DeckLink cards
+ // that support both; pick_default_video_connection() will generally pick one of those
+ // if they exist. We're not very likely to need analog outputs, so we don't need a way
+ // to change beyond that.
+ video_connection = pick_default_video_connection(decklink, BMDDeckLinkVideoOutputConnections, card_index);
}
void DeckLinkOutput::start_output(uint32_t mode, int64_t base_pts)
{
assert(output);
+ assert(!playback_initiated);
should_quit = false;
+ playback_initiated = true;
playback_started = false;
this->base_pts = base_pts;
fprintf(stderr, "Failed to set low latency output\n");
exit(1);
}
- // HDMI or SDI generally mean “both HDMI and SDI at the same time” on DeckLink cards.
- // We're not very likely to need analog outputs.
- if (config->SetInt(bmdDeckLinkConfigVideoOutputConnection, bmdVideoConnectionHDMI) != S_OK) {
+ if (config->SetInt(bmdDeckLinkConfigVideoOutputConnection, video_connection) != S_OK) {
fprintf(stderr, "Failed to set video output connection for card %u\n", card_index);
exit(1);
}
void DeckLinkOutput::end_output()
{
+ if (!playback_initiated) {
+ return;
+ }
+
should_quit = true;
frame_queues_changed.notify_all();
present_thread.join();
+ playback_initiated = false;
output->StopScheduledPlayback(0, nullptr, 0);
output->DisableVideoOutput();
void DeckLinkOutput::send_frame(GLuint y_tex, GLuint cbcr_tex, const vector<RefCountedFrame> &input_frames, int64_t pts, int64_t duration)
{
+ assert(!should_quit);
+
unique_ptr<Frame> frame = move(get_frame());
chroma_subsampler->create_uyvy(y_tex, cbcr_tex, width, height, frame->uyvy_tex);
void DeckLinkOutput::wait_for_frame(int64_t pts, int *dropped_frames, int64_t *frame_duration)
{
+ assert(!should_quit);
+
*dropped_frames = 0;
*frame_duration = this->frame_duration;
void DeckLinkOutput::present_thread_func()
{
+ pthread_setname_np(pthread_self(), "DeckLinkOutput");
for ( ;; ) {
unique_ptr<Frame> frame;
{