mirror of
https://github.com/clementine-player/Clementine
synced 2025-02-07 06:35:15 +01:00
gstengine: Move pipeline id handling to base class
Move the id and the global counter from GstEnginePipeline to GstPipelineBase. Make counter atomic.
This commit is contained in:
parent
2dd424a195
commit
5ffdb7d98c
@ -48,13 +48,11 @@ const int GstEnginePipeline::kEqBandCount = 10;
|
||||
const int GstEnginePipeline::kEqBandFrequencies[] = {
|
||||
60, 170, 310, 600, 1000, 3000, 6000, 12000, 14000, 16000};
|
||||
|
||||
int GstEnginePipeline::sId = 1;
|
||||
GstElementDeleter* GstEnginePipeline::sElementDeleter = nullptr;
|
||||
|
||||
GstEnginePipeline::GstEnginePipeline(GstEngine* engine)
|
||||
: GstPipelineBase(),
|
||||
engine_(engine),
|
||||
id_(sId++),
|
||||
valid_(false),
|
||||
sink_(GstEngine::kAutoSink),
|
||||
segment_start_(0),
|
||||
|
@ -44,9 +44,6 @@ class GstEnginePipeline : public GstPipelineBase {
|
||||
GstEnginePipeline(GstEngine* engine);
|
||||
~GstEnginePipeline();
|
||||
|
||||
// Globally unique across all pipelines.
|
||||
int id() const { return id_; }
|
||||
|
||||
// Call these setters before Init
|
||||
void set_output_device(const QString& sink, const QVariant& device);
|
||||
void set_replaygain(bool enabled, int mode, float preamp, bool compression);
|
||||
@ -181,14 +178,6 @@ class GstEnginePipeline : public GstPipelineBase {
|
||||
|
||||
GstEngine* engine_;
|
||||
|
||||
// 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.
|
||||
// Threading warning: access to the static ID field isn't protected by a
|
||||
// mutex because all pipeline creation is currently done in the main thread.
|
||||
static int sId;
|
||||
int id_;
|
||||
|
||||
// General settings for the pipeline
|
||||
bool valid_;
|
||||
QString sink_;
|
||||
|
@ -19,7 +19,10 @@
|
||||
|
||||
#include "core/logging.h"
|
||||
|
||||
GstPipelineBase::GstPipelineBase() : QObject(nullptr), pipeline_(nullptr) {}
|
||||
std::atomic<int> GstPipelineBase::sId(1);
|
||||
|
||||
GstPipelineBase::GstPipelineBase()
|
||||
: QObject(nullptr), pipeline_(nullptr), id_(sId++) {}
|
||||
|
||||
GstPipelineBase::~GstPipelineBase() {
|
||||
if (pipeline_) {
|
||||
|
@ -29,10 +29,20 @@ class GstPipelineBase : public QObject {
|
||||
|
||||
virtual bool Init(const QString& name);
|
||||
|
||||
// Globally unique across all pipelines.
|
||||
int id() const { return id_; }
|
||||
|
||||
void DumpGraph();
|
||||
|
||||
protected:
|
||||
GstElement* pipeline_;
|
||||
|
||||
private:
|
||||
// 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.
|
||||
static std::atomic<int> sId;
|
||||
const int id_;
|
||||
};
|
||||
|
||||
#endif // GSTPIPELINEBASE_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user