mirror of
https://github.com/mpv-player/mpv
synced 2025-01-02 04:42:10 +00:00
cache: cache DVD volume ID
Since this might be queried every frame or so, it's important not to stall the cache by doing a synchronous stream_control().
This commit is contained in:
parent
42e70868ab
commit
f30149e80e
@ -113,6 +113,7 @@ struct priv {
|
||||
int stream_cache_idle;
|
||||
int stream_cache_fill;
|
||||
char **stream_metadata;
|
||||
char *dvd_volume_id;
|
||||
};
|
||||
|
||||
// Store additional per-byte metadata. Since per-byte would be way too
|
||||
@ -301,6 +302,7 @@ static void update_cached_controls(struct priv *s)
|
||||
unsigned int ui;
|
||||
double d;
|
||||
char **m;
|
||||
char *t;
|
||||
s->stream_time_length = 0;
|
||||
if (stream_control(s->stream, STREAM_CTRL_GET_TIME_LENGTH, &d) == STREAM_OK)
|
||||
s->stream_time_length = d;
|
||||
@ -317,6 +319,11 @@ static void update_cached_controls(struct priv *s)
|
||||
talloc_free(s->stream_metadata);
|
||||
s->stream_metadata = talloc_steal(s, m);
|
||||
}
|
||||
if (stream_control(s->stream, STREAM_CTRL_GET_DVD_VOLUME_ID, &t) == STREAM_OK)
|
||||
{
|
||||
talloc_free(s->dvd_volume_id);
|
||||
s->dvd_volume_id = talloc_steal(s, t);
|
||||
}
|
||||
stream_update_size(s->stream);
|
||||
s->stream_size = s->stream->end_pos;
|
||||
}
|
||||
@ -382,6 +389,12 @@ static int cache_get_cached_control(stream_t *cache, int cmd, void *arg)
|
||||
}
|
||||
return STREAM_UNSUPPORTED;
|
||||
}
|
||||
case STREAM_CTRL_GET_DVD_VOLUME_ID: {
|
||||
if (!s->dvd_volume_id)
|
||||
return STREAM_UNSUPPORTED;
|
||||
*(char **)arg = talloc_strdup(NULL, s->dvd_volume_id);
|
||||
return STREAM_OK;
|
||||
}
|
||||
case STREAM_CTRL_RESUME_CACHE:
|
||||
s->idle = s->eof = false;
|
||||
pthread_cond_signal(&s->wakeup);
|
||||
|
Loading…
Reference in New Issue
Block a user