rendertask: return errors and respond appropriately

Fixes #1348
This commit is contained in:
itsmattkc
2022-01-10 10:15:45 -08:00
parent e0c8a2e569
commit b40a61c6ed
6 changed files with 75 additions and 34 deletions
+31 -9
View File
@@ -156,7 +156,7 @@ bool ExportTask::Run()
return success;
}
void ExportTask::FrameDownloaded(FramePtr f, const QByteArray &hash, const QVector<rational> &times)
bool ExportTask::FrameDownloaded(FramePtr f, const QByteArray &hash, const QVector<rational> &times)
{
Q_UNUSED(hash)
@@ -180,14 +180,19 @@ void ExportTask::FrameDownloaded(FramePtr f, const QByteArray &hash, const QVect
// Unfortunately this can't be done in another thread since the frames need to be sent
// one after the other chronologically.
encoder_->WriteFrame(time_map_.take(real_time), real_time);
if (!encoder_->WriteFrame(time_map_.take(real_time), real_time)) {
SetError(encoder_->GetError());
return false;
}
frame_time_++;
emit ProgressChanged(double(frame_time_) / double(GetTotalNumberOfFrames()));
}
return true;
}
void ExportTask::AudioDownloaded(const TimeRange &range, SampleBufferPtr samples)
bool ExportTask::AudioDownloaded(const TimeRange &range, SampleBufferPtr samples)
{
TimeRange adjusted_range = range;
@@ -196,20 +201,33 @@ void ExportTask::AudioDownloaded(const TimeRange &range, SampleBufferPtr samples
}
if (adjusted_range.in() == audio_time_) {
WriteAudioLoop(adjusted_range, samples);
if (!WriteAudioLoop(adjusted_range, samples)) {
return false;
}
} else {
audio_map_.insert(adjusted_range, samples);
}
return true;
}
void ExportTask::EncodeSubtitle(const SubtitleBlock *sub)
bool ExportTask::EncodeSubtitle(const SubtitleBlock *sub)
{
encoder_->WriteSubtitle(sub);
if (!encoder_->WriteSubtitle(sub)) {
SetError(encoder_->GetError());
return false;
} else {
return true;
}
}
void ExportTask::WriteAudioLoop(const TimeRange& time, SampleBufferPtr samples)
bool ExportTask::WriteAudioLoop(const TimeRange& time, SampleBufferPtr samples)
{
encoder_->WriteAudio(samples);
if (!encoder_->WriteAudio(samples)) {
SetError(encoder_->GetError());
return false;
}
audio_time_ = time.out();
for (auto it=audio_map_.begin(); it!=audio_map_.end(); it++) {
@@ -221,12 +239,16 @@ void ExportTask::WriteAudioLoop(const TimeRange& time, SampleBufferPtr samples)
audio_map_.erase(it);
// Call recursively to write the next sample buffer
WriteAudioLoop(t, s);
if (!WriteAudioLoop(t, s)) {
return false;
}
// Break out of loop
break;
}
}
return true;
}
}