1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-16 11:19:18 +01:00

Fix compilation without gstreamer. Fixes issue #440

This commit is contained in:
David Sansome 2010-06-26 13:20:08 +00:00
parent 7c09e39d41
commit 0404ecec70
5 changed files with 73 additions and 30 deletions

View File

@ -111,10 +111,6 @@ set(SOURCES
radio/savedradio.cpp
radio/somafmservice.cpp
transcoder/transcodedialog.cpp
transcoder/transcoder.cpp
transcoder/transcoderformats.cpp
ui/about.cpp
ui/addstreamdialog.cpp
ui/albumcovermanager.cpp
@ -224,9 +220,6 @@ set(HEADERS
radio/savedradio.h
radio/somafmservice.h
transcoder/transcodedialog.h
transcoder/transcoder.h
ui/about.h
ui/addstreamdialog.h
ui/albumcovermanager.h
@ -275,9 +268,6 @@ set(UI
radio/magnatunedownloaddialog.ui
radio/radioviewcontainer.ui
transcoder/transcodedialog.ui
transcoder/transcodelogdialog.ui
ui/about.ui
ui/addstreamdialog.ui
ui/albumcovermanager.ui
@ -378,6 +368,25 @@ if(ENABLE_VISUALISATIONS)
)
endif(ENABLE_VISUALISATIONS)
# Transcoder
if(HAVE_GSTREAMER)
list(APPEND SOURCES
transcoder/transcodedialog.cpp
transcoder/transcoder.cpp
transcoder/transcoderformats.cpp
)
list(APPEND HEADERS
transcoder/transcodedialog.h
transcoder/transcoder.h
)
list(APPEND UI
transcoder/transcodedialog.ui
transcoder/transcodelogdialog.ui
)
endif(HAVE_GSTREAMER)
# OSDs
if(APPLE)
list(APPEND SOURCES widgets/osd_mac.mm)

View File

@ -47,14 +47,19 @@ SongLoader::SongLoader(QObject *parent)
}
timeout_timer_->setSingleShot(true);
#ifdef HAVE_GSTREAMER
connect(timeout_timer_, SIGNAL(timeout()), SLOT(Timeout()));
#endif
}
SongLoader::~SongLoader() {
#ifdef HAVE_GSTREAMER
if (pipeline_) {
state_ = Finished;
gst_element_set_state(pipeline_.get(), GST_STATE_NULL);
}
#endif // HAVE_GSTREAMER
}
SongLoader::Result SongLoader::Load(const QUrl& url) {
@ -71,8 +76,15 @@ SongLoader::Result SongLoader::Load(const QUrl& url) {
return Success;
}
#ifdef HAVE_GSTREAMER
timeout_timer_->start(timeout_);
return LoadRemote();
#else
// If we don't have GStreamer we can't check the type of remote playlists,
// so just assume it's a raw stream and get on with our lives.
AddAsRawStream();
return Success;
#endif
}
SongLoader::Result SongLoader::LoadLocal() {
@ -139,6 +151,16 @@ void SongLoader::LoadLocalDirectory(const QString& filename) {
emit LoadFinished(true);
}
void SongLoader::AddAsRawStream() {
Song song;
song.set_valid(true);
song.set_filetype(Song::Type_Stream);
song.set_filename(url_.toString());
song.set_title(url_.toString());
songs_ << song;
}
#ifdef HAVE_GSTREAMER
SongLoader::Result SongLoader::LoadRemote() {
qDebug() << "Loading remote file" << url_;
@ -226,6 +248,12 @@ void SongLoader::DataReady(GstPad *, GstBuffer *buf, void *self) {
}
}
void SongLoader::Timeout() {
state_ = Finished;
success_ = false;
StopTypefind();
}
gboolean SongLoader::BusCallback(GstBus*, GstMessage* msg, gpointer self) {
SongLoader* instance = reinterpret_cast<SongLoader*>(self);
@ -346,18 +374,4 @@ void SongLoader::StopTypefind() {
emit LoadFinished(success_);
}
void SongLoader::AddAsRawStream() {
Song song;
song.set_valid(true);
song.set_filetype(Song::Type_Stream);
song.set_filename(url_.toString());
song.set_title(url_.toString());
songs_ << song;
}
void SongLoader::Timeout() {
state_ = Finished;
success_ = false;
StopTypefind();
}
#endif // HAVE_GSTREAMER

View File

@ -20,10 +20,14 @@
#include <QObject>
#include <QUrl>
#include "config.h"
#include "song.h"
#include <boost/shared_ptr.hpp>
#include <gst/gst.h>
#ifdef HAVE_GSTREAMER
# include <gst/gst.h>
#endif
class ParserBase;
class PlaylistParser;
@ -54,8 +58,10 @@ signals:
void LoadFinished(bool success);
private slots:
#ifdef HAVE_GSTREAMER
void Timeout();
void StopTypefind();
#endif // HAVE_GSTREAMER
private:
enum State {
@ -66,9 +72,13 @@ private:
};
Result LoadLocal();
Result LoadRemote();
void LoadLocalDirectory(const QString& filename);
void AddAsRawStream();
#ifdef HAVE_GSTREAMER
Result LoadRemote();
// GStreamer callbacks
static void TypeFound(GstElement* typefind, uint probability, GstCaps* caps, void* self);
static void DataReady(GstPad*, GstBuffer* buf, void* self);
@ -79,8 +89,7 @@ private:
void ErrorMessageReceived(GstMessage* msg);
void EndOfStreamReached();
void MagicReady();
void AddAsRawStream();
#endif // HAVE_GSTREAMER
private:
static QSet<QString> sRawUriSchemes;
@ -95,10 +104,13 @@ private:
int timeout_;
State state_;
bool success_;
boost::shared_ptr<GstElement> pipeline_;
ParserBase* parser_;
QString mime_type_;
QByteArray buffer_;
#ifdef HAVE_GSTREAMER
boost::shared_ptr<GstElement> pipeline_;
#endif
};
#endif // SONGLOADER_H

View File

@ -123,7 +123,9 @@ MainWindow::MainWindow(NetworkAccessManager* network, Engine::Type engine, QWidg
add_stream_dialog_(new AddStreamDialog),
cover_manager_(NULL),
equalizer_(new Equalizer),
#ifdef HAVE_GSTREAMER
transcode_dialog_(new TranscodeDialog),
#endif
error_dialog_(new ErrorDialog),
organise_dialog_(new OrganiseDialog(task_manager_)),
#ifdef ENABLE_VISUALISATIONS
@ -171,7 +173,11 @@ MainWindow::MainWindow(NetworkAccessManager* network, Engine::Type engine, QWidg
# ifdef ENABLE_VISUALISATIONS
visualisation_->SetEngine(engine);
# endif
} else {
ui_->action_transcode->setEnabled(false);
}
#else // HAVE_GSTREAMER
ui_->action_transcode->setEnabled(false);
#endif // HAVE_GSTREAMER
// Models

View File

@ -145,12 +145,14 @@ void ProjectMVisualisation::SetDuration(int seconds) {
}
void ProjectMVisualisation::ConsumeBuffer(GstBuffer *buffer, GstEnginePipeline*) {
#ifdef HAVE_GSTREAMER
const int samples_per_channel = GST_BUFFER_SIZE(buffer) / sizeof(short) / 2;
const short* data = reinterpret_cast<short*>(GST_BUFFER_DATA(buffer));
if (projectm_)
projectm_->pcm()->addPCM16Data(data, samples_per_channel);
gst_buffer_unref(buffer);
#endif
}
void ProjectMVisualisation::SetSelected(const QStringList& paths, bool selected) {