Make the gst engine emit Error() instead of showing its own dialog when a plugin couldn't be found.
This commit is contained in:
parent
37f7b1ca3b
commit
4eedddd57c
@ -32,7 +32,6 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
@ -452,10 +451,8 @@ GstElement* GstEngine::CreateElement(
|
|||||||
if ( element ) {
|
if ( element ) {
|
||||||
if ( bin ) gst_bin_add( GST_BIN( bin ), element );
|
if ( bin ) gst_bin_add( GST_BIN( bin ), element );
|
||||||
} else {
|
} else {
|
||||||
QMessageBox::critical( 0, "Error",
|
emit Error(QString("GStreamer could not create the element: %1. "
|
||||||
QString("<h3>GStreamer could not create the element: <i>%1</i></h3> "
|
"Please make sure that you have installed all necessary GStreamer plugins (e.g. OGG and MP3)").arg( factoryName ) );
|
||||||
"<p>Please make sure that you have installed all necessary GStreamer plugins (e.g. OGG and MP3), and run <i>'gst-register'</i> afterwards.</p>"
|
|
||||||
"<p>For further assistance consult the GStreamer manual, and join #gstreamer on irc.freenode.net.</p>" ).arg( factoryName ) );
|
|
||||||
gst_object_unref( GST_OBJECT( bin ) );
|
gst_object_unref( GST_OBJECT( bin ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -489,7 +486,7 @@ GstEngine::PluginDetailsList
|
|||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<GstEnginePipeline> GstEngine::CreatePipeline(const QUrl& url) {
|
shared_ptr<GstEnginePipeline> GstEngine::CreatePipeline(const QUrl& url) {
|
||||||
shared_ptr<GstEnginePipeline> ret(new GstEnginePipeline);
|
shared_ptr<GstEnginePipeline> ret(new GstEnginePipeline(this));
|
||||||
ret->set_forwards_buffers(true);
|
ret->set_forwards_buffers(true);
|
||||||
ret->set_output_device(sink_, device_);
|
ret->set_output_device(sink_, device_);
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ class GstEngine : public Engine::Base {
|
|||||||
PluginDetailsList GetOutputsList() const { return GetPluginList( "Sink/Audio" ); }
|
PluginDetailsList GetOutputsList() const { return GetPluginList( "Sink/Audio" ); }
|
||||||
static bool DoesThisSinkSupportChangingTheOutputDeviceToAUserEditableString(const QString& name);
|
static bool DoesThisSinkSupportChangingTheOutputDeviceToAUserEditableString(const QString& name);
|
||||||
|
|
||||||
static GstElement* CreateElement(
|
GstElement* CreateElement(
|
||||||
const QString& factoryName, GstElement* bin = 0, const QString& name = 0);
|
const QString& factoryName, GstElement* bin = 0, const QString& name = 0);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -27,8 +27,9 @@ const char* GstEnginePipeline::kHttpGstreamerSource =
|
|||||||
"souphttpsrc"; // Does not exist on mac/fink.
|
"souphttpsrc"; // Does not exist on mac/fink.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GstEnginePipeline::GstEnginePipeline()
|
GstEnginePipeline::GstEnginePipeline(GstEngine* engine)
|
||||||
: QObject(NULL),
|
: QObject(NULL),
|
||||||
|
engine_(engine),
|
||||||
valid_(false),
|
valid_(false),
|
||||||
sink_(GstEngine::kAutoSink),
|
sink_(GstEngine::kAutoSink),
|
||||||
forwards_buffers_(false),
|
forwards_buffers_(false),
|
||||||
@ -67,10 +68,10 @@ bool GstEnginePipeline::Init(const QUrl &url) {
|
|||||||
|
|
||||||
// Source
|
// Source
|
||||||
if (url.scheme() == "http") {
|
if (url.scheme() == "http") {
|
||||||
src_ = GstEngine::CreateElement(kHttpGstreamerSource);
|
src_ = engine_->CreateElement(kHttpGstreamerSource);
|
||||||
g_object_set(G_OBJECT(src_), "iradio-mode", true, NULL);
|
g_object_set(G_OBJECT(src_), "iradio-mode", true, NULL);
|
||||||
} else {
|
} else {
|
||||||
src_ = GstEngine::CreateElement("giosrc");
|
src_ = engine_->CreateElement("giosrc");
|
||||||
}
|
}
|
||||||
if (!src_) // CreateElement will have shown an error dialog, so no need
|
if (!src_) // CreateElement will have shown an error dialog, so no need
|
||||||
return false; // one of our own.
|
return false; // one of our own.
|
||||||
@ -79,7 +80,7 @@ bool GstEnginePipeline::Init(const QUrl &url) {
|
|||||||
gst_bin_add(GST_BIN(pipeline_), src_);
|
gst_bin_add(GST_BIN(pipeline_), src_);
|
||||||
|
|
||||||
// Decode bin
|
// Decode bin
|
||||||
if (!(decodebin_ = GstEngine::CreateElement("decodebin", pipeline_))) { return false; }
|
if (!(decodebin_ = engine_->CreateElement("decodebin", pipeline_))) { return false; }
|
||||||
g_signal_connect(G_OBJECT(decodebin_), "new-decoded-pad", G_CALLBACK(NewPadCallback), this);
|
g_signal_connect(G_OBJECT(decodebin_), "new-decoded-pad", G_CALLBACK(NewPadCallback), this);
|
||||||
|
|
||||||
// Does some stuff with ghost pads
|
// Does some stuff with ghost pads
|
||||||
@ -96,7 +97,7 @@ bool GstEnginePipeline::Init(const QUrl &url) {
|
|||||||
audiobin_ = gst_bin_new("audiobin");
|
audiobin_ = gst_bin_new("audiobin");
|
||||||
gst_bin_add(GST_BIN(pipeline_), audiobin_);
|
gst_bin_add(GST_BIN(pipeline_), audiobin_);
|
||||||
|
|
||||||
if (!(audiosink_ = GstEngine::CreateElement(sink_, audiobin_)))
|
if (!(audiosink_ = engine_->CreateElement(sink_, audiobin_)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (GstEngine::DoesThisSinkSupportChangingTheOutputDeviceToAUserEditableString(sink_) && !device_.isEmpty())
|
if (GstEngine::DoesThisSinkSupportChangingTheOutputDeviceToAUserEditableString(sink_) && !device_.isEmpty())
|
||||||
@ -105,9 +106,9 @@ bool GstEnginePipeline::Init(const QUrl &url) {
|
|||||||
equalizer_ = GST_ELEMENT(gst_equalizer_new());
|
equalizer_ = GST_ELEMENT(gst_equalizer_new());
|
||||||
gst_bin_add(GST_BIN(audiobin_), equalizer_);
|
gst_bin_add(GST_BIN(audiobin_), equalizer_);
|
||||||
|
|
||||||
if (!(audioconvert_ = GstEngine::CreateElement("audioconvert", audiobin_))) { return false; }
|
if (!(audioconvert_ = engine_->CreateElement("audioconvert", audiobin_))) { return false; }
|
||||||
if (!(volume_ = GstEngine::CreateElement("volume", audiobin_))) { return false; }
|
if (!(volume_ = engine_->CreateElement("volume", audiobin_))) { return false; }
|
||||||
if (!(audioscale_ = GstEngine::CreateElement("audioresample", audiobin_))) { return false; }
|
if (!(audioscale_ = engine_->CreateElement("audioresample", audiobin_))) { return false; }
|
||||||
|
|
||||||
pad = gst_element_get_pad(audioconvert_, "sink");
|
pad = gst_element_get_pad(audioconvert_, "sink");
|
||||||
gst_element_add_pad(audiobin_, gst_ghost_pad_new("sink", pad));
|
gst_element_add_pad(audiobin_, gst_ghost_pad_new("sink", pad));
|
||||||
@ -129,7 +130,7 @@ bool GstEnginePipeline::Init(const QUrl &url) {
|
|||||||
gst_caps_unref(caps);
|
gst_caps_unref(caps);
|
||||||
|
|
||||||
// Add an extra audioconvert at the end as osxaudiosink supports only one format.
|
// Add an extra audioconvert at the end as osxaudiosink supports only one format.
|
||||||
GstElement* convert = GstEngine::CreateElement("audioconvert", audiobin_, "FFFUUUU");
|
GstElement* convert = engine_->CreateElement("audioconvert", audiobin_, "FFFUUUU");
|
||||||
if (!convert) { return false; }
|
if (!convert) { return false; }
|
||||||
gst_element_link_many(equalizer_, volume_,
|
gst_element_link_many(equalizer_, volume_,
|
||||||
audioscale_, convert, audiosink_, NULL);
|
audioscale_, convert, audiosink_, NULL);
|
||||||
|
@ -31,7 +31,7 @@ class GstEnginePipeline : public QObject {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GstEnginePipeline();
|
GstEnginePipeline(GstEngine* engine);
|
||||||
~GstEnginePipeline();
|
~GstEnginePipeline();
|
||||||
|
|
||||||
// Call these setters before Init
|
// Call these setters before Init
|
||||||
@ -86,6 +86,8 @@ class GstEnginePipeline : public QObject {
|
|||||||
|
|
||||||
static const char* kHttpGstreamerSource;
|
static const char* kHttpGstreamerSource;
|
||||||
|
|
||||||
|
GstEngine* engine_;
|
||||||
|
|
||||||
bool valid_;
|
bool valid_;
|
||||||
QString sink_;
|
QString sink_;
|
||||||
QString device_;
|
QString device_;
|
||||||
|
@ -99,5 +99,5 @@ add_test_file(albumcovermanager_test.cpp true)
|
|||||||
add_test_file(songplaylistitem_test.cpp false)
|
add_test_file(songplaylistitem_test.cpp false)
|
||||||
add_test_file(translations_test.cpp false)
|
add_test_file(translations_test.cpp false)
|
||||||
add_test_file(playlist_test.cpp true)
|
add_test_file(playlist_test.cpp true)
|
||||||
add_test_file(scopedtransaction_test.cpp true)
|
add_test_file(scopedtransaction_test.cpp false)
|
||||||
add_test_file(fileformats_test.cpp true)
|
add_test_file(fileformats_test.cpp false)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user