#include <common/utility/timer.h>\r
\r
#include <core/consumer/frame_consumer.h>\r
+#include <core/mixer/audio/audio_util.h>\r
\r
#include <tbb/concurrent_queue.h>\r
\r
#include <memory>\r
#include <array>\r
\r
-namespace caspar { \r
+namespace caspar { namespace bluefish { \r
\r
struct bluefish_consumer : boost::noncopyable\r
{\r
\r
const std::wstring model_name_;\r
\r
- std::shared_ptr<diagnostics::graph> graph_;\r
+ safe_ptr<diagnostics::graph> graph_;\r
boost::timer frame_timer_;\r
boost::timer tick_timer_;\r
boost::timer sync_timer_; \r
{\r
executor_.set_capacity(core::consumer_buffer_depth());\r
\r
- graph_ = diagnostics::create_graph(narrow(print()));\r
graph_->add_guide("tick-time", 0.5);\r
graph_->set_color("tick-time", diagnostics::color(0.0f, 0.6f, 0.9f)); \r
graph_->add_guide("frame-time", 0.5f); \r
graph_->set_color("frame-time", diagnostics::color(1.0f, 0.0f, 0.0f));\r
graph_->set_color("sync-time", diagnostics::color(0.5f, 1.0f, 0.2f));\r
graph_->set_color("input-buffer", diagnostics::color(1.0f, 1.0f, 0.0f));\r
+ graph_->set_text(print());\r
+ diagnostics::register_graph(graph_);\r
\r
//Setting output Video mode\r
if(BLUE_FAIL(set_card_property(blue_, VIDEO_MODE, vid_fmt_))) \r
\r
if(embedded_audio_)\r
{ \r
- auto frame_audio_data = frame->audio_data().empty() ? silence.data() : const_cast<int16_t*>(frame->audio_data().begin());\r
+ auto frame_audio = core::audio_32_to_16_sse(frame->audio_data());\r
+ auto frame_audio_data = frame_audio.size() != audio_samples ? silence.data() : frame_audio.data(); \r
\r
encode_hanc(reinterpret_cast<BLUE_UINT32*>(reserved_frames_.front()->hanc_data()), frame_audio_data, audio_samples, audio_nchannels);\r
\r
const bool embedded_audio_;\r
const bool key_only_;\r
core::video_format_desc format_desc_;\r
- size_t fail_count_;\r
public:\r
\r
bluefish_consumer_proxy(size_t device_index, bool embedded_audio, bool key_only)\r
: device_index_(device_index)\r
, embedded_audio_(embedded_audio)\r
, key_only_(key_only)\r
- , fail_count_(0)\r
{\r
}\r
\r
\r
virtual bool send(const safe_ptr<core::read_frame>& frame)\r
{\r
- if(!consumer_)\r
- consumer_.reset(new bluefish_consumer(format_desc_, device_index_, embedded_audio_, key_only_));\r
-\r
- try\r
- {\r
- consumer_->send(frame);\r
- fail_count_ = 0;\r
- }\r
- catch(...)\r
- {\r
- consumer_.reset();\r
-\r
- if(fail_count_++ > 3)\r
- return false; // Outside didn't handle exception properly, just give up.\r
-\r
- throw;\r
- }\r
-\r
+ consumer_->send(frame);\r
return true;\r
}\r
\r
}\r
}; \r
\r
-safe_ptr<core::frame_consumer> create_bluefish_consumer(const std::vector<std::wstring>& params)\r
+safe_ptr<core::frame_consumer> create_consumer(const std::vector<std::wstring>& params)\r
{\r
if(params.size() < 1 || params[0] != L"BLUEFISH")\r
return core::frame_consumer::empty();\r
return make_safe<bluefish_consumer_proxy>(device_index, embedded_audio, key_only);\r
}\r
\r
-safe_ptr<core::frame_consumer> create_bluefish_consumer(const boost::property_tree::ptree& ptree) \r
+safe_ptr<core::frame_consumer> create_consumer(const boost::property_tree::ptree& ptree) \r
{ \r
const auto device_index = ptree.get("device", 1);\r
const auto embedded_audio = ptree.get("embedded-audio", false);\r
return make_safe<bluefish_consumer_proxy>(device_index, embedded_audio, key_only);\r
}\r
\r
-}
\ No newline at end of file
+}}
\ No newline at end of file