]> git.sesse.net Git - nageru/blobdiff - quicksync_encoder.cpp
Add a summary for the amount of margin we have in reaching the output clock (ie....
[nageru] / quicksync_encoder.cpp
index 1b36aa5246fbda3b19b5e65a5abc48365ab23840..88d0fb401d514ff7422e1239a007e7d206eda319 100644 (file)
@@ -1840,6 +1840,7 @@ void QuickSyncEncoderImpl::open_output_file(const std::string &filename)
        AVCodecParametersWithDeleter audio_codecpar = file_audio_encoder->get_codec_parameters();
        file_mux.reset(new Mux(avctx, frame_width, frame_height, Mux::CODEC_H264, video_extradata, audio_codecpar.get(), TIMEBASE,
                std::bind(&DiskSpaceEstimator::report_write, disk_space_estimator, filename, _1),
+               Mux::WRITE_BACKGROUND,
                { &current_file_mux_metrics, &total_mux_metrics }));
        metric_current_file_start_time_seconds = get_timestamp_for_metrics();
 
@@ -1981,8 +1982,12 @@ void QuickSyncEncoderImpl::pass_frame(QuickSyncEncoderImpl::PendingFrame frame,
        // Wait for the GPU to be done with the frame.
        GLenum sync_status;
        do {
-               sync_status = glClientWaitSync(frame.fence.get(), 0, 1000000000);
+               sync_status = glClientWaitSync(frame.fence.get(), 0, 0);
                check_error();
+               if (sync_status == GL_TIMEOUT_EXPIRED) {
+                       // NVIDIA likes to busy-wait; yield instead.
+                       this_thread::sleep_for(milliseconds(1));
+               }
        } while (sync_status == GL_TIMEOUT_EXPIRED);
        assert(sync_status != GL_WAIT_FAILED);