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[] = {
|
const int GstEnginePipeline::kEqBandFrequencies[] = {
|
||||||
60, 170, 310, 600, 1000, 3000, 6000, 12000, 14000, 16000};
|
60, 170, 310, 600, 1000, 3000, 6000, 12000, 14000, 16000};
|
||||||
|
|
||||||
int GstEnginePipeline::sId = 1;
|
|
||||||
GstElementDeleter* GstEnginePipeline::sElementDeleter = nullptr;
|
GstElementDeleter* GstEnginePipeline::sElementDeleter = nullptr;
|
||||||
|
|
||||||
GstEnginePipeline::GstEnginePipeline(GstEngine* engine)
|
GstEnginePipeline::GstEnginePipeline(GstEngine* engine)
|
||||||
: GstPipelineBase(),
|
: GstPipelineBase(),
|
||||||
engine_(engine),
|
engine_(engine),
|
||||||
id_(sId++),
|
|
||||||
valid_(false),
|
valid_(false),
|
||||||
sink_(GstEngine::kAutoSink),
|
sink_(GstEngine::kAutoSink),
|
||||||
segment_start_(0),
|
segment_start_(0),
|
||||||
|
|
|
@ -44,9 +44,6 @@ class GstEnginePipeline : public GstPipelineBase {
|
||||||
GstEnginePipeline(GstEngine* engine);
|
GstEnginePipeline(GstEngine* engine);
|
||||||
~GstEnginePipeline();
|
~GstEnginePipeline();
|
||||||
|
|
||||||
// Globally unique across all pipelines.
|
|
||||||
int id() const { return id_; }
|
|
||||||
|
|
||||||
// Call these setters before Init
|
// Call these setters before Init
|
||||||
void set_output_device(const QString& sink, const QVariant& device);
|
void set_output_device(const QString& sink, const QVariant& device);
|
||||||
void set_replaygain(bool enabled, int mode, float preamp, bool compression);
|
void set_replaygain(bool enabled, int mode, float preamp, bool compression);
|
||||||
|
@ -181,14 +178,6 @@ class GstEnginePipeline : public GstPipelineBase {
|
||||||
|
|
||||||
GstEngine* engine_;
|
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
|
// General settings for the pipeline
|
||||||
bool valid_;
|
bool valid_;
|
||||||
QString sink_;
|
QString sink_;
|
||||||
|
|
|
@ -19,7 +19,10 @@
|
||||||
|
|
||||||
#include "core/logging.h"
|
#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() {
|
GstPipelineBase::~GstPipelineBase() {
|
||||||
if (pipeline_) {
|
if (pipeline_) {
|
||||||
|
|
|
@ -29,10 +29,20 @@ class GstPipelineBase : public QObject {
|
||||||
|
|
||||||
virtual bool Init(const QString& name);
|
virtual bool Init(const QString& name);
|
||||||
|
|
||||||
|
// Globally unique across all pipelines.
|
||||||
|
int id() const { return id_; }
|
||||||
|
|
||||||
void DumpGraph();
|
void DumpGraph();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GstElement* pipeline_;
|
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
|
#endif // GSTPIPELINEBASE_H
|
||||||
|
|
Loading…
Reference in New Issue