Fix crash on startup with Visualizer as the initial screen
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# ncmpcpp-0.10 (????-??-??)
|
||||
* Add support for fetching lyrics from musixmatch.com.
|
||||
* Fix intermittent failures of the Genius fetcher.
|
||||
* Fix crash on startup with Visualizer as the initial screen.
|
||||
|
||||
# ncmpcpp-0.9 (2020-12-20)
|
||||
* Fix various Mopidy specific bugs.
|
||||
|
||||
@@ -69,6 +69,8 @@ const NC::FormattedColor &toColor(size_t number, size_t max, bool wrap = true)
|
||||
|
||||
Visualizer::Visualizer()
|
||||
: Screen(NC::Window(0, MainStartY, COLS, MainHeight, "", NC::Color::Default, NC::Border()))
|
||||
, m_output_id(-1)
|
||||
, m_reset_output(false)
|
||||
, m_source_fd(-1)
|
||||
, m_sample_consumption_rate(5)
|
||||
, m_sample_consumption_rate_up_ctr(0)
|
||||
@@ -103,14 +105,7 @@ void Visualizer::switchTo()
|
||||
SwitchTo::execute(this);
|
||||
Clear();
|
||||
OpenDataSource();
|
||||
// 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);
|
||||
}
|
||||
m_reset_output = true;
|
||||
drawHeader();
|
||||
# ifdef HAVE_FFTW3_H
|
||||
GenLogspace();
|
||||
@@ -142,6 +137,16 @@ void Visualizer::update()
|
||||
if (m_source_fd < 0)
|
||||
return;
|
||||
|
||||
// Disable and enable FIFO to get rid of the difference between audio and
|
||||
// visualization.
|
||||
if (m_reset_output && m_output_id != -1)
|
||||
{
|
||||
Mpd.DisableOutput(m_output_id);
|
||||
usleep(50000);
|
||||
Mpd.EnableOutput(m_output_id);
|
||||
m_reset_output = false;
|
||||
}
|
||||
|
||||
// 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(),
|
||||
|
||||
@@ -87,6 +87,7 @@ private:
|
||||
void (Visualizer::*drawStereo)(const int16_t *, const int16_t *, ssize_t, size_t);
|
||||
|
||||
int m_output_id;
|
||||
bool m_reset_output;
|
||||
|
||||
int m_source_fd;
|
||||
std::string m_source_location;
|
||||
|
||||
Reference in New Issue
Block a user