+ });
+ }
+
+ static void dma_present_thread_actual(void* arg)
+ {
+ bluefish_consumer* blue = (bluefish_consumer*)arg;
+
+ bvc_wrapper wait_b;
+ wait_b.attach(blue->device_index_);
+ EBlueVideoChannel out_vid_channel = get_bluesdk_videochannel_from_streamid(blue->device_output_channel_);
+ wait_b.set_card_property32(DEFAULT_VIDEO_OUTPUT_CHANNEL, out_vid_channel);
+ int frames_to_buffer = 3;
+ unsigned long buffer_id = 0;
+ unsigned long underrun = 0;
+
+ while (!blue->end_dma_thread_)
+ {
+ if (blue->live_frames_.size() && BLUE_OK(blue->blue_->video_playback_allocate(buffer_id, underrun)))
+ {
+ blue->live_frames_lock_.lock();
+ blue_dma_buffer_ptr buf = blue->live_frames_.front();
+ blue->live_frames_.pop();
+ blue->live_frames_lock_.unlock();
+
+ // Send and display
+ if (blue->embedded_audio_)
+ {
+ // Do video first, then encode hanc, then do hanc DMA...
+ blue->blue_->system_buffer_write(const_cast<uint8_t*>(buf->image_data()),
+ static_cast<unsigned long>(buf->image_size()),
+ BlueImage_HANC_DMABuffer(buffer_id, BLUE_DATA_IMAGE),
+ 0);
+
+ blue->blue_->system_buffer_write(buf->hanc_data(),
+ static_cast<unsigned long>(buf->hanc_size()),
+ BlueImage_HANC_DMABuffer(buffer_id, BLUE_DATA_HANC),
+ 0);
+
+ if (BLUE_FAIL(blue->blue_->video_playback_present(BlueBuffer_Image_HANC(buffer_id), 1, 0, 0)))
+ {
+ CASPAR_LOG(warning) << blue->print() << TEXT(" video_playback_present failed.");
+ }
+ }
+ else
+ {
+ blue->blue_->system_buffer_write(const_cast<uint8_t*>(buf->image_data()),
+ static_cast<unsigned long>(buf->image_size()),
+ BlueImage_DMABuffer(buffer_id, BLUE_DATA_IMAGE),
+ 0);
+
+ if (BLUE_FAIL(blue->blue_->video_playback_present(BlueBuffer_Image(buffer_id), 1, 0, 0)))
+ CASPAR_LOG(warning) << blue->print() << TEXT(" video_playback_present failed.");
+ }
+
+ // blue->graph_->set_value("frame-time", static_cast<float>(blue->frame_timer_.elapsed()*blue->format_desc_.fps*0.5));
+
+ blue->reserved_frames_lock_.lock();
+ blue->reserved_frames_.push(buf);
+ blue->reserved_frames_lock_.unlock();
+ }
+ else
+ {
+ // do WFS
+ unsigned long n_field = 0;
+ wait_b.wait_video_output_sync(UPD_FMT_FRAME, n_field);
+ }
+
+ if (frames_to_buffer > 0)
+ {
+ frames_to_buffer--;
+ if (frames_to_buffer == 0)
+ {
+ if (BLUE_FAIL(blue->blue_->video_playback_start(0, 0)))
+ CASPAR_LOG(warning) << blue->print() << TEXT("Error video playback start failed");
+ }
+ }
+ }
+ wait_b.detach();