Commit 181edf4b authored by Max Kellermann's avatar Max Kellermann

InputStream: make offset_type unsigned

parent dfa53cb8
...@@ -187,8 +187,6 @@ LoadEOSPacket(InputStream &is, Decoder *decoder, int serialno, ...@@ -187,8 +187,6 @@ LoadEOSPacket(InputStream &is, Decoder *decoder, int serialno,
return -1; return -1;
const auto old_offset = is.GetOffset(); const auto old_offset = is.GetOffset();
if (old_offset < 0)
return -1;
/* create temporary Ogg objects for seeking and parsing the /* create temporary Ogg objects for seeking and parsing the
EOS packet */ EOS packet */
...@@ -335,7 +333,6 @@ MPDOpusDecoder::Seek(OggSyncState &oy, double where_s) ...@@ -335,7 +333,6 @@ MPDOpusDecoder::Seek(OggSyncState &oy, double where_s)
assert(eos_granulepos > 0); assert(eos_granulepos > 0);
assert(input_stream.IsSeekable()); assert(input_stream.IsSeekable());
assert(input_stream.KnownSize()); assert(input_stream.KnownSize());
assert(input_stream.GetOffset() >= 0);
const ogg_int64_t where_granulepos(where_s * opus_sample_rate); const ogg_int64_t where_granulepos(where_s * opus_sample_rate);
......
...@@ -116,9 +116,6 @@ AsyncInputStream::Seek(offset_type new_offset, Error &error) ...@@ -116,9 +116,6 @@ AsyncInputStream::Seek(offset_type new_offset, Error &error)
if (!IsSeekable()) if (!IsSeekable())
return false; return false;
if (new_offset < 0)
return false;
/* check if we can fast-forward the buffer */ /* check if we can fast-forward the buffer */
while (new_offset > offset) { while (new_offset > offset) {
......
...@@ -35,7 +35,7 @@ struct Tag; ...@@ -35,7 +35,7 @@ struct Tag;
class InputStream { class InputStream {
public: public:
typedef int64_t offset_type; typedef uint64_t offset_type;
private: private:
/** /**
...@@ -236,8 +236,6 @@ public: ...@@ -236,8 +236,6 @@ public:
void AddOffset(offset_type delta) { void AddOffset(offset_type delta) {
assert(ready); assert(ready);
assert(offset >= 0);
assert(delta >= 0);
offset += delta; offset += delta;
} }
...@@ -253,7 +251,6 @@ public: ...@@ -253,7 +251,6 @@ public:
offset_type GetRest() const { offset_type GetRest() const {
assert(ready); assert(ready);
assert(KnownSize()); assert(KnownSize());
assert(offset >= 0);
return size - offset; return size - offset;
} }
......
...@@ -274,7 +274,7 @@ input_cdio_open(const char *uri, ...@@ -274,7 +274,7 @@ input_cdio_open(const char *uri,
bool bool
CdioParanoiaInputStream::Seek(offset_type new_offset, Error &error) CdioParanoiaInputStream::Seek(offset_type new_offset, Error &error)
{ {
if (new_offset < 0 || new_offset > size) { if (new_offset > size) {
error.Format(cdio_domain, "Invalid offset to seek %ld (%ld)", error.Format(cdio_domain, "Invalid offset to seek %ld (%ld)",
(long int)new_offset, (long int)size); (long int)new_offset, (long int)size);
return false; return false;
......
...@@ -101,13 +101,13 @@ input_file_open(const char *filename, ...@@ -101,13 +101,13 @@ input_file_open(const char *filename,
bool bool
FileInputStream::Seek(offset_type new_offset, Error &error) FileInputStream::Seek(offset_type new_offset, Error &error)
{ {
new_offset = (offset_type)lseek(fd, (off_t)new_offset, SEEK_SET); auto result = lseek(fd, (off_t)new_offset, SEEK_SET);
if (new_offset < 0) { if (result < 0) {
error.SetErrno("Failed to seek"); error.SetErrno("Failed to seek");
return false; return false;
} }
offset = new_offset; offset = (offset_type)result;
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment