mirror of
https://github.com/clementine-player/Clementine
synced 2025-02-03 20:57:35 +01:00
gstenginepipeline: make buffer min fill configurable
This commit is contained in:
parent
4c70f17444
commit
e3bea84bea
@ -90,6 +90,7 @@ GstEngine::GstEngine(TaskManager* task_manager)
|
|||||||
rg_preamp_(0.0),
|
rg_preamp_(0.0),
|
||||||
rg_compression_(true),
|
rg_compression_(true),
|
||||||
buffer_duration_nanosec_(1 * kNsecPerSec), // 1s
|
buffer_duration_nanosec_(1 * kNsecPerSec), // 1s
|
||||||
|
buffer_min_fill_(33),
|
||||||
mono_playback_(false),
|
mono_playback_(false),
|
||||||
seek_timer_(new QTimer(this)),
|
seek_timer_(new QTimer(this)),
|
||||||
timer_id_(-1),
|
timer_id_(-1),
|
||||||
@ -179,6 +180,8 @@ void GstEngine::ReloadSettings() {
|
|||||||
buffer_duration_nanosec_ =
|
buffer_duration_nanosec_ =
|
||||||
s.value("bufferduration", 4000).toLongLong() * kNsecPerMsec;
|
s.value("bufferduration", 4000).toLongLong() * kNsecPerMsec;
|
||||||
|
|
||||||
|
buffer_min_fill_ = s.value("bufferminfill", 33).toInt();
|
||||||
|
|
||||||
mono_playback_ = s.value("monoplayback", false).toBool();
|
mono_playback_ = s.value("monoplayback", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -700,6 +703,7 @@ shared_ptr<GstEnginePipeline> GstEngine::CreatePipeline() {
|
|||||||
ret->set_output_device(sink_, device_);
|
ret->set_output_device(sink_, device_);
|
||||||
ret->set_replaygain(rg_enabled_, rg_mode_, rg_preamp_, rg_compression_);
|
ret->set_replaygain(rg_enabled_, rg_mode_, rg_preamp_, rg_compression_);
|
||||||
ret->set_buffer_duration_nanosec(buffer_duration_nanosec_);
|
ret->set_buffer_duration_nanosec(buffer_duration_nanosec_);
|
||||||
|
ret->set_buffer_min_fill(buffer_min_fill_);
|
||||||
ret->set_mono_playback(mono_playback_);
|
ret->set_mono_playback(mono_playback_);
|
||||||
|
|
||||||
ret->AddBufferConsumer(this);
|
ret->AddBufferConsumer(this);
|
||||||
|
@ -204,6 +204,8 @@ class GstEngine : public Engine::Base, public BufferConsumer {
|
|||||||
|
|
||||||
qint64 buffer_duration_nanosec_;
|
qint64 buffer_duration_nanosec_;
|
||||||
|
|
||||||
|
int buffer_min_fill_;
|
||||||
|
|
||||||
bool mono_playback_;
|
bool mono_playback_;
|
||||||
|
|
||||||
mutable bool can_decode_success_;
|
mutable bool can_decode_success_;
|
||||||
|
@ -62,6 +62,7 @@ GstEnginePipeline::GstEnginePipeline(GstEngine* engine)
|
|||||||
rg_preamp_(0.0),
|
rg_preamp_(0.0),
|
||||||
rg_compression_(true),
|
rg_compression_(true),
|
||||||
buffer_duration_nanosec_(1 * kNsecPerSec),
|
buffer_duration_nanosec_(1 * kNsecPerSec),
|
||||||
|
buffer_min_fill_(33),
|
||||||
buffering_(false),
|
buffering_(false),
|
||||||
mono_playback_(false),
|
mono_playback_(false),
|
||||||
end_offset_nanosec_(-1),
|
end_offset_nanosec_(-1),
|
||||||
@ -113,6 +114,10 @@ void GstEnginePipeline::set_buffer_duration_nanosec(
|
|||||||
buffer_duration_nanosec_ = buffer_duration_nanosec;
|
buffer_duration_nanosec_ = buffer_duration_nanosec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GstEnginePipeline::set_buffer_min_fill(int percent) {
|
||||||
|
buffer_min_fill_ = percent;
|
||||||
|
}
|
||||||
|
|
||||||
void GstEnginePipeline::set_mono_playback(bool enabled) {
|
void GstEnginePipeline::set_mono_playback(bool enabled) {
|
||||||
mono_playback_ = enabled;
|
mono_playback_ = enabled;
|
||||||
}
|
}
|
||||||
@ -349,7 +354,7 @@ bool GstEnginePipeline::Init() {
|
|||||||
g_object_set(G_OBJECT(queue_), "max-size-bytes", 0, nullptr);
|
g_object_set(G_OBJECT(queue_), "max-size-bytes", 0, nullptr);
|
||||||
g_object_set(G_OBJECT(queue_), "max-size-time", buffer_duration_nanosec_,
|
g_object_set(G_OBJECT(queue_), "max-size-time", buffer_duration_nanosec_,
|
||||||
nullptr);
|
nullptr);
|
||||||
g_object_set(G_OBJECT(queue_), "low-percent", 1, nullptr);
|
g_object_set(G_OBJECT(queue_), "low-percent", buffer_min_fill_, nullptr);
|
||||||
|
|
||||||
if (buffer_duration_nanosec_ > 0) {
|
if (buffer_duration_nanosec_ > 0) {
|
||||||
g_object_set(G_OBJECT(queue_), "use-buffering", true, nullptr);
|
g_object_set(G_OBJECT(queue_), "use-buffering", true, nullptr);
|
||||||
|
@ -53,6 +53,7 @@ class GstEnginePipeline : public QObject {
|
|||||||
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);
|
||||||
void set_buffer_duration_nanosec(qint64 duration_nanosec);
|
void set_buffer_duration_nanosec(qint64 duration_nanosec);
|
||||||
|
void set_buffer_min_fill(int percent);
|
||||||
void set_mono_playback(bool enabled);
|
void set_mono_playback(bool enabled);
|
||||||
|
|
||||||
// Creates the pipeline, returns false on error
|
// Creates the pipeline, returns false on error
|
||||||
@ -213,6 +214,7 @@ signals:
|
|||||||
|
|
||||||
// Buffering
|
// Buffering
|
||||||
quint64 buffer_duration_nanosec_;
|
quint64 buffer_duration_nanosec_;
|
||||||
|
int buffer_min_fill_;
|
||||||
bool buffering_;
|
bool buffering_;
|
||||||
|
|
||||||
bool mono_playback_;
|
bool mono_playback_;
|
||||||
|
@ -33,6 +33,11 @@ PlaybackSettingsPage::PlaybackSettingsPage(SettingsDialog* dialog)
|
|||||||
connect(ui_->fading_auto, SIGNAL(toggled(bool)),
|
connect(ui_->fading_auto, SIGNAL(toggled(bool)),
|
||||||
SLOT(FadingOptionsChanged()));
|
SLOT(FadingOptionsChanged()));
|
||||||
|
|
||||||
|
connect(ui_->buffer_min_fill, SIGNAL(valueChanged(int)),
|
||||||
|
SLOT(BufferMinFillChanged(int)));
|
||||||
|
ui_->buffer_min_fill_value_label->setMinimumWidth(
|
||||||
|
QFontMetrics(ui_->buffer_min_fill_value_label->font()).width("WW%"));
|
||||||
|
|
||||||
connect(ui_->replaygain_preamp, SIGNAL(valueChanged(int)),
|
connect(ui_->replaygain_preamp, SIGNAL(valueChanged(int)),
|
||||||
SLOT(RgPreampChanged(int)));
|
SLOT(RgPreampChanged(int)));
|
||||||
ui_->replaygain_preamp_label->setMinimumWidth(
|
ui_->replaygain_preamp_label->setMinimumWidth(
|
||||||
@ -102,6 +107,7 @@ void PlaybackSettingsPage::Load() {
|
|||||||
s.value("rgcompression", true).toBool());
|
s.value("rgcompression", true).toBool());
|
||||||
ui_->buffer_duration->setValue(s.value("bufferduration", 4000).toInt());
|
ui_->buffer_duration->setValue(s.value("bufferduration", 4000).toInt());
|
||||||
ui_->mono_playback->setChecked(s.value("monoplayback", false).toBool());
|
ui_->mono_playback->setChecked(s.value("monoplayback", false).toBool());
|
||||||
|
ui_->buffer_min_fill->setValue(s.value("bufferminfill", 33).toInt());
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,6 +141,7 @@ void PlaybackSettingsPage::Save() {
|
|||||||
s.setValue("rgcompression", ui_->replaygain_compression->isChecked());
|
s.setValue("rgcompression", ui_->replaygain_compression->isChecked());
|
||||||
s.setValue("bufferduration", ui_->buffer_duration->value());
|
s.setValue("bufferduration", ui_->buffer_duration->value());
|
||||||
s.setValue("monoplayback", ui_->mono_playback->isChecked());
|
s.setValue("monoplayback", ui_->mono_playback->isChecked());
|
||||||
|
s.setValue("bufferminfill", ui_->buffer_min_fill->value());
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,6 +152,12 @@ void PlaybackSettingsPage::RgPreampChanged(int value) {
|
|||||||
ui_->replaygain_preamp_label->setText(db_str);
|
ui_->replaygain_preamp_label->setText(db_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlaybackSettingsPage::BufferMinFillChanged(int value) {
|
||||||
|
QString percent;
|
||||||
|
percent.sprintf("%d%%", value);
|
||||||
|
ui_->buffer_min_fill_value_label->setText(percent);
|
||||||
|
}
|
||||||
|
|
||||||
void PlaybackSettingsPage::FadingOptionsChanged() {
|
void PlaybackSettingsPage::FadingOptionsChanged() {
|
||||||
ui_->fading_options->setEnabled(ui_->fading_out->isChecked() ||
|
ui_->fading_options->setEnabled(ui_->fading_out->isChecked() ||
|
||||||
ui_->fading_cross->isChecked() ||
|
ui_->fading_cross->isChecked() ||
|
||||||
|
@ -35,6 +35,7 @@ class PlaybackSettingsPage : public SettingsPage {
|
|||||||
private slots:
|
private slots:
|
||||||
void FadingOptionsChanged();
|
void FadingOptionsChanged();
|
||||||
void RgPreampChanged(int value);
|
void RgPreampChanged(int value);
|
||||||
|
void BufferMinFillChanged(int value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui_PlaybackSettingsPage* ui_;
|
Ui_PlaybackSettingsPage* ui_;
|
||||||
|
@ -293,7 +293,14 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="2">
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="buffer_min_fill_label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Buffer low fill</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0" colspan="2">
|
||||||
<widget class="QCheckBox" name="mono_playback">
|
<widget class="QCheckBox" name="mono_playback">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Changing mono playback preference will be effective for the next playing songs</string>
|
<string>Changing mono playback preference will be effective for the next playing songs</string>
|
||||||
@ -303,6 +310,36 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="buffer_min_fill_value_label">
|
||||||
|
<property name="text">
|
||||||
|
<string> </string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSlider" name="buffer_min_fill">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>50</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>33</number>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="tickInterval">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user