mirror of
https://github.com/mpv-player/mpv
synced 2024-11-14 22:48:35 +01:00
stream_file: remove file size caching
With the last 3 commits, this caching should be completely unnecessary.
This commit is contained in:
parent
1a54339705
commit
aafc434f00
@ -64,7 +64,6 @@ struct priv {
|
||||
bool use_poll;
|
||||
bool regular_file;
|
||||
bool appending;
|
||||
int64_t cached_size; // -2: invalid, -1: unknown
|
||||
int64_t orig_size;
|
||||
struct mp_cancel *cancel;
|
||||
};
|
||||
@ -76,25 +75,20 @@ struct priv {
|
||||
static int64_t get_size(stream_t *s)
|
||||
{
|
||||
struct priv *p = s->priv;
|
||||
if (p->cached_size == -2) {
|
||||
int64_t size = -1;
|
||||
struct stat st;
|
||||
if (fstat(p->fd, &st) == 0) {
|
||||
if (st.st_size <= 0 && !s->seekable)
|
||||
st.st_size = -1;
|
||||
size = st.st_size < 0 ? -1 : st.st_size;
|
||||
}
|
||||
p->cached_size = size;
|
||||
struct stat st;
|
||||
if (fstat(p->fd, &st) == 0) {
|
||||
if (st.st_size <= 0 && !s->seekable)
|
||||
st.st_size = -1;
|
||||
if (st.st_size >= 0)
|
||||
return st.st_size;
|
||||
}
|
||||
return p->cached_size;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int fill_buffer(stream_t *s, void *buffer, int max_len)
|
||||
{
|
||||
struct priv *p = s->priv;
|
||||
|
||||
p->cached_size = -2; // always invalidate cached size
|
||||
|
||||
#ifndef __MINGW32__
|
||||
if (p->use_poll) {
|
||||
int c = mp_cancel_get_fd(p->cancel);
|
||||
@ -257,7 +251,6 @@ static int open_f(stream_t *stream)
|
||||
struct priv *p = talloc_ptrtype(stream, p);
|
||||
*p = (struct priv) {
|
||||
.fd = -1,
|
||||
.cached_size = -2,
|
||||
};
|
||||
stream->priv = p;
|
||||
stream->is_local_file = true;
|
||||
|
Loading…
Reference in New Issue
Block a user