\r
#include "layer.h"\r
\r
-#include "../processor/draw_frame.h"\r
+#include "../mixer/frame/draw_frame.h"\r
+#include "../mixer/image/image_mixer.h"\r
+#include "../mixer/audio/audio_mixer.h"\r
#include "../producer/frame_producer.h"\r
\r
#include "../video_format.h"\r
\r
+#include <common/utility/assert.h>\r
+\r
namespace caspar { namespace core {\r
\r
struct layer::implementation : boost::noncopyable\r
safe_ptr<frame_producer> foreground_;\r
safe_ptr<frame_producer> background_;\r
safe_ptr<draw_frame> last_frame_;\r
- const int index_;\r
bool is_paused_;\r
\r
public:\r
- implementation(int index) \r
+ implementation() \r
: foreground_(frame_producer::empty())\r
, background_(frame_producer::empty())\r
, last_frame_(draw_frame::empty())\r
- , index_(index) \r
, is_paused_(false){}\r
\r
void load(const safe_ptr<frame_producer>& frame_producer, bool play_on_load)\r
{ \r
background_ = frame_producer;\r
- CASPAR_LOG(info) << print() << " " << frame_producer->print() << " => background";\r
if(play_on_load)\r
play(); \r
}\r
background_->set_leading_producer(foreground_);\r
foreground_ = background_;\r
background_ = frame_producer::empty();\r
- CASPAR_LOG(info) << print() << L" background => foreground";\r
}\r
}\r
\r
pause();\r
last_frame_ = draw_frame::empty();\r
foreground_ = frame_producer::empty();\r
- CASPAR_LOG(warning) << print() << L" empty => foreground";\r
}\r
\r
void clear()\r
{\r
stop();\r
background_ = frame_producer::empty();\r
- CASPAR_LOG(warning) << print() << L" empty => background";\r
}\r
\r
safe_ptr<draw_frame> receive()\r
last_frame_ = foreground_->receive(); \r
if(last_frame_ == draw_frame::eof())\r
{\r
- assert(foreground_ != frame_producer::empty());\r
+ CASPAR_ASSERT(foreground_ != frame_producer::empty());\r
\r
auto following = foreground_->get_following_producer();\r
following->set_leading_producer(foreground_);\r
foreground_ = following;\r
\r
- CASPAR_LOG(info) << print() << L" [EOF] " << foreground_->print() << " => foreground";\r
-\r
last_frame_ = receive();\r
}\r
}\r
\r
return last_frame_;\r
}\r
-\r
- std::wstring print() const { return L"layer[" + boost::lexical_cast<std::wstring>(index_) + L"]"; }\r
};\r
\r
-layer::layer(int index) : impl_(new implementation(index)){}\r
-layer::layer(layer&& other) : impl_(std::move(other.impl_)){other.impl_ = nullptr;}\r
+layer::layer() \r
+{\r
+ impl_ = new implementation();\r
+}\r
+layer::layer(layer&& other) \r
+{\r
+ impl_ = other.impl_.compare_and_swap(nullptr, other.impl_);\r
+}\r
+layer::~layer()\r
+{\r
+ delete impl_.fetch_and_store(nullptr);\r
+}\r
layer& layer::operator=(layer&& other)\r
{\r
- impl_ = std::move(other.impl_); \r
- other.impl_ = nullptr;\r
+ impl_ = other.impl_.compare_and_swap(nullptr, other.impl_);\r
return *this;\r
}\r
+void layer::swap(layer& other)\r
+{\r
+ impl_ = other.impl_.compare_and_swap(impl_, other.impl_);\r
+}\r
void layer::load(const safe_ptr<frame_producer>& frame_producer, bool play_on_load){return impl_->load(frame_producer, play_on_load);} \r
void layer::preview(const safe_ptr<frame_producer>& frame_producer){return impl_->preview(frame_producer);} \r
void layer::play(){impl_->play();}\r
void layer::pause(){impl_->pause();}\r
void layer::stop(){impl_->stop();}\r
void layer::clear(){impl_->clear();}\r
-bool layer::empty() const { return impl_->foreground_ == frame_producer::empty() && impl_->background_ == frame_producer::empty();}\r
safe_ptr<draw_frame> layer::receive() {return impl_->receive();}\r
safe_ptr<frame_producer> layer::foreground() const { return impl_->foreground_;}\r
safe_ptr<frame_producer> layer::background() const { return impl_->background_;}\r