#include "../../mixer/write_frame.h"\r
#include "../../mixer/read_frame.h"\r
\r
+#include <boost/thread/once.hpp>\r
+\r
#include <common/exception/exceptions.h>\r
#include <common/memory/memcpy.h>\r
#include <common/concurrency/future_util.h>\r
tbb::concurrent_bounded_queue<std::shared_ptr<read_frame>> frame_buffer_;\r
core::video_format_desc format_desc_;\r
int channel_index_;\r
+ int consumer_index_;\r
tbb::atomic<bool> is_running_;\r
tbb::atomic<int64_t> current_age_;\r
\r
{\r
is_running_ = true;\r
current_age_ = 0;\r
+ consumer_index_ = next_consumer_index();\r
frame_buffer_.set_capacity(3);\r
}\r
\r
+ static int next_consumer_index()\r
+ {\r
+ static tbb::atomic<int> consumer_index_counter;\r
+ static boost::once_flag consumer_index_counter_initialized;\r
+\r
+ boost::call_once(consumer_index_counter_initialized, [&]()\r
+ {\r
+ consumer_index_counter = 0;\r
+ });\r
+\r
+ return ++consumer_index_counter;\r
+ }\r
+\r
~channel_consumer()\r
{\r
stop();\r
\r
virtual int index() const override\r
{\r
- return 78500 + channel_index_;\r
+ return 78500 + consumer_index_;\r
}\r
\r
// channel_consumer\r