Deprecate visualizer_fifo_path in favor of visualizer_data_source

This commit is contained in:
Andrzej Rybczak
2020-12-17 22:14:11 +01:00
parent 519f44e27c
commit fb886f6870
6 changed files with 57 additions and 25 deletions

View File

@@ -24,6 +24,8 @@
* 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 * Allow setting `visualizer_sync_interval` to 0 (a new default) to disable
synchronization attempts. 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) # ncmpcpp-0.8.2 (2018-04-11)
* Help screen: fixed display of EoF keycode * Help screen: fixed display of EoF keycode

View File

@@ -40,10 +40,10 @@
# #
##### music visualizer ##### ##### music visualizer #####
## ##
## Note: In order to make music visualizer work you'll need to use mpd fifo ## In order to make music visualizer work with MPD you need to use the fifo
## output, whose format parameter has to be set to 44100:16:1 for mono ## output. Its format parameter has to be set to 44100:16:1 for mono
## visualization or 44100:16:2 for stereo visualization. Example configuration ## visualization or 44100:16:2 for stereo visualization. As an example here is
## (it has to be put into mpd.conf): ## the relevant section for mpd.conf:
## ##
## audio_output { ## audio_output {
## type "fifo" ## type "fifo"
@@ -52,8 +52,19 @@
## format "44100:16:2" ## 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 ## Note: Below parameter is needed for ncmpcpp to determine which output

View File

@@ -78,8 +78,9 @@ Set connection timeout to MPD to given value.
.B mpd_crossfade_time = SECONDS .B mpd_crossfade_time = SECONDS
Default number of seconds to crossfade, if enabled by ncmpcpp. Default number of seconds to crossfade, if enabled by ncmpcpp.
.TP .TP
.B visualizer_fifo_path = PATH .B visualizer_data_source = LOCATION
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) 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 .TP
.B visualizer_output_name = NAME .B visualizer_output_name = NAME
Name of output that provides data for visualizer. Needed to keep sound and visualization in sync. Name of output that provides data for visualizer. Needed to keep sound and visualization in sync.

View File

@@ -192,6 +192,8 @@ void Visualizer::update()
if (new_samples == 0) if (new_samples == 0)
return; 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_buffered_samples.size() > 0)
{ {
if (++m_sample_consumption_rate_up_ctr > 8) if (++m_sample_consumption_rate_up_ctr > 8)
@@ -624,19 +626,21 @@ void Visualizer::GenLogspace()
void Visualizer::InitDataSource() void Visualizer::InitDataSource()
{ {
auto colon = Config.visualizer_fifo_path.rfind(':'); if (!Config.visualizer_fifo_path.empty())
if (Config.visualizer_fifo_path[0] != '/' && colon != std::string::npos) 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_port = m_source_location.substr(colon+1);
m_source_location = Config.visualizer_fifo_path.substr(0, colon); m_source_location.resize(colon);
m_source_port = Config.visualizer_fifo_path.substr(colon+1);
} }
else else
{
// FIFO source
m_source_location = Config.visualizer_fifo_path;
m_source_port.clear(); m_source_port.clear();
}
} }
void Visualizer::InitVisualization() void Visualizer::InitVisualization()
@@ -782,7 +786,7 @@ void Visualizer::OpenDataSource()
m_source_fd = open(m_source_location.c_str(), O_RDONLY | O_NONBLOCK); m_source_fd = open(m_source_location.c_str(), O_RDONLY | O_NONBLOCK);
if (m_source_fd < 0) if (m_source_fd < 0)
Statusbar::printf("Couldn't open \"%1%\" for reading PCM data: %2%", 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() void Visualizer::FindOutputID()
{ {
m_output_id = -1; 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) for (MPD::OutputIterator out = Mpd.GetOutputs(), end; out != end; ++out)
{ {

View File

@@ -196,7 +196,8 @@ NC::Buffer buffer_wlength(const NC::Buffer *target,
return *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 std::cerr << "WARNING: Variable '" << option
<< "' is deprecated and will be removed in " << "' 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()) if (!v.empty())
deprecated( deprecated(
"visualizer_sample_multiplier", "visualizer_sample_multiplier",
0.9, "0.9",
"visualizer scales automatically"); "visualizer scales automatically");
}); });
p.add<void>("progressbar_boldness", nullptr, "", [](std::string v) { p.add<void>("progressbar_boldness", nullptr, "", [](std::string v) {
if (!v.empty()) if (!v.empty())
deprecated( deprecated(
"progressbar_boldness", "progressbar_boldness",
0.9, "0.9",
"use extended progressbar_color and progressbar_elapsed_color instead"); "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); current_item_suffix_str);
deprecated( deprecated(
"main_window_highlight_color", "main_window_highlight_color",
0.9, "0.9",
"set current_item_prefix = \"" "set current_item_prefix = \""
+ current_item_prefix_str + current_item_prefix_str
+ "\" and current_item_suffix = \"" + "\" and current_item_suffix = \""
@@ -256,12 +257,22 @@ bool Configuration::read(const std::vector<std::string> &config_paths, bool igno
{ {
deprecated( deprecated(
"active_column_color", "active_column_color",
0.9, "0.9",
"replaced by current_item_inactive_column_prefix" "replaced by current_item_inactive_column_prefix"
" and current_item_inactive_column_suffix"); " 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 // keep the same order of variables as in configuration file
p.add("ncmpcpp_directory", &ncmpcpp_directory, "~/.ncmpcpp/", adjust_directory); p.add("ncmpcpp_directory", &ncmpcpp_directory, "~/.ncmpcpp/", adjust_directory);
p.add("lyrics_directory", &lyrics_directory, "~/.lyrics/", 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_connection_timeout", &mpd_connection_timeout, "5");
p.add("mpd_crossfade_time", &crossfade_time, "5"); p.add("mpd_crossfade_time", &crossfade_time, "5");
p.add("random_exclude_pattern", &random_exclude_pattern, ""); 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_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, "0", p.add("visualizer_sync_interval", &visualizer_sync_interval, "0",

View File

@@ -61,7 +61,8 @@ struct Configuration
std::string lyrics_directory; std::string lyrics_directory;
std::string mpd_music_dir; 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 visualizer_output_name;
std::string empty_tag; std::string empty_tag;