viewer: ensure prequeue is done before starting

This commit is contained in:
itsmattkc
2021-09-29 10:33:17 -07:00
parent 3a1c9233b9
commit 93bdf409b9
2 changed files with 10 additions and 8 deletions
+9 -7
View File
@@ -57,7 +57,7 @@ ViewerWidget::ViewerWidget(QWidget *parent) :
color_menu_enabled_(true),
time_changed_from_timer_(false),
prequeuing_video_(false),
prequeuing_audio_(false),
prequeuing_audio_(0),
audio_playback_device_(nullptr)
{
// Set up main layout
@@ -425,7 +425,6 @@ void ViewerWidget::StartAudioOutput()
void ViewerWidget::QueueNextAudioBuffer()
{
// NOTE: Hardcoded 2 second interval
rational queue_end = audio_playback_queue_time_ + (kAudioPlaybackInterval * playback_speed_);
// Clamp queue end by zero and the audio length
@@ -474,8 +473,11 @@ void ViewerWidget::ReceivedAudioBufferForPlayback()
audio_playback_device_->Push(pack);
if (prequeuing_audio_) {
prequeuing_audio_ = false;
FinishPlayPreprocess();
prequeuing_audio_--;
if (!prequeuing_audio_) {
FinishPlayPreprocess();
}
}
}
}
@@ -676,9 +678,9 @@ void ViewerWidget::PlayInternal(int speed, bool in_to_out_only)
tempo_processor_.Open(GetConnectedNode()->GetAudioParams(), std::abs(playback_speed_));
}
audio_playback_device_ = std::make_shared<PreviewAudioDevice>();
prequeuing_audio_ = true;
prequeuing_audio_ = 2; // Queue two buffers ahead of time
audio_playback_queue_time_ = GetTime();
for (int i=0; i<2; i++) {
for (int i=0; i<prequeuing_audio_; i++) {
QueueNextAudioBuffer();
}
}
@@ -714,7 +716,7 @@ void ViewerWidget::PauseInternal()
}
prequeuing_video_ = false;
prequeuing_audio_ = false;
prequeuing_audio_ = 0;
}
void ViewerWidget::PushScrubbedAudio()
+1 -1
View File
@@ -244,7 +244,7 @@ private:
int64_t playback_queue_next_frame_;
bool prequeuing_video_;
bool prequeuing_audio_;
int prequeuing_audio_;
QList<RenderTicketWatcher*> nonqueue_watchers_;