summaryrefslogtreecommitdiffstats
path: root/stream/cache2.c
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-05-26 18:46:13 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-05-26 18:46:13 +0000
commit8e218ff32956e6279d909814bc7e7c7f82921729 (patch)
tree3de64b8891962bd78ea7072b4ddb4126c8fde72d /stream/cache2.c
parent68fef9a5173b5209f6c80e5dfdfebe129ca9de73 (diff)
downloadmpv-8e218ff32956e6279d909814bc7e7c7f82921729.tar.bz2
mpv-8e218ff32956e6279d909814bc7e7c7f82921729.tar.xz
Emulate STREAM_CTRL_GET_TIME_LENGTH if cache is used.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26879 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'stream/cache2.c')
-rw-r--r--stream/cache2.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/stream/cache2.c b/stream/cache2.c
index 584af1faf4..11d6574cf2 100644
--- a/stream/cache2.c
+++ b/stream/cache2.c
@@ -63,6 +63,7 @@ typedef struct {
volatile double control_double_arg;
volatile int control_res;
volatile off_t control_new_pos;
+ volatile double stream_time_length;
} cache_vars_t;
static int min_fill=0;
@@ -198,9 +199,17 @@ int cache_fill(cache_vars_t* s){
}
static void cache_execute_control(cache_vars_t *s) {
+ static unsigned last;
+ if (GetTimerMS() - last > 99) {
+ double len;
+ if (s->stream->control(s->stream, STREAM_CTRL_GET_TIME_LENGTH, &len) == STREAM_OK)
+ s->stream_time_length = len;
+ else
+ s->stream_time_length = 0;
+ last = GetTimerMS();
+ }
if (s->control == -1) return;
switch (s->control) {
- case STREAM_CTRL_GET_TIME_LENGTH:
case STREAM_CTRL_GET_CURRENT_TIME:
case STREAM_CTRL_SEEK_TO_TIME:
case STREAM_CTRL_GET_ASPECT_RATIO:
@@ -432,7 +441,9 @@ int cache_do_control(stream_t *stream, int cmd, void *arg) {
case STREAM_CTRL_GET_NUM_CHAPTERS:
case STREAM_CTRL_GET_CURRENT_CHAPTER:
// the core might call these every frame, they are too slow for this...
-// case STREAM_CTRL_GET_TIME_LENGTH:
+ case STREAM_CTRL_GET_TIME_LENGTH:
+ *(double *)arg = s->stream_time_length;
+ return s->stream_time_length ? STREAM_OK : STREAM_UNSUPPORTED;
// case STREAM_CTRL_GET_CURRENT_TIME:
case STREAM_CTRL_GET_ASPECT_RATIO:
case STREAM_CTRL_GET_NUM_ANGLES: