audiomonitor: update parameters immediately when panels are focused

This commit is contained in:
itsmattkc
2021-04-27 00:54:46 +10:00
parent f2f5ab8739
commit 4ab4380057
4 changed files with 42 additions and 2 deletions
+21
View File
@@ -58,6 +58,8 @@ void AudioMonitor::SetParams(const AudioParams &params)
peaked_.resize(params_.channel_count());
peaked_.fill(false);
update();
}
void AudioMonitor::OutputDeviceSet(AudioPlaybackCache *cache, qint64 offset, int playback_speed)
@@ -72,6 +74,11 @@ void AudioMonitor::OutputDeviceSet(AudioPlaybackCache *cache, qint64 offset, int
return;
}
if (offset > file_->size()) {
Stop();
return;
}
file_->seek(offset);
playback_speed_ = playback_speed;
@@ -86,6 +93,8 @@ void AudioMonitor::Stop()
delete file_;
file_ = nullptr;
waveform_ = nullptr;
SetUpdateLoop(false);
}
void AudioMonitor::OutputPushed(const QByteArray &d)
@@ -103,6 +112,10 @@ void AudioMonitor::OutputAudioVisualWaveformSet(const AudioVisualWaveform *wavef
{
Stop();
if (start >= waveform->length()) {
return;
}
waveform_ = waveform;
waveform_time_ = start;
@@ -240,8 +253,16 @@ void AudioMonitor::paintGL()
if (file_) {
UpdateValuesFromFile(v, delta_time);
if (file_->atEnd()) {
Stop();
}
} else if (waveform_) {
UpdateValuesFromWaveform(v, delta_time);
if (waveform_time_ >= waveform_->length()) {
Stop();
}
}
last_time_ = current_time;