]> git.sesse.net Git - casparcg/blobdiff - core/mixer/write_frame.cpp
2.0. audio:
[casparcg] / core / mixer / write_frame.cpp
index 8f10bba5b6cb06fa5241e8718e4c0c91299b4d42..f7b25f50a08c56660f7fa8c17886fe9c942ce677 100644 (file)
@@ -28,6 +28,8 @@
 #include <core/producer/frame/frame_visitor.h>\r
 #include <core/producer/frame/pixel_format.h>\r
 \r
+#include <boost/lexical_cast.hpp>\r
+\r
 namespace caspar { namespace core {\r
                                                                                                                                                                                                                                                                                                                        \r
 struct write_frame::implementation\r
@@ -35,20 +37,21 @@ struct write_frame::implementation
        ogl_device*                                                                     ogl_;\r
        std::vector<std::shared_ptr<host_buffer>>       buffers_;\r
        std::vector<safe_ptr<device_buffer>>            textures_;\r
-       std::vector<int16_t>                                            audio_data_;\r
+       audio_buffer                                                            audio_data_;\r
        const core::pixel_format_desc                           desc_;\r
-       int                                                                                     tag_;\r
-       core::video_mode::type                                          mode_;\r
+       const void*                                                                     tag_;\r
+       core::field_mode::type                                          mode_;\r
 \r
-       implementation()\r
+       implementation(const void* tag)\r
+               : tag_(tag)\r
        {\r
        }\r
 \r
-       implementation(ogl_device& ogl, int tag, const core::pixel_format_desc& desc) \r
+       implementation(ogl_device& ogl, const void* tag, const core::pixel_format_desc& desc) \r
                : ogl_(&ogl)\r
                , desc_(desc)\r
                , tag_(tag)\r
-               , mode_(core::video_mode::progressive)\r
+               , mode_(core::field_mode::progressive)\r
        {\r
                ogl_->invoke([&]\r
                {\r
@@ -106,33 +109,57 @@ struct write_frame::implementation
                \r
                ogl_->begin_invoke([=]\r
                {                       \r
-                       texture->read(*buffer);\r
+                       buffer->unmap();\r
+                       buffer->bind();\r
+                       texture->begin_read();\r
+                       buffer->unbind();\r
                }, high_priority);\r
        }\r
+\r
+       std::wstring print() const\r
+       {\r
+               return L"write_frame[" + boost::lexical_cast<std::wstring>(tag_) + L"]";\r
+       }\r
 };\r
        \r
-write_frame::write_frame() : impl_(new implementation()){}\r
-write_frame::write_frame(ogl_device& ogl, int32_t tag, const core::pixel_format_desc& desc) \r
+write_frame::write_frame(const void* tag) : impl_(new implementation(tag)){}\r
+write_frame::write_frame(ogl_device& ogl, const void* tag, const core::pixel_format_desc& desc) \r
        : impl_(new implementation(ogl, tag, desc)){}\r
 write_frame::write_frame(const write_frame& other) : impl_(new implementation(*other.impl_)){}\r
-void write_frame::accept(core::frame_visitor& visitor){impl_->accept(*this, visitor);}\r
+write_frame::write_frame(write_frame&& other) : impl_(std::move(*other.impl_)){}\r
+write_frame& write_frame::operator=(const write_frame& other)\r
+{\r
+       basic_frame temp(other);\r
+       temp.swap(*this);\r
+       return *this;\r
+}\r
+write_frame& write_frame::operator=(write_frame&& other)\r
+{\r
+       write_frame temp(std::move(other));\r
+       temp.swap(*this);\r
+       return *this;\r
+}\r
+void write_frame::swap(write_frame& other){impl_.swap(other.impl_);}\r
 \r
 boost::iterator_range<uint8_t*> write_frame::image_data(size_t index){return impl_->image_data(index);}\r
-std::vector<int16_t>& write_frame::audio_data() { return impl_->audio_data_; }\r
+audio_buffer& write_frame::audio_data() { return impl_->audio_data_; }\r
 const boost::iterator_range<const uint8_t*> write_frame::image_data(size_t index) const\r
 {\r
        return boost::iterator_range<const uint8_t*>(impl_->image_data(index).begin(), impl_->image_data(index).end());\r
 }\r
-const boost::iterator_range<const int16_t*> write_frame::audio_data() const\r
+const boost::iterator_range<const int32_t*> write_frame::audio_data() const\r
 {\r
-       return boost::iterator_range<const int16_t*>(impl_->audio_data_.data(), impl_->audio_data_.data() + impl_->audio_data_.size());\r
+       return boost::iterator_range<const int32_t*>(impl_->audio_data_.data(), impl_->audio_data_.data() + impl_->audio_data_.size());\r
 }\r
-int write_frame::tag() const {return impl_->tag_;}\r
+const void* write_frame::tag() const {return impl_->tag_;}\r
 const core::pixel_format_desc& write_frame::get_pixel_format_desc() const{return impl_->desc_;}\r
 const std::vector<safe_ptr<device_buffer>>& write_frame::get_textures() const{return impl_->textures_;}\r
 void write_frame::commit(size_t plane_index){impl_->commit(plane_index);}\r
 void write_frame::commit(){impl_->commit();}\r
-void write_frame::set_type(const video_mode::type& mode){impl_->mode_ = mode;}\r
-core::video_mode::type write_frame::get_type() const{return impl_->mode_;}\r
+void write_frame::set_type(const field_mode::type& mode){impl_->mode_ = mode;}\r
+core::field_mode::type write_frame::get_type() const{return impl_->mode_;}\r
+\r
+std::wstring write_frame::print() const{return impl_->print();}\r
+void write_frame::accept(core::frame_visitor& visitor){impl_->accept(*this, visitor);}\r
 \r
 }}
\ No newline at end of file