From: Martin Ling Date: Sun, 30 Dec 2018 03:29:10 +0000 (+0100) Subject: Create LegacyOutput from format, device and options. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=726122c2de29c2e31d535368bcf649e64d0d2e81;p=libsigrokflow.git Create LegacyOutput from format, device and options. --- diff --git a/include/libsigrokflow/libsigrokflow.hpp b/include/libsigrokflow/libsigrokflow.hpp index e9a725e..59de83c 100644 --- a/include/libsigrokflow/libsigrokflow.hpp +++ b/include/libsigrokflow/libsigrokflow.hpp @@ -100,10 +100,12 @@ class LegacyOutput : public: /* Create from libsigrok output object */ static Glib::RefPtr create( - shared_ptr libsigrok_output); + shared_ptr libsigrok_output_format, + shared_ptr libsigrok_device, + map options = map()); - /* Retrieve libsigrok output object */ - shared_ptr libsigrok_output(); + /* Override start */ + bool start_vfunc(); /* Override render */ Gst::FlowReturn render_vfunc(const Glib::RefPtr &buffer); @@ -120,8 +122,10 @@ public: /* Constructor used by element factory */ explicit LegacyOutput(GstBaseSink *gobj); private: + shared_ptr _libsigrok_output_format; + shared_ptr _libsigrok_device; shared_ptr _libsigrok_output; - Glib::RefPtr _sink_pad; + map _options; }; diff --git a/src/main.cpp b/src/main.cpp index 10baaec..cd9c134 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -185,26 +185,32 @@ LegacyOutput::LegacyOutput(GstBaseSink *gobj) : } Glib::RefPtrLegacyOutput::create( - shared_ptr libsigrok_output) + shared_ptr libsigrok_output_format, + shared_ptr libsigrok_device, + map options) { auto element = Gst::ElementFactory::create_element("sigrok_legacy_output"); if (!element) throw runtime_error("Failed to create element - plugin not registered?"); auto output = Glib::RefPtr::cast_static(element); - output->_libsigrok_output = libsigrok_output; + output->_libsigrok_output_format = libsigrok_output_format; + output->_libsigrok_device = libsigrok_device; + output->_options = options; return output; } -shared_ptr LegacyOutput::libsigrok_output() +bool LegacyOutput::start_vfunc() { - return _libsigrok_output; + _libsigrok_output = _libsigrok_output_format->create_output( + _libsigrok_device, _options); + return true; } Gst::FlowReturn LegacyOutput::render_vfunc(const Glib::RefPtr &buffer) { Gst::MapInfo info; buffer->map(info, Gst::MAP_READ); - auto context = _libsigrok_output->format()->parent(); + auto context = _libsigrok_output_format->parent(); auto packet = context->create_logic_packet( info.get_data(), info.get_size(), 2); auto result = _libsigrok_output->receive(packet); @@ -215,7 +221,7 @@ Gst::FlowReturn LegacyOutput::render_vfunc(const Glib::RefPtr &buff bool LegacyOutput::stop_vfunc() { - auto context = _libsigrok_output->format()->parent(); + auto context = _libsigrok_output_format->parent(); auto end_packet = context->create_end_packet(); auto result = _libsigrok_output->receive(end_packet); cout << result;