tests: coverage round 8 (serialization, folder, text/polygon, probe, render tail)
- node_save_load_test: Node Save/Load round trips for values, keyframes, hints, caches, connections, positions - node_polygon_folder_test: Folder child management, PolygonGenerator rasterization/gizmos, TextGeneratorV1/V2 - footage_probe_test: real FFmpeg/OIIO probing of demo.mp4/img.png, metadata cache, footage state transitions - render_tail_test: DynamicRenderer, color-context shader plumbing, PreviewAutoCacher pause/clear paths, DiskManager edges, AudioPlaybackCache segment I/O Also fixes AudioPlaybackCache::WritePartOfSampleBuffer, found by the new tests: zero padding was written via QFile::write(const char*) which treats the buffer as a NUL-terminated string, so no padding bytes were ever written; the write length was also computed from the segment end instead of the range end, making WriteSilence() spin forever on an empty buffer
This commit is contained in:
@@ -99,7 +99,9 @@ bool AudioPlaybackCache::WritePartOfSampleBuffer(const SampleBuffer &samples,
|
||||
int64_t segment_end = segment_start + kDefaultSegmentSizePerChannel;
|
||||
|
||||
int64_t offset_in_segment = current_cache_offset - segment_start;
|
||||
int64_t write_len = segment_end - offset_in_segment;
|
||||
// Never write past the end of the requested range
|
||||
int64_t write_len = std::min(segment_end - current_cache_offset,
|
||||
end_cache_offset - current_cache_offset);
|
||||
int64_t max_buffer_len = end_buffer_offset - current_buffer_offset;
|
||||
int64_t zero_len = 0;
|
||||
|
||||
@@ -119,13 +121,17 @@ bool AudioPlaybackCache::WritePartOfSampleBuffer(const SampleBuffer &samples,
|
||||
QFile f(filename);
|
||||
if (f.open(QFile::ReadWrite)) {
|
||||
f.seek(offset_in_segment);
|
||||
f.write(reinterpret_cast<const char *>(samples.data(channel)) +
|
||||
current_buffer_offset,
|
||||
write_len);
|
||||
if (write_len > 0) {
|
||||
f.write(reinterpret_cast<const char *>(samples.data(channel)) +
|
||||
current_buffer_offset,
|
||||
write_len);
|
||||
}
|
||||
|
||||
if (zero_len > 0) {
|
||||
// NOTE: the length must be passed explicitly; write(const
|
||||
// char*) would treat the zeros as an empty C string
|
||||
QByteArray b(zero_len, 0);
|
||||
f.write(b.constData());
|
||||
f.write(b.constData(), b.size());
|
||||
}
|
||||
|
||||
f.close();
|
||||
@@ -134,7 +140,7 @@ bool AudioPlaybackCache::WritePartOfSampleBuffer(const SampleBuffer &samples,
|
||||
}
|
||||
}
|
||||
|
||||
current_cache_offset += write_len;
|
||||
current_cache_offset += write_len + zero_len;
|
||||
current_buffer_offset += write_len;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user