mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 15:43:55 +02:00
Fixed streaming for big files.
This commit is contained in:
parent
308f106dc1
commit
88393eb77b
4 changed files with 8 additions and 7 deletions
|
@ -54,8 +54,9 @@ int64_t File::Context::Seek(void *opaque, int64_t offset, int whence) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int File::Context::read(bytes::span buffer) {
|
int File::Context::read(bytes::span buffer) {
|
||||||
Assert(_size >= _offset);
|
Expects(_size >= _offset);
|
||||||
const auto amount = std::min(std::size_t(_size - _offset), buffer.size());
|
|
||||||
|
const auto amount = std::min(_size - _offset, int64(buffer.size()));
|
||||||
|
|
||||||
if (unroll()) {
|
if (unroll()) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -102,7 +103,7 @@ int File::Context::read(bytes::span buffer) {
|
||||||
int64_t File::Context::seek(int64_t offset, int whence) {
|
int64_t File::Context::seek(int64_t offset, int whence) {
|
||||||
const auto checkedSeek = [&](int64_t offset) {
|
const auto checkedSeek = [&](int64_t offset) {
|
||||||
if (_failed || offset < 0 || offset > _size) {
|
if (_failed || offset < 0 || offset > _size) {
|
||||||
return -1;
|
return int64(-1);
|
||||||
}
|
}
|
||||||
return (_offset = offset);
|
return (_offset = offset);
|
||||||
};
|
};
|
||||||
|
|
|
@ -97,8 +97,8 @@ private:
|
||||||
const not_null<Reader*> _reader;
|
const not_null<Reader*> _reader;
|
||||||
|
|
||||||
base::flat_map<int, std::vector<FFmpeg::Packet>> _queuedPackets;
|
base::flat_map<int, std::vector<FFmpeg::Packet>> _queuedPackets;
|
||||||
int _offset = 0;
|
int64 _offset = 0;
|
||||||
int _size = 0;
|
int64 _size = 0;
|
||||||
bool _failed = false;
|
bool _failed = false;
|
||||||
bool _readTillEnd = false;
|
bool _readTillEnd = false;
|
||||||
std::optional<bool> _fullInCache;
|
std::optional<bool> _fullInCache;
|
||||||
|
|
|
@ -32,7 +32,7 @@ StreamedFileDownloader::StreamedFileDownloader(
|
||||||
|
|
||||||
// For FileLoader
|
// For FileLoader
|
||||||
const QString &toFile,
|
const QString &toFile,
|
||||||
int32 size,
|
int64 size,
|
||||||
LocationType locationType,
|
LocationType locationType,
|
||||||
LoadToCacheSetting toCache,
|
LoadToCacheSetting toCache,
|
||||||
LoadFromCloudSetting fromCloud,
|
LoadFromCloudSetting fromCloud,
|
||||||
|
|
|
@ -34,7 +34,7 @@ public:
|
||||||
|
|
||||||
// For FileLoader
|
// For FileLoader
|
||||||
const QString &toFile,
|
const QString &toFile,
|
||||||
int32 size,
|
int64 size,
|
||||||
LocationType locationType,
|
LocationType locationType,
|
||||||
LoadToCacheSetting toCache,
|
LoadToCacheSetting toCache,
|
||||||
LoadFromCloudSetting fromCloud,
|
LoadFromCloudSetting fromCloud,
|
||||||
|
|
Loading…
Add table
Reference in a new issue