summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej Rybczak <andrzej@rybczak.net>2020-12-13 16:14:13 +0100
committerAndrzej Rybczak <andrzej@rybczak.net>2020-12-13 16:16:34 +0100
commit8575a9132cbb411a717204fb4f0cc3b954e44e31 (patch)
treef851bb8d0b15a5f201e176bffa350575df506639
parent9749e49cfcbed1e2525bfb72bc6e44e90db72034 (diff)
Disable hacky attempt to sync visualization with audio by default
-rw-r--r--CHANGELOG.md2
-rw-r--r--doc/config8
-rw-r--r--doc/ncmpcpp.13
-rw-r--r--src/screens/visualizer.cpp13
-rw-r--r--src/settings.cpp5
5 files changed, 18 insertions, 13 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 06348a22..3fb60fb9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,6 +20,8 @@
configuration file for controlling the look of the new spectrum visualizer.
* Add `visualizer_autoscale` option to a configuration file.
* Allow for editing multiple titles in the Tag Editor.
+* Allow setting `visualizer_sync_interval` to 0 (a new default) to disable
+ synchronization attempts.
# ncmpcpp-0.8.2 (2018-04-11)
* Help screen: fixed display of EoF keycode
diff --git a/doc/config b/doc/config
index 1501e2af..7706d052 100644
--- a/doc/config
+++ b/doc/config
@@ -69,13 +69,11 @@
#visualizer_in_stereo = yes
#
##
-## Note: Below parameter defines how often ncmpcpp has to "synchronize"
-## visualizer and audio outputs. 30 seconds is optimal value, but if you
-## experience synchronization problems, set it to lower value. Keep in mind
-## that sane values start with >=10.
+## Note: set below to >=10 only if you have synchronization issues with
+## visualization and audio.
##
#
-#visualizer_sync_interval = 30
+#visualizer_sync_interval = 0
#
##
## Note: To enable spectrum frequency visualization you need to compile ncmpcpp
diff --git a/doc/ncmpcpp.1 b/doc/ncmpcpp.1
index 52580ec2..97c6ed25 100644
--- a/doc/ncmpcpp.1
+++ b/doc/ncmpcpp.1
@@ -88,7 +88,8 @@ Name of output that provides data for visualizer. Needed to keep sound and visua
Should be set to 'yes', if fifo output's format was set to 44100:16:2.
.TP
.B visualizer_sync_interval = SECONDS
-Defines interval between syncing visualizer and audio outputs.
+Try synchronizing visualization with audio every N seconds by flushing the FIFO
+output. A value of 0 disables it, use only when necessary.
.TP
.B visualizer_type = spectrum/wave/wave_filled/ellipse
Defines default visualizer type (spectrum is available only if ncmpcpp was compiled with fftw support).
diff --git a/src/screens/visualizer.cpp b/src/screens/visualizer.cpp
index 9955ee42..39da67eb 100644
--- a/src/screens/visualizer.cpp
+++ b/src/screens/visualizer.cpp
@@ -160,12 +160,15 @@ void Visualizer::update()
memcpy(sdata_end - data, temp_sdata, data);
}
- if (m_output_id != -1 && Global::Timer - m_timer > Config.visualizer_sync_interval)
+ if (Config.visualizer_sync_interval > boost::posix_time::seconds(0))
{
- Mpd.DisableOutput(m_output_id);
- usleep(50000);
- Mpd.EnableOutput(m_output_id);
- m_timer = Global::Timer;
+ if (m_output_id != -1 && Global::Timer - m_timer > Config.visualizer_sync_interval)
+ {
+ Mpd.DisableOutput(m_output_id);
+ usleep(50000);
+ Mpd.EnableOutput(m_output_id);
+ m_timer = Global::Timer;
+ }
}
void (Visualizer::*draw)(int16_t *, ssize_t, size_t, size_t);
diff --git a/src/settings.cpp b/src/settings.cpp
index b3e582ba..d8291a96 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -279,10 +279,11 @@ bool Configuration::read(const std::vector<std::string> &config_paths, bool igno
p.add("visualizer_fifo_path", &visualizer_fifo_path, "/tmp/mpd.fifo", adjust_path);
p.add("visualizer_output_name", &visualizer_output_name, "Visualizer feed");
p.add("visualizer_in_stereo", &visualizer_in_stereo, "yes", yes_no);
- p.add("visualizer_sync_interval", &visualizer_sync_interval, "30",
+ p.add("visualizer_sync_interval", &visualizer_sync_interval, "0",
[](std::string v) {
unsigned sync_interval = verbose_lexical_cast<unsigned>(v);
- lowerBoundCheck<unsigned>(sync_interval, 10);
+ if (sync_interval > 0)
+ lowerBoundCheck<unsigned>(sync_interval, 10);
return boost::posix_time::seconds(sync_interval);
});
p.add("visualizer_type", &visualizer_type, "wave");