]> git.sesse.net Git - casparcg/commitdiff
2.0.0.2: bluefish_consumer: Added proper prerolling.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Wed, 1 Jun 2011 14:29:24 +0000 (14:29 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Wed, 1 Jun 2011 14:29:24 +0000 (14:29 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@835 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

common/concurrency/executor.h
core/producer/frame_producer_device.cpp
modules/bluefish/consumer/bluefish_consumer.cpp
modules/decklink/consumer/decklink_consumer.cpp

index 4409295c8f05459dee88603da047af8ca6f10dfa..2caf5c705f65e2c8c18a6dae82da5b7aa770c5b8 100644 (file)
@@ -185,11 +185,7 @@ public:
                {\r
                        try{task_adaptor.value();}\r
                        catch(boost::task_already_started&){}\r
-                       catch(...)\r
-                       {\r
-                               CASPAR_LOG_CURRENT_EXCEPTION();\r
-                               throw;\r
-                       }\r
+                       catch(...){CASPAR_LOG_CURRENT_EXCEPTION();}\r
                });\r
 \r
                if(priority != normal_priority)\r
index 5d912275c49f7142fef8748bfd6a88cf0d4991fd..4d351ce19d6a2c400576fed5bffe57b4e1c5bc9c 100644 (file)
@@ -82,7 +82,7 @@ struct frame_producer_device::implementation : boost::noncopyable
        boost::timer                                                            tick_timer_;\r
        boost::timer                                                            output_timer_;\r
        \r
-       video_channel_context&                                                  channel_;\r
+       video_channel_context&                                          channel_;\r
 public:\r
        implementation(video_channel_context& video_channel)  \r
                : diag_(diagnostics::create_graph(std::string("frame_producer_device")))\r
@@ -161,7 +161,7 @@ public:
                else\r
                {\r
                        if(channel_.format_desc != other.impl_->channel_.format_desc)\r
-                               BOOST_THROW_EXCEPTION(invalid_operation() << msg_info("Cannot swap between channels with different formats."));\r
+                               BOOST_THROW_EXCEPTION(not_supported() << msg_info("Cannot swap between channels with different formats."));\r
 \r
                        auto func = [&]{layers_[index].swap(other.impl_->layers_[other_index]);};\r
                \r
@@ -175,7 +175,7 @@ public:
                        return;\r
 \r
                if(channel_.format_desc != other.impl_->channel_.format_desc)\r
-                       BOOST_THROW_EXCEPTION(invalid_operation() << msg_info("Cannot swap between channels with different formats."));\r
+                       BOOST_THROW_EXCEPTION(not_supported() << msg_info("Cannot swap between channels with different formats."));\r
 \r
                auto func = [&]\r
                {\r
index c186d73110a3764293fce4afffec67a5afbdc71e..2f07217520d80fdaf2e67c625f7154192c838384 100644 (file)
@@ -135,6 +135,8 @@ struct bluefish_consumer : boost::noncopyable
        std::array<blue_dma_buffer_ptr, 4> reserved_frames_;    \r
        tbb::concurrent_bounded_queue<std::shared_ptr<const core::read_frame>> frame_buffer_;\r
 \r
+       int preroll_count_;\r
+\r
        const bool embedded_audio_;\r
        \r
        executor executor_;\r
@@ -148,7 +150,8 @@ public:
                , mem_fmt_(MEM_FMT_ARGB_PC)\r
                , upd_fmt_(UPD_FMT_FRAME)\r
                , res_fmt_(RES_FMT_NORMAL) \r
-               , engine_mode_(VIDEO_ENGINE_FRAMESTORE)         \r
+               , engine_mode_(VIDEO_ENGINE_FRAMESTORE) \r
+               , preroll_count_(0)\r
                , embedded_audio_(embedded_audio)\r
                , executor_(print())\r
        {\r
@@ -160,6 +163,7 @@ public:
                graph_->add_guide("frame-time", 0.5f);  \r
                graph_->set_color("frame-time", diagnostics::color(1.0f, 0.0f, 0.0f));\r
                graph_->set_color("sync-time", diagnostics::color(0.5f, 1.0f, 0.2f));\r
+               graph_->set_color("input-buffer", diagnostics::color(1.0f, 1.0f, 0.0f));\r
                        \r
                //Setting output Video mode\r
                if(BLUE_FAIL(set_card_property(blue_, VIDEO_MODE, vid_fmt_))) \r
@@ -222,10 +226,7 @@ public:
                                                \r
                for(size_t n = 0; n < reserved_frames_.size(); ++n)\r
                        reserved_frames_[n] = std::make_shared<blue_dma_buffer>(format_desc_.size, n);  \r
-\r
-               for(int n = 0; n < executor_.capacity(); ++n)\r
-                       schedule_next_video(core::read_frame::empty());\r
-                                               \r
+                                                               \r
                CASPAR_LOG(info) << print() << L" Successfully Initialized.";\r
        }\r
 \r
@@ -258,7 +259,13 @@ public:
        }\r
        \r
        void send(const safe_ptr<const core::read_frame>& frame)\r
-       {                       \r
+       {       \r
+               if(preroll_count_ < executor_.capacity())\r
+               {\r
+                       while(preroll_count_++ < executor_.capacity())\r
+                               schedule_next_video(core::read_frame::empty());\r
+               }\r
+               \r
                schedule_next_video(frame);                     \r
        }\r
        \r
@@ -270,10 +277,10 @@ public:
                {\r
                        try\r
                        {\r
-                               frame_timer_.restart();\r
+                               const size_t audio_samples       = format_desc_.audio_samples_per_frame;\r
+                               const size_t audio_nchannels = format_desc_.audio_channels;\r
 \r
-                               const size_t audio_samples = static_cast<size_t>(48000.0 / format_desc_.fps);\r
-                               const size_t audio_nchannels = 2;\r
+                               frame_timer_.restart();\r
                                \r
                                if(!frame->image_data().empty())\r
                                        fast_memcpy(reserved_frames_.front()->image_data(), frame->image_data().begin(), frame->image_data().size());\r
@@ -326,7 +333,9 @@ public:
                        {\r
                                CASPAR_LOG_CURRENT_EXCEPTION();\r
                        }\r
+                       graph_->set_value("input-buffer", static_cast<double>(executor_.size())/static_cast<double>(executor_.capacity()));\r
                });\r
+               graph_->set_value("input-buffer", static_cast<double>(executor_.size())/static_cast<double>(executor_.capacity()));\r
        }\r
 \r
        void encode_hanc(BLUE_UINT32* hanc_data, void* audio_data, size_t audio_samples, size_t audio_nchannels)\r
index 4ceaee69ebf8acb43948da7aaf6c070d7194f5d2..3e41b4c5d0cb4c22393f42e8b9887bac68a6b3af 100644 (file)
@@ -285,6 +285,7 @@ public:
 \r
                        std::shared_ptr<const core::read_frame> frame;  \r
                        video_frame_buffer_.pop(frame);         \r
+                       \r
                        schedule_next_video(safe_ptr<const core::read_frame>(frame));                   \r
                }\r
                catch(...)\r