X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=decklink_capture.cpp;h=6507959251d08a82bec466f180949d4985bdc1f8;hb=e5a0d3dfb676087bdcef4c82876234782e46604c;hp=ea9520705781bcb31da57713e0a0be1d0174e1ee;hpb=90598079cba30f18714212ecd3f8602d7bcdfa67;p=nageru diff --git a/decklink_capture.cpp b/decklink_capture.cpp index ea95207..6507959 100644 --- a/decklink_capture.cpp +++ b/decklink_capture.cpp @@ -319,6 +319,14 @@ HRESULT STDMETHODCALLTYPE DeckLinkCapture::VideoInputFrameArrived( char thread_name[16]; snprintf(thread_name, sizeof(thread_name), "DeckLink_C_%d", card_index); pthread_setname_np(pthread_self(), thread_name); + + sched_param param; + memset(¶m, 0, sizeof(param)); + param.sched_priority = 1; + if (sched_setscheduler(0, SCHED_RR, ¶m) == -1) { + printf("couldn't set realtime priority for DeckLink thread: %s\n", strerror(errno)); + } + if (has_dequeue_callbacks) { dequeue_init_callback(); } @@ -340,8 +348,8 @@ HRESULT STDMETHODCALLTYPE DeckLinkCapture::VideoInputFrameArrived( if (video_frame) { video_format.has_signal = !(video_frame->GetFlags() & bmdFrameHasNoInputSource); - int width = video_frame->GetWidth(); - int height = video_frame->GetHeight(); + const int width = video_frame->GetWidth(); + const int height = video_frame->GetHeight(); const int stride = video_frame->GetRowBytes(); const BMDPixelFormat format = video_frame->GetPixelFormat(); assert(format == pixel_format_to_bmd(current_pixel_format)); @@ -460,14 +468,11 @@ void DeckLinkCapture::stop_dequeue_thread() fprintf(stderr, "StopStreams failed with error 0x%x\n", result); exit(1); } - if (input->DisableVideoInput() != S_OK) { - fprintf(stderr, "Failed to disable video input for card %d\n", card_index); - exit(1); - } - if (input->DisableAudioInput() != S_OK) { - fprintf(stderr, "Failed to disable audio input for card %d\n", card_index); - exit(1); - } + + // 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. + running = false; }