]> git.sesse.net Git - casparcg/commitdiff
2.0. layer: Pause on eof.
authorRonag <Ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 14 Aug 2011 20:29:13 +0000 (20:29 +0000)
committerRonag <Ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 14 Aug 2011 20:29:13 +0000 (20:29 +0000)
     last_frame: Added missing disable_audio.

git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@1174 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

core/mixer/gpu/device_buffer.cpp
core/mixer/gpu/host_buffer.cpp
core/mixer/gpu/ogl_device.cpp
core/producer/frame_producer.cpp
core/producer/layer.cpp
core/producer/separated/separated_producer.cpp
core/producer/transition/transition_producer.cpp
modules/ffmpeg/producer/ffmpeg_producer.cpp

index 4eaf6e3e4a1d500f4eed8f1b64aa5a5533b41f8f..8a60fc9ef69d5bddf8386f07c069849227644c2e 100644 (file)
@@ -28,6 +28,8 @@
 \r
 #include <gl/glew.h>\r
 \r
+#include <tbb/atomic.h>\r
+\r
 namespace caspar { namespace core {\r
        \r
 static GLenum FORMAT[] = {0, GL_RED, GL_RG, GL_BGR, GL_BGRA};\r
@@ -38,6 +40,8 @@ unsigned int format(size_t stride)
        return FORMAT[stride];\r
 }\r
 \r
+static tbb::atomic<int> g_total_count;\r
+\r
 struct device_buffer::implementation : boost::noncopyable\r
 {\r
        GLuint id_;\r
@@ -62,7 +66,7 @@ public:
                GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));\r
                GL(glTexImage2D(GL_TEXTURE_2D, 0, INTERNAL_FORMAT[stride_], width_, height_, 0, FORMAT[stride_], GL_UNSIGNED_BYTE, NULL));\r
                GL(glBindTexture(GL_TEXTURE_2D, 0));\r
-               CASPAR_LOG(debug) << "[device_buffer] allocated size:" << width*height*stride;  \r
+               CASPAR_LOG(debug) << "[device_buffer] [" << ++g_total_count << L"] allocated size:" << width*height*stride;     \r
        }       \r
 \r
        ~implementation()\r
@@ -70,6 +74,7 @@ public:
                try\r
                {\r
                        GL(glDeleteTextures(1, &id_));\r
+                       CASPAR_LOG(debug) << "[device_buffer] [" << --g_total_count << L"] deallocated size:" << width_*height_*stride_;\r
                }\r
                catch(...)\r
                {\r
index e1695f07fa8dcbc651c118a607857512a5811f5c..aefcb9e5b5f6e8b8e80e900c06dcc42d059ba413 100644 (file)
 \r
 #include <gl/glew.h>\r
 \r
+#include <tbb/atomic.h>\r
+\r
 namespace caspar { namespace core {\r
+\r
+static tbb::atomic<int> g_w_total_count;\r
+static tbb::atomic<int> g_r_total_count;\r
                                                                                                                                                                                                                                                                                                                                \r
 struct host_buffer::implementation : boost::noncopyable\r
 {      \r
@@ -58,7 +63,7 @@ public:
                if(!pbo_)\r
                        BOOST_THROW_EXCEPTION(caspar_exception() << msg_info("Failed to allocate buffer."));\r
 \r
-               CASPAR_LOG(debug) << "[host_buffer] allocated size:" << size_ << " usage: " << (usage == write_only ? "write_only" : "read_only");\r
+               CASPAR_LOG(debug) << "[host_buffer] [" << ++(usage_ == write_only ? g_w_total_count : g_r_total_count) << L"] allocated size:" << size_ << " usage: " << (usage == write_only ? "write_only" : "read_only");\r
        }       \r
 \r
        ~implementation()\r
@@ -66,6 +71,7 @@ public:
                try\r
                {\r
                        GL(glDeleteBuffers(1, &pbo_));\r
+                       CASPAR_LOG(debug) << "[host_buffer] [" << --(usage_ == write_only ? g_w_total_count : g_r_total_count) << L"] deallocated size:" << size_ << " usage: " << (usage_ == write_only ? "write_only" : "read_only");\r
                }\r
                catch(...)\r
                {\r
index 1f2698d532a412c59a2af65e88f3aa87be1305ed..9d6a4221b456c904a6a295b28b3b9de8d0a62d4f 100644 (file)
@@ -57,6 +57,7 @@ ogl_device::ogl_device()
                GL(glGenFramebuffers(1, &fbo_));                \r
                GL(glBindFramebuffer(GL_FRAMEBUFFER_EXT, fbo_));\r
                GL(glReadBuffer(GL_COLOR_ATTACHMENT0_EXT));\r
+        GL(glDisable(GL_MULTISAMPLE_ARB));\r
        });\r
 }\r
 \r
index 08f3b17093f575cad5f2bee7648bbd994e5d90f0..548d8314a4c931b384e7e59601c00371cd435253 100644 (file)
@@ -50,9 +50,6 @@ const safe_ptr<frame_producer>& frame_producer::empty() // nothrow
 \r
 safe_ptr<basic_frame> receive_and_follow(safe_ptr<frame_producer>& producer, int hints)\r
 {      \r
-       if(producer == frame_producer::empty())\r
-               return basic_frame::eof();\r
-\r
        auto frame = producer->receive(hints);\r
        if(frame == basic_frame::eof())\r
        {\r
@@ -60,7 +57,10 @@ safe_ptr<basic_frame> receive_and_follow(safe_ptr<frame_producer>& producer, int
                auto following = producer->get_following_producer();\r
                following->set_leading_producer(producer);\r
                producer = std::move(following);                \r
-               \r
+                               \r
+               if(producer == frame_producer::empty())\r
+                       return basic_frame::eof();\r
+\r
                return receive_and_follow(producer, hints);\r
        }\r
        return frame;\r
index 9010954f4b587c8ac020c214d94b0ae205aedeef..c267c611e7d00bd922ba107a8336fb43b7ae764c 100644 (file)
@@ -34,13 +34,16 @@ struct layer::implementation
        bool                                            is_paused_;\r
        int                                                     auto_play_delta_;\r
        int64_t                                         frame_number_;\r
+       safe_ptr<core::basic_frame> last_frame_;\r
+\r
 public:\r
        implementation() \r
                : foreground_(frame_producer::empty())\r
                , background_(frame_producer::empty())\r
                , is_paused_(false)\r
                , auto_play_delta_(-1)\r
-               , frame_number_(0){}\r
+               , frame_number_(0)\r
+               , last_frame_(core::basic_frame::empty()){}\r
        \r
        void pause()\r
        {\r
@@ -82,6 +85,7 @@ public:
        {\r
                foreground_ = frame_producer::empty();\r
                frame_number_ = 0;\r
+               last_frame_ = core::basic_frame::empty();\r
        }\r
                \r
        safe_ptr<basic_frame> receive()\r
@@ -89,7 +93,7 @@ public:
                try\r
                {\r
                        if(is_paused_)\r
-                               return foreground_->last_frame();\r
+                               return disable_audio(last_frame_);\r
                \r
                        const auto frames_left = foreground_->nb_frames() - (++frame_number_) - auto_play_delta_;\r
 \r
@@ -99,6 +103,7 @@ public:
                \r
                        if(auto_play_delta_ >= 0)\r
                        {\r
+                               CASPAR_ASSERT(background_ != core::frame_producer::empty());\r
                                if(frames_left <= 0 || frame == core::basic_frame::eof())\r
                                {\r
                                        //CASPAR_ASSERT(frame != core::basic_frame::eof() && "Received early EOF. Media duration metadata incorrect.");\r
@@ -109,8 +114,14 @@ public:
                                        frame = receive();\r
                                }\r
                        }\r
+\r
+                       if(frame == core::basic_frame::eof())\r
+                       {\r
+                               pause();\r
+                               return receive();\r
+                       }\r
                                \r
-                       return frame;\r
+                       return last_frame_ = frame;\r
                }\r
                catch(...)\r
                {\r
index 66cb7e8281f47706fae0b722d63ae0cdbe160a10..e03c83d4f8bb1c206929a908136cfd08e9989709 100644 (file)
@@ -75,7 +75,7 @@ struct separated_producer : public frame_producer
 \r
        virtual safe_ptr<core::basic_frame> last_frame() const\r
        {\r
-               return last_frame_;\r
+               return disable_audio(last_frame_);\r
        }\r
 \r
        virtual std::wstring print() const\r
index 5bf9f4ab484896e2538813c5b5b6a0fb28be01c6..9673d51630d53620655954a28806d155daeab5da 100644 (file)
@@ -90,7 +90,7 @@ struct transition_producer : public frame_producer
 \r
        virtual safe_ptr<core::basic_frame> last_frame() const\r
        {\r
-               return last_frame_;\r
+               return disable_audio(last_frame_);\r
        }\r
 \r
        virtual int64_t nb_frames() const \r
index d0f00dbd8c7449e42ed854e994b07e2e5eee2087..a8988ad753f2f3a37690d6d186fe3daee755a997 100644 (file)
@@ -81,7 +81,6 @@ struct ffmpeg_producer : public core::frame_producer
        const bool                                                                              loop_;\r
 \r
        safe_ptr<core::basic_frame>                                             last_frame_;\r
-       bool                                                                                    eof_;\r
        \r
 public:\r
        explicit ffmpeg_producer(const safe_ptr<core::frame_factory>& frame_factory, const std::wstring& filename, const std::wstring& filter, bool loop, int start, int length) \r
@@ -97,7 +96,6 @@ public:
                , start_(start)\r
                , loop_(loop)\r
                , last_frame_(core::basic_frame::empty())\r
-               , eof_(false)\r
        {\r
                graph_->add_guide("frame-time", 0.5);\r
                graph_->set_color("frame-time", diagnostics::color(1.0f, 0.0f, 0.0f));\r
@@ -109,9 +107,6 @@ public:
                        \r
        virtual safe_ptr<core::basic_frame> receive(int hints)\r
        {\r
-               if(eof_)\r
-                       return last_frame();\r
-\r
                auto frame = core::basic_frame::late();\r
                \r
                frame_timer_.restart();\r
@@ -126,10 +121,7 @@ public:
                else\r
                {\r
                        if(input_.eof())\r
-                       {\r
-                               eof_ = true;\r
-                               return last_frame();\r
-                       }\r
+                               return core::basic_frame::eof();\r
                        else\r
                        {\r
                                graph_->add_tag("underflow");   \r