diff options
author | wm4 <wm4@nowhere> | 2015-10-23 14:53:19 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-10-23 14:53:19 +0200 |
commit | 955c6843b6b7a491d1707104e5fad048cd1ab72c (patch) | |
tree | 25a603abddfebabb46869a0cef8d11a10ac580ca /demux | |
parent | d1528e51d50002a67b692ec359b61aba9258d3c2 (diff) | |
download | mpv-955c6843b6b7a491d1707104e5fad048cd1ab72c.tar.bz2 mpv-955c6843b6b7a491d1707104e5fad048cd1ab72c.tar.xz |
command: do not return 0 for bitrates if unknown
This makes the bitrate properties unavailable, instead of
returning 0 when:
1. No track is selected, or
2. Not enough packets have been read to have a bitrate estimate yet
Diffstat (limited to 'demux')
-rw-r--r-- | demux/demux.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/demux/demux.c b/demux/demux.c index 53fb5c6cad..3233541be2 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -1392,10 +1392,11 @@ static int cached_demux_control(struct demux_internal *in, int cmd, void *arg) case DEMUXER_CTRL_GET_BITRATE_STATS: { double *rates = arg; for (int n = 0; n < STREAM_TYPE_COUNT; n++) - rates[n] = 0; + rates[n] = -1; for (int n = 0; n < in->d_user->num_streams; n++) { struct demux_stream *ds = in->d_user->streams[n]->ds; - rates[ds->type] += MPMAX(0, ds->bitrate); + if (ds->selected && ds->bitrate >= 0) + rates[ds->type] = MPMAX(0, rates[ds->type]) + ds->bitrate; } return DEMUXER_CTRL_OK; } |