summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--stream/cache2.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/stream/cache2.c b/stream/cache2.c
index 6a8b7c7a70..b643ed8897 100644
--- a/stream/cache2.c
+++ b/stream/cache2.c
@@ -64,6 +64,7 @@ static void *ThreadProc(void *s);
#include "stream.h"
#include "cache2.h"
+#include "mpcommon.h"
typedef struct {
// constats:
@@ -91,6 +92,7 @@ typedef struct {
volatile int control_res;
volatile off_t control_new_pos;
volatile double stream_time_length;
+ volatile double stream_time_pos;
} cache_vars_t;
static int min_fill=0;
@@ -260,17 +262,22 @@ static int cache_execute_control(cache_vars_t *s) {
int quit = s->control == -2;
if (quit || !s->stream->control) {
s->stream_time_length = 0;
+ s->stream_time_pos = MP_NOPTS_VALUE;
s->control_new_pos = 0;
s->control_res = STREAM_UNSUPPORTED;
s->control = -1;
return !quit;
}
if (GetTimerMS() - last > 99) {
- double len;
+ double len, pos;
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;
+ if (s->stream->control(s->stream, STREAM_CTRL_GET_CURRENT_TIME, &pos) == STREAM_OK)
+ s->stream_time_pos = pos;
+ else
+ s->stream_time_pos = MP_NOPTS_VALUE;
last = GetTimerMS();
}
if (s->control == -1) return 1;
@@ -581,11 +588,13 @@ int cache_do_control(stream_t *stream, int cmd, void *arg) {
s->control_uint_arg = *(unsigned *)arg;
s->control = cmd;
break;
+ // the core might call these every frame, so cache them...
case STREAM_CTRL_GET_TIME_LENGTH:
*(double *)arg = s->stream_time_length;
return s->stream_time_length ? STREAM_OK : STREAM_UNSUPPORTED;
-// the core might call this every frame, but it is too slow for this...
-// case STREAM_CTRL_GET_CURRENT_TIME:
+ case STREAM_CTRL_GET_CURRENT_TIME:
+ *(double *)arg = s->stream_time_pos;
+ return s->stream_time_pos != MP_NOPTS_VALUE ? STREAM_OK : STREAM_UNSUPPORTED;
case STREAM_CTRL_GET_NUM_CHAPTERS:
case STREAM_CTRL_GET_CURRENT_CHAPTER:
case STREAM_CTRL_GET_ASPECT_RATIO: