Disable hacky attempt to sync visualization with audio by default

This commit is contained in:
Andrzej Rybczak
2020-12-13 16:14:13 +01:00
parent 9749e49cfc
commit 8575a9132c
5 changed files with 18 additions and 13 deletions

View File

@@ -20,6 +20,8 @@
configuration file for controlling the look of the new spectrum visualizer. configuration file for controlling the look of the new spectrum visualizer.
* Add `visualizer_autoscale` option to a configuration file. * Add `visualizer_autoscale` option to a configuration file.
* Allow for editing multiple titles in the Tag Editor. * 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) # ncmpcpp-0.8.2 (2018-04-11)
* Help screen: fixed display of EoF keycode * Help screen: fixed display of EoF keycode

View File

@@ -69,13 +69,11 @@
#visualizer_in_stereo = yes #visualizer_in_stereo = yes
# #
## ##
## Note: Below parameter defines how often ncmpcpp has to "synchronize" ## Note: set below to >=10 only if you have synchronization issues with
## visualizer and audio outputs. 30 seconds is optimal value, but if you ## visualization and audio.
## experience synchronization problems, set it to lower value. Keep in mind
## that sane values start with >=10.
## ##
# #
#visualizer_sync_interval = 30 #visualizer_sync_interval = 0
# #
## ##
## Note: To enable spectrum frequency visualization you need to compile ncmpcpp ## Note: To enable spectrum frequency visualization you need to compile ncmpcpp

View File

@@ -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. Should be set to 'yes', if fifo output's format was set to 44100:16:2.
.TP .TP
.B visualizer_sync_interval = SECONDS .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 .TP
.B visualizer_type = spectrum/wave/wave_filled/ellipse .B visualizer_type = spectrum/wave/wave_filled/ellipse
Defines default visualizer type (spectrum is available only if ncmpcpp was compiled with fftw support). Defines default visualizer type (spectrum is available only if ncmpcpp was compiled with fftw support).

View File

@@ -160,12 +160,15 @@ void Visualizer::update()
memcpy(sdata_end - data, temp_sdata, data); 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); if (m_output_id != -1 && Global::Timer - m_timer > Config.visualizer_sync_interval)
usleep(50000); {
Mpd.EnableOutput(m_output_id); Mpd.DisableOutput(m_output_id);
m_timer = Global::Timer; usleep(50000);
Mpd.EnableOutput(m_output_id);
m_timer = Global::Timer;
}
} }
void (Visualizer::*draw)(int16_t *, ssize_t, size_t, size_t); void (Visualizer::*draw)(int16_t *, ssize_t, size_t, size_t);

View File

@@ -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_fifo_path", &visualizer_fifo_path, "/tmp/mpd.fifo", adjust_path);
p.add("visualizer_output_name", &visualizer_output_name, "Visualizer feed"); p.add("visualizer_output_name", &visualizer_output_name, "Visualizer feed");
p.add("visualizer_in_stereo", &visualizer_in_stereo, "yes", yes_no); 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) { [](std::string v) {
unsigned sync_interval = verbose_lexical_cast<unsigned>(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); return boost::posix_time::seconds(sync_interval);
}); });
p.add("visualizer_type", &visualizer_type, "wave"); p.add("visualizer_type", &visualizer_type, "wave");