mirror of
https://github.com/Qz3rK/tdesktop.git
synced 2026-07-03 14:15:08 +02:00
Fixed streaming for big files.
This commit is contained in:
@@ -54,8 +54,9 @@ int64_t File::Context::Seek(void *opaque, int64_t offset, int whence) {
|
||||
}
|
||||
|
||||
int File::Context::read(bytes::span buffer) {
|
||||
Assert(_size >= _offset);
|
||||
const auto amount = std::min(std::size_t(_size - _offset), buffer.size());
|
||||
Expects(_size >= _offset);
|
||||
|
||||
const auto amount = std::min(_size - _offset, int64(buffer.size()));
|
||||
|
||||
if (unroll()) {
|
||||
return -1;
|
||||
@@ -102,7 +103,7 @@ int File::Context::read(bytes::span buffer) {
|
||||
int64_t File::Context::seek(int64_t offset, int whence) {
|
||||
const auto checkedSeek = [&](int64_t offset) {
|
||||
if (_failed || offset < 0 || offset > _size) {
|
||||
return -1;
|
||||
return int64(-1);
|
||||
}
|
||||
return (_offset = offset);
|
||||
};
|
||||
|
||||
@@ -97,8 +97,8 @@ private:
|
||||
const not_null<Reader*> _reader;
|
||||
|
||||
base::flat_map<int, std::vector<FFmpeg::Packet>> _queuedPackets;
|
||||
int _offset = 0;
|
||||
int _size = 0;
|
||||
int64 _offset = 0;
|
||||
int64 _size = 0;
|
||||
bool _failed = false;
|
||||
bool _readTillEnd = false;
|
||||
std::optional<bool> _fullInCache;
|
||||
|
||||
@@ -32,7 +32,7 @@ StreamedFileDownloader::StreamedFileDownloader(
|
||||
|
||||
// For FileLoader
|
||||
const QString &toFile,
|
||||
int32 size,
|
||||
int64 size,
|
||||
LocationType locationType,
|
||||
LoadToCacheSetting toCache,
|
||||
LoadFromCloudSetting fromCloud,
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
|
||||
// For FileLoader
|
||||
const QString &toFile,
|
||||
int32 size,
|
||||
int64 size,
|
||||
LocationType locationType,
|
||||
LoadToCacheSetting toCache,
|
||||
LoadFromCloudSetting fromCloud,
|
||||
|
||||
Reference in New Issue
Block a user