1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-20 06:46:55 +00:00

cache: simplify the check for printing the "cache stuck" message

This put some effort into distinguishing between two messages to print -
all worthless. Even more so, this kept printing the message, which
doesn't feel overly useful either. (The message will be printed
repeatedly anyway if network recovers for a while and then gets stuck
again.)

All in all, the demuxer cache triggering the buffering state does a
better job here. But don't remove it completely, since knowing that the
network did nothing for a relatively short time is still useful.
This commit is contained in:
wm4 2015-04-21 22:25:49 +02:00
parent 0b240bca8a
commit 3990fe74f6

View File

@ -18,7 +18,7 @@
// Time in seconds the main thread waits for the cache thread. On wakeups, the
// code checks for user requested aborts and also prints warnings that the
// cache is being slow.
#define CACHE_WAIT_TIME 0.5
#define CACHE_WAIT_TIME 1.0
// The time the cache sleeps in idle mode. This controls how often the cache
// retries reading from the stream after EOF has reached (in case the stream is
@ -32,9 +32,6 @@
// the cache is active.
#define CACHE_UPDATE_CONTROLS_TIME 2.0
// Time in seconds the cache prints a new message at all.
#define CACHE_NO_SPAM 5.0
#include <stdio.h>
#include <stdlib.h>
@ -81,7 +78,6 @@ struct priv {
// Owned by the main thread
stream_t *cache; // wrapper stream, used by demuxer etc.
double last_warn_time;
// Owned by the cache thread
stream_t *stream; // "real" stream, used to read from the source media
@ -138,22 +134,16 @@ static int cache_wakeup_and_wait(struct priv *s, double *retry_time)
return CACHE_INTERRUPTED;
double start = mp_time_sec();
if (!s->last_warn_time || start - s->last_warn_time >= CACHE_NO_SPAM) {
// Print a "more severe" warning after waiting 1 second and no new data
if ((*retry_time) >= 1.0) {
MP_ERR(s, "Cache keeps not responding.\n");
s->last_warn_time = start;
} else if (*retry_time > 0.1) {
MP_WARN(s, "Cache is not responding - slow/stuck network connection?\n");
s->last_warn_time = start;
}
if (*retry_time >= CACHE_WAIT_TIME) {
MP_WARN(s, "Cache is not responding - slow/stuck network connection?\n");
*retry_time = -1; // do not warn again for this call
}
pthread_cond_signal(&s->wakeup);
mpthread_cond_timedwait_rel(&s->wakeup, &s->mutex, CACHE_WAIT_TIME);
*retry_time += mp_time_sec() - start;
if (*retry_time >= 0)
*retry_time += mp_time_sec() - start;
return 0;
}