Ubuntu 10.04/12.04 で次のコードをテストしています。エラーが表示されます
#include <gtkmm.h>
#include <gstreamermm.h>
#include <iostream>
using namespace std;
class Sound
{
public:
Sound();
void start_playing(double frequency);
bool stop_playing();
private:
Glib::RefPtr<Gst::Pipeline> m_pipeline;
Glib::RefPtr<Gst::Element> m_source;
Glib::RefPtr<Gst::Element> 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->add(m_source);
m_pipeline->add(m_sink);
m_source->link(m_sink);
}
void Sound::start_playing (double frequency)
{
m_source->set_property("freq", frequency);
m_pipeline->set_state(Gst::STATE_PLAYING);
/* stop it after 200ms */
Glib::signal_timeout().connect(sigc::mem_fun(*this, &Sound::stop_playing),
200);
}
bool Sound::stop_playing()
{
m_pipeline->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& 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,
// &Buttons::on_button_clicked) );
//m_button.signal_clicked().connect (sigc::bind<double, Sound*>(sigc::ptr_fun(&Buttons::on_button_clicked),
// 369.23, &sound));
//m_button.signal_clicked().connect( sigc::bind<double, Sound&>( sigc::mem_fun(*this, &Buttons::on_button_clicked), 369.23, sound) );
m_button.signal_clicked().connect( sigc::bind<double, Sound*>( sigc::mem_fun(*this, &Buttons::on_button_clicked), 369.23, &sound) );
add(m_button);
show_all_children();
}
Buttons::~Buttons()
{
}
/*
void Buttons::on_button_clicked()
{
std::cout << "The Button was clicked." << std::endl;
}
*/
/*
void
Buttons::on_button_clicked(double frequency, Sound& sound)
{
sound.start_playing (frequency);
}
*/
void
Buttons::on_button_clicked(double frequency, Sound* sound)
{
sound->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;
}
を使用してコンパイルしますg++ gstmm1.cc -o gstmm1 ``pkg-config --cflags --libs gstreamermm-0.10 gtkmm-2.4
terminate called after throwing an instance of 'std::runtime_error'
what(): Failed to add null element.
Aborted
何が間違っている可能性がありますか?これは、次の投稿に関連しているよう です http://old.nabble.com/gstmm-add-element-to-pipeline-test-td14042055.html