\r
#include "audio_mixer.h"\r
\r
-#include <core/frame/write_frame.h>\r
+#include <core/frame/frame.h>\r
#include <core/frame/frame_transform.h>\r
#include <common/diagnostics/graph.h>\r
\r
struct audio_item\r
{\r
const void* tag;\r
- frame_transform transform;\r
+ audio_transform transform;\r
audio_buffer audio_data;\r
\r
audio_item()\r
\r
struct audio_stream\r
{\r
- frame_transform prev_transform;\r
+ audio_transform prev_transform;\r
audio_buffer_ps audio_data;\r
};\r
\r
struct audio_mixer::impl : boost::noncopyable\r
{\r
- std::stack<core::frame_transform> transform_stack_;\r
+ std::stack<core::audio_transform> transform_stack_;\r
std::map<const void*, audio_stream> audio_streams_;\r
std::vector<audio_item> items_;\r
std::vector<int> audio_cadence_;\r
public:\r
impl()\r
{\r
- transform_stack_.push(core::frame_transform());\r
+ transform_stack_.push(core::audio_transform());\r
}\r
\r
- void push(frame_transform& transform)\r
+ void push(const frame_transform& transform)\r
{\r
- transform_stack_.push(transform_stack_.top()*transform);\r
+ transform_stack_.push(transform_stack_.top()*transform.audio_transform);\r
}\r
\r
- void visit(data_frame& frame)\r
+ void visit(const const_frame& frame)\r
{\r
audio_item item;\r
item.tag = frame.tag();\r
items_.push_back(std::move(item)); \r
}\r
\r
- void begin(const core::frame_transform& transform)\r
+ void begin(const core::audio_transform& transform)\r
{\r
transform_stack_.push(transform_stack_.top()*transform);\r
}\r
} \r
\r
std::map<const void*, audio_stream> next_audio_streams;\r
+ std::vector<const void*> used_tags;\r
\r
BOOST_FOREACH(auto& item, items_)\r
{ \r
auto next_transform = item.transform;\r
auto prev_transform = next_transform;\r
\r
- const auto it = audio_streams_.find(item.tag);\r
+ auto tag = item.tag;\r
+\r
+ if(boost::range::find(used_tags, tag) != used_tags.end())\r
+ continue;\r
+ \r
+ used_tags.push_back(tag);\r
+\r
+ const auto it = audio_streams_.find(tag);\r
if(it != audio_streams_.end())\r
{ \r
prev_transform = it->second.prev_transform;\r
for(size_t n = 0; n < item.audio_data.size(); ++n)\r
next_audio.push_back(item.audio_data[n] * (prev_volume + (n/format_desc_.audio_channels) * alpha));\r
\r
- next_audio_streams[item.tag].prev_transform = std::move(next_transform); // Store all active tags, inactive tags will be removed at the end.\r
- next_audio_streams[item.tag].audio_data = std::move(next_audio); \r
+ next_audio_streams[tag].prev_transform = std::move(next_transform); // Store all active tags, inactive tags will be removed at the end.\r
+ next_audio_streams[tag].audio_data = std::move(next_audio); \r
} \r
\r
items_.clear();\r
};\r
\r
audio_mixer::audio_mixer() : impl_(new impl()){}\r
-void audio_mixer::push(frame_transform& transform){impl_->push(transform);}\r
-void audio_mixer::visit(data_frame& frame){impl_->visit(frame);}\r
+void audio_mixer::push(const frame_transform& transform){impl_->push(transform);}\r
+void audio_mixer::visit(const const_frame& frame){impl_->visit(frame);}\r
void audio_mixer::pop(){impl_->pop();}\r
audio_buffer audio_mixer::operator()(const video_format_desc& format_desc){return impl_->mix(format_desc);}\r
\r