mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-31 11:35:24 +01:00
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 <QRegExp>
|
||||
#include <QFile>
|
||||
#include <QMessageBox>
|
||||
#include <QSettings>
|
||||
#include <QtDebug>
|
||||
#include <QCoreApplication>
|
||||
@ -452,10 +451,8 @@ GstElement* GstEngine::CreateElement(
|
||||
if ( element ) {
|
||||
if ( bin ) gst_bin_add( GST_BIN( bin ), element );
|
||||
} else {
|
||||
QMessageBox::critical( 0, "Error",
|
||||
QString("<h3>GStreamer could not create the element: <i>%1</i></h3> "
|
||||
"<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 ) );
|
||||
emit Error(QString("GStreamer could not create the element: %1. "
|
||||
"Please make sure that you have installed all necessary GStreamer plugins (e.g. OGG and MP3)").arg( factoryName ) );
|
||||
gst_object_unref( GST_OBJECT( bin ) );
|
||||
}
|
||||
|
||||
@ -489,7 +486,7 @@ GstEngine::PluginDetailsList
|
||||
}
|
||||
|
||||
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_output_device(sink_, device_);
|
||||
|
||||
|
@ -71,7 +71,7 @@ class GstEngine : public Engine::Base {
|
||||
PluginDetailsList GetOutputsList() const { return GetPluginList( "Sink/Audio" ); }
|
||||
static bool DoesThisSinkSupportChangingTheOutputDeviceToAUserEditableString(const QString& name);
|
||||
|
||||
static GstElement* CreateElement(
|
||||
GstElement* CreateElement(
|
||||
const QString& factoryName, GstElement* bin = 0, const QString& name = 0);
|
||||
|
||||
public slots:
|
||||
|
@ -27,8 +27,9 @@ const char* GstEnginePipeline::kHttpGstreamerSource =
|
||||
"souphttpsrc"; // Does not exist on mac/fink.
|
||||
#endif
|
||||
|
||||
GstEnginePipeline::GstEnginePipeline()
|
||||
GstEnginePipeline::GstEnginePipeline(GstEngine* engine)
|
||||
: QObject(NULL),
|
||||
engine_(engine),
|
||||
valid_(false),
|
||||
sink_(GstEngine::kAutoSink),
|
||||
forwards_buffers_(false),
|
||||
@ -67,10 +68,10 @@ bool GstEnginePipeline::Init(const QUrl &url) {
|
||||
|
||||
// Source
|
||||
if (url.scheme() == "http") {
|
||||
src_ = GstEngine::CreateElement(kHttpGstreamerSource);
|
||||
src_ = engine_->CreateElement(kHttpGstreamerSource);
|
||||
g_object_set(G_OBJECT(src_), "iradio-mode", true, NULL);
|
||||
} else {
|
||||
src_ = GstEngine::CreateElement("giosrc");
|
||||
src_ = engine_->CreateElement("giosrc");
|
||||
}
|
||||
if (!src_) // CreateElement will have shown an error dialog, so no need
|
||||
return false; // one of our own.
|
||||
@ -79,7 +80,7 @@ bool GstEnginePipeline::Init(const QUrl &url) {
|
||||
gst_bin_add(GST_BIN(pipeline_), src_);
|
||||
|
||||
// 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);
|
||||
|
||||
// Does some stuff with ghost pads
|
||||
@ -96,7 +97,7 @@ bool GstEnginePipeline::Init(const QUrl &url) {
|
||||
audiobin_ = gst_bin_new("audiobin");
|
||||
gst_bin_add(GST_BIN(pipeline_), audiobin_);
|
||||
|
||||
if (!(audiosink_ = GstEngine::CreateElement(sink_, audiobin_)))
|
||||
if (!(audiosink_ = engine_->CreateElement(sink_, audiobin_)))
|
||||
return false;
|
||||
|
||||
if (GstEngine::DoesThisSinkSupportChangingTheOutputDeviceToAUserEditableString(sink_) && !device_.isEmpty())
|
||||
@ -105,9 +106,9 @@ bool GstEnginePipeline::Init(const QUrl &url) {
|
||||
equalizer_ = GST_ELEMENT(gst_equalizer_new());
|
||||
gst_bin_add(GST_BIN(audiobin_), equalizer_);
|
||||
|
||||
if (!(audioconvert_ = GstEngine::CreateElement("audioconvert", audiobin_))) { return false; }
|
||||
if (!(volume_ = GstEngine::CreateElement("volume", audiobin_))) { return false; }
|
||||
if (!(audioscale_ = GstEngine::CreateElement("audioresample", audiobin_))) { return false; }
|
||||
if (!(audioconvert_ = engine_->CreateElement("audioconvert", audiobin_))) { return false; }
|
||||
if (!(volume_ = engine_->CreateElement("volume", audiobin_))) { return false; }
|
||||
if (!(audioscale_ = engine_->CreateElement("audioresample", audiobin_))) { return false; }
|
||||
|
||||
pad = gst_element_get_pad(audioconvert_, "sink");
|
||||
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);
|
||||
|
||||
// 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; }
|
||||
gst_element_link_many(equalizer_, volume_,
|
||||
audioscale_, convert, audiosink_, NULL);
|
||||
|
@ -31,7 +31,7 @@ class GstEnginePipeline : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GstEnginePipeline();
|
||||
GstEnginePipeline(GstEngine* engine);
|
||||
~GstEnginePipeline();
|
||||
|
||||
// Call these setters before Init
|
||||
@ -86,6 +86,8 @@ class GstEnginePipeline : public QObject {
|
||||
|
||||
static const char* kHttpGstreamerSource;
|
||||
|
||||
GstEngine* engine_;
|
||||
|
||||
bool valid_;
|
||||
QString sink_;
|
||||
QString device_;
|
||||
|
@ -99,5 +99,5 @@ add_test_file(albumcovermanager_test.cpp true)
|
||||
add_test_file(songplaylistitem_test.cpp false)
|
||||
add_test_file(translations_test.cpp false)
|
||||
add_test_file(playlist_test.cpp true)
|
||||
add_test_file(scopedtransaction_test.cpp true)
|
||||
add_test_file(fileformats_test.cpp true)
|
||||
add_test_file(scopedtransaction_test.cpp false)
|
||||
add_test_file(fileformats_test.cpp false)
|
||||
|
Loading…
x
Reference in New Issue
Block a user