]> git.sesse.net Git - nageru/blobdiff - decklink_output.cpp
Do not try to adjust the audio timer during HDMI/SDI output preroll.
[nageru] / decklink_output.cpp
index c5bf96b3a0c404f0f448535d5da3fd3a286641c1..a826dfe22ee95c5588f86edebec1c2ad1ce64ed3 100644 (file)
@@ -1,6 +1,7 @@
 #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>
 
@@ -180,6 +181,8 @@ void DeckLinkOutput::end_output()
 
 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);
 
@@ -239,8 +242,10 @@ void DeckLinkOutput::send_audio(int64_t pts, const std::vector<float> &samples)
        }
 }
 
-void DeckLinkOutput::wait_for_frame(int64_t pts, int *dropped_frames, int64_t *frame_duration)
+void DeckLinkOutput::wait_for_frame(int64_t pts, int *dropped_frames, int64_t *frame_duration, bool *is_preroll)
 {
+       assert(!should_quit);
+
        *dropped_frames = 0;
        *frame_duration = this->frame_duration;
 
@@ -250,9 +255,12 @@ void DeckLinkOutput::wait_for_frame(int64_t pts, int *dropped_frames, int64_t *f
 
        // While prerolling, we send out frames as quickly as we can.
        if (target_time < base_pts) {
+               *is_preroll = true;
                return;
        }
 
+       *is_preroll = !playback_started;
+
        if (!playback_started) {
                if (output->EndAudioPreroll() != S_OK) {
                        fprintf(stderr, "Could not end audio preroll\n");
@@ -361,6 +369,7 @@ unique_ptr<DeckLinkOutput::Frame> DeckLinkOutput::get_frame()
 
 void DeckLinkOutput::present_thread_func()
 {
+       pthread_setname_np(pthread_self(), "DeckLinkOutput");
        for ( ;; ) {
                unique_ptr<Frame> frame;
                {