2013-10-29 21:38:29 +00:00
|
|
|
/*
|
2015-04-13 07:36:54 +00:00
|
|
|
* This file is part of mpv.
|
2013-10-29 21:38:29 +00:00
|
|
|
*
|
player: change license of most core files to LGPL
These files have all in common that they were fully or mostly taken from
mplayer.c. (mplayer.c was a huge file that contains almost all of the
playback core, until it was split into multiple parts.) This was
probably the hardest part to relicense, because so much code was moved
around all the time.
player/audio.c still does not compile. We'll have to redo audio
filtering. Once that is done, we can probably actually provide an
actual LGPL configure switch.
Here is a relatively detailed list of potential issues:
8d190244: author did not reply, parts were made GPL-only in a previous
commit.
7882ea9b: author could not be reached, but the code is gone. wscript
still has --datadir switch, but I don't think this is relevant to
copyright.
f197efd5: unclear origin, but I consider the code gone anyway (replaced
with generic OSD mechanisms).
8337d9c2: author did not reply, but only the option still exists (under
a different name), other code was removed.
d8fd7131: did not reply. Disabled in a previous commit.
05258251: same author as above. Both fields actually seem to have
vanished (even when tracking renames), so no action taken.
d459e644, 268b2c1a: author did not reply, but we reuse only the options
(with different names and slightly or fully different semantics, and
completely different implementations), so I don't think this is relevant
for copyright.
09e742fe, 17c39c4e: same as above.
e8a173de, bff4b3ee: author could not be reached. The commands were
reworked to properties, and the code outside of the TV code were moved
back to the TV code. So I don't think copyright applies to the current
command.c parts (mp_property_tv_color, mp_property_tv_freq,
mp_property_tv_scan). The TV parts remain GPL.
0810e427: could not be reached. Disabled in a previous commit.
43744a2d: unknown author, but this was replaced by dynamic alloc (if the
change is even copyrightable).
116ca0c7: unknown author; reasoning see input.c relicensing commit.
e7e4d1d8: these semantics still exist, but as generic code, and this
code was fully removed.
f1175cd9: the author of the cited patch is unknown, and upon inspection
it turns out that I was only using the idea to pause the player on EOF,
so I claim it's not copyright relevant.
25affdcc: author could not be reached (yet) - but it's only a function
rename, not copyrightable.
5728504c was committed by Arpi (who agreed), but hints that it might be
by a different author. In fact it seems to be mostly this patch:
http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2001-November/002041.html
The author did not respond, but it all seems to have been removed later.
It's a terrible mess though. Arpi reverted the A-V sync code at first,
but left the RTC code for a while. The following commits remove these
changes 100%: 14b35442, 7181a091, 31482783, 614f8475, df58e822.
cehoyos did explicitly not agree to LGPL, but was involved in the
following changes:
c99d8fc8: applied a patch and didn't modify it, the original author
agreed.
40ac0d31: author could not be reached, but all code is gone anyway. The
"af" command has a similar function, but works completely different and
actually reuses a mechanism older than this patch.
54350436: applied a patch, but didn't modify it, except for adding a
German translation, which was removed later.
a2dda036: same situation as above
240b743e: this was made GPL-only in a previous commit
7b25afd7: same as above (for now)
kirijua could not be reached, but was a regular patch contributor:
c2c997fd: video equalizer code move; probably not copyrightable. Is GPL
due to Nick anyway.
be54f481: technically, this became the audio track property later. But
all what is left is the fact that you pass a track ID to it, so consider
the original coypright non-relevant.
2f376d1b: this was rewritten in b7052b43, but for now we can afford to
be careful, so this was marked as GPL only in a previous commit.
43844d09: remaining parts in main.c were reverted in a previous commit.
anders has mostly disagreed with the LGPL relicensing. Does not want
libaf to become LGPL, but made some concessions. In particular, he
granted us permission to relicense 4943e9c52c and 242aa6ebd4. We also
consider some of his changes remaining in mpv not relevant for copyright
(such as 735de602 - we won't remove the this option completely). We will
completely remove his other contributions, including the entire audio
filter chain. For now, this stuff is marked as GPL only. The remaining
question is how much code in player/audio.c (based on the former
mplayer.c and dec_audio.c) is under his copyright. I made claims about
this in a previous commit.
Nick(ols) Kurshev, svn username "nick" and "nickols_k", could not be
reached. He had a lot of changes in early MPlayer. It seems all of that
was removed, at least in mpv. His main work, like VIDIX or libswscale
work, does not exist in mpv anymore, but the changes to mplayer.c and
other core parts still deserve attention:
a4119f6b, fb927549, ad3529b8, e11b23dc, 5f2178be, 93c371d5: removed in
b43d67e0, d1628d12, 24ed01fe, df58e822.
0a83c6ec, 104c125e, 4e067f62, aec5dcc8, b587a3d6, f3de6e6b: DR, VAA, and
"tune" stuff was fully removed later on or replaced with other
mechanisms.
340183b0: screenshots were redone later (the VOCTRL was even removed,
with an independent implementation using the same VOCTRL a few years
later), so not relevant anymore. Basically only the 's' shortcut remains
(but not its implementation).
92c5c274, bffd4007, 555c6766: for now marked as GPL only in a previous
commit.
Might contain some trace amounts of "michael"'s copyright, who agreed to
LGPL only once the core is relicensed. This will still be respected, but
I don't think it matters at this in this case. (Some code touched by him
was merged into mplayer.c, and then disappeared after heavy
refactoring.)
I tried to be as careful and as complete as possible. It can't be
excluded that amends to this will be made later.
This does not make the player LGPL yet.
2017-06-23 13:53:41 +00:00
|
|
|
* mpv is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2013-10-29 21:38:29 +00:00
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* mpv is distributed in the hope that it will be useful,
|
2013-10-29 21:38:29 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
player: change license of most core files to LGPL
These files have all in common that they were fully or mostly taken from
mplayer.c. (mplayer.c was a huge file that contains almost all of the
playback core, until it was split into multiple parts.) This was
probably the hardest part to relicense, because so much code was moved
around all the time.
player/audio.c still does not compile. We'll have to redo audio
filtering. Once that is done, we can probably actually provide an
actual LGPL configure switch.
Here is a relatively detailed list of potential issues:
8d190244: author did not reply, parts were made GPL-only in a previous
commit.
7882ea9b: author could not be reached, but the code is gone. wscript
still has --datadir switch, but I don't think this is relevant to
copyright.
f197efd5: unclear origin, but I consider the code gone anyway (replaced
with generic OSD mechanisms).
8337d9c2: author did not reply, but only the option still exists (under
a different name), other code was removed.
d8fd7131: did not reply. Disabled in a previous commit.
05258251: same author as above. Both fields actually seem to have
vanished (even when tracking renames), so no action taken.
d459e644, 268b2c1a: author did not reply, but we reuse only the options
(with different names and slightly or fully different semantics, and
completely different implementations), so I don't think this is relevant
for copyright.
09e742fe, 17c39c4e: same as above.
e8a173de, bff4b3ee: author could not be reached. The commands were
reworked to properties, and the code outside of the TV code were moved
back to the TV code. So I don't think copyright applies to the current
command.c parts (mp_property_tv_color, mp_property_tv_freq,
mp_property_tv_scan). The TV parts remain GPL.
0810e427: could not be reached. Disabled in a previous commit.
43744a2d: unknown author, but this was replaced by dynamic alloc (if the
change is even copyrightable).
116ca0c7: unknown author; reasoning see input.c relicensing commit.
e7e4d1d8: these semantics still exist, but as generic code, and this
code was fully removed.
f1175cd9: the author of the cited patch is unknown, and upon inspection
it turns out that I was only using the idea to pause the player on EOF,
so I claim it's not copyright relevant.
25affdcc: author could not be reached (yet) - but it's only a function
rename, not copyrightable.
5728504c was committed by Arpi (who agreed), but hints that it might be
by a different author. In fact it seems to be mostly this patch:
http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2001-November/002041.html
The author did not respond, but it all seems to have been removed later.
It's a terrible mess though. Arpi reverted the A-V sync code at first,
but left the RTC code for a while. The following commits remove these
changes 100%: 14b35442, 7181a091, 31482783, 614f8475, df58e822.
cehoyos did explicitly not agree to LGPL, but was involved in the
following changes:
c99d8fc8: applied a patch and didn't modify it, the original author
agreed.
40ac0d31: author could not be reached, but all code is gone anyway. The
"af" command has a similar function, but works completely different and
actually reuses a mechanism older than this patch.
54350436: applied a patch, but didn't modify it, except for adding a
German translation, which was removed later.
a2dda036: same situation as above
240b743e: this was made GPL-only in a previous commit
7b25afd7: same as above (for now)
kirijua could not be reached, but was a regular patch contributor:
c2c997fd: video equalizer code move; probably not copyrightable. Is GPL
due to Nick anyway.
be54f481: technically, this became the audio track property later. But
all what is left is the fact that you pass a track ID to it, so consider
the original coypright non-relevant.
2f376d1b: this was rewritten in b7052b43, but for now we can afford to
be careful, so this was marked as GPL only in a previous commit.
43844d09: remaining parts in main.c were reverted in a previous commit.
anders has mostly disagreed with the LGPL relicensing. Does not want
libaf to become LGPL, but made some concessions. In particular, he
granted us permission to relicense 4943e9c52c and 242aa6ebd4. We also
consider some of his changes remaining in mpv not relevant for copyright
(such as 735de602 - we won't remove the this option completely). We will
completely remove his other contributions, including the entire audio
filter chain. For now, this stuff is marked as GPL only. The remaining
question is how much code in player/audio.c (based on the former
mplayer.c and dec_audio.c) is under his copyright. I made claims about
this in a previous commit.
Nick(ols) Kurshev, svn username "nick" and "nickols_k", could not be
reached. He had a lot of changes in early MPlayer. It seems all of that
was removed, at least in mpv. His main work, like VIDIX or libswscale
work, does not exist in mpv anymore, but the changes to mplayer.c and
other core parts still deserve attention:
a4119f6b, fb927549, ad3529b8, e11b23dc, 5f2178be, 93c371d5: removed in
b43d67e0, d1628d12, 24ed01fe, df58e822.
0a83c6ec, 104c125e, 4e067f62, aec5dcc8, b587a3d6, f3de6e6b: DR, VAA, and
"tune" stuff was fully removed later on or replaced with other
mechanisms.
340183b0: screenshots were redone later (the VOCTRL was even removed,
with an independent implementation using the same VOCTRL a few years
later), so not relevant anymore. Basically only the 's' shortcut remains
(but not its implementation).
92c5c274, bffd4007, 555c6766: for now marked as GPL only in a previous
commit.
Might contain some trace amounts of "michael"'s copyright, who agreed to
LGPL only once the core is relicensed. This will still be respected, but
I don't think it matters at this in this case. (Some code touched by him
was merged into mplayer.c, and then disappeared after heavy
refactoring.)
I tried to be as careful and as complete as possible. It can't be
excluded that amends to this will be made later.
This does not make the player LGPL yet.
2017-06-23 13:53:41 +00:00
|
|
|
* GNU Lesser General Public License for more details.
|
2013-10-29 21:38:29 +00:00
|
|
|
*
|
player: change license of most core files to LGPL
These files have all in common that they were fully or mostly taken from
mplayer.c. (mplayer.c was a huge file that contains almost all of the
playback core, until it was split into multiple parts.) This was
probably the hardest part to relicense, because so much code was moved
around all the time.
player/audio.c still does not compile. We'll have to redo audio
filtering. Once that is done, we can probably actually provide an
actual LGPL configure switch.
Here is a relatively detailed list of potential issues:
8d190244: author did not reply, parts were made GPL-only in a previous
commit.
7882ea9b: author could not be reached, but the code is gone. wscript
still has --datadir switch, but I don't think this is relevant to
copyright.
f197efd5: unclear origin, but I consider the code gone anyway (replaced
with generic OSD mechanisms).
8337d9c2: author did not reply, but only the option still exists (under
a different name), other code was removed.
d8fd7131: did not reply. Disabled in a previous commit.
05258251: same author as above. Both fields actually seem to have
vanished (even when tracking renames), so no action taken.
d459e644, 268b2c1a: author did not reply, but we reuse only the options
(with different names and slightly or fully different semantics, and
completely different implementations), so I don't think this is relevant
for copyright.
09e742fe, 17c39c4e: same as above.
e8a173de, bff4b3ee: author could not be reached. The commands were
reworked to properties, and the code outside of the TV code were moved
back to the TV code. So I don't think copyright applies to the current
command.c parts (mp_property_tv_color, mp_property_tv_freq,
mp_property_tv_scan). The TV parts remain GPL.
0810e427: could not be reached. Disabled in a previous commit.
43744a2d: unknown author, but this was replaced by dynamic alloc (if the
change is even copyrightable).
116ca0c7: unknown author; reasoning see input.c relicensing commit.
e7e4d1d8: these semantics still exist, but as generic code, and this
code was fully removed.
f1175cd9: the author of the cited patch is unknown, and upon inspection
it turns out that I was only using the idea to pause the player on EOF,
so I claim it's not copyright relevant.
25affdcc: author could not be reached (yet) - but it's only a function
rename, not copyrightable.
5728504c was committed by Arpi (who agreed), but hints that it might be
by a different author. In fact it seems to be mostly this patch:
http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2001-November/002041.html
The author did not respond, but it all seems to have been removed later.
It's a terrible mess though. Arpi reverted the A-V sync code at first,
but left the RTC code for a while. The following commits remove these
changes 100%: 14b35442, 7181a091, 31482783, 614f8475, df58e822.
cehoyos did explicitly not agree to LGPL, but was involved in the
following changes:
c99d8fc8: applied a patch and didn't modify it, the original author
agreed.
40ac0d31: author could not be reached, but all code is gone anyway. The
"af" command has a similar function, but works completely different and
actually reuses a mechanism older than this patch.
54350436: applied a patch, but didn't modify it, except for adding a
German translation, which was removed later.
a2dda036: same situation as above
240b743e: this was made GPL-only in a previous commit
7b25afd7: same as above (for now)
kirijua could not be reached, but was a regular patch contributor:
c2c997fd: video equalizer code move; probably not copyrightable. Is GPL
due to Nick anyway.
be54f481: technically, this became the audio track property later. But
all what is left is the fact that you pass a track ID to it, so consider
the original coypright non-relevant.
2f376d1b: this was rewritten in b7052b43, but for now we can afford to
be careful, so this was marked as GPL only in a previous commit.
43844d09: remaining parts in main.c were reverted in a previous commit.
anders has mostly disagreed with the LGPL relicensing. Does not want
libaf to become LGPL, but made some concessions. In particular, he
granted us permission to relicense 4943e9c52c and 242aa6ebd4. We also
consider some of his changes remaining in mpv not relevant for copyright
(such as 735de602 - we won't remove the this option completely). We will
completely remove his other contributions, including the entire audio
filter chain. For now, this stuff is marked as GPL only. The remaining
question is how much code in player/audio.c (based on the former
mplayer.c and dec_audio.c) is under his copyright. I made claims about
this in a previous commit.
Nick(ols) Kurshev, svn username "nick" and "nickols_k", could not be
reached. He had a lot of changes in early MPlayer. It seems all of that
was removed, at least in mpv. His main work, like VIDIX or libswscale
work, does not exist in mpv anymore, but the changes to mplayer.c and
other core parts still deserve attention:
a4119f6b, fb927549, ad3529b8, e11b23dc, 5f2178be, 93c371d5: removed in
b43d67e0, d1628d12, 24ed01fe, df58e822.
0a83c6ec, 104c125e, 4e067f62, aec5dcc8, b587a3d6, f3de6e6b: DR, VAA, and
"tune" stuff was fully removed later on or replaced with other
mechanisms.
340183b0: screenshots were redone later (the VOCTRL was even removed,
with an independent implementation using the same VOCTRL a few years
later), so not relevant anymore. Basically only the 's' shortcut remains
(but not its implementation).
92c5c274, bffd4007, 555c6766: for now marked as GPL only in a previous
commit.
Might contain some trace amounts of "michael"'s copyright, who agreed to
LGPL only once the core is relicensed. This will still be respected, but
I don't think it matters at this in this case. (Some code touched by him
was merged into mplayer.c, and then disappeared after heavy
refactoring.)
I tried to be as careful and as complete as possible. It can't be
excluded that amends to this will be made later.
This does not make the player LGPL yet.
2017-06-23 13:53:41 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Parts under HAVE_GPL are licensed under GNU General Public License.
|
2013-10-29 21:38:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include "config.h"
|
2016-01-11 18:03:40 +00:00
|
|
|
#include "mpv_talloc.h"
|
2013-10-29 21:38:29 +00:00
|
|
|
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "common/msg.h"
|
2014-01-16 20:24:39 +00:00
|
|
|
#include "common/msg_control.h"
|
2013-12-17 01:02:25 +00:00
|
|
|
#include "options/options.h"
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "common/common.h"
|
2013-12-17 01:02:25 +00:00
|
|
|
#include "options/m_property.h"
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "common/encode.h"
|
2013-10-29 21:38:29 +00:00
|
|
|
|
2013-12-19 20:31:27 +00:00
|
|
|
#include "osdep/terminal.h"
|
2013-10-29 21:38:29 +00:00
|
|
|
#include "osdep/timer.h"
|
|
|
|
|
2013-11-23 21:08:42 +00:00
|
|
|
#include "demux/demux.h"
|
2014-08-27 20:42:28 +00:00
|
|
|
#include "stream/stream.h"
|
2013-11-24 11:58:06 +00:00
|
|
|
#include "sub/osd.h"
|
2013-10-29 21:38:29 +00:00
|
|
|
|
2016-01-16 20:19:52 +00:00
|
|
|
#include "video/decode/dec_video.h"
|
video: add VO framedropping mode
This mostly uses the same idea as with vo_vdpau.c, but much simplified.
On X11, it tries to get the display framerate with XF86VM, and limits
the frequency of new video frames against it. Note that this is an old
extension, and is confirmed not to work correctly with multi-monitor
setups. But we're using it because it was already around (it is also
used by vo_vdpau).
This attempts to predict the next vsync event by using the time of the
last frame and the display FPS. Even if that goes completely wrong,
the results are still relatively good.
On other systems, or if the X11 code doesn't return a display FPS, a
framerate of 1000 is assumed. This is infinite for all practical
purposes, and means that only frames which are definitely too late are
dropped. This probably has worse results, but is still useful.
"--framedrop=yes" is basically replaced with "--framedrop=decoder". The
old framedropping mode is kept around, and should perhaps be improved.
Dropping on the decoder level is still useful if decoding itself is too
slow.
2014-08-15 21:33:33 +00:00
|
|
|
#include "video/out/vo.h"
|
|
|
|
|
2013-12-17 00:08:53 +00:00
|
|
|
#include "core.h"
|
2013-10-29 21:38:29 +00:00
|
|
|
#include "command.h"
|
|
|
|
|
|
|
|
#define saddf(var, ...) (*(var) = talloc_asprintf_append((*var), __VA_ARGS__))
|
|
|
|
|
|
|
|
// append time in the hh:mm:ss format (plus fractions if wanted)
|
|
|
|
static void sadd_hhmmssff(char **buf, double time, bool fractions)
|
|
|
|
{
|
|
|
|
char *s = mp_format_time(time, fractions);
|
|
|
|
*buf = talloc_strdup_append(*buf, s);
|
|
|
|
talloc_free(s);
|
|
|
|
}
|
|
|
|
|
2015-10-16 14:16:10 +00:00
|
|
|
// If time unknown (MP_NOPTS_VALUE), use 0 instead.
|
|
|
|
static void sadd_hhmmssff_u(char **buf, double time, bool fractions)
|
|
|
|
{
|
|
|
|
if (time == MP_NOPTS_VALUE)
|
|
|
|
time = 0;
|
|
|
|
sadd_hhmmssff(buf, time, fractions);
|
|
|
|
}
|
|
|
|
|
2013-10-29 21:38:29 +00:00
|
|
|
static void sadd_percentage(char **buf, int percent) {
|
|
|
|
if (percent >= 0)
|
|
|
|
*buf = talloc_asprintf_append(*buf, " (%d%%)", percent);
|
|
|
|
}
|
|
|
|
|
player: redo terminal OSD and status line handling
The terminal OSD code includes the handling of the terminal status line,
showing player OSD messages on the terminal, and showing subtitles on
terminal (the latter two only if there is no video window, or if
terminal OSD is forced).
This didn't handle some corner cases correctly. For example, showing an
OSD message on the terminal always cleared the previous line, even if
the line was an important message (or even just the command prompt, if
most other messages were silenced).
Attempt to handle this correctly by keeping track of how many lines the
terminal OSD currently consists of. Since there could be race conditions
with other messages being printed, implement this in msg.c. Now msg.c
expects that MSGL_STATUS messages rewrite the status line, so the caller
is forced to use a single mp_msg() call to set the status line.
Instead of littering print_status() all over the place, update the
status only once per playloop iteration in update_osd_msg(). In audio-
only mode, the status line might now be a little bit off, but it's
perhaps ok.
Print the status line only if it has changed, or if another message was
printed. This might help with extremely slow terminals, although in
audio+video mode, it'll still be updated very often (A-V sync display
changes on every frame).
Instead of hardcoding the terminal sequences, use
terminfo/termcap to get the sequences. Remove the --term-osd-esc option,
which allowed to override the hardcoded escapes - it's useless now.
The fallback for terminals with no escape sequences for moving the
cursor and clearing a line is removed. This somewhat breaks status line
display on these terminals, including the MS Windows console: instead of
querying the terminal size and clearing the line manually by padding the
output with spaces, the line is simply not cleared. I don't expect this
to be a problem on UNIX, and on MS Windows we could emulate escape
sequences. Note that terminal OSD (other than the status line) was
broken anyway on these terminals.
In osd.c, the function get_term_width() is not used anymore, so remove
it. To remind us that the MS Windows console apparently adds a line
break when writint the last column, adjust screen_width in terminal-
win.c accordingly.
2014-01-13 19:05:41 +00:00
|
|
|
static char *join_lines(void *ta_ctx, char **parts, int num_parts)
|
2013-10-29 21:38:29 +00:00
|
|
|
{
|
player: redo terminal OSD and status line handling
The terminal OSD code includes the handling of the terminal status line,
showing player OSD messages on the terminal, and showing subtitles on
terminal (the latter two only if there is no video window, or if
terminal OSD is forced).
This didn't handle some corner cases correctly. For example, showing an
OSD message on the terminal always cleared the previous line, even if
the line was an important message (or even just the command prompt, if
most other messages were silenced).
Attempt to handle this correctly by keeping track of how many lines the
terminal OSD currently consists of. Since there could be race conditions
with other messages being printed, implement this in msg.c. Now msg.c
expects that MSGL_STATUS messages rewrite the status line, so the caller
is forced to use a single mp_msg() call to set the status line.
Instead of littering print_status() all over the place, update the
status only once per playloop iteration in update_osd_msg(). In audio-
only mode, the status line might now be a little bit off, but it's
perhaps ok.
Print the status line only if it has changed, or if another message was
printed. This might help with extremely slow terminals, although in
audio+video mode, it'll still be updated very often (A-V sync display
changes on every frame).
Instead of hardcoding the terminal sequences, use
terminfo/termcap to get the sequences. Remove the --term-osd-esc option,
which allowed to override the hardcoded escapes - it's useless now.
The fallback for terminals with no escape sequences for moving the
cursor and clearing a line is removed. This somewhat breaks status line
display on these terminals, including the MS Windows console: instead of
querying the terminal size and clearing the line manually by padding the
output with spaces, the line is simply not cleared. I don't expect this
to be a problem on UNIX, and on MS Windows we could emulate escape
sequences. Note that terminal OSD (other than the status line) was
broken anyway on these terminals.
In osd.c, the function get_term_width() is not used anymore, so remove
it. To remind us that the MS Windows console apparently adds a line
break when writint the last column, adjust screen_width in terminal-
win.c accordingly.
2014-01-13 19:05:41 +00:00
|
|
|
char *res = talloc_strdup(ta_ctx, "");
|
|
|
|
for (int n = 0; n < num_parts; n++)
|
|
|
|
res = talloc_asprintf_append(res, "%s%s", n ? "\n" : "", parts[n]);
|
|
|
|
return res;
|
2013-10-29 21:38:29 +00:00
|
|
|
}
|
|
|
|
|
player: redo terminal OSD and status line handling
The terminal OSD code includes the handling of the terminal status line,
showing player OSD messages on the terminal, and showing subtitles on
terminal (the latter two only if there is no video window, or if
terminal OSD is forced).
This didn't handle some corner cases correctly. For example, showing an
OSD message on the terminal always cleared the previous line, even if
the line was an important message (or even just the command prompt, if
most other messages were silenced).
Attempt to handle this correctly by keeping track of how many lines the
terminal OSD currently consists of. Since there could be race conditions
with other messages being printed, implement this in msg.c. Now msg.c
expects that MSGL_STATUS messages rewrite the status line, so the caller
is forced to use a single mp_msg() call to set the status line.
Instead of littering print_status() all over the place, update the
status only once per playloop iteration in update_osd_msg(). In audio-
only mode, the status line might now be a little bit off, but it's
perhaps ok.
Print the status line only if it has changed, or if another message was
printed. This might help with extremely slow terminals, although in
audio+video mode, it'll still be updated very often (A-V sync display
changes on every frame).
Instead of hardcoding the terminal sequences, use
terminfo/termcap to get the sequences. Remove the --term-osd-esc option,
which allowed to override the hardcoded escapes - it's useless now.
The fallback for terminals with no escape sequences for moving the
cursor and clearing a line is removed. This somewhat breaks status line
display on these terminals, including the MS Windows console: instead of
querying the terminal size and clearing the line manually by padding the
output with spaces, the line is simply not cleared. I don't expect this
to be a problem on UNIX, and on MS Windows we could emulate escape
sequences. Note that terminal OSD (other than the status line) was
broken anyway on these terminals.
In osd.c, the function get_term_width() is not used anymore, so remove
it. To remind us that the MS Windows console apparently adds a line
break when writint the last column, adjust screen_width in terminal-
win.c accordingly.
2014-01-13 19:05:41 +00:00
|
|
|
static void term_osd_update(struct MPContext *mpctx)
|
2013-10-29 21:38:29 +00:00
|
|
|
{
|
player: redo terminal OSD and status line handling
The terminal OSD code includes the handling of the terminal status line,
showing player OSD messages on the terminal, and showing subtitles on
terminal (the latter two only if there is no video window, or if
terminal OSD is forced).
This didn't handle some corner cases correctly. For example, showing an
OSD message on the terminal always cleared the previous line, even if
the line was an important message (or even just the command prompt, if
most other messages were silenced).
Attempt to handle this correctly by keeping track of how many lines the
terminal OSD currently consists of. Since there could be race conditions
with other messages being printed, implement this in msg.c. Now msg.c
expects that MSGL_STATUS messages rewrite the status line, so the caller
is forced to use a single mp_msg() call to set the status line.
Instead of littering print_status() all over the place, update the
status only once per playloop iteration in update_osd_msg(). In audio-
only mode, the status line might now be a little bit off, but it's
perhaps ok.
Print the status line only if it has changed, or if another message was
printed. This might help with extremely slow terminals, although in
audio+video mode, it'll still be updated very often (A-V sync display
changes on every frame).
Instead of hardcoding the terminal sequences, use
terminfo/termcap to get the sequences. Remove the --term-osd-esc option,
which allowed to override the hardcoded escapes - it's useless now.
The fallback for terminals with no escape sequences for moving the
cursor and clearing a line is removed. This somewhat breaks status line
display on these terminals, including the MS Windows console: instead of
querying the terminal size and clearing the line manually by padding the
output with spaces, the line is simply not cleared. I don't expect this
to be a problem on UNIX, and on MS Windows we could emulate escape
sequences. Note that terminal OSD (other than the status line) was
broken anyway on these terminals.
In osd.c, the function get_term_width() is not used anymore, so remove
it. To remind us that the MS Windows console apparently adds a line
break when writint the last column, adjust screen_width in terminal-
win.c accordingly.
2014-01-13 19:05:41 +00:00
|
|
|
int num_parts = 0;
|
2014-01-17 20:55:23 +00:00
|
|
|
char *parts[3] = {0};
|
player: redo terminal OSD and status line handling
The terminal OSD code includes the handling of the terminal status line,
showing player OSD messages on the terminal, and showing subtitles on
terminal (the latter two only if there is no video window, or if
terminal OSD is forced).
This didn't handle some corner cases correctly. For example, showing an
OSD message on the terminal always cleared the previous line, even if
the line was an important message (or even just the command prompt, if
most other messages were silenced).
Attempt to handle this correctly by keeping track of how many lines the
terminal OSD currently consists of. Since there could be race conditions
with other messages being printed, implement this in msg.c. Now msg.c
expects that MSGL_STATUS messages rewrite the status line, so the caller
is forced to use a single mp_msg() call to set the status line.
Instead of littering print_status() all over the place, update the
status only once per playloop iteration in update_osd_msg(). In audio-
only mode, the status line might now be a little bit off, but it's
perhaps ok.
Print the status line only if it has changed, or if another message was
printed. This might help with extremely slow terminals, although in
audio+video mode, it'll still be updated very often (A-V sync display
changes on every frame).
Instead of hardcoding the terminal sequences, use
terminfo/termcap to get the sequences. Remove the --term-osd-esc option,
which allowed to override the hardcoded escapes - it's useless now.
The fallback for terminals with no escape sequences for moving the
cursor and clearing a line is removed. This somewhat breaks status line
display on these terminals, including the MS Windows console: instead of
querying the terminal size and clearing the line manually by padding the
output with spaces, the line is simply not cleared. I don't expect this
to be a problem on UNIX, and on MS Windows we could emulate escape
sequences. Note that terminal OSD (other than the status line) was
broken anyway on these terminals.
In osd.c, the function get_term_width() is not used anymore, so remove
it. To remind us that the MS Windows console apparently adds a line
break when writint the last column, adjust screen_width in terminal-
win.c accordingly.
2014-01-13 19:05:41 +00:00
|
|
|
|
2014-02-06 15:49:50 +00:00
|
|
|
if (!mpctx->opts->use_terminal)
|
|
|
|
return;
|
|
|
|
|
2014-01-17 20:55:23 +00:00
|
|
|
if (mpctx->term_osd_subs && mpctx->term_osd_subs[0])
|
|
|
|
parts[num_parts++] = mpctx->term_osd_subs;
|
player: redo terminal OSD and status line handling
The terminal OSD code includes the handling of the terminal status line,
showing player OSD messages on the terminal, and showing subtitles on
terminal (the latter two only if there is no video window, or if
terminal OSD is forced).
This didn't handle some corner cases correctly. For example, showing an
OSD message on the terminal always cleared the previous line, even if
the line was an important message (or even just the command prompt, if
most other messages were silenced).
Attempt to handle this correctly by keeping track of how many lines the
terminal OSD currently consists of. Since there could be race conditions
with other messages being printed, implement this in msg.c. Now msg.c
expects that MSGL_STATUS messages rewrite the status line, so the caller
is forced to use a single mp_msg() call to set the status line.
Instead of littering print_status() all over the place, update the
status only once per playloop iteration in update_osd_msg(). In audio-
only mode, the status line might now be a little bit off, but it's
perhaps ok.
Print the status line only if it has changed, or if another message was
printed. This might help with extremely slow terminals, although in
audio+video mode, it'll still be updated very often (A-V sync display
changes on every frame).
Instead of hardcoding the terminal sequences, use
terminfo/termcap to get the sequences. Remove the --term-osd-esc option,
which allowed to override the hardcoded escapes - it's useless now.
The fallback for terminals with no escape sequences for moving the
cursor and clearing a line is removed. This somewhat breaks status line
display on these terminals, including the MS Windows console: instead of
querying the terminal size and clearing the line manually by padding the
output with spaces, the line is simply not cleared. I don't expect this
to be a problem on UNIX, and on MS Windows we could emulate escape
sequences. Note that terminal OSD (other than the status line) was
broken anyway on these terminals.
In osd.c, the function get_term_width() is not used anymore, so remove
it. To remind us that the MS Windows console apparently adds a line
break when writint the last column, adjust screen_width in terminal-
win.c accordingly.
2014-01-13 19:05:41 +00:00
|
|
|
if (mpctx->term_osd_text && mpctx->term_osd_text[0])
|
|
|
|
parts[num_parts++] = mpctx->term_osd_text;
|
|
|
|
if (mpctx->term_osd_status && mpctx->term_osd_status[0])
|
|
|
|
parts[num_parts++] = mpctx->term_osd_status;
|
|
|
|
|
|
|
|
char *s = join_lines(mpctx, parts, num_parts);
|
|
|
|
|
|
|
|
if (strcmp(mpctx->term_osd_contents, s) == 0 &&
|
|
|
|
mp_msg_has_status_line(mpctx->global))
|
|
|
|
{
|
|
|
|
talloc_free(s);
|
2013-10-29 21:38:29 +00:00
|
|
|
} else {
|
player: redo terminal OSD and status line handling
The terminal OSD code includes the handling of the terminal status line,
showing player OSD messages on the terminal, and showing subtitles on
terminal (the latter two only if there is no video window, or if
terminal OSD is forced).
This didn't handle some corner cases correctly. For example, showing an
OSD message on the terminal always cleared the previous line, even if
the line was an important message (or even just the command prompt, if
most other messages were silenced).
Attempt to handle this correctly by keeping track of how many lines the
terminal OSD currently consists of. Since there could be race conditions
with other messages being printed, implement this in msg.c. Now msg.c
expects that MSGL_STATUS messages rewrite the status line, so the caller
is forced to use a single mp_msg() call to set the status line.
Instead of littering print_status() all over the place, update the
status only once per playloop iteration in update_osd_msg(). In audio-
only mode, the status line might now be a little bit off, but it's
perhaps ok.
Print the status line only if it has changed, or if another message was
printed. This might help with extremely slow terminals, although in
audio+video mode, it'll still be updated very often (A-V sync display
changes on every frame).
Instead of hardcoding the terminal sequences, use
terminfo/termcap to get the sequences. Remove the --term-osd-esc option,
which allowed to override the hardcoded escapes - it's useless now.
The fallback for terminals with no escape sequences for moving the
cursor and clearing a line is removed. This somewhat breaks status line
display on these terminals, including the MS Windows console: instead of
querying the terminal size and clearing the line manually by padding the
output with spaces, the line is simply not cleared. I don't expect this
to be a problem on UNIX, and on MS Windows we could emulate escape
sequences. Note that terminal OSD (other than the status line) was
broken anyway on these terminals.
In osd.c, the function get_term_width() is not used anymore, so remove
it. To remind us that the MS Windows console apparently adds a line
break when writint the last column, adjust screen_width in terminal-
win.c accordingly.
2014-01-13 19:05:41 +00:00
|
|
|
talloc_free(mpctx->term_osd_contents);
|
|
|
|
mpctx->term_osd_contents = s;
|
|
|
|
mp_msg(mpctx->statusline, MSGL_STATUS, "%s", s);
|
2013-10-29 21:38:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-17 00:54:02 +00:00
|
|
|
void term_osd_set_subs(struct MPContext *mpctx, const char *text)
|
2014-01-17 20:55:23 +00:00
|
|
|
{
|
|
|
|
if (mpctx->video_out || !text)
|
|
|
|
text = ""; // disable
|
|
|
|
if (strcmp(mpctx->term_osd_subs ? mpctx->term_osd_subs : "", text) == 0)
|
|
|
|
return;
|
|
|
|
talloc_free(mpctx->term_osd_subs);
|
|
|
|
mpctx->term_osd_subs = talloc_strdup(mpctx, text);
|
|
|
|
term_osd_update(mpctx);
|
|
|
|
}
|
|
|
|
|
2016-08-26 18:27:46 +00:00
|
|
|
static void term_osd_set_text_lazy(struct MPContext *mpctx, const char *text)
|
player: redo terminal OSD and status line handling
The terminal OSD code includes the handling of the terminal status line,
showing player OSD messages on the terminal, and showing subtitles on
terminal (the latter two only if there is no video window, or if
terminal OSD is forced).
This didn't handle some corner cases correctly. For example, showing an
OSD message on the terminal always cleared the previous line, even if
the line was an important message (or even just the command prompt, if
most other messages were silenced).
Attempt to handle this correctly by keeping track of how many lines the
terminal OSD currently consists of. Since there could be race conditions
with other messages being printed, implement this in msg.c. Now msg.c
expects that MSGL_STATUS messages rewrite the status line, so the caller
is forced to use a single mp_msg() call to set the status line.
Instead of littering print_status() all over the place, update the
status only once per playloop iteration in update_osd_msg(). In audio-
only mode, the status line might now be a little bit off, but it's
perhaps ok.
Print the status line only if it has changed, or if another message was
printed. This might help with extremely slow terminals, although in
audio+video mode, it'll still be updated very often (A-V sync display
changes on every frame).
Instead of hardcoding the terminal sequences, use
terminfo/termcap to get the sequences. Remove the --term-osd-esc option,
which allowed to override the hardcoded escapes - it's useless now.
The fallback for terminals with no escape sequences for moving the
cursor and clearing a line is removed. This somewhat breaks status line
display on these terminals, including the MS Windows console: instead of
querying the terminal size and clearing the line manually by padding the
output with spaces, the line is simply not cleared. I don't expect this
to be a problem on UNIX, and on MS Windows we could emulate escape
sequences. Note that terminal OSD (other than the status line) was
broken anyway on these terminals.
In osd.c, the function get_term_width() is not used anymore, so remove
it. To remind us that the MS Windows console apparently adds a line
break when writint the last column, adjust screen_width in terminal-
win.c accordingly.
2014-01-13 19:05:41 +00:00
|
|
|
{
|
2016-08-28 16:15:37 +00:00
|
|
|
bool video_osd = mpctx->video_out && mpctx->opts->video_osd;
|
|
|
|
if ((video_osd && mpctx->opts->term_osd != 1) || !text)
|
player: redo terminal OSD and status line handling
The terminal OSD code includes the handling of the terminal status line,
showing player OSD messages on the terminal, and showing subtitles on
terminal (the latter two only if there is no video window, or if
terminal OSD is forced).
This didn't handle some corner cases correctly. For example, showing an
OSD message on the terminal always cleared the previous line, even if
the line was an important message (or even just the command prompt, if
most other messages were silenced).
Attempt to handle this correctly by keeping track of how many lines the
terminal OSD currently consists of. Since there could be race conditions
with other messages being printed, implement this in msg.c. Now msg.c
expects that MSGL_STATUS messages rewrite the status line, so the caller
is forced to use a single mp_msg() call to set the status line.
Instead of littering print_status() all over the place, update the
status only once per playloop iteration in update_osd_msg(). In audio-
only mode, the status line might now be a little bit off, but it's
perhaps ok.
Print the status line only if it has changed, or if another message was
printed. This might help with extremely slow terminals, although in
audio+video mode, it'll still be updated very often (A-V sync display
changes on every frame).
Instead of hardcoding the terminal sequences, use
terminfo/termcap to get the sequences. Remove the --term-osd-esc option,
which allowed to override the hardcoded escapes - it's useless now.
The fallback for terminals with no escape sequences for moving the
cursor and clearing a line is removed. This somewhat breaks status line
display on these terminals, including the MS Windows console: instead of
querying the terminal size and clearing the line manually by padding the
output with spaces, the line is simply not cleared. I don't expect this
to be a problem on UNIX, and on MS Windows we could emulate escape
sequences. Note that terminal OSD (other than the status line) was
broken anyway on these terminals.
In osd.c, the function get_term_width() is not used anymore, so remove
it. To remind us that the MS Windows console apparently adds a line
break when writint the last column, adjust screen_width in terminal-
win.c accordingly.
2014-01-13 19:05:41 +00:00
|
|
|
text = ""; // disable
|
|
|
|
talloc_free(mpctx->term_osd_text);
|
|
|
|
mpctx->term_osd_text = talloc_strdup(mpctx, text);
|
|
|
|
}
|
|
|
|
|
2016-08-26 18:27:46 +00:00
|
|
|
static void term_osd_set_status_lazy(struct MPContext *mpctx, const char *text)
|
player: redo terminal OSD and status line handling
The terminal OSD code includes the handling of the terminal status line,
showing player OSD messages on the terminal, and showing subtitles on
terminal (the latter two only if there is no video window, or if
terminal OSD is forced).
This didn't handle some corner cases correctly. For example, showing an
OSD message on the terminal always cleared the previous line, even if
the line was an important message (or even just the command prompt, if
most other messages were silenced).
Attempt to handle this correctly by keeping track of how many lines the
terminal OSD currently consists of. Since there could be race conditions
with other messages being printed, implement this in msg.c. Now msg.c
expects that MSGL_STATUS messages rewrite the status line, so the caller
is forced to use a single mp_msg() call to set the status line.
Instead of littering print_status() all over the place, update the
status only once per playloop iteration in update_osd_msg(). In audio-
only mode, the status line might now be a little bit off, but it's
perhaps ok.
Print the status line only if it has changed, or if another message was
printed. This might help with extremely slow terminals, although in
audio+video mode, it'll still be updated very often (A-V sync display
changes on every frame).
Instead of hardcoding the terminal sequences, use
terminfo/termcap to get the sequences. Remove the --term-osd-esc option,
which allowed to override the hardcoded escapes - it's useless now.
The fallback for terminals with no escape sequences for moving the
cursor and clearing a line is removed. This somewhat breaks status line
display on these terminals, including the MS Windows console: instead of
querying the terminal size and clearing the line manually by padding the
output with spaces, the line is simply not cleared. I don't expect this
to be a problem on UNIX, and on MS Windows we could emulate escape
sequences. Note that terminal OSD (other than the status line) was
broken anyway on these terminals.
In osd.c, the function get_term_width() is not used anymore, so remove
it. To remind us that the MS Windows console apparently adds a line
break when writint the last column, adjust screen_width in terminal-
win.c accordingly.
2014-01-13 19:05:41 +00:00
|
|
|
{
|
|
|
|
talloc_free(mpctx->term_osd_status);
|
|
|
|
mpctx->term_osd_status = talloc_strdup(mpctx, text);
|
2016-07-06 17:52:09 +00:00
|
|
|
|
|
|
|
int w = 80, h = 24;
|
|
|
|
terminal_get_size(&w, &h);
|
2016-07-15 16:58:36 +00:00
|
|
|
if (strlen(mpctx->term_osd_status) > w && !strchr(mpctx->term_osd_status, '\n'))
|
2016-07-06 17:52:09 +00:00
|
|
|
mpctx->term_osd_status[w] = '\0';
|
player: redo terminal OSD and status line handling
The terminal OSD code includes the handling of the terminal status line,
showing player OSD messages on the terminal, and showing subtitles on
terminal (the latter two only if there is no video window, or if
terminal OSD is forced).
This didn't handle some corner cases correctly. For example, showing an
OSD message on the terminal always cleared the previous line, even if
the line was an important message (or even just the command prompt, if
most other messages were silenced).
Attempt to handle this correctly by keeping track of how many lines the
terminal OSD currently consists of. Since there could be race conditions
with other messages being printed, implement this in msg.c. Now msg.c
expects that MSGL_STATUS messages rewrite the status line, so the caller
is forced to use a single mp_msg() call to set the status line.
Instead of littering print_status() all over the place, update the
status only once per playloop iteration in update_osd_msg(). In audio-
only mode, the status line might now be a little bit off, but it's
perhaps ok.
Print the status line only if it has changed, or if another message was
printed. This might help with extremely slow terminals, although in
audio+video mode, it'll still be updated very often (A-V sync display
changes on every frame).
Instead of hardcoding the terminal sequences, use
terminfo/termcap to get the sequences. Remove the --term-osd-esc option,
which allowed to override the hardcoded escapes - it's useless now.
The fallback for terminals with no escape sequences for moving the
cursor and clearing a line is removed. This somewhat breaks status line
display on these terminals, including the MS Windows console: instead of
querying the terminal size and clearing the line manually by padding the
output with spaces, the line is simply not cleared. I don't expect this
to be a problem on UNIX, and on MS Windows we could emulate escape
sequences. Note that terminal OSD (other than the status line) was
broken anyway on these terminals.
In osd.c, the function get_term_width() is not used anymore, so remove
it. To remind us that the MS Windows console apparently adds a line
break when writint the last column, adjust screen_width in terminal-
win.c accordingly.
2014-01-13 19:05:41 +00:00
|
|
|
}
|
|
|
|
|
2014-01-15 15:14:37 +00:00
|
|
|
static void add_term_osd_bar(struct MPContext *mpctx, char **line, int width)
|
|
|
|
{
|
|
|
|
struct MPOpts *opts = mpctx->opts;
|
|
|
|
|
|
|
|
if (width < 5)
|
|
|
|
return;
|
|
|
|
|
2014-01-15 21:37:53 +00:00
|
|
|
int pos = get_current_pos_ratio(mpctx, false) * (width - 3);
|
|
|
|
pos = MPCLAMP(pos, 0, width - 3);
|
2014-01-15 15:14:37 +00:00
|
|
|
|
|
|
|
bstr chars = bstr0(opts->term_osd_bar_chars);
|
|
|
|
bstr parts[5];
|
|
|
|
for (int n = 0; n < 5; n++)
|
|
|
|
parts[n] = bstr_split_utf8(chars, &chars);
|
|
|
|
|
2014-04-13 11:03:31 +00:00
|
|
|
saddf(line, "\r%.*s", BSTR_P(parts[0]));
|
2014-01-15 15:14:37 +00:00
|
|
|
for (int n = 0; n < pos; n++)
|
|
|
|
saddf(line, "%.*s", BSTR_P(parts[1]));
|
|
|
|
saddf(line, "%.*s", BSTR_P(parts[2]));
|
2014-01-15 21:37:53 +00:00
|
|
|
for (int n = 0; n < width - 3 - pos; n++)
|
2014-01-15 15:14:37 +00:00
|
|
|
saddf(line, "%.*s", BSTR_P(parts[3]));
|
|
|
|
saddf(line, "%.*s", BSTR_P(parts[4]));
|
|
|
|
}
|
|
|
|
|
2014-10-22 14:11:44 +00:00
|
|
|
static bool is_busy(struct MPContext *mpctx)
|
|
|
|
{
|
|
|
|
return !mpctx->restart_complete && mp_time_sec() - mpctx->start_timestamp > 0.3;
|
|
|
|
}
|
|
|
|
|
2016-08-26 18:27:46 +00:00
|
|
|
static void term_osd_print_status_lazy(struct MPContext *mpctx)
|
2013-10-29 21:38:29 +00:00
|
|
|
{
|
|
|
|
struct MPOpts *opts = mpctx->opts;
|
|
|
|
|
2013-11-09 23:49:13 +00:00
|
|
|
update_window_title(mpctx, false);
|
2015-11-15 22:03:48 +00:00
|
|
|
update_vo_playback_state(mpctx);
|
2013-10-29 21:38:29 +00:00
|
|
|
|
2014-02-06 15:49:50 +00:00
|
|
|
if (!opts->use_terminal)
|
|
|
|
return;
|
|
|
|
|
2014-10-03 17:57:49 +00:00
|
|
|
if (opts->quiet || !mpctx->playback_initialized || !mpctx->playing_msg_shown)
|
2014-08-17 23:25:59 +00:00
|
|
|
{
|
2016-08-26 18:27:46 +00:00
|
|
|
term_osd_set_status_lazy(mpctx, "");
|
2013-10-29 21:38:29 +00:00
|
|
|
return;
|
player: redo terminal OSD and status line handling
The terminal OSD code includes the handling of the terminal status line,
showing player OSD messages on the terminal, and showing subtitles on
terminal (the latter two only if there is no video window, or if
terminal OSD is forced).
This didn't handle some corner cases correctly. For example, showing an
OSD message on the terminal always cleared the previous line, even if
the line was an important message (or even just the command prompt, if
most other messages were silenced).
Attempt to handle this correctly by keeping track of how many lines the
terminal OSD currently consists of. Since there could be race conditions
with other messages being printed, implement this in msg.c. Now msg.c
expects that MSGL_STATUS messages rewrite the status line, so the caller
is forced to use a single mp_msg() call to set the status line.
Instead of littering print_status() all over the place, update the
status only once per playloop iteration in update_osd_msg(). In audio-
only mode, the status line might now be a little bit off, but it's
perhaps ok.
Print the status line only if it has changed, or if another message was
printed. This might help with extremely slow terminals, although in
audio+video mode, it'll still be updated very often (A-V sync display
changes on every frame).
Instead of hardcoding the terminal sequences, use
terminfo/termcap to get the sequences. Remove the --term-osd-esc option,
which allowed to override the hardcoded escapes - it's useless now.
The fallback for terminals with no escape sequences for moving the
cursor and clearing a line is removed. This somewhat breaks status line
display on these terminals, including the MS Windows console: instead of
querying the terminal size and clearing the line manually by padding the
output with spaces, the line is simply not cleared. I don't expect this
to be a problem on UNIX, and on MS Windows we could emulate escape
sequences. Note that terminal OSD (other than the status line) was
broken anyway on these terminals.
In osd.c, the function get_term_width() is not used anymore, so remove
it. To remind us that the MS Windows console apparently adds a line
break when writint the last column, adjust screen_width in terminal-
win.c accordingly.
2014-01-13 19:05:41 +00:00
|
|
|
}
|
2013-10-29 21:38:29 +00:00
|
|
|
|
|
|
|
if (opts->status_msg) {
|
2014-02-20 13:46:23 +00:00
|
|
|
char *r = mp_property_expand_escaped_string(mpctx, opts->status_msg);
|
2016-08-26 18:27:46 +00:00
|
|
|
term_osd_set_status_lazy(mpctx, r);
|
2013-10-29 21:38:29 +00:00
|
|
|
talloc_free(r);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *line = NULL;
|
|
|
|
|
|
|
|
// Playback status
|
2014-10-22 14:11:44 +00:00
|
|
|
if (is_busy(mpctx)) {
|
2014-08-07 22:05:24 +00:00
|
|
|
saddf(&line, "(...) ");
|
|
|
|
} else if (mpctx->paused_for_cache && !opts->pause) {
|
2013-10-29 21:38:29 +00:00
|
|
|
saddf(&line, "(Buffering) ");
|
|
|
|
} else if (mpctx->paused) {
|
|
|
|
saddf(&line, "(Paused) ");
|
|
|
|
}
|
|
|
|
|
2016-01-21 21:24:20 +00:00
|
|
|
if (mpctx->ao_chain)
|
2013-10-29 21:38:29 +00:00
|
|
|
saddf(&line, "A");
|
2016-01-17 17:07:50 +00:00
|
|
|
if (mpctx->vo_chain)
|
2013-10-29 21:38:29 +00:00
|
|
|
saddf(&line, "V");
|
|
|
|
saddf(&line, ": ");
|
|
|
|
|
|
|
|
// Playback position
|
2015-10-16 14:16:10 +00:00
|
|
|
sadd_hhmmssff_u(&line, get_playback_time(mpctx), mpctx->opts->osd_fractions);
|
2013-10-29 21:38:29 +00:00
|
|
|
|
|
|
|
double len = get_time_length(mpctx);
|
|
|
|
if (len >= 0) {
|
|
|
|
saddf(&line, " / ");
|
|
|
|
sadd_hhmmssff(&line, len, mpctx->opts->osd_fractions);
|
|
|
|
}
|
|
|
|
|
|
|
|
sadd_percentage(&line, get_percent_pos(mpctx));
|
|
|
|
|
|
|
|
// other
|
|
|
|
if (opts->playback_speed != 1)
|
|
|
|
saddf(&line, " x%4.2f", opts->playback_speed);
|
|
|
|
|
|
|
|
// A-V sync
|
2016-02-01 21:14:32 +00:00
|
|
|
if (mpctx->ao_chain && mpctx->vo_chain && !mpctx->vo_chain->is_coverart) {
|
2015-05-24 18:57:31 +00:00
|
|
|
saddf(&line, " A-V:%7.3f", mpctx->last_av_difference);
|
2013-10-29 21:38:29 +00:00
|
|
|
if (fabs(mpctx->total_avsync_change) > 0.05)
|
|
|
|
saddf(&line, " ct:%7.3f", mpctx->total_avsync_change);
|
|
|
|
}
|
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_ENCODING
|
2013-10-29 21:38:29 +00:00
|
|
|
double position = get_current_pos_ratio(mpctx, true);
|
|
|
|
char lavcbuf[80];
|
|
|
|
if (encode_lavc_getstatus(mpctx->encode_lavc_ctx, lavcbuf, sizeof(lavcbuf),
|
|
|
|
position) >= 0)
|
|
|
|
{
|
|
|
|
// encoding stats
|
|
|
|
saddf(&line, " %s", lavcbuf);
|
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
// VO stats
|
2016-01-17 17:07:50 +00:00
|
|
|
if (mpctx->vo_chain) {
|
2015-08-10 16:43:25 +00:00
|
|
|
if (mpctx->display_sync_active) {
|
2016-01-20 15:52:32 +00:00
|
|
|
char *r = mp_property_expand_string(mpctx,
|
|
|
|
"${?vsync-ratio:${vsync-ratio}}");
|
|
|
|
if (r[0]) {
|
|
|
|
saddf(&line, " DS: %s/%"PRId64, r,
|
|
|
|
vo_get_delayed_count(mpctx->video_out));
|
|
|
|
}
|
2015-11-18 20:21:57 +00:00
|
|
|
talloc_free(r);
|
2015-08-10 16:43:25 +00:00
|
|
|
}
|
video: add VO framedropping mode
This mostly uses the same idea as with vo_vdpau.c, but much simplified.
On X11, it tries to get the display framerate with XF86VM, and limits
the frequency of new video frames against it. Note that this is an old
extension, and is confirmed not to work correctly with multi-monitor
setups. But we're using it because it was already around (it is also
used by vo_vdpau).
This attempts to predict the next vsync event by using the time of the
last frame and the display FPS. Even if that goes completely wrong,
the results are still relatively good.
On other systems, or if the X11 code doesn't return a display FPS, a
framerate of 1000 is assumed. This is infinite for all practical
purposes, and means that only frames which are definitely too late are
dropped. This probably has worse results, but is still useful.
"--framedrop=yes" is basically replaced with "--framedrop=decoder". The
old framedropping mode is kept around, and should perhaps be improved.
Dropping on the decoder level is still useful if decoding itself is too
slow.
2014-08-15 21:33:33 +00:00
|
|
|
int64_t c = vo_get_drop_count(mpctx->video_out);
|
2016-01-29 21:46:28 +00:00
|
|
|
struct dec_video *d_video = mpctx->vo_chain->video_src;
|
|
|
|
int dropped_frames = d_video ? d_video->dropped_frames : 0;
|
2016-01-16 20:19:52 +00:00
|
|
|
if (c > 0 || dropped_frames > 0) {
|
2014-10-31 00:01:58 +00:00
|
|
|
saddf(&line, " Dropped: %"PRId64, c);
|
2016-01-16 20:19:52 +00:00
|
|
|
if (dropped_frames)
|
|
|
|
saddf(&line, "/%d", dropped_frames);
|
2014-10-31 00:01:58 +00:00
|
|
|
}
|
video: add VO framedropping mode
This mostly uses the same idea as with vo_vdpau.c, but much simplified.
On X11, it tries to get the display framerate with XF86VM, and limits
the frequency of new video frames against it. Note that this is an old
extension, and is confirmed not to work correctly with multi-monitor
setups. But we're using it because it was already around (it is also
used by vo_vdpau).
This attempts to predict the next vsync event by using the time of the
last frame and the display FPS. Even if that goes completely wrong,
the results are still relatively good.
On other systems, or if the X11 code doesn't return a display FPS, a
framerate of 1000 is assumed. This is infinite for all practical
purposes, and means that only frames which are definitely too late are
dropped. This probably has worse results, but is still useful.
"--framedrop=yes" is basically replaced with "--framedrop=decoder". The
old framedropping mode is kept around, and should perhaps be improved.
Dropping on the decoder level is still useful if decoding itself is too
slow.
2014-08-15 21:33:33 +00:00
|
|
|
}
|
2013-10-29 21:38:29 +00:00
|
|
|
}
|
|
|
|
|
2014-08-27 20:42:28 +00:00
|
|
|
if (mpctx->demuxer) {
|
2016-03-29 09:29:52 +00:00
|
|
|
struct stream_cache_info info = {0};
|
|
|
|
demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_INFO, &info);
|
2017-02-02 17:38:16 +00:00
|
|
|
if (info.size > 0 || mpctx->demuxer->is_network) {
|
2014-08-27 20:42:28 +00:00
|
|
|
saddf(&line, " Cache: ");
|
|
|
|
|
|
|
|
struct demux_ctrl_reader_state s = {.ts_duration = -1};
|
|
|
|
demux_control(mpctx->demuxer, DEMUXER_CTRL_GET_READER_STATE, &s);
|
|
|
|
|
|
|
|
if (s.ts_duration < 0) {
|
|
|
|
saddf(&line, "???");
|
|
|
|
} else {
|
|
|
|
saddf(&line, "%2ds", (int)s.ts_duration);
|
|
|
|
}
|
2017-02-02 17:38:16 +00:00
|
|
|
if (info.size > 0) {
|
|
|
|
if (info.fill >= 1024 * 1024) {
|
|
|
|
saddf(&line, "+%lldMB", (long long)(info.fill / 1024 / 1024));
|
|
|
|
} else {
|
|
|
|
saddf(&line, "+%lldKB", (long long)(info.fill / 1024));
|
|
|
|
}
|
2015-07-14 21:23:23 +00:00
|
|
|
}
|
2014-08-27 20:42:28 +00:00
|
|
|
}
|
|
|
|
}
|
2013-10-29 21:38:29 +00:00
|
|
|
|
2014-01-15 15:14:37 +00:00
|
|
|
if (opts->term_osd_bar) {
|
|
|
|
saddf(&line, "\n");
|
2014-08-21 20:13:10 +00:00
|
|
|
int w = 80, h = 24;
|
|
|
|
terminal_get_size(&w, &h);
|
|
|
|
add_term_osd_bar(mpctx, &line, w);
|
2014-01-15 15:14:37 +00:00
|
|
|
}
|
|
|
|
|
2013-10-29 21:38:29 +00:00
|
|
|
// end
|
2016-08-26 18:27:46 +00:00
|
|
|
term_osd_set_status_lazy(mpctx, line);
|
2013-10-29 21:38:29 +00:00
|
|
|
talloc_free(line);
|
|
|
|
}
|
|
|
|
|
2014-09-25 19:14:00 +00:00
|
|
|
static bool set_osd_msg_va(struct MPContext *mpctx, int level, int time,
|
2013-10-29 21:38:29 +00:00
|
|
|
const char *fmt, va_list ap)
|
|
|
|
{
|
2014-09-25 19:14:00 +00:00
|
|
|
if (level > mpctx->opts->osd_level)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
talloc_free(mpctx->osd_msg_text);
|
|
|
|
mpctx->osd_msg_text = talloc_vasprintf(mpctx, fmt, ap);
|
|
|
|
mpctx->osd_show_pos = false;
|
2014-10-06 20:19:24 +00:00
|
|
|
mpctx->osd_msg_next_duration = time / 1000.0;
|
2014-09-25 19:14:00 +00:00
|
|
|
mpctx->osd_force_update = true;
|
2016-09-16 12:24:15 +00:00
|
|
|
mp_wakeup_core(mpctx);
|
2014-10-14 17:20:36 +00:00
|
|
|
if (mpctx->osd_msg_next_duration <= 0)
|
|
|
|
mpctx->osd_msg_visible = mp_time_sec();
|
2014-09-25 19:14:00 +00:00
|
|
|
return true;
|
2013-10-29 21:38:29 +00:00
|
|
|
}
|
|
|
|
|
2014-09-25 19:14:00 +00:00
|
|
|
bool set_osd_msg(struct MPContext *mpctx, int level, int time,
|
2013-10-29 21:38:29 +00:00
|
|
|
const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
2014-09-25 19:14:00 +00:00
|
|
|
bool r = set_osd_msg_va(mpctx, level, time, fmt, ap);
|
2013-10-29 21:38:29 +00:00
|
|
|
va_end(ap);
|
2014-09-25 19:14:00 +00:00
|
|
|
return r;
|
2013-10-29 21:38:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// type: mp_osd_font_codepoints, ASCII, or OSD_BAR_*
|
2014-09-21 21:40:45 +00:00
|
|
|
void set_osd_bar(struct MPContext *mpctx, int type,
|
2014-06-08 21:52:58 +00:00
|
|
|
double min, double max, double neutral, double val)
|
2013-10-29 21:38:29 +00:00
|
|
|
{
|
|
|
|
struct MPOpts *opts = mpctx->opts;
|
2016-08-28 16:15:37 +00:00
|
|
|
bool video_osd = mpctx->video_out && mpctx->opts->video_osd;
|
|
|
|
if (opts->osd_level < 1 || !opts->osd_bar_visible || !video_osd)
|
2013-10-29 21:38:29 +00:00
|
|
|
return;
|
|
|
|
|
2014-09-25 19:23:33 +00:00
|
|
|
mpctx->osd_visible = mp_time_sec() + opts->osd_duration / 1000.0;
|
|
|
|
mpctx->osd_progbar.type = type;
|
|
|
|
mpctx->osd_progbar.value = (val - min) / (max - min);
|
|
|
|
mpctx->osd_progbar.num_stops = 0;
|
|
|
|
if (neutral > min && neutral < max) {
|
|
|
|
float pos = (neutral - min) / (max - min);
|
|
|
|
MP_TARRAY_APPEND(mpctx, mpctx->osd_progbar.stops,
|
|
|
|
mpctx->osd_progbar.num_stops, pos);
|
2013-10-29 21:38:29 +00:00
|
|
|
}
|
2014-09-25 19:23:33 +00:00
|
|
|
osd_set_progbar(mpctx->osd, &mpctx->osd_progbar);
|
2016-09-16 12:24:15 +00:00
|
|
|
mp_wakeup_core(mpctx);
|
2013-10-29 21:38:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update a currently displayed bar of the same type, without resetting the
|
|
|
|
// timer.
|
|
|
|
static void update_osd_bar(struct MPContext *mpctx, int type,
|
|
|
|
double min, double max, double val)
|
|
|
|
{
|
2014-09-25 19:23:33 +00:00
|
|
|
if (mpctx->osd_progbar.type != type)
|
|
|
|
return;
|
|
|
|
|
|
|
|
float new_value = (val - min) / (max - min);
|
|
|
|
if (new_value != mpctx->osd_progbar.value) {
|
|
|
|
mpctx->osd_progbar.value = new_value;
|
|
|
|
osd_set_progbar(mpctx->osd, &mpctx->osd_progbar);
|
2013-10-29 21:38:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-18 19:28:54 +00:00
|
|
|
void set_osd_bar_chapters(struct MPContext *mpctx, int type)
|
2013-10-29 21:38:29 +00:00
|
|
|
{
|
2014-11-17 23:09:42 +00:00
|
|
|
struct MPOpts *opts = mpctx->opts;
|
2014-09-25 19:23:33 +00:00
|
|
|
if (mpctx->osd_progbar.type != type)
|
|
|
|
return;
|
|
|
|
|
2014-01-18 00:19:20 +00:00
|
|
|
mpctx->osd_progbar.num_stops = 0;
|
2014-09-25 19:23:33 +00:00
|
|
|
double len = get_time_length(mpctx);
|
|
|
|
if (len > 0) {
|
2016-04-21 20:15:17 +00:00
|
|
|
if (opts->ab_loop[0] != MP_NOPTS_VALUE) {
|
2014-11-17 23:09:42 +00:00
|
|
|
MP_TARRAY_APPEND(mpctx, mpctx->osd_progbar.stops,
|
|
|
|
mpctx->osd_progbar.num_stops, opts->ab_loop[0] / len);
|
2016-04-21 20:15:17 +00:00
|
|
|
}
|
|
|
|
if (opts->ab_loop[1] != MP_NOPTS_VALUE) {
|
2014-11-17 23:09:42 +00:00
|
|
|
MP_TARRAY_APPEND(mpctx, mpctx->osd_progbar.stops,
|
|
|
|
mpctx->osd_progbar.num_stops, opts->ab_loop[1] / len);
|
2016-04-21 20:15:17 +00:00
|
|
|
}
|
2016-04-22 07:31:11 +00:00
|
|
|
if (mpctx->osd_progbar.num_stops == 0) {
|
2014-11-17 23:09:42 +00:00
|
|
|
int num = get_chapter_count(mpctx);
|
|
|
|
for (int n = 0; n < num; n++) {
|
2015-11-16 21:47:17 +00:00
|
|
|
double time = chapter_start_time(mpctx, n);
|
2014-11-17 23:09:42 +00:00
|
|
|
if (time >= 0) {
|
|
|
|
float pos = time / len;
|
|
|
|
MP_TARRAY_APPEND(mpctx, mpctx->osd_progbar.stops,
|
|
|
|
mpctx->osd_progbar.num_stops, pos);
|
|
|
|
}
|
2013-10-29 21:38:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-01-18 00:19:20 +00:00
|
|
|
osd_set_progbar(mpctx->osd, &mpctx->osd_progbar);
|
2016-09-16 12:24:15 +00:00
|
|
|
mp_wakeup_core(mpctx);
|
2013-10-29 21:38:29 +00:00
|
|
|
}
|
|
|
|
|
2013-10-30 20:47:14 +00:00
|
|
|
// osd_function is the symbol appearing in the video status, such as OSD_PLAY
|
2013-10-29 21:38:29 +00:00
|
|
|
void set_osd_function(struct MPContext *mpctx, int osd_function)
|
|
|
|
{
|
|
|
|
struct MPOpts *opts = mpctx->opts;
|
|
|
|
|
|
|
|
mpctx->osd_function = osd_function;
|
|
|
|
mpctx->osd_function_visible = mp_time_sec() + opts->osd_duration / 1000.0;
|
2014-11-01 16:32:34 +00:00
|
|
|
mpctx->osd_force_update = true;
|
2016-09-16 12:24:15 +00:00
|
|
|
mp_wakeup_core(mpctx);
|
2013-10-29 21:38:29 +00:00
|
|
|
}
|
|
|
|
|
2014-09-17 22:12:59 +00:00
|
|
|
void get_current_osd_sym(struct MPContext *mpctx, char *buf, size_t buf_size)
|
2013-10-29 21:38:29 +00:00
|
|
|
{
|
|
|
|
int sym = mpctx->osd_function;
|
|
|
|
if (!sym) {
|
2014-10-22 14:11:44 +00:00
|
|
|
if (is_busy(mpctx) || (mpctx->paused_for_cache && !mpctx->opts->pause)) {
|
2013-10-29 21:38:29 +00:00
|
|
|
sym = OSD_CLOCK;
|
|
|
|
} else if (mpctx->paused || mpctx->step_frames) {
|
|
|
|
sym = OSD_PAUSE;
|
|
|
|
} else {
|
|
|
|
sym = OSD_PLAY;
|
|
|
|
}
|
|
|
|
}
|
2014-09-17 22:12:59 +00:00
|
|
|
osd_get_function_sym(buf, buf_size, sym);
|
|
|
|
}
|
|
|
|
|
2014-09-17 23:19:27 +00:00
|
|
|
static void sadd_osd_status(char **buffer, struct MPContext *mpctx, int level)
|
2014-09-17 22:12:59 +00:00
|
|
|
{
|
2014-09-17 23:19:27 +00:00
|
|
|
assert(level >= 0 && level <= 3);
|
|
|
|
if (level == 0)
|
|
|
|
return;
|
|
|
|
char *msg = mpctx->opts->osd_msg[level - 1];
|
|
|
|
|
|
|
|
if (msg && msg[0]) {
|
|
|
|
char *text = mp_property_expand_escaped_string(mpctx, msg);
|
2013-10-29 21:38:29 +00:00
|
|
|
*buffer = talloc_strdup_append(*buffer, text);
|
|
|
|
talloc_free(text);
|
2014-09-17 23:19:27 +00:00
|
|
|
} else if (level >= 2) {
|
|
|
|
bool fractions = mpctx->opts->osd_fractions;
|
|
|
|
char sym[10];
|
|
|
|
get_current_osd_sym(mpctx, sym, sizeof(sym));
|
|
|
|
saddf(buffer, "%s ", sym);
|
|
|
|
char *custom_msg = mpctx->opts->osd_status_msg;
|
|
|
|
if (custom_msg && level == 3) {
|
|
|
|
char *text = mp_property_expand_escaped_string(mpctx, custom_msg);
|
|
|
|
*buffer = talloc_strdup_append(*buffer, text);
|
|
|
|
talloc_free(text);
|
|
|
|
} else {
|
2015-10-16 14:16:10 +00:00
|
|
|
sadd_hhmmssff_u(buffer, get_playback_time(mpctx), fractions);
|
2017-06-23 12:27:53 +00:00
|
|
|
#if HAVE_GPL
|
|
|
|
// Potentially GPL due to 8d190244d21a4d40bb9e8f7d51aa09ca1888de09.
|
2014-09-17 23:19:27 +00:00
|
|
|
if (level == 3) {
|
2014-10-29 20:54:59 +00:00
|
|
|
double len = get_time_length(mpctx);
|
|
|
|
if (len >= 0) {
|
|
|
|
saddf(buffer, " / ");
|
|
|
|
sadd_hhmmssff(buffer, len, fractions);
|
|
|
|
}
|
2014-09-17 23:19:27 +00:00
|
|
|
sadd_percentage(buffer, get_percent_pos(mpctx));
|
|
|
|
}
|
2017-06-23 12:27:53 +00:00
|
|
|
#endif
|
2013-10-29 21:38:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// OSD messages initated by seeking commands are added lazily with this
|
|
|
|
// function, because multiple successive seek commands can be coalesced.
|
|
|
|
static void add_seek_osd_messages(struct MPContext *mpctx)
|
|
|
|
{
|
|
|
|
if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_BAR) {
|
|
|
|
double pos = get_current_pos_ratio(mpctx, false);
|
2014-09-21 21:40:45 +00:00
|
|
|
set_osd_bar(mpctx, OSD_BAR_SEEK, 0, 1, 0, MPCLAMP(pos, 0, 1));
|
2013-10-29 21:38:29 +00:00
|
|
|
set_osd_bar_chapters(mpctx, OSD_BAR_SEEK);
|
|
|
|
}
|
|
|
|
if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_TEXT) {
|
2014-01-13 18:46:16 +00:00
|
|
|
// Never in term-osd mode
|
2016-08-28 16:15:37 +00:00
|
|
|
bool video_osd = mpctx->video_out && mpctx->opts->video_osd;
|
|
|
|
if (video_osd && mpctx->opts->term_osd != 1) {
|
2014-09-26 11:52:55 +00:00
|
|
|
if (set_osd_msg(mpctx, 1, mpctx->opts->osd_duration, ""))
|
2014-09-25 19:14:00 +00:00
|
|
|
mpctx->osd_show_pos = true;
|
2014-01-13 18:46:16 +00:00
|
|
|
}
|
2013-10-29 21:38:29 +00:00
|
|
|
}
|
|
|
|
if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_CHAPTER_TEXT) {
|
|
|
|
char *chapter = chapter_display_name(mpctx, get_current_chapter(mpctx));
|
2014-01-17 21:34:47 +00:00
|
|
|
set_osd_msg(mpctx, 1, mpctx->opts->osd_duration,
|
2013-10-29 21:38:29 +00:00
|
|
|
"Chapter: %s", chapter);
|
|
|
|
talloc_free(chapter);
|
|
|
|
}
|
2014-11-11 21:07:16 +00:00
|
|
|
if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_CURRENT_FILE) {
|
|
|
|
if (mpctx->filename) {
|
|
|
|
set_osd_msg(mpctx, 1, mpctx->opts->osd_duration, "%s",
|
|
|
|
mpctx->filename);
|
|
|
|
}
|
|
|
|
}
|
2013-10-29 21:38:29 +00:00
|
|
|
mpctx->add_osd_seek_info = 0;
|
|
|
|
}
|
|
|
|
|
2014-09-25 18:25:24 +00:00
|
|
|
// Update the OSD text (both on VO and terminal status line).
|
2013-10-29 21:38:29 +00:00
|
|
|
void update_osd_msg(struct MPContext *mpctx)
|
|
|
|
{
|
|
|
|
struct MPOpts *opts = mpctx->opts;
|
|
|
|
struct osd_state *osd = mpctx->osd;
|
|
|
|
|
2014-09-25 19:14:00 +00:00
|
|
|
double now = mp_time_sec();
|
|
|
|
|
2014-09-25 18:25:24 +00:00
|
|
|
if (!mpctx->osd_force_update) {
|
player: do not update OSD all the time when paused
Normally, OSD is updated every time the playloop is run. This has to be
done, because the OSD may implicitly reference various properties,
without knowing whether they really need to be updated or not. (There's
a property update mechanism, but it's mostly unavailable, because OSD is
special-cased and can not use the client API mechanism properly.)
Normally, these updates are no problem, because the OSD is only actually
printed when the OSD text actually changes.
But commit d23ffd24 added a rate-limiting mechanism, which tries to
limit OSD updates at most every 50ms (or the next video frame). Since it
can't know in advance whether the OSD is going to change or not, this
simply waked up the player every 50ms.
Change this so that the player is updated only as part of general
updates determined through mp_notify(). (This function also notifies the
client API of changed properties.) The desired result is that the player
will not wake up at all in normal idle mode, but still update properties
that can change when paused, such as the cache.
This is mostly a cosmetic change (in the sense of making runtime
behavior just slightly better). It has the slightly more negative
consequence that properties which update implicitly (such as "clock")
will not update periodically anymore.
2016-06-11 16:40:08 +00:00
|
|
|
// Assume nothing is going on at all.
|
|
|
|
if (!mpctx->osd_idle_update)
|
|
|
|
return;
|
|
|
|
|
2014-09-25 18:25:24 +00:00
|
|
|
double delay = 0.050; // update the OSD at most this often
|
|
|
|
double diff = now - mpctx->osd_last_update;
|
|
|
|
if (diff < delay) {
|
2016-09-16 12:24:15 +00:00
|
|
|
mp_set_timeout(mpctx, delay - diff);
|
2014-09-25 18:25:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mpctx->osd_force_update = false;
|
player: do not update OSD all the time when paused
Normally, OSD is updated every time the playloop is run. This has to be
done, because the OSD may implicitly reference various properties,
without knowing whether they really need to be updated or not. (There's
a property update mechanism, but it's mostly unavailable, because OSD is
special-cased and can not use the client API mechanism properly.)
Normally, these updates are no problem, because the OSD is only actually
printed when the OSD text actually changes.
But commit d23ffd24 added a rate-limiting mechanism, which tries to
limit OSD updates at most every 50ms (or the next video frame). Since it
can't know in advance whether the OSD is going to change or not, this
simply waked up the player every 50ms.
Change this so that the player is updated only as part of general
updates determined through mp_notify(). (This function also notifies the
client API of changed properties.) The desired result is that the player
will not wake up at all in normal idle mode, but still update properties
that can change when paused, such as the cache.
This is mostly a cosmetic change (in the sense of making runtime
behavior just slightly better). It has the slightly more negative
consequence that properties which update implicitly (such as "clock")
will not update periodically anymore.
2016-06-11 16:40:08 +00:00
|
|
|
mpctx->osd_idle_update = false;
|
2014-09-25 19:14:00 +00:00
|
|
|
mpctx->osd_last_update = now;
|
|
|
|
|
|
|
|
if (mpctx->osd_visible) {
|
|
|
|
double sleep = mpctx->osd_visible - now;
|
|
|
|
if (sleep > 0) {
|
2016-09-16 12:24:15 +00:00
|
|
|
mp_set_timeout(mpctx, sleep);
|
2016-06-12 10:52:35 +00:00
|
|
|
mpctx->osd_idle_update = true;
|
2014-09-25 19:14:00 +00:00
|
|
|
} else {
|
|
|
|
mpctx->osd_visible = 0;
|
|
|
|
mpctx->osd_progbar.type = -1; // disable
|
|
|
|
osd_set_progbar(mpctx->osd, &mpctx->osd_progbar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-01 16:32:34 +00:00
|
|
|
if (mpctx->osd_function_visible) {
|
|
|
|
double sleep = mpctx->osd_function_visible - now;
|
|
|
|
if (sleep > 0) {
|
2016-09-16 12:24:15 +00:00
|
|
|
mp_set_timeout(mpctx, sleep);
|
2016-06-12 10:52:35 +00:00
|
|
|
mpctx->osd_idle_update = true;
|
2014-11-01 16:32:34 +00:00
|
|
|
} else {
|
|
|
|
mpctx->osd_function_visible = 0;
|
|
|
|
mpctx->osd_function = 0;
|
|
|
|
}
|
2014-09-25 19:14:00 +00:00
|
|
|
}
|
|
|
|
|
2014-10-06 20:19:24 +00:00
|
|
|
if (mpctx->osd_msg_next_duration > 0) {
|
|
|
|
// This is done to avoid cutting the OSD message short if slow commands
|
|
|
|
// are executed between setting the OSD message and showing it.
|
|
|
|
mpctx->osd_msg_visible = now + mpctx->osd_msg_next_duration;
|
|
|
|
mpctx->osd_msg_next_duration = 0;
|
|
|
|
}
|
|
|
|
|
2014-09-25 19:14:00 +00:00
|
|
|
if (mpctx->osd_msg_visible) {
|
|
|
|
double sleep = mpctx->osd_msg_visible - now;
|
|
|
|
if (sleep > 0) {
|
2016-09-16 12:24:15 +00:00
|
|
|
mp_set_timeout(mpctx, sleep);
|
2016-06-12 10:52:35 +00:00
|
|
|
mpctx->osd_idle_update = true;
|
2014-09-25 19:14:00 +00:00
|
|
|
} else {
|
|
|
|
talloc_free(mpctx->osd_msg_text);
|
|
|
|
mpctx->osd_msg_text = NULL;
|
|
|
|
mpctx->osd_msg_visible = 0;
|
|
|
|
mpctx->osd_show_pos = false;
|
|
|
|
}
|
|
|
|
}
|
2014-09-25 18:25:24 +00:00
|
|
|
|
2013-10-29 21:38:29 +00:00
|
|
|
add_seek_osd_messages(mpctx);
|
2014-09-25 19:14:00 +00:00
|
|
|
|
|
|
|
if (mpctx->osd_progbar.type == OSD_BAR_SEEK) {
|
|
|
|
double pos = get_current_pos_ratio(mpctx, false);
|
|
|
|
update_osd_bar(mpctx, OSD_BAR_SEEK, 0, 1, MPCLAMP(pos, 0, 1));
|
|
|
|
}
|
2013-10-29 21:38:29 +00:00
|
|
|
|
2016-08-26 18:27:46 +00:00
|
|
|
term_osd_set_text_lazy(mpctx, mpctx->osd_msg_text);
|
|
|
|
term_osd_print_status_lazy(mpctx);
|
|
|
|
term_osd_update(mpctx);
|
player: redo terminal OSD and status line handling
The terminal OSD code includes the handling of the terminal status line,
showing player OSD messages on the terminal, and showing subtitles on
terminal (the latter two only if there is no video window, or if
terminal OSD is forced).
This didn't handle some corner cases correctly. For example, showing an
OSD message on the terminal always cleared the previous line, even if
the line was an important message (or even just the command prompt, if
most other messages were silenced).
Attempt to handle this correctly by keeping track of how many lines the
terminal OSD currently consists of. Since there could be race conditions
with other messages being printed, implement this in msg.c. Now msg.c
expects that MSGL_STATUS messages rewrite the status line, so the caller
is forced to use a single mp_msg() call to set the status line.
Instead of littering print_status() all over the place, update the
status only once per playloop iteration in update_osd_msg(). In audio-
only mode, the status line might now be a little bit off, but it's
perhaps ok.
Print the status line only if it has changed, or if another message was
printed. This might help with extremely slow terminals, although in
audio+video mode, it'll still be updated very often (A-V sync display
changes on every frame).
Instead of hardcoding the terminal sequences, use
terminfo/termcap to get the sequences. Remove the --term-osd-esc option,
which allowed to override the hardcoded escapes - it's useless now.
The fallback for terminals with no escape sequences for moving the
cursor and clearing a line is removed. This somewhat breaks status line
display on these terminals, including the MS Windows console: instead of
querying the terminal size and clearing the line manually by padding the
output with spaces, the line is simply not cleared. I don't expect this
to be a problem on UNIX, and on MS Windows we could emulate escape
sequences. Note that terminal OSD (other than the status line) was
broken anyway on these terminals.
In osd.c, the function get_term_width() is not used anymore, so remove
it. To remind us that the MS Windows console apparently adds a line
break when writint the last column, adjust screen_width in terminal-
win.c accordingly.
2014-01-13 19:05:41 +00:00
|
|
|
|
2016-08-28 16:15:37 +00:00
|
|
|
if (!opts->video_osd)
|
|
|
|
return;
|
|
|
|
|
2013-10-29 21:38:29 +00:00
|
|
|
int osd_level = opts->osd_level;
|
2015-11-29 16:51:48 +00:00
|
|
|
if (mpctx->osd_show_pos)
|
2013-10-29 21:38:29 +00:00
|
|
|
osd_level = 3;
|
|
|
|
|
player: redo terminal OSD and status line handling
The terminal OSD code includes the handling of the terminal status line,
showing player OSD messages on the terminal, and showing subtitles on
terminal (the latter two only if there is no video window, or if
terminal OSD is forced).
This didn't handle some corner cases correctly. For example, showing an
OSD message on the terminal always cleared the previous line, even if
the line was an important message (or even just the command prompt, if
most other messages were silenced).
Attempt to handle this correctly by keeping track of how many lines the
terminal OSD currently consists of. Since there could be race conditions
with other messages being printed, implement this in msg.c. Now msg.c
expects that MSGL_STATUS messages rewrite the status line, so the caller
is forced to use a single mp_msg() call to set the status line.
Instead of littering print_status() all over the place, update the
status only once per playloop iteration in update_osd_msg(). In audio-
only mode, the status line might now be a little bit off, but it's
perhaps ok.
Print the status line only if it has changed, or if another message was
printed. This might help with extremely slow terminals, although in
audio+video mode, it'll still be updated very often (A-V sync display
changes on every frame).
Instead of hardcoding the terminal sequences, use
terminfo/termcap to get the sequences. Remove the --term-osd-esc option,
which allowed to override the hardcoded escapes - it's useless now.
The fallback for terminals with no escape sequences for moving the
cursor and clearing a line is removed. This somewhat breaks status line
display on these terminals, including the MS Windows console: instead of
querying the terminal size and clearing the line manually by padding the
output with spaces, the line is simply not cleared. I don't expect this
to be a problem on UNIX, and on MS Windows we could emulate escape
sequences. Note that terminal OSD (other than the status line) was
broken anyway on these terminals.
In osd.c, the function get_term_width() is not used anymore, so remove
it. To remind us that the MS Windows console apparently adds a line
break when writint the last column, adjust screen_width in terminal-
win.c accordingly.
2014-01-13 19:05:41 +00:00
|
|
|
char *text = NULL;
|
2014-09-17 23:19:27 +00:00
|
|
|
sadd_osd_status(&text, mpctx, osd_level);
|
2015-11-29 16:51:48 +00:00
|
|
|
if (mpctx->osd_msg_text && mpctx->osd_msg_text[0]) {
|
|
|
|
text = talloc_asprintf_append(text, "%s%s", text ? "\n" : "",
|
|
|
|
mpctx->osd_msg_text);
|
|
|
|
}
|
2016-03-08 20:54:17 +00:00
|
|
|
osd_set_text(osd, text);
|
player: redo terminal OSD and status line handling
The terminal OSD code includes the handling of the terminal status line,
showing player OSD messages on the terminal, and showing subtitles on
terminal (the latter two only if there is no video window, or if
terminal OSD is forced).
This didn't handle some corner cases correctly. For example, showing an
OSD message on the terminal always cleared the previous line, even if
the line was an important message (or even just the command prompt, if
most other messages were silenced).
Attempt to handle this correctly by keeping track of how many lines the
terminal OSD currently consists of. Since there could be race conditions
with other messages being printed, implement this in msg.c. Now msg.c
expects that MSGL_STATUS messages rewrite the status line, so the caller
is forced to use a single mp_msg() call to set the status line.
Instead of littering print_status() all over the place, update the
status only once per playloop iteration in update_osd_msg(). In audio-
only mode, the status line might now be a little bit off, but it's
perhaps ok.
Print the status line only if it has changed, or if another message was
printed. This might help with extremely slow terminals, although in
audio+video mode, it'll still be updated very often (A-V sync display
changes on every frame).
Instead of hardcoding the terminal sequences, use
terminfo/termcap to get the sequences. Remove the --term-osd-esc option,
which allowed to override the hardcoded escapes - it's useless now.
The fallback for terminals with no escape sequences for moving the
cursor and clearing a line is removed. This somewhat breaks status line
display on these terminals, including the MS Windows console: instead of
querying the terminal size and clearing the line manually by padding the
output with spaces, the line is simply not cleared. I don't expect this
to be a problem on UNIX, and on MS Windows we could emulate escape
sequences. Note that terminal OSD (other than the status line) was
broken anyway on these terminals.
In osd.c, the function get_term_width() is not used anymore, so remove
it. To remind us that the MS Windows console apparently adds a line
break when writint the last column, adjust screen_width in terminal-
win.c accordingly.
2014-01-13 19:05:41 +00:00
|
|
|
talloc_free(text);
|
2013-10-29 21:38:29 +00:00
|
|
|
}
|