render: queue audio alongside video

Previously, audio was all queued first and would therefore all have to
finish before any video frames could start caching. No longer! Now they're
queued side by side so users won't have to wait for audio to finish before
their cached frames come in.
This commit is contained in:
itsmattkc
2020-06-16 03:49:12 +10:00
parent 3a4e13a04f
commit f70f266ca0
3 changed files with 15 additions and 10 deletions
+9 -5
View File
@@ -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<TimeRange> audio_queue;
std::list<RangeSampleFuturePair> audio_lookup_table;
if (!audio_range.isEmpty()) {
foreach (const TimeRange& r, audio_range) {
total_length += r.length().toDouble();
QList<TimeRange> ranges = RenderBackend::SplitRangeIntoChunks(r);
foreach (const TimeRange& split, ranges) {
audio_lookup_table.push_back({split, backend_.RenderAudio(split)});
}
std::list<TimeRange> 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()) {