From c4ba661adcbdebe0edf5fb18f77d137a739a5d12 Mon Sep 17 00:00:00 2001 From: ronag Date: Mon, 14 Mar 2011 20:13:34 +0000 Subject: [PATCH] git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@557 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d --- common/common.vcxproj | 1 - common/common.vcxproj.filters | 3 - common/diagnostics/graph.cpp | 4 +- common/utility/timer.h | 77 ------------------- .../bluefish/consumer/bluefish_consumer.cpp | 6 +- modules/flash/producer/flash_producer.cpp | 2 +- shell/caspar.config | 10 +-- 7 files changed, 10 insertions(+), 93 deletions(-) delete mode 100644 common/utility/timer.h diff --git a/common/common.vcxproj b/common/common.vcxproj index c183cef41..1c48447df 100644 --- a/common/common.vcxproj +++ b/common/common.vcxproj @@ -222,7 +222,6 @@ - diff --git a/common/common.vcxproj.filters b/common/common.vcxproj.filters index 0504c22f9..696f82a3c 100644 --- a/common/common.vcxproj.filters +++ b/common/common.vcxproj.filters @@ -81,8 +81,5 @@ utility - - utility - \ No newline at end of file diff --git a/common/diagnostics/graph.cpp b/common/diagnostics/graph.cpp index 928d7c245..63b5dd82d 100644 --- a/common/diagnostics/graph.cpp +++ b/common/diagnostics/graph.cpp @@ -5,7 +5,6 @@ #pragma warning (disable : 4244) #include "../concurrency/executor.h" -#include "../utility/timer.h" #include "../env.h" #include @@ -30,7 +29,6 @@ struct drawable : public sf::Drawable class context : public drawable { - timer timer_; sf::RenderWindow window_; std::list> drawables_; @@ -79,7 +77,7 @@ private: glClear(GL_COLOR_BUFFER_BIT); window_.Draw(*this); window_.Display(); - timer_.tick(1.0/50.0); + boost::this_thread::sleep(boost::posix_time::milliseconds(20)); executor_.begin_invoke([this]{tick();}); } diff --git a/common/utility/timer.h b/common/utility/timer.h deleted file mode 100644 index 6d5a15dca..000000000 --- a/common/utility/timer.h +++ /dev/null @@ -1,77 +0,0 @@ -#pragma once - -#include - -namespace caspar { - -class timer -{ -public: - timer() - { - QueryPerformanceFrequency(&freq_); - QueryPerformanceCounter(&time_); - } - - double elapsed() - { - LARGE_INTEGER t; - QueryPerformanceCounter(&t); - int ticks_passed = static_cast(static_cast<__int64>(t.QuadPart) - static_cast<__int64>(time_.QuadPart)); - return static_cast(ticks_passed)/static_cast(freq_.QuadPart); - } - - void reset() - { - QueryPerformanceCounter(&time_); - } - - // Author: Ryan M. Geiss - // http://www.geisswerks.com/ryan/FAQS/timing.html - void tick(double interval) - { - LARGE_INTEGER t; - QueryPerformanceCounter(&t); - - if (time_.QuadPart != 0) - { - int ticks_to_wait = static_cast(static_cast(freq_.QuadPart) * interval); - int done = 0; - do - { - QueryPerformanceCounter(&t); - - int ticks_passed = static_cast(static_cast<__int64>(t.QuadPart) - static_cast<__int64>(time_.QuadPart)); - int ticks_left = ticks_to_wait - ticks_passed; - - if (t.QuadPart < time_.QuadPart) // time wrap - done = 1; - if (ticks_passed >= ticks_to_wait) - done = 1; - - if (!done) - { - // if > 0.002s left, do Sleep(1), which will actually sleep some - // steady amount, probably 1-2 ms, - // and do so in a nice way (cpu meter drops; laptop battery spared). - // otherwise, do a few Sleep(0)'s, which just give up the timeslice, - // but don't really save cpu or battery, but do pass a tiny - // amount of time. - if (ticks_left > static_cast((freq_.QuadPart*2)/1000)) - Sleep(1); - else - for (int i = 0; i < 10; ++i) - Sleep(0); // causes thread to give up its timeslice - } - } - while (!done); - } - - time_ = t; - } -private: - LARGE_INTEGER freq_; - LARGE_INTEGER time_; -}; - -} \ No newline at end of file diff --git a/modules/bluefish/consumer/bluefish_consumer.cpp b/modules/bluefish/consumer/bluefish_consumer.cpp index 14f0ac353..8bbfafc4b 100644 --- a/modules/bluefish/consumer/bluefish_consumer.cpp +++ b/modules/bluefish/consumer/bluefish_consumer.cpp @@ -271,9 +271,6 @@ public: try { std::copy_n(frame->image_data().begin(), frame->image_data().size(), reserved_frames_.front()->image_data()); - - unsigned long n_field = 0; - blue_->wait_output_video_synch(UPD_FMT_FRAME, n_field); if(embed_audio_) { @@ -305,6 +302,9 @@ public: CASPAR_LOG(warning) << print() << TEXT(" render_buffer_update failed."); } + unsigned long n_field = 0; + blue_->wait_output_video_synch(UPD_FMT_FRAME, n_field); + std::rotate(reserved_frames_.begin(), reserved_frames_.begin() + 1, reserved_frames_.end()); graph_->update_value("tick-time", static_cast(perf_timer_.elapsed()/format_desc_.interval*0.5)); perf_timer_.reset(); diff --git a/modules/flash/producer/flash_producer.cpp b/modules/flash/producer/flash_producer.cpp index 033a5d9ce..f09e5cb08 100644 --- a/modules/flash/producer/flash_producer.cpp +++ b/modules/flash/producer/flash_producer.cpp @@ -177,7 +177,7 @@ private: graph_->add_tag("underflow"); double frame_time = 1.0/ax_->GetFPS()*(underflow ? 0.90 : 1.0); // Reduce sync-time if in underflow. - timer_.tick(frame_time); // Tick doesnt work on nested timelines, force an actual sync + //timer_.tick(frame_time); // Tick doesnt work on nested timelines, force an actual sync perf_timer_.reset(); ax_->Tick(); diff --git a/shell/caspar.config b/shell/caspar.config index 0bf5fd4e6..c99fdedc4 100644 --- a/shell/caspar.config +++ b/shell/caspar.config @@ -14,21 +14,21 @@ PAL - + -- 2.39.2