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
// 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
\r
~implementation()\r
{ \r
+ executor_.invoke([]{});\r
executor_.stop();\r
- executor_.wait();\r
\r
av_write_trailer(oc_.get());\r
\r
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
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
\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
, 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
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
{\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
{\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
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
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
\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