]> git.sesse.net Git - casparcg/commitdiff
2.0.0.2: Fixed consumer-device shutdown dead-lock.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 27 Feb 2011 19:27:21 +0000 (19:27 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 27 Feb 2011 19:27:21 +0000 (19:27 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@489 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

common/concurrency/executor.h
core/channel.cpp
core/consumer/ffmpeg/ffmpeg_consumer.cpp
core/producer/ffmpeg/input.cpp
core/producer/ffmpeg/video/video_decoder.cpp
core/producer/flash/cg_producer.cpp
core/producer/layer.cpp
mixer/frame_mixer_device.cpp
mixer/gpu/ogl_device.cpp

index 89d30b1173933292ffe73db54c9c6c5332f467e0..95f2c17d6528ee6a6e3d3e87b6c19450c6868039 100644 (file)
@@ -76,15 +76,9 @@ public:
        void stop() // noexcept\r
        {\r
                is_running_ = false;    \r
-               execution_queue_.push([]{});\r
+               execution_queue_.try_push([]{});\r
        }\r
-\r
-       void wait()\r
-       {\r
-               if(is_running_)\r
-                       invoke([]{});\r
-       }\r
-\r
+       \r
        void clear()\r
        {\r
                std::function<void()> func;\r
index b68e6c06d5a756e799550413562c4a836e9dbb4d..3f1522c25aed9317ca92544ea05027924268d06b 100644 (file)
@@ -48,11 +48,11 @@ public:
                // Shutdown order is important! Destroy all created frames to mixer before destroying mixer.\r
                CASPAR_LOG(info) << print() << " Shutting down channel.";\r
                producer_.reset();\r
-               CASPAR_LOG(info) << print() << " Successfully shut down producer-device.";\r
+               CASPAR_LOG(info) << print() << " Successfully shutdown producer-device.";\r
                consumer_.reset();\r
-               CASPAR_LOG(info) << print() << " Successfully shut down consumer-device.";\r
+               CASPAR_LOG(info) << print() << " Successfully shutdown consumer-device.";\r
                mixer_.reset();\r
-               CASPAR_LOG(info) << print() << " Successfully shut down mixer-device.";\r
+               CASPAR_LOG(info) << print() << " Successfully shutdown mixer-device.";\r
        }\r
 \r
        std::wstring print() const\r
index 733a9a9da02f97b4a63fc3dcccfe4a8255fe9e3d..dbbb419422f1a6a0ac1f3698785aab607009bf7d 100644 (file)
@@ -90,8 +90,8 @@ public:
 \r
        ~implementation()\r
        {    \r
+               executor_.invoke([]{});\r
                executor_.stop();\r
-               executor_.wait();\r
 \r
                av_write_trailer(oc_.get());\r
 \r
index b8f89728873a084629b121a1c45526a3b209278f..5860a15002e1c7b8289c6a4609563ffda8e6179a 100644 (file)
@@ -93,17 +93,21 @@ public:
                video_codec_context_ = open_stream(CODEC_TYPE_VIDEO, video_s_index_);\r
                if(!video_codec_context_)\r
                        CASPAR_LOG(warning) << print() << " Could not open any video stream.";\r
+               else\r
+                       fix_time_base(video_codec_context_.get());\r
                \r
                audio_codex_context_ = open_stream(CODEC_TYPE_AUDIO, audio_s_index_);\r
                if(!audio_codex_context_)\r
                        CASPAR_LOG(warning) << print() << " Could not open any audio stream.";\r
+               else\r
+                       fix_time_base(video_codec_context_.get());\r
 \r
                if(!video_codec_context_ && !audio_codex_context_)\r
                        BOOST_THROW_EXCEPTION(\r
                                file_read_error() << \r
                                source_info(narrow(print())) << \r
                                msg_info("No video or audio codec context found."));            \r
-                                       \r
+                       \r
                executor_.start();\r
                executor_.begin_invoke([this]{read_file();});\r
                CASPAR_LOG(info) << print() << " Started.";\r
@@ -116,7 +120,13 @@ public:
                cond_.notify_all();\r
                CASPAR_LOG(info) << print() << " Stopped.";\r
        }\r
-                                                       \r
+                       \r
+       void fix_time_base(AVCodecContext* context) // Some files give an invalid numerator, try to fix it.\r
+       {\r
+               if(context && context->time_base.num == 1)\r
+                       context->time_base.num = static_cast<int>(std::pow(10.0, static_cast<int>(std::log10(static_cast<float>(context->time_base.den)))-1));\r
+       }\r
+\r
        std::shared_ptr<AVCodecContext> open_stream(int codec_type, int& s_index)\r
        {               \r
                AVStream** streams_end = format_context_->streams+format_context_->nb_streams;\r
@@ -211,7 +221,7 @@ public:
 \r
        std::wstring print() const\r
        {\r
-               return (parent_printer_ ? parent_printer_() + L"/" : L"") + L"async_input";\r
+               return (parent_printer_ ? parent_printer_() + L"/" : L"") + L"input";\r
        }\r
 };\r
 \r
index 1a87cfc3e141326ba97049da0fc672689320c0db..3fd6273e7aff2b67562d2bb5cdebe37f51c92e4e 100644 (file)
@@ -109,8 +109,6 @@ public:
                , pix_fmt_(codec_context_->pix_fmt)\r
                , desc_(get_pixel_format_desc(pix_fmt_, width_, height_))\r
        {\r
-               if(codec_context_->time_base.num == 1) // Some files give an invalid numerator, try to fix it.\r
-                       codec_context_->time_base.num = static_cast<int>(std::pow(10.0, static_cast<int>(std::log10(static_cast<float>(codec_context_->time_base.den)))-1));\r
                double frame_time = static_cast<double>(codec_context_->time_base.num) / static_cast<double>(codec_context_->time_base.den);\r
                double format_frame_time = 1.0/frame_factory->get_video_format_desc().fps;\r
                if(abs(frame_time - format_frame_time) > 0.0001)\r
index 9db8567ec37321544860e680c34dde9910959665..95db82b42d3b55b525865b010ba4b3985aa95d6c 100644 (file)
@@ -80,8 +80,8 @@ public:
        void initialize(const safe_ptr<frame_factory>& frame_factory)\r
        {\r
                frame_factory_ = frame_factory;\r
-               flash_producer_->initialize(frame_factory);\r
                flash_producer_->set_parent_printer(parent_printer_);\r
+               flash_producer_->initialize(frame_factory);\r
        }\r
 \r
        void set_parent_printer(const printer& parent_printer) \r
index f8a863d9ca4098013f6c53a93ec404e86df4b498..3d8f88126a2fe355c0d05f993eb0d19e86b25105 100644 (file)
@@ -27,7 +27,7 @@ class frame_producer_remover
        {\r
                auto name = producer->print();\r
                producer = frame_producer::empty();\r
-               CASPAR_LOG(info) <<  name << L" Removed.";\r
+               CASPAR_LOG(info) << name << L" Removed.";\r
        }\r
 public:\r
 \r
@@ -87,7 +87,7 @@ public:
                {\r
                        background_->set_leading_producer(foreground_);\r
                        foreground_ = background_;\r
-                       CASPAR_LOG(info) << foreground_->print() << L" Activated.";\r
+                       CASPAR_LOG(info) << foreground_->print() << L" Added.";\r
                        background_ = frame_producer::empty();\r
                }\r
                is_paused_ = false;\r
@@ -133,7 +133,7 @@ public:
                                following->set_parent_printer(boost::bind(&implementation::print, this));\r
                                g_remover.remove(std::move(foreground_));\r
                                foreground_ = following;\r
-                               CASPAR_LOG(info) << foreground_->print() << L" Activated.";\r
+                               CASPAR_LOG(info) << foreground_->print() << L" Added.";\r
 \r
                                last_frame_ = receive();\r
                        }\r
index b4dae9ac785bda289527632988892fc189b97444..aa71ea5d7ab9ff0be5e38a2fc35804fc3886f536 100644 (file)
@@ -63,11 +63,6 @@ public:
                CASPAR_LOG(info) << print() << L" Successfully initialized.";   \r
        }\r
                \r
-       ~implementation()\r
-       {\r
-               executor_.clear();\r
-       }\r
-\r
        void send(const std::vector<safe_ptr<draw_frame>>& frames)\r
        {                       \r
                executor_.begin_invoke([=]\r
index 109ea1a40c1b0ebdc3816678adea1e28e4dab8dd..0630d3ea132214d02cbb2e38f54fc42f16aaed9a 100644 (file)
@@ -11,7 +11,7 @@
 \r
 namespace caspar { namespace core {\r
 \r
-ogl_device::ogl_device()\r
+ogl_device::ogl_device() : executor_(L"ogl_device")\r
 {\r
        executor_.start();\r
        invoke([=]\r