mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-18 12:32:09 +01:00
gstengine: Give pipelines unique names
Currently, most pipelines are named "pipeline". Use a type string in combination with the stream id to give each pipeline a unique name.
This commit is contained in:
parent
5ffdb7d98c
commit
4f5bf1cc6f
@ -51,7 +51,7 @@ const int GstEnginePipeline::kEqBandFrequencies[] = {
|
||||
GstElementDeleter* GstEnginePipeline::sElementDeleter = nullptr;
|
||||
|
||||
GstEnginePipeline::GstEnginePipeline(GstEngine* engine)
|
||||
: GstPipelineBase(),
|
||||
: GstPipelineBase("audio"),
|
||||
engine_(engine),
|
||||
valid_(false),
|
||||
sink_(GstEngine::kAutoSink),
|
||||
@ -508,7 +508,7 @@ void GstEnginePipeline::MaybeLinkDecodeToAudio() {
|
||||
}
|
||||
|
||||
bool GstEnginePipeline::InitFromString(const QString& pipeline) {
|
||||
if (!Init("pipeline")) return false;
|
||||
if (!Init()) return false;
|
||||
|
||||
GstElement* new_bin =
|
||||
CreateDecodeBinFromString(pipeline.toLatin1().constData());
|
||||
@ -527,7 +527,7 @@ bool GstEnginePipeline::InitFromString(const QString& pipeline) {
|
||||
|
||||
bool GstEnginePipeline::InitFromReq(const MediaPlaybackRequest& req,
|
||||
qint64 end_nanosec) {
|
||||
if (!Init("pipeline")) return false;
|
||||
if (!Init()) return false;
|
||||
|
||||
current_ = req;
|
||||
QUrl url = current_.url_;
|
||||
|
@ -21,8 +21,8 @@
|
||||
|
||||
std::atomic<int> GstPipelineBase::sId(1);
|
||||
|
||||
GstPipelineBase::GstPipelineBase()
|
||||
: QObject(nullptr), pipeline_(nullptr), id_(sId++) {}
|
||||
GstPipelineBase::GstPipelineBase(const QString& type)
|
||||
: QObject(nullptr), pipeline_(nullptr), type_(type), id_(sId++) {}
|
||||
|
||||
GstPipelineBase::~GstPipelineBase() {
|
||||
if (pipeline_) {
|
||||
@ -31,7 +31,8 @@ GstPipelineBase::~GstPipelineBase() {
|
||||
}
|
||||
}
|
||||
|
||||
bool GstPipelineBase::Init(const QString& name) {
|
||||
bool GstPipelineBase::Init() {
|
||||
QString name = QString("%1-pipeline-%2").arg(type_).arg(id_);
|
||||
pipeline_ = gst_pipeline_new(name.toUtf8().constData());
|
||||
return pipeline_ != nullptr;
|
||||
}
|
||||
|
@ -24,10 +24,10 @@
|
||||
|
||||
class GstPipelineBase : public QObject {
|
||||
public:
|
||||
GstPipelineBase();
|
||||
GstPipelineBase(const QString& type);
|
||||
virtual ~GstPipelineBase();
|
||||
|
||||
virtual bool Init(const QString& name);
|
||||
virtual bool Init();
|
||||
|
||||
// Globally unique across all pipelines.
|
||||
int id() const { return id_; }
|
||||
@ -38,6 +38,8 @@ class GstPipelineBase : public QObject {
|
||||
GstElement* pipeline_;
|
||||
|
||||
private:
|
||||
const QString type_;
|
||||
|
||||
// Using == to compare two pipelines is a bad idea, because new ones often
|
||||
// get created in the same address as old ones. This ID will be unique for
|
||||
// each pipeline.
|
||||
|
@ -402,7 +402,7 @@ bool Transcoder::StartJob(const Job& job) {
|
||||
// Create the pipeline.
|
||||
// This should be a scoped_ptr, but scoped_ptr doesn't support custom
|
||||
// destructors.
|
||||
if (!state->Init("pipeline")) return false;
|
||||
if (!state->Init()) return false;
|
||||
|
||||
// Create all the elements
|
||||
GstElement* src = CreateElement("filesrc", state->Pipeline());
|
||||
|
@ -88,7 +88,10 @@ class Transcoder : public QObject {
|
||||
class JobState : public GstPipelineBase {
|
||||
public:
|
||||
JobState(const Job& job, Transcoder* parent)
|
||||
: job_(job), parent_(parent), convert_element_(nullptr) {}
|
||||
: GstPipelineBase("transcode"),
|
||||
job_(job),
|
||||
parent_(parent),
|
||||
convert_element_(nullptr) {}
|
||||
|
||||
void PostFinished(bool success);
|
||||
void ReportError(GstMessage* msg);
|
||||
|
Loading…
Reference in New Issue
Block a user