From: Ronag Date: Sun, 14 Aug 2011 20:29:13 +0000 (+0000) Subject: 2.0. layer: Pause on eof. X-Git-Tag: 2.0.1~166 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=af660bb0772edbc122286d1e1bc1ded9bc6b2794;p=casparcg 2.0. layer: Pause on eof. 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 --- diff --git a/core/mixer/gpu/device_buffer.cpp b/core/mixer/gpu/device_buffer.cpp index 4eaf6e3e4..8a60fc9ef 100644 --- a/core/mixer/gpu/device_buffer.cpp +++ b/core/mixer/gpu/device_buffer.cpp @@ -28,6 +28,8 @@ #include +#include + namespace caspar { namespace core { static GLenum FORMAT[] = {0, GL_RED, GL_RG, GL_BGR, GL_BGRA}; @@ -38,6 +40,8 @@ unsigned int format(size_t stride) return FORMAT[stride]; } +static tbb::atomic g_total_count; + struct device_buffer::implementation : boost::noncopyable { GLuint id_; @@ -62,7 +66,7 @@ public: GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); GL(glTexImage2D(GL_TEXTURE_2D, 0, INTERNAL_FORMAT[stride_], width_, height_, 0, FORMAT[stride_], GL_UNSIGNED_BYTE, NULL)); GL(glBindTexture(GL_TEXTURE_2D, 0)); - CASPAR_LOG(debug) << "[device_buffer] allocated size:" << width*height*stride; + CASPAR_LOG(debug) << "[device_buffer] [" << ++g_total_count << L"] allocated size:" << width*height*stride; } ~implementation() @@ -70,6 +74,7 @@ public: try { GL(glDeleteTextures(1, &id_)); + CASPAR_LOG(debug) << "[device_buffer] [" << --g_total_count << L"] deallocated size:" << width_*height_*stride_; } catch(...) { diff --git a/core/mixer/gpu/host_buffer.cpp b/core/mixer/gpu/host_buffer.cpp index e1695f07f..aefcb9e5b 100644 --- a/core/mixer/gpu/host_buffer.cpp +++ b/core/mixer/gpu/host_buffer.cpp @@ -30,7 +30,12 @@ #include +#include + namespace caspar { namespace core { + +static tbb::atomic g_w_total_count; +static tbb::atomic g_r_total_count; struct host_buffer::implementation : boost::noncopyable { @@ -58,7 +63,7 @@ public: if(!pbo_) BOOST_THROW_EXCEPTION(caspar_exception() << msg_info("Failed to allocate buffer.")); - CASPAR_LOG(debug) << "[host_buffer] allocated size:" << size_ << " usage: " << (usage == write_only ? "write_only" : "read_only"); + 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"); } ~implementation() @@ -66,6 +71,7 @@ public: try { GL(glDeleteBuffers(1, &pbo_)); + 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"); } catch(...) { diff --git a/core/mixer/gpu/ogl_device.cpp b/core/mixer/gpu/ogl_device.cpp index 1f2698d53..9d6a4221b 100644 --- a/core/mixer/gpu/ogl_device.cpp +++ b/core/mixer/gpu/ogl_device.cpp @@ -57,6 +57,7 @@ ogl_device::ogl_device() GL(glGenFramebuffers(1, &fbo_)); GL(glBindFramebuffer(GL_FRAMEBUFFER_EXT, fbo_)); GL(glReadBuffer(GL_COLOR_ATTACHMENT0_EXT)); + GL(glDisable(GL_MULTISAMPLE_ARB)); }); } diff --git a/core/producer/frame_producer.cpp b/core/producer/frame_producer.cpp index 08f3b1709..548d8314a 100644 --- a/core/producer/frame_producer.cpp +++ b/core/producer/frame_producer.cpp @@ -50,9 +50,6 @@ const safe_ptr& frame_producer::empty() // nothrow safe_ptr receive_and_follow(safe_ptr& producer, int hints) { - if(producer == frame_producer::empty()) - return basic_frame::eof(); - auto frame = producer->receive(hints); if(frame == basic_frame::eof()) { @@ -60,7 +57,10 @@ safe_ptr receive_and_follow(safe_ptr& producer, int auto following = producer->get_following_producer(); following->set_leading_producer(producer); producer = std::move(following); - + + if(producer == frame_producer::empty()) + return basic_frame::eof(); + return receive_and_follow(producer, hints); } return frame; diff --git a/core/producer/layer.cpp b/core/producer/layer.cpp index 9010954f4..c267c611e 100644 --- a/core/producer/layer.cpp +++ b/core/producer/layer.cpp @@ -34,13 +34,16 @@ struct layer::implementation bool is_paused_; int auto_play_delta_; int64_t frame_number_; + safe_ptr last_frame_; + public: implementation() : foreground_(frame_producer::empty()) , background_(frame_producer::empty()) , is_paused_(false) , auto_play_delta_(-1) - , frame_number_(0){} + , frame_number_(0) + , last_frame_(core::basic_frame::empty()){} void pause() { @@ -82,6 +85,7 @@ public: { foreground_ = frame_producer::empty(); frame_number_ = 0; + last_frame_ = core::basic_frame::empty(); } safe_ptr receive() @@ -89,7 +93,7 @@ public: try { if(is_paused_) - return foreground_->last_frame(); + return disable_audio(last_frame_); const auto frames_left = foreground_->nb_frames() - (++frame_number_) - auto_play_delta_; @@ -99,6 +103,7 @@ public: if(auto_play_delta_ >= 0) { + CASPAR_ASSERT(background_ != core::frame_producer::empty()); if(frames_left <= 0 || frame == core::basic_frame::eof()) { //CASPAR_ASSERT(frame != core::basic_frame::eof() && "Received early EOF. Media duration metadata incorrect."); @@ -109,8 +114,14 @@ public: frame = receive(); } } + + if(frame == core::basic_frame::eof()) + { + pause(); + return receive(); + } - return frame; + return last_frame_ = frame; } catch(...) { diff --git a/core/producer/separated/separated_producer.cpp b/core/producer/separated/separated_producer.cpp index 66cb7e828..e03c83d4f 100644 --- a/core/producer/separated/separated_producer.cpp +++ b/core/producer/separated/separated_producer.cpp @@ -75,7 +75,7 @@ struct separated_producer : public frame_producer virtual safe_ptr last_frame() const { - return last_frame_; + return disable_audio(last_frame_); } virtual std::wstring print() const diff --git a/core/producer/transition/transition_producer.cpp b/core/producer/transition/transition_producer.cpp index 5bf9f4ab4..9673d5163 100644 --- a/core/producer/transition/transition_producer.cpp +++ b/core/producer/transition/transition_producer.cpp @@ -90,7 +90,7 @@ struct transition_producer : public frame_producer virtual safe_ptr last_frame() const { - return last_frame_; + return disable_audio(last_frame_); } virtual int64_t nb_frames() const diff --git a/modules/ffmpeg/producer/ffmpeg_producer.cpp b/modules/ffmpeg/producer/ffmpeg_producer.cpp index d0f00dbd8..a8988ad75 100644 --- a/modules/ffmpeg/producer/ffmpeg_producer.cpp +++ b/modules/ffmpeg/producer/ffmpeg_producer.cpp @@ -81,7 +81,6 @@ struct ffmpeg_producer : public core::frame_producer const bool loop_; safe_ptr last_frame_; - bool eof_; public: explicit ffmpeg_producer(const safe_ptr& frame_factory, const std::wstring& filename, const std::wstring& filter, bool loop, int start, int length) @@ -97,7 +96,6 @@ public: , start_(start) , loop_(loop) , last_frame_(core::basic_frame::empty()) - , eof_(false) { graph_->add_guide("frame-time", 0.5); graph_->set_color("frame-time", diagnostics::color(1.0f, 0.0f, 0.0f)); @@ -109,9 +107,6 @@ public: virtual safe_ptr receive(int hints) { - if(eof_) - return last_frame(); - auto frame = core::basic_frame::late(); frame_timer_.restart(); @@ -126,10 +121,7 @@ public: else { if(input_.eof()) - { - eof_ = true; - return last_frame(); - } + return core::basic_frame::eof(); else { graph_->add_tag("underflow");