diff --git a/app/render/backend/renderbackend.cpp b/app/render/backend/renderbackend.cpp index 636b5808c..5a1c8d3bd 100644 --- a/app/render/backend/renderbackend.cpp +++ b/app/render/backend/renderbackend.cpp @@ -175,18 +175,19 @@ void RenderBackend::SetVideoDownloadMatrix(const QMatrix4x4 &mat) video_download_matrix_ = mat; } -QList RenderBackend::SplitRangeIntoChunks(const TimeRange &r) +std::list RenderBackend::SplitRangeIntoChunks(const TimeRange &r) { + // FIXME: Magic number const int chunk_size = 2; - QList split_ranges; + std::list split_ranges; int start_time = qFloor(r.in().toDouble() / static_cast(chunk_size)) * chunk_size; int end_time = qCeil(r.out().toDouble() / static_cast(chunk_size)) * chunk_size; for (int i=start_time; i SplitRangeIntoChunks(const TimeRange& r); + static std::list SplitRangeIntoChunks(const TimeRange& r); public slots: void NodeGraphChanged(NodeInput *source); diff --git a/app/task/render/render.cpp b/app/task/render/render.cpp index 175e3144d..133a6bf1d 100644 --- a/app/task/render/render.cpp +++ b/app/task/render/render.cpp @@ -74,16 +74,14 @@ void RenderTask::Render(const TimeRangeList& video_range, double total_length = 0; double video_frame_sz = video_params_.time_base().toDouble(); + std::list audio_queue; std::list audio_lookup_table; if (!audio_range.isEmpty()) { foreach (const TimeRange& r, audio_range) { total_length += r.length().toDouble(); - QList ranges = RenderBackend::SplitRangeIntoChunks(r); - - foreach (const TimeRange& split, ranges) { - audio_lookup_table.push_back({split, backend_.RenderAudio(split)}); - } + std::list ranges = RenderBackend::SplitRangeIntoChunks(r); + audio_queue.insert(audio_queue.end(), ranges.begin(), ranges.end()); } } @@ -123,6 +121,7 @@ void RenderTask::Render(const TimeRangeList& video_range, while (!IsCancelled() && (!render_lookup_table.empty() || !frame_queue.empty() + || !audio_queue.empty() || !download_futures.empty() || !audio_lookup_table.empty())) { @@ -168,6 +167,11 @@ void RenderTask::Render(const TimeRangeList& video_range, frame_queue.pop_front(); } + if (!audio_queue.empty()) { + audio_lookup_table.push_back({audio_queue.front(), backend_.RenderAudio(audio_queue.front())}); + audio_queue.pop_front(); + } + i = render_lookup_table.begin(); while (!IsCancelled() && i != render_lookup_table.end()) {