summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-04-21 22:25:49 +0200
committerwm4 <wm4@nowhere>2015-04-21 22:25:49 +0200
commit3990fe74f6597ee6f8950a5640378f703f596a7a (patch)
treef4923a0f7f16038e6141bb6430d7b4bca36294c4 /stream
parent0b240bca8aa27a861d6c56be6808662f0e49d26b (diff)
downloadmpv-3990fe74f6597ee6f8950a5640378f703f596a7a.tar.bz2
mpv-3990fe74f6597ee6f8950a5640378f703f596a7a.tar.xz
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.
Diffstat (limited to 'stream')
-rw-r--r--stream/cache.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/stream/cache.c b/stream/cache.c
index 51d228a08c..9aab8285c3 100644
--- a/stream/cache.c
+++ b/stream/cache.c
@@ -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;
}