summaryrefslogtreecommitdiffstats
path: root/demux
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-08-27 00:20:38 +0200
committerwm4 <wm4@nowhere>2014-08-27 00:20:38 +0200
commita8513f8b37343c27a4abea380ae0aa6bbae3894c (patch)
tree3d6779c304f222bf7d5b8b615cf05ae8fa36fcbc /demux
parent08b5dccd1212e442fa3105fc9f14ebe2e8fc445b (diff)
downloadmpv-a8513f8b37343c27a4abea380ae0aa6bbae3894c.tar.bz2
mpv-a8513f8b37343c27a4abea380ae0aa6bbae3894c.tar.xz
demux: reduce wakeups if no cache is active
The purpose of the unconditional pthread_cond_signal() when reading cached DEMUXER_CTRLs and STREAM_CTRLs was apparently to update the stream cache state. Otherwise, the cached fields would never be updated when the stream is e.g. paused. The same could be said about other CTRLs, but these aren't as important, since they are normally updated while reading packet data. In order to reduce wakeups, make this logic explicit.
Diffstat (limited to 'demux')
-rw-r--r--demux/demux.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/demux/demux.c b/demux/demux.c
index f27b8d1855..e54027cc9d 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -1112,6 +1112,10 @@ static void update_cache(struct demux_internal *in)
// must be called locked
static int cached_stream_control(struct demux_internal *in, int cmd, void *arg)
{
+ // If the cache is active, wake up the thread to possibly update cache state.
+ if (in->stream_cache_size >= 0)
+ pthread_cond_signal(&in->wakeup);
+
switch (cmd) {
case STREAM_CTRL_GET_CACHE_SIZE:
if (in->stream_cache_size < 0)
@@ -1156,6 +1160,7 @@ static int cached_demux_control(struct demux_internal *in, int cmd, void *arg)
}
case DEMUXER_CTRL_SWITCHED_TRACKS:
in->tracks_switched = true;
+ pthread_cond_signal(&in->wakeup);
return DEMUXER_CTRL_OK;
}
return DEMUXER_CTRL_DONTKNOW;
@@ -1167,7 +1172,6 @@ int demux_control(demuxer_t *demuxer, int cmd, void *arg)
if (in->threading) {
pthread_mutex_lock(&in->lock);
- pthread_cond_signal(&in->wakeup);
int cr = cached_demux_control(in, cmd, arg);
pthread_mutex_unlock(&in->lock);
if (cr != DEMUXER_CTRL_DONTKNOW)