Note that there are some explanatory texts on larger screens.

plurals
  1. POgtkmm and gstreamermm test code throws run time error
    text
    copied!<p>I am testing the following code on Ubuntu 10.04/12.04. I am receiving an error</p> <pre><code>#include &lt;gtkmm.h&gt; #include &lt;gstreamermm.h&gt; #include &lt;iostream&gt; using namespace std; class Sound { public: Sound(); void start_playing(double frequency); bool stop_playing(); private: Glib::RefPtr&lt;Gst::Pipeline&gt; m_pipeline; Glib::RefPtr&lt;Gst::Element&gt; m_source; Glib::RefPtr&lt;Gst::Element&gt; m_sink; }; Sound::Sound() { m_pipeline = Gst::Pipeline::create("note"); m_source = Gst::ElementFactory::create_element("audiotestsrc", "source"); m_sink = Gst::ElementFactory::create_element("autoaudiosink", "output"); m_pipeline-&gt;add(m_source); m_pipeline-&gt;add(m_sink); m_source-&gt;link(m_sink); } void Sound::start_playing (double frequency) { m_source-&gt;set_property("freq", frequency); m_pipeline-&gt;set_state(Gst::STATE_PLAYING); /* stop it after 200ms */ Glib::signal_timeout().connect(sigc::mem_fun(*this, &amp;Sound::stop_playing), 200); } bool Sound::stop_playing() { m_pipeline-&gt;set_state(Gst::STATE_NULL); return false; } class Buttons : public Gtk::Window { public: Buttons(); virtual ~Buttons(); protected: //Signal handlers: //void on_button_clicked(); Sound sound; //void on_button_clicked(double frequency, Sound&amp; sound); void on_button_clicked(double frequency, Sound* sound); //Child widgets: Gtk::Button m_button; }; Buttons::Buttons() { m_button.add_pixlabel("info.xpm", "cool button"); set_title("Pixmap'd buttons!"); set_border_width(10); //m_button.signal_clicked().connect( sigc::mem_fun(*this, // &amp;Buttons::on_button_clicked) ); //m_button.signal_clicked().connect (sigc::bind&lt;double, Sound*&gt;(sigc::ptr_fun(&amp;Buttons::on_button_clicked), // 369.23, &amp;sound)); //m_button.signal_clicked().connect( sigc::bind&lt;double, Sound&amp;&gt;( sigc::mem_fun(*this, &amp;Buttons::on_button_clicked), 369.23, sound) ); m_button.signal_clicked().connect( sigc::bind&lt;double, Sound*&gt;( sigc::mem_fun(*this, &amp;Buttons::on_button_clicked), 369.23, &amp;sound) ); add(m_button); show_all_children(); } Buttons::~Buttons() { } /* void Buttons::on_button_clicked() { std::cout &lt;&lt; "The Button was clicked." &lt;&lt; std::endl; } */ /* void Buttons::on_button_clicked(double frequency, Sound&amp; sound) { sound.start_playing (frequency); } */ void Buttons::on_button_clicked(double frequency, Sound* sound) { sound-&gt;start_playing (frequency); } int main(int argc, char *argv[]) { Gtk::Main kit(argc, argv); Buttons buttons; //Shows the window and returns when it is closed. Gtk::Main::run(buttons); return 0; } </code></pre> <p>I compile using <code>g++ gstmm1.cc -o gstmm1 ``pkg-config --cflags --libs gstreamermm-0.10 gtkmm-2.4</code></p> <pre><code>terminate called after throwing an instance of 'std::runtime_error' what(): Failed to add null element. Aborted </code></pre> <p>Any Idea what could be wrong? It almost appears that this may be related to the following post <a href="http://old.nabble.com/gstmm-add-element-to-pipeline-test-td14042055.html" rel="nofollow">http://old.nabble.com/gstmm-add-element-to-pipeline-test-td14042055.html</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload