GstEnginePipeline: "gracefully" flush stale pipeline caches
Now that we have an output audio queue, which is fully processed, if we change some parameters of the elements (that are placed before said queue), the changes will not propagate to the output immediately, as expected. But that is not what one wants. So when changing parameters of such elements, we must ensure to flush the now-stale caches, thus forcing re-processing of the audio. Now, this works, but i really don't understand how flushing is supposed to work in gstreamer, it just doesn't seem to work if there is no seeking, so there is some jumps when changing parameters now. Maybe this can be avoided? Also, fader needs to be reimplemented. It fundamentally does not fit into this structure.
This commit is contained in:
parent
c8e6fa7e74
commit
92f40302ed
|
@ -1558,6 +1558,17 @@ bool GstEnginePipeline::Seek(const qint64 nanosec) {
|
|||
|
||||
}
|
||||
|
||||
static void flush_pipeline(GstElement *pipeline) {
|
||||
// FIXME: is this really the right way to flush pipeline without seeking?
|
||||
gint64 position_ns_;
|
||||
gst_element_query_position(pipeline, GST_FORMAT_TIME, &position_ns_);
|
||||
gst_element_seek_simple (pipeline, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, position_ns_);
|
||||
}
|
||||
|
||||
QFuture<void> GstEnginePipeline::FlushPipeline() {
|
||||
return QtConcurrent::run(&set_state_threadpool_, &flush_pipeline, pipeline_);
|
||||
}
|
||||
|
||||
void GstEnginePipeline::SetEBUR128LoudnessNormalizingGain_dB(const double ebur128_loudness_normalizing_gain_db) {
|
||||
|
||||
ebur128_loudness_normalizing_gain_db_ = ebur128_loudness_normalizing_gain_db;
|
||||
|
@ -1571,6 +1582,8 @@ void GstEnginePipeline::UpdateEBUR128LoudnessNormalizingGaindB() {
|
|||
auto dB_to_mult = [](const double gain_dB) { return std::pow(10., gain_dB / 20.); };
|
||||
|
||||
g_object_set(G_OBJECT(ebur128_volume_), "volume", dB_to_mult(ebur128_loudness_normalizing_gain_db_), nullptr);
|
||||
|
||||
FlushPipeline();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1588,6 +1601,10 @@ void GstEnginePipeline::SetVolume(const uint volume_percent) {
|
|||
}
|
||||
}
|
||||
|
||||
if (volume_ == volume_sw_) {
|
||||
FlushPipeline();
|
||||
}
|
||||
|
||||
volume_percent_ = volume_percent;
|
||||
|
||||
}
|
||||
|
@ -1596,6 +1613,7 @@ void GstEnginePipeline::SetFaderVolume(const qreal volume) {
|
|||
|
||||
if (volume_fading_) {
|
||||
g_object_set(G_OBJECT(volume_fading_), "volume", volume, nullptr);
|
||||
FlushPipeline(); // FIXME: this is not the right solution.
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1611,6 +1629,8 @@ void GstEnginePipeline::UpdateStereoBalance() {
|
|||
|
||||
if (audiopanorama_) {
|
||||
g_object_set(G_OBJECT(audiopanorama_), "panorama", stereo_balance_, nullptr);
|
||||
|
||||
FlushPipeline();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1650,6 +1670,8 @@ void GstEnginePipeline::UpdateEqualizer() {
|
|||
|
||||
g_object_set(G_OBJECT(equalizer_preamp_), "volume", preamp, nullptr);
|
||||
|
||||
FlushPipeline();
|
||||
|
||||
}
|
||||
|
||||
void GstEnginePipeline::StartFader(const qint64 duration_nanosec, const QTimeLine::Direction direction, const QEasingCurve::Type shape, const bool use_fudge_timer) {
|
||||
|
|
|
@ -85,6 +85,7 @@ class GstEnginePipeline : public QObject {
|
|||
void RemoveAllBufferConsumers();
|
||||
|
||||
// Control the music playback
|
||||
QFuture<void> FlushPipeline();
|
||||
QFuture<GstStateChangeReturn> SetState(const GstState state);
|
||||
Q_INVOKABLE bool Seek(const qint64 nanosec);
|
||||
void SetEBUR128LoudnessNormalizingGain_dB(const double ebur128_loudness_normalizing_gain_db);
|
||||
|
|
Loading…
Reference in New Issue