1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-28 03:10:55 +00:00

cache: fix compilation on Libav

Appears Libav doesn't have av_clip64(). So implement our own.
This commit is contained in:
wm4 2013-06-16 22:52:49 +02:00
parent 0221f16b36
commit fa30dc4154

View File

@ -119,6 +119,13 @@ enum {
CACHE_CTRL_PING = -2,
};
static int64_t mp_clipi64(int64_t val, int64_t min, int64_t max)
{
val = FFMIN(val, max);
val = FFMAX(val, min);
return val;
}
// pthread_cond_timedwait() with a relative timeout in seconds
static int cond_timed_wait(pthread_cond_t *cond, pthread_mutex_t *mutex,
double timeout)
@ -229,7 +236,7 @@ static bool cache_fill(struct priv *s)
}
// number of buffer bytes which should be preserved in backwards direction
int64_t back = av_clip64(read - s->min_filepos, 0, s->back_size);
int64_t back = mp_clipi64(read - s->min_filepos, 0, s->back_size);
// number of buffer bytes that are valid and can be read
int64_t newb = FFMAX(s->max_filepos - read, 0);