summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-07-16 22:40:21 +0200
committerwm4 <wm4@nowhere>2014-07-16 23:25:56 +0200
commit1301a907617459237fb0071b4640ad53d0ae491f (patch)
treea3eb637ac01f1f11c53922ac9589e2e826869f2c /stream
parent69a8f08f3e7cc0a9121c7fdb3499081fb2e34ddf (diff)
downloadmpv-1301a907617459237fb0071b4640ad53d0ae491f.tar.bz2
mpv-1301a907617459237fb0071b4640ad53d0ae491f.tar.xz
demux: add a demuxer thread
This adds a thread to the demuxer which reads packets asynchronously. It will do so until a configurable minimum packet queue size is reached. (See options.rst additions.) For now, the thread is disabled by default. There are some corner cases that have to be fixed, such as fixing cache behavior with webradios. Note that most interaction with the demuxer is still blocking, so if e.g. network dies, the player will still freeze. But this change will make it possible to remove most causes for freezing. Most of the new code in demux.c actually consists of weird caches to compensate for thread-safety issues (with the previously single-threaded design), or to avoid blocking by having to wait on the demuxer thread. Most of the changes in the player are due to the fact that we must not access the source stream directly. the demuxer thread already accesses it, and the stream stuff is not thread-safe. For timeline stuff (like ordered chapters), we enable the thread for the current segment only. We also clear its packet queue on seek, so that the remaining (unconsumed) readahead buffer doesn't waste memory. Keep in mind that insane subtitles (such as ASS typesetting muxed into mkv files) will practically disable the readahead, because the total queue size is considered when checking whether the minimum queue size was reached.
Diffstat (limited to 'stream')
-rw-r--r--stream/cache.c23
1 files changed, 0 insertions, 23 deletions
diff --git a/stream/cache.c b/stream/cache.c
index 197f7d3391..b1b3c9301f 100644
--- a/stream/cache.c
+++ b/stream/cache.c
@@ -110,11 +110,7 @@ struct priv {
// Cached STREAM_CTRLs
double stream_time_length;
int64_t stream_size;
- unsigned int stream_num_chapters;
- int stream_cache_idle;
- int stream_cache_fill;
struct mp_tags *stream_metadata;
- char *disc_name;
double start_pts;
};
@@ -352,26 +348,16 @@ static int resize_cache(struct priv *s, int64_t size)
static void update_cached_controls(struct priv *s)
{
- unsigned int ui;
int64_t i64;
double d;
struct mp_tags *tags;
- 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;
- s->stream_num_chapters = 0;
- if (stream_control(s->stream, STREAM_CTRL_GET_NUM_CHAPTERS, &ui) == STREAM_OK)
- s->stream_num_chapters = ui;
if (stream_control(s->stream, STREAM_CTRL_GET_METADATA, &tags) == STREAM_OK) {
talloc_free(s->stream_metadata);
s->stream_metadata = talloc_steal(s, tags);
}
- if (stream_control(s->stream, STREAM_CTRL_GET_DISC_NAME, &t) == STREAM_OK)
- {
- talloc_free(s->disc_name);
- s->disc_name = talloc_steal(s, t);
- }
s->stream_size = -1;
if (stream_control(s->stream, STREAM_CTRL_GET_SIZE, &i64) == STREAM_OK)
s->stream_size = i64;
@@ -399,9 +385,6 @@ static int cache_get_cached_control(stream_t *cache, int cmd, void *arg)
return STREAM_UNSUPPORTED;
*(int64_t *)arg = s->stream_size;
return STREAM_OK;
- case STREAM_CTRL_GET_NUM_CHAPTERS:
- *(unsigned int *)arg = s->stream_num_chapters;
- return STREAM_OK;
case STREAM_CTRL_GET_CURRENT_TIME: {
if (s->start_pts == MP_NOPTS_VALUE)
return STREAM_UNSUPPORTED;
@@ -417,12 +400,6 @@ static int cache_get_cached_control(stream_t *cache, int cmd, void *arg)
}
return STREAM_UNSUPPORTED;
}
- case STREAM_CTRL_GET_DISC_NAME: {
- if (!s->disc_name)
- return STREAM_UNSUPPORTED;
- *(char **)arg = talloc_strdup(NULL, s->disc_name);
- return STREAM_OK;
- }
case STREAM_CTRL_RESUME_CACHE:
s->idle = s->eof = false;
pthread_cond_signal(&s->wakeup);