Give each gstreamer element a unique name
This commit is contained in:
parent
93f4fca324
commit
aad6093b63
|
@ -72,7 +72,8 @@ GstEngine::GstEngine()
|
|||
rg_preamp_(0.0),
|
||||
rg_compression_(true),
|
||||
seek_timer_(new QTimer(this)),
|
||||
timer_id_(-1)
|
||||
timer_id_(-1),
|
||||
next_element_id_(0)
|
||||
{
|
||||
seek_timer_->setSingleShot(true);
|
||||
seek_timer_->setInterval(kSeekDelay);
|
||||
|
@ -661,21 +662,24 @@ void GstEngine::NewMetaData(const Engine::SimpleMetaBundle& bundle) {
|
|||
emit MetaData(bundle);
|
||||
}
|
||||
|
||||
GstElement* GstEngine::CreateElement(
|
||||
const QString& factoryName, GstElement* bin, const QString& name ) {
|
||||
GstElement* element =
|
||||
gst_element_factory_make(
|
||||
factoryName.toAscii().constData(),
|
||||
name.isNull() ? factoryName.toAscii().constData() : name.toAscii().constData() );
|
||||
GstElement* GstEngine::CreateElement(const QString& factoryName, GstElement* bin) {
|
||||
// Make a unique name
|
||||
QString name = factoryName + "-" + QString::number(next_element_id_ ++);
|
||||
qDebug() << name;
|
||||
|
||||
if ( element ) {
|
||||
if ( bin ) gst_bin_add( GST_BIN( bin ), element );
|
||||
} else {
|
||||
GstElement* element = gst_element_factory_make(
|
||||
factoryName.toAscii().constData(), name.toAscii().constData());
|
||||
|
||||
if (!element) {
|
||||
emit Error(QString("GStreamer could not create the element: %1. "
|
||||
"Please make sure that you have installed all necessary GStreamer plugins (e.g. OGG and MP3)").arg( factoryName ) );
|
||||
gst_object_unref( GST_OBJECT( bin ) );
|
||||
gst_object_unref(GST_OBJECT(bin));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (bin)
|
||||
gst_bin_add(GST_BIN(bin), element);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,8 +78,7 @@ class GstEngine : public Engine::Base, public BufferConsumer {
|
|||
PluginDetailsList GetOutputsList() const { return GetPluginList( "Sink/Audio" ); }
|
||||
static bool DoesThisSinkSupportChangingTheOutputDeviceToAUserEditableString(const QString& name);
|
||||
|
||||
GstElement* CreateElement(
|
||||
const QString& factoryName, GstElement* bin = 0, const QString& name = 0);
|
||||
GstElement* CreateElement(const QString& factoryName, GstElement* bin = 0);
|
||||
|
||||
// BufferConsumer
|
||||
void ConsumeBuffer(GstBuffer *buffer, GstEnginePipeline* pipeline);
|
||||
|
@ -181,6 +180,7 @@ class GstEngine : public Engine::Base, public BufferConsumer {
|
|||
uint seek_pos_;
|
||||
|
||||
int timer_id_;
|
||||
int next_element_id_;
|
||||
|
||||
QHash<int, boost::shared_ptr<GstEnginePipeline> > background_streams_;
|
||||
};
|
||||
|
|
|
@ -139,7 +139,7 @@ bool GstEnginePipeline::Init() {
|
|||
if (GstEngine::DoesThisSinkSupportChangingTheOutputDeviceToAUserEditableString(sink_) && !device_.isEmpty())
|
||||
g_object_set(G_OBJECT(audiosink_), "device", device_.toUtf8().constData(), NULL);
|
||||
|
||||
if (!(equalizer_preamp_ = engine_->CreateElement("volume", audiobin_, "equalizer-preamp"))) { return false; }
|
||||
if (!(equalizer_preamp_ = engine_->CreateElement("volume", audiobin_))) { return false; }
|
||||
if (!(equalizer_ = engine_->CreateElement("equalizer-nbands", audiobin_))) { return false; }
|
||||
if (!(audioconvert_ = engine_->CreateElement("audioconvert", audiobin_))) { return false; }
|
||||
if (!(volume_ = engine_->CreateElement("volume", audiobin_))) { return false; }
|
||||
|
@ -149,7 +149,7 @@ bool GstEnginePipeline::Init() {
|
|||
if (rg_enabled_) {
|
||||
if (!(rgvolume_ = engine_->CreateElement("rgvolume", audiobin_))) { return false; }
|
||||
if (!(rglimiter_ = engine_->CreateElement("rglimiter", audiobin_))) { return false; }
|
||||
if (!(audioconvert2_ = engine_->CreateElement("audioconvert", audiobin_, "audioconvert2"))) { return false; }
|
||||
if (!(audioconvert2_ = engine_->CreateElement("audioconvert", audiobin_))) { return false; }
|
||||
scope_element = audioconvert2_;
|
||||
|
||||
// Set replaygain settings
|
||||
|
@ -196,7 +196,7 @@ bool GstEnginePipeline::Init() {
|
|||
gst_caps_unref(caps);
|
||||
|
||||
// Add an extra audioconvert at the end as osxaudiosink supports only one format.
|
||||
GstElement* convert = engine_->CreateElement("audioconvert", audiobin_, "audioconvert3");
|
||||
GstElement* convert = engine_->CreateElement("audioconvert", audiobin_);
|
||||
if (!convert) { return false; }
|
||||
if (rg_enabled_)
|
||||
gst_element_link_many(audioconvert_, rgvolume_, rglimiter_, audioconvert2_, NULL);
|
||||
|
|
Loading…
Reference in New Issue