mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-28 10:09:24 +01:00
Remove CanDecode from GstEngine - it was only used by a test, and the test was disabled on buildbot because it was unreliable.
This commit is contained in:
parent
116bfc4594
commit
b3db5d699e
@ -43,7 +43,6 @@ class Base : public QObject, boost::noncopyable {
|
||||
virtual ~Base();
|
||||
|
||||
virtual bool Init() = 0;
|
||||
virtual bool CanDecode(const QUrl &url) = 0;
|
||||
|
||||
virtual void StartPreloading(const QUrl&, qint64, qint64) {}
|
||||
virtual bool Play(quint64 offset_nanosec) = 0;
|
||||
|
@ -169,97 +169,6 @@ void GstEngine::ReloadSettings() {
|
||||
}
|
||||
|
||||
|
||||
bool GstEngine::CanDecode(const QUrl &url) {
|
||||
EnsureInitialised();
|
||||
|
||||
// We had some bug reports claiming that video files cause crashes in canDecode(),
|
||||
// so don't try to decode them
|
||||
if ( url.path().toLower().endsWith( ".mov" ) ||
|
||||
url.path().toLower().endsWith( ".avi" ) ||
|
||||
url.path().toLower().endsWith( ".wmv" ) )
|
||||
return false;
|
||||
|
||||
can_decode_success_ = false;
|
||||
can_decode_last_ = false;
|
||||
|
||||
// Create the pipeline
|
||||
shared_ptr<GstElement> pipeline(gst_pipeline_new("pipeline"),
|
||||
boost::bind(gst_object_unref, _1));
|
||||
if (!pipeline) return false;
|
||||
GstElement* src = CreateElement("giosrc", pipeline.get()); if (!src) return false;
|
||||
GstElement* bin = CreateElement("decodebin2", pipeline.get()); if (!bin) return false;
|
||||
|
||||
gst_element_link(src, bin);
|
||||
g_signal_connect(G_OBJECT(bin), "new-decoded-pad", G_CALLBACK(CanDecodeNewPadCallback), this);
|
||||
g_signal_connect(G_OBJECT(bin), "no-more-pads", G_CALLBACK(CanDecodeLastCallback), this);
|
||||
|
||||
// These handlers just print out errors to stderr
|
||||
gst_bus_set_sync_handler(gst_pipeline_get_bus(GST_PIPELINE(pipeline.get())), CanDecodeBusCallbackSync, 0);
|
||||
gst_bus_add_watch(gst_pipeline_get_bus(GST_PIPELINE(pipeline.get())), CanDecodeBusCallback, 0);
|
||||
|
||||
// Set the file we're testing
|
||||
g_object_set(G_OBJECT(src), "location", url.toEncoded().constData(), NULL);
|
||||
|
||||
// Start the pipeline playing
|
||||
gst_element_set_state(pipeline.get(), GST_STATE_PLAYING);
|
||||
|
||||
// Wait until found audio stream
|
||||
int count = 0;
|
||||
while (!can_decode_success_ && !can_decode_last_ && count < 100) {
|
||||
count++;
|
||||
usleep(1000);
|
||||
}
|
||||
|
||||
// Stop playing
|
||||
gst_element_set_state(pipeline.get(), GST_STATE_NULL);
|
||||
|
||||
return can_decode_success_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GstEngine::CanDecodeNewPadCallback(GstElement*, GstPad* pad, gboolean, gpointer self) {
|
||||
GstEngine* instance = reinterpret_cast<GstEngine*>(self);
|
||||
|
||||
GstCaps* caps = gst_pad_get_caps(pad);
|
||||
if (gst_caps_get_size(caps) > 0) {
|
||||
GstStructure* str = gst_caps_get_structure(caps, 0);
|
||||
if (g_strrstr(gst_structure_get_name( str ), "audio" ))
|
||||
instance->can_decode_success_ = true;
|
||||
}
|
||||
gst_caps_unref(caps);
|
||||
}
|
||||
|
||||
void GstEngine::CanDecodeLastCallback(GstElement*, gpointer self) {
|
||||
GstEngine* instance = reinterpret_cast<GstEngine*>(self);
|
||||
instance->can_decode_last_ = true;
|
||||
}
|
||||
|
||||
void GstEngine::PrintGstError(GstMessage *msg) {
|
||||
GError* error;
|
||||
gchar* debugs;
|
||||
|
||||
gst_message_parse_error(msg, &error, &debugs);
|
||||
qDebug() << error->message;
|
||||
qDebug() << debugs;
|
||||
|
||||
g_error_free(error);
|
||||
free(debugs);
|
||||
}
|
||||
|
||||
GstBusSyncReply GstEngine::CanDecodeBusCallbackSync(GstBus*, GstMessage* msg, gpointer) {
|
||||
if (GST_MESSAGE_TYPE(msg) == GST_MESSAGE_ERROR)
|
||||
PrintGstError(msg);
|
||||
return GST_BUS_PASS;
|
||||
}
|
||||
|
||||
gboolean GstEngine::CanDecodeBusCallback(GstBus*, GstMessage* msg, gpointer) {
|
||||
if (GST_MESSAGE_TYPE(msg) == GST_MESSAGE_ERROR)
|
||||
PrintGstError(msg);
|
||||
return GST_BUS_DROP;
|
||||
}
|
||||
|
||||
|
||||
qint64 GstEngine::position_nanosec() const {
|
||||
if (!current_pipeline_)
|
||||
return 0;
|
||||
|
@ -68,8 +68,6 @@ class GstEngine : public Engine::Base, public BufferConsumer {
|
||||
bool Init();
|
||||
void EnsureInitialised() { initialising_.waitForFinished(); }
|
||||
|
||||
bool CanDecode(const QUrl& url);
|
||||
|
||||
int AddBackgroundStream(const QUrl& url);
|
||||
void StopBackgroundStream(int id);
|
||||
void SetBackgroundStreamVolume(int id, int volume);
|
||||
@ -129,13 +127,6 @@ class GstEngine : public Engine::Base, public BufferConsumer {
|
||||
typedef QPair<quint64, GstEnginePipeline*> PlayFutureWatcherArg;
|
||||
typedef BoundFutureWatcher<GstStateChangeReturn, PlayFutureWatcherArg> PlayFutureWatcher;
|
||||
|
||||
// Callbacks
|
||||
static void CanDecodeNewPadCallback(GstElement*, GstPad*, gboolean, gpointer);
|
||||
static void CanDecodeLastCallback(GstElement*, gpointer);
|
||||
static GstBusSyncReply CanDecodeBusCallbackSync(GstBus*, GstMessage*, gpointer);
|
||||
static gboolean CanDecodeBusCallback(GstBus*, GstMessage*, gpointer);
|
||||
static void PrintGstError(GstMessage* msg);
|
||||
|
||||
static void SetEnv(const char* key, const QString& value);
|
||||
PluginDetailsList GetPluginList(const QString& classname) const;
|
||||
void InitialiseGstreamer();
|
||||
|
@ -94,21 +94,4 @@ TEST_P(FileformatsTest, LoadsTags) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(FileformatsTest, GstCanDecode) {
|
||||
QTemporaryFile temp(temp_filetemplate_);
|
||||
SaveToTempFile(&temp);
|
||||
|
||||
QSignalSpy spy(sGstEngine, SIGNAL(Error(QString)));
|
||||
|
||||
EXPECT_TRUE(sGstEngine->CanDecode(QUrl::fromLocalFile(temp.fileName())));
|
||||
|
||||
QList<QList<QVariant> > calls(spy);
|
||||
foreach (const QList<QVariant>& call, calls) {
|
||||
qDebug() << "GstEngine::Error emitted:" << call[0].toString();
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Formats, FileformatsTest, ::testing::Values(
|
||||
"flac", "mp3", "ogg", "spx", "wav", "wma", "m4a"));
|
||||
|
||||
} // namespace
|
||||
|
Loading…
x
Reference in New Issue
Block a user