diff --git a/CHANGELOG.md b/CHANGELOG.md index 294dd870..53f8aa50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ * Deprecate `visualizer_fifo_path` in favor of `visualizer_data_source`. * Don't run volume changing actions if there is no mixer. * Do not loop after sending a database update command to Mopidy. +* Deprecate `visualizer_sync_interval` configuration option. # ncmpcpp-0.8.2 (2018-04-11) * Help screen: fixed display of EoF keycode diff --git a/doc/config b/doc/config index 4ce11d51..eaf46d83 100644 --- a/doc/config +++ b/doc/config @@ -52,6 +52,10 @@ ## format "44100:16:2" ## } ## +## If the visualization on occasion diverges from the audio output, please set +## 'buffer_time' parameter of your audio output in mpd.conf to '100000' (100ms) +## or less to prevent that from happening. +## ## Note: If you're using Mopidy, an address of a udpsink gstreamer's output is ## also accepted. For example, the following section in mopidy.conf: ## @@ -68,8 +72,8 @@ # ## ## Note: Below parameter is needed for ncmpcpp to determine which output -## provides data for visualizer and thus allow syncing between visualization and -## sound as currently there are some problems with it. +## provides data for visualizer and reset it at the beginning of visualization +## to synchronize with audio. ## # #visualizer_output_name = Visualizer feed diff --git a/doc/ncmpcpp.1 b/doc/ncmpcpp.1 index fd2e4476..407e7813 100644 --- a/doc/ncmpcpp.1 +++ b/doc/ncmpcpp.1 @@ -88,10 +88,6 @@ Name of output that provides data for visualizer. Needed to keep sound and visua .B visualizer_in_stereo = yes/no Should be set to 'yes', if fifo output's format was set to 44100:16:2. .TP -.B visualizer_sync_interval = SECONDS -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). .TP diff --git a/src/screens/visualizer.cpp b/src/screens/visualizer.cpp index 2be3b9c8..dfb80922 100644 --- a/src/screens/visualizer.cpp +++ b/src/screens/visualizer.cpp @@ -103,8 +103,14 @@ void Visualizer::switchTo() SwitchTo::execute(this); Clear(); OpenDataSource(); - // negative infinity to toggle output in update() at least once - m_timer = boost::posix_time::neg_infin; + // Disable and enable FIFO to get rid of the difference between audio and + // visualization. + if (m_output_id != -1) + { + Mpd.DisableOutput(m_output_id); + usleep(50000); + Mpd.EnableOutput(m_output_id); + } drawHeader(); # ifdef HAVE_FFTW3_H GenLogspace(); @@ -136,14 +142,6 @@ void Visualizer::update() if (m_source_fd < 0) return; - 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; - } - // PCM in format 44100:16:1 (for mono visualization) and // 44100:16:2 (for stereo visualization) is supported. ssize_t bytes_read = read(m_source_fd, m_incoming_samples.data(), diff --git a/src/screens/visualizer.h b/src/screens/visualizer.h index a50a531d..87cb0c80 100644 --- a/src/screens/visualizer.h +++ b/src/screens/visualizer.h @@ -87,7 +87,6 @@ private: void (Visualizer::*drawStereo)(const int16_t *, const int16_t *, ssize_t, size_t); int m_output_id; - boost::posix_time::ptime m_timer; int m_source_fd; std::string m_source_location; diff --git a/src/settings.cpp b/src/settings.cpp index 654b9b76..70aba9e8 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -272,6 +272,16 @@ bool Configuration::read(const std::vector &config_paths, bool igno } return adjust_path(v); }); + p.add("visualizer_sync_interval", nullptr, "", [](std::string v) { + if (!v.empty()) + { + deprecated("visualizer_sync_interval", + "0.10", + "set 'buffer_time' parameter of your MPD audio output to '100000' " + "(100ms) or lower if you experience synchronization issues " + "between audio and visualization"); + } + }); // keep the same order of variables as in configuration file p.add("ncmpcpp_directory", &ncmpcpp_directory, "~/.ncmpcpp/", adjust_directory); @@ -290,14 +300,6 @@ bool Configuration::read(const std::vector &config_paths, bool igno p.add("visualizer_data_source", &visualizer_data_source, "/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, "0", - [](std::string v) { - unsigned sync_interval = verbose_lexical_cast(v); - if (sync_interval == 0) - sync_interval = std::numeric_limits::max(); - lowerBoundCheck(sync_interval, 10); - return boost::posix_time::seconds(sync_interval); - }); p.add("visualizer_type", &visualizer_type, #ifdef HAVE_FFTW3_H "spectrum" diff --git a/src/settings.h b/src/settings.h index 7eb76d2e..78e5480f 100644 --- a/src/settings.h +++ b/src/settings.h @@ -52,7 +52,7 @@ struct Column struct Configuration { Configuration() - : playlist_disable_highlight_delay(0), visualizer_sync_interval(0) + : playlist_disable_highlight_delay(0) { } bool read(const std::vector &config_paths, bool ignore_errors); @@ -198,7 +198,6 @@ struct Configuration boost::regex::flag_type regex_type; boost::posix_time::seconds playlist_disable_highlight_delay; - boost::posix_time::seconds visualizer_sync_interval; double locked_screen_width_part;