diff options
author | Andrzej Rybczak <andrzej@rybczak.net> | 2020-12-17 22:14:11 +0100 |
---|---|---|
committer | Andrzej Rybczak <andrzej@rybczak.net> | 2020-12-17 22:29:37 +0100 |
commit | fb886f687014e22b2fe1477da855be5201063ea8 (patch) | |
tree | eee4c006c273b87574516efedeb80b16b97e1821 | |
parent | 519f44e27c28921a60421bdd2481231e9f859938 (diff) |
Deprecate visualizer_fifo_path in favor of visualizer_data_source
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | doc/config | 21 | ||||
-rw-r--r-- | doc/ncmpcpp.1 | 5 | ||||
-rw-r--r-- | src/screens/visualizer.cpp | 28 | ||||
-rw-r--r-- | src/settings.cpp | 23 | ||||
-rw-r--r-- | src/settings.h | 3 |
6 files changed, 57 insertions, 25 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index d6770748..38257fa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ * Allow for editing multiple titles in the Tag Editor. * Allow setting `visualizer_sync_interval` to 0 (a new default) to disable synchronization attempts. +* Support gstreamer's udpsink as a data source for visualization (Mopidy). +* Deprecate `visualizer_fifo_path` in favor of `visualizer_data_source`. # ncmpcpp-0.8.2 (2018-04-11) * Help screen: fixed display of EoF keycode @@ -40,10 +40,10 @@ # ##### music visualizer ##### ## -## Note: In order to make music visualizer work you'll need to use mpd fifo -## output, whose format parameter has to be set to 44100:16:1 for mono -## visualization or 44100:16:2 for stereo visualization. Example configuration -## (it has to be put into mpd.conf): +## In order to make music visualizer work with MPD you need to use the fifo +## output. Its format parameter has to be set to 44100:16:1 for mono +## visualization or 44100:16:2 for stereo visualization. As an example here is +## the relevant section for mpd.conf: ## ## audio_output { ## type "fifo" @@ -52,8 +52,19 @@ ## format "44100:16:2" ## } ## +## 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: +## +## [audio] +## output = tee name=t ! queue ! autoaudiosink t. +## ! queue ! audio/x-raw,rate=44100,channels=2,format=S16LE +## ! udpsink host=localhost port=5555 +## +## will make localhost:5555 available as a source of data for the stereo +## visualizer. +## # -#visualizer_fifo_path = /tmp/mpd.fifo +#visualizer_data_source = /tmp/mpd.fifo # ## ## Note: Below parameter is needed for ncmpcpp to determine which output diff --git a/doc/ncmpcpp.1 b/doc/ncmpcpp.1 index bfeeb3d9..fd2e4476 100644 --- a/doc/ncmpcpp.1 +++ b/doc/ncmpcpp.1 @@ -78,8 +78,9 @@ Set connection timeout to MPD to given value. .B mpd_crossfade_time = SECONDS Default number of seconds to crossfade, if enabled by ncmpcpp. .TP -.B visualizer_fifo_path = PATH -Path to mpd fifo output. This is needed to make music visualizer work (note that output sound format of this fifo has to be either 44100:16:1 or 44100:16:2, depending on whether you want mono or stereo visualization) +.B visualizer_data_source = LOCATION +Source of data for the visualizer. For MPD it's going to be a fifo output, for +Mopidy a udpsink output (see the example configuration file for more details). .TP .B visualizer_output_name = NAME Name of output that provides data for visualizer. Needed to keep sound and visualization in sync. diff --git a/src/screens/visualizer.cpp b/src/screens/visualizer.cpp index 19d88463..2be3b9c8 100644 --- a/src/screens/visualizer.cpp +++ b/src/screens/visualizer.cpp @@ -192,6 +192,8 @@ void Visualizer::update() if (new_samples == 0) return; + // A crude way to adjust the amount of samples consumed from the buffer + // depending on how fast the rendering is. if (m_buffered_samples.size() > 0) { if (++m_sample_consumption_rate_up_ctr > 8) @@ -624,19 +626,21 @@ void Visualizer::GenLogspace() void Visualizer::InitDataSource() { - auto colon = Config.visualizer_fifo_path.rfind(':'); - if (Config.visualizer_fifo_path[0] != '/' && colon != std::string::npos) + if (!Config.visualizer_fifo_path.empty()) + m_source_location = Config.visualizer_fifo_path; // deprecated + else + m_source_location = Config.visualizer_data_source; + + // If there's a colon and a location doesn't start with '/' we have a UDP + // sink. Otherwise assume it's a FIFO. + auto colon = m_source_location.rfind(':'); + if (m_source_location[0] != '/' && colon != std::string::npos) { - // UDP source - m_source_location = Config.visualizer_fifo_path.substr(0, colon); - m_source_port = Config.visualizer_fifo_path.substr(colon+1); + m_source_port = m_source_location.substr(colon+1); + m_source_location.resize(colon); } else - { - // FIFO source - m_source_location = Config.visualizer_fifo_path; m_source_port.clear(); - } } void Visualizer::InitVisualization() @@ -782,7 +786,7 @@ void Visualizer::OpenDataSource() m_source_fd = open(m_source_location.c_str(), O_RDONLY | O_NONBLOCK); if (m_source_fd < 0) Statusbar::printf("Couldn't open \"%1%\" for reading PCM data: %2%", - Config.visualizer_fifo_path, strerror(errno)); + m_source_location, strerror(errno)); } } @@ -796,7 +800,9 @@ void Visualizer::CloseDataSource() void Visualizer::FindOutputID() { m_output_id = -1; - if (!Config.visualizer_output_name.empty()) + // Look for the output only if its name is specified and we're fetching + // samples from a FIFO. + if (!Config.visualizer_output_name.empty() && m_source_port.empty()) { for (MPD::OutputIterator out = Mpd.GetOutputs(), end; out != end; ++out) { diff --git a/src/settings.cpp b/src/settings.cpp index ee6d319d..654b9b76 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -196,7 +196,8 @@ NC::Buffer buffer_wlength(const NC::Buffer *target, return *target; } -void deprecated(const char *option, double version_removal, const std::string &advice) +void deprecated(const char *option, const char *version_removal, + const std::string &advice) { std::cerr << "WARNING: Variable '" << option << "' is deprecated and will be removed in " @@ -217,14 +218,14 @@ bool Configuration::read(const std::vector<std::string> &config_paths, bool igno if (!v.empty()) deprecated( "visualizer_sample_multiplier", - 0.9, + "0.9", "visualizer scales automatically"); }); p.add<void>("progressbar_boldness", nullptr, "", [](std::string v) { if (!v.empty()) deprecated( "progressbar_boldness", - 0.9, + "0.9", "use extended progressbar_color and progressbar_elapsed_color instead"); }); @@ -243,7 +244,7 @@ bool Configuration::read(const std::vector<std::string> &config_paths, bool igno current_item_suffix_str); deprecated( "main_window_highlight_color", - 0.9, + "0.9", "set current_item_prefix = \"" + current_item_prefix_str + "\" and current_item_suffix = \"" @@ -256,12 +257,22 @@ bool Configuration::read(const std::vector<std::string> &config_paths, bool igno { deprecated( "active_column_color", - 0.9, + "0.9", "replaced by current_item_inactive_column_prefix" " and current_item_inactive_column_suffix"); }; }); + p.add("visualizer_fifo_path", &visualizer_fifo_path, "", [](std::string v) { + if (!v.empty()) + { + deprecated("visualizer_fifo_path", + "0.10", + "replaced by visualizer_data_source"); + } + return adjust_path(v); + }); + // keep the same order of variables as in configuration file p.add("ncmpcpp_directory", &ncmpcpp_directory, "~/.ncmpcpp/", adjust_directory); p.add("lyrics_directory", &lyrics_directory, "~/.lyrics/", adjust_directory); @@ -276,7 +287,7 @@ bool Configuration::read(const std::vector<std::string> &config_paths, bool igno p.add("mpd_connection_timeout", &mpd_connection_timeout, "5"); p.add("mpd_crossfade_time", &crossfade_time, "5"); p.add("random_exclude_pattern", &random_exclude_pattern, ""); - p.add("visualizer_fifo_path", &visualizer_fifo_path, "/tmp/mpd.fifo", adjust_path); + 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", diff --git a/src/settings.h b/src/settings.h index a3f923ce..7eb76d2e 100644 --- a/src/settings.h +++ b/src/settings.h @@ -61,7 +61,8 @@ struct Configuration std::string lyrics_directory; std::string mpd_music_dir; - std::string visualizer_fifo_path; + std::string visualizer_fifo_path; // deprecated + std::string visualizer_data_source; std::string visualizer_output_name; std::string empty_tag; |