1
mirror of https://github.com/mpv-player/mpv synced 2024-07-11 23:47:56 +02:00
Commit Graph

427 Commits

Author SHA1 Message Date
wm4
c92538dfaa Remove dead code
This was done with the help of callcatcher [1]. Only functions which
are statically known to be unused are removed.

Some unused functions are not removed yet, because they might be needed
in the near future (such as open_output_stream for the encode branch).

There is one user visible change: the --subcc option did nothing, and is
removed with this commit.

[1] http://www.skynet.ie/~caolan/Packages/callcatcher.html
2012-08-01 17:07:35 +02:00
wm4
e9a18efa2b VO: add mechanisms to change VO commandline for VOs supporting it 2012-08-01 01:06:59 +02:00
wm4
89a17bcda6 mplayer: turn playtree into a list, and change per-file option handling
Summary:
- There is no playtree anymore. It's reduced to a simple list.
- Options are now always global. You can still have per-file options,
  but these are optional and require special syntax.
- The slave command pt_step has been removed, and playlist_next
  and playlist_prev added. (See etc/input.conf changes.)
  This is a user visible incompatible change, and will break slave-mode
  applications.
- The pt_clear slave command is renamed to playlist_clear.
- Playtree entries could have multiple files. This is not the case
  anymore, and playlist entries have always exactly one entry. Whenever
  something adds more than one file (like ASX playlists or dvd:// or
  dvdnav:// on the command line), all files are added as separate
  playlist entries.

Note that some of the changes are quite deep and violent. Expect
regressions.

The playlist parsing code in particular is of low quality. I didn't try
to improve it, and merely spent to least effort necessary to keep it
somehow working. (Especially ASX playlist handling.)

The playtree code was complicated and bloated. It was also barely used.
Most users don't even know that mplayer manages the playlist as tree,
or how to use it. The most obscure features was probably specifying a
tree on command line (with '{' and '}' to create/close tree nodes). It
filled the player code with complexity and confused users with weird
slave commands like pt_up.

Replace the playtree with a simple flat playlist. Playlist parsers that
actually return trees are changed to append all files to the playlist
pre-order.

It used to be the responsibility of the playtree code to change per-file
config options. Now this is done by the player core, and the playlist
code is free of such details.

Options are not per-file by default anymore. This was a very obscure and
complicated feature that confused even experienced users. Consider the
following command line:

    mplayer file1.mkv file2.mkv --no-audio file3.mkv

This will disable the audio for file2.mkv only, because options are
per-file by default. To make the option affect all files, you're
supposed to put it before the first file.

This is bad, because normally you don't need per-file options. They are
very rarely needed, and the only reasonable use cases I can imagine are
use of the encode backend (mplayer encode branch), or for debugging. The
normal use case is made harder, and the feature is perceived as bug.
Even worse, correct usage is hard to explain for users.

Make all options global by default. The position of an option isn't
significant anymore (except for options that compensate each other,
consider --shuffle --no-shuffle).

One other important change is that no options are reset anymore if a
new file is started. If you change settings with slave mode commands,
they will not be changed by playing a new file. (Exceptions include
settings that are too file specific, like audio/subtitle stream
selection.)

There is still some need for per-file options. Debugging and encoding
are use cases that profit from per-file options. Per-file profiles (as
well as per-protocol and per-VO/AO options) need the implementation
related mechanisms to backup and restore options when the playback file
changes.

Simplify the save-slot stuff, which is possible because there is no
hierarchical play tree anymore. Now there's a simple backup field.

Add a way to specify per-file options on command line. Example:

    mplayer f1.mkv -o0 --{ -o1 f2.mkv -o2 f3.mkv --} f4.mkv -o3

will have the following options per file set:

    f1.mkv, f4.mkv: -o0 -o3
    f2.mkv, f3.mkv: -o0 -o3 -o1 -o2

The options --{ and --} start and end per-file options. All files inside
the { } will be affected by the options equally (similar to how global
options and multiple files are handled). When playback of a file starts,
the per-file options are set according to the command line. When
playback ends, the per-file options are restored to the values when
playback started.
2012-07-31 21:33:26 +02:00
wm4
6d6ae638fa lirc: silence output in case LIRC can't be opened
By default mplayer attempts to use LIRC. If LIRC can't be opened, a
bunch of warnings are printed. Since mplayer is often built with LIRC
enabled by default, many users will see these rather pointless
warnings. Lower verbosity, so that the warnings are not visible by
default anymore.
2012-07-30 01:46:04 +02:00
wm4
08caadb9c0 bstr: rename bstr() function to bstr0(), and typedef bstr to struct bstr
Replace all uses of bstr() with bstr0().
Also remove the ridiculous C++ workaround.
2012-07-28 23:47:42 +02:00
wm4
42c3a30008 commands: add show_tracks_osd command to display audio and subtitle tracks on OSD
The command lists the audio and subtitle tracks in the current file on the
OSD. It also marks the currently active streams.
Video streams are not shown, as files with more than one video stream are
exceedingly rare.
2012-07-28 20:57:44 +02:00
wm4
af7a29424c commands: add show_chapters_osd command to display chapters on OSD
The command lists the chapters in the current file on the OSD. It also
marks the current chapter.

This is actually a cheap replacement for the chapter select libmenu
functionality.
2012-07-28 20:57:40 +02:00
wm4
51e198c2a1 Merge remote-tracking branch 'origin/master'
Conflicts:
	.gitignore
	bstr.c
	cfg-mplayer.h
	defaultopts.c
	libvo/video_out.c

The conflict in bstr.c is due to uau adding a bstr_getline function in
commit 2ba8b91a97. This function already existed in this branch.
While uau's function is obviously derived from mine, it's incompatible.
His function preserves line breaks, while mine strips them. Add a
bstr_strip_linebreaks function, fix all other uses of bstr_getline, and
pick uau's implementation.

In .gitignore, change vo_gl3_shaders.h to use an absolute path
additional to resolving the merge conflict.
2012-07-28 17:24:05 +02:00
Uoti Urpala
dc2a4863af options: support parsing values into substructs
Add an alternate mode for option parser objects (struct m_config)
which is not inherently tied to any particular instance of an option
value struct. Instead, this type or parsers can be used to initialize
defaults in or parse values into a struct given as a parameter. They
do not have the save slot functionality used for main player
configuration. The new functionality will be used to replace the
separate subopt_helper.c parsing code that is currently used to parse
per-object suboptions in VOs etc.

Previously, option default values were handled by initializing them in
external code before creating a parser. This initialization was done
with constants even for dynamically-allocated types like strings.
Because trying to free a pointer to a constant would cause a crash
when trying to replace the default with another value, parser
initialization code then replaced all the original defaults with
dynamically-allocated copies. This replace-with-copy behavior is no
longer supported for new-style options; instead the option definition
itself may contain a default value (new OPTDEF macros), and the new
function m_config_initialize() is used to set all options to their
default values. Convert the existing initialized dynamically allocated
options in main config (the string options --dumpfile, --term-osd-esc,
--input=conf) to use this. Other non-dynamic ones could be later
converted to use this style of initialization too.

There's currently no public call to free all dynamically allocated
options in a given option struct because I intend to use talloc
functionality for that (make them children of the struct and free with
it).
2012-07-16 21:08:42 +03:00
wm4
2793e7eb70 Merge remote-tracking branch 'origin/master' 2012-05-20 11:42:44 +02:00
Uoti Urpala
c02d0ee703 options: change --input=keylist, cmdlist implementation
Change the --input=keylist and --input=cmdlist suboptions to use the
"print function" option type. This changes their semantics somewhat,
and now some other output can appear after the printed lists (before,
they called "exit(0)" directly). I'm not aware of any program parsing
the output which could be affected.
2012-05-07 23:21:23 +03:00
wm4
97ac824124 Merge remote-tracking branch 'origin/master'
Conflicts:
	bstr.c
	bstr.h
	libvo/cocoa_common.m
	libvo/gl_common.c
	libvo/video_out.c
	mplayer.c
	screenshot.c
	sub/subassconvert.c

Merge of cocoa_common.m done by pigoz.

Picking my version of screenshot.c. The fix in commit aadf1002f8 will
be redone in a follow-up commit, as the original commit causes too many
conflicts with the work done locally in this branch, and other work in
progress.
2012-04-29 10:01:28 +02:00
Stefano Pigozzi
86790494d3 OSX, input: implement wakeup in response to Cocoa events
Add code to wake up the select() call in input.c when an OSX event is
available and a Cocoa OpenGL backend is initialized.

Fixes the slow response to input or other events in Cocoa-based VOs
during long select() sleeps (e.g., when mplayer2 is paused) introduced
by commit 7040968.
2012-04-26 21:03:10 +03:00
wm4
ce7562705e win32: support key modifiers (shift, ctrl, alt)
Support for this is rather simple, and some combinations of modifiers
and keys don't work. For example, Ctrl+Alt+character is not supported,
because Windows doesn't emit a WM_CHAR in this case.

Also add support for the pause and print screen keys. Remove the
pointless KEY_CTRL translation. Remove KEY_CTRL altogether, because it
was not clear what it was actually supposed to mean.
2012-04-06 23:56:30 +02:00
wm4
1aa2e36122 Merge remote-tracking branch 'origin/master'
Conflicts:
	bstr.c
	bstr.h
	etc/input.conf
	input/input.c
	input/input.h
	libao2/ao_pulse.c
	libmpcodecs/vf_ass.c
	libmpcodecs/vf_vo.c
	libvo/gl_common.c
	libvo/x11_common.c
	mixer.c
	mixer.h
	mplayer.c
2012-04-01 22:52:33 +02:00
Uoti Urpala
a0de4bc500 ao_pulse, core: make pulse thread wake up core for more data
For ao_pulse, the current latency is not a good indicator of how soon
the AO requires new data to avoid underflow. Add an internal pipe that
can be used to wake up the input loop from select(), and make the
pulseaudio main loop (which runs in a separate thread) use this
mechanism when pulse requests more data. The wakeup signal currently
contains no information about the reason for the wakup, but audio
buffers are always filled when the event loop wakes up.

Also, request a latency of 1 second from the Pulseaudio server. The
default is normally significantly higher. We don't need low latency,
while higher latency helps prevent underflows reduces need for
wakeups.
2012-03-26 03:55:31 +03:00
Uoti Urpala
215035b31a input.c: simplify command definitions
Change command definitions to allow writing the command definition
table in more readable format.
2012-03-25 22:30:38 +03:00
wm4
f561c19fe1 x11: input: add print and menu keys 2012-03-25 22:30:37 +03:00
wm4
166a7de4cf input: allow unicode keys and reassign internal key codes
This moves all key codes above the highest valid unicode code point
(which is 0x10FFFF). All key codes below MP_KEY_BASE now directly map
to unicode (KEY_ENTER is 13, carriage return). Configuration files
(input.conf) can contain unicode characters in UTF-8 to map non-ASCII
characters/keys.

This shouldn't change anything user visible, except that "direct key
codes" (as used in input.conf) will change their meaning.

Parts of the bstr functions taken from libavutil's GET_UTF8 and
slightly modified.
2012-03-25 22:30:37 +03:00
wm4
6de8120822 Merge remote-tracking branch 'origin/master' into my_master
Conflicts:
	command.c
	mp_core.h
	mplayer.c
	screenshot.c
2012-03-16 19:14:44 +01:00
wm4
a1244111a7 windows support: unicode filenames
Windows uses a legacy codepage for char* / runtime functions accepting
char *. Using UTF-8 as the codepage with setlocale() is explicitly
forbidden.

Work this around by overriding the MSVCRT functions with wrapper
macros, that assume UTF-8 and use "proper" API calls like _wopen etc.
to deal with unicode filenames. All code that uses standard functions
that take or return filenames must now include osdep/io.h. stat()
can't be overridden, because MinGW-w64 itself defines "stat" as a
macro. Change code to use use mp_stat() instead.

This is not perfectly clean, but still somewhat sane, and much better
than littering the rest of the mplayer code with MinGW specific hacks.
It's also a bit fragile, but that's actually little different from the
previous situation. Also, MinGW is unlikely to ever include a nice way
of dealing with this.
2012-03-09 20:48:54 +02:00
wm4
f440a244e3 input: fix OSD cycling 2012-02-12 19:09:41 +01:00
wm4
489f61aa4c commands: add pt_clear command to clear playlist
This deletes all playlist elements, except the currently active
playlist entry.

NOTE: this doesn't remove parent nodes in the case when we really have
a play tree (as opposed to a play list). Apparently this doesn't cause
any harm.
2012-02-10 19:14:19 +01:00
wm4
02fedc7bab input.c: simplify command definitions
Using type = -1 for terminating the command argument list was an
unnecessary complication. Change it to 0 to make use of default
initialization. Remove the explicit termination from the command
definitions. Now the argument list is automatically terminated by C
default initialization rules.

Also remove other redundant {0} initializers.

When an argument's default value is actually initialized to something other
than 0, make the field being initialized explicit (e.g. {1} becomes
{.i = 1}).

Try to make use of whitespace more consistent.
2012-01-26 03:06:59 +01:00
wm4
064f8c2fb6 Merge branch 'utf8_input' into my_master 2012-01-18 04:19:24 +01:00
wm4
fdc7155ced x11: add print and menu keys 2012-01-18 04:13:27 +01:00
wm4
a63e880400 input: allow unicode keys and reassign internal key codes
This moves all key codes above the highest valid unicode code point (which
is 0x10FFFF). All key codes below MP_KEY_BASE now directly map to unicode.
Configuration files (input.conf) can contain unicode characters in UTF-8
to map non-ASCII characters/keys.

This shouldn't change anything user visible, except that "direct key codes"
(as used in input.conf) will change their meaning.
2012-01-18 04:11:48 +01:00
wm4
f9141fc36f input: simplify previous commit a bit more
Less mutable state = better.
2012-01-18 02:53:23 +01:00
wm4
98203198b6 input: fix crashes with libmenu
Note: now that libmenu has been removed, the related code in input.c has
been removed. If libmenu is ever added back, a queue_remove() function
that can remove any item in the input queue will be required.

libmenu triggered some special case that caused crashes by double frees.
In particular the queue_pop function is used, expecting to remove an element
that is not necessarily always the one that queue_pop removes. Fix by
adding a queue_remove functions. Rewrite the other queue functions, since
these are probably buggy as well. queue_pop didn't even attempt to
maintain the doubly linked list.
2012-01-18 02:52:34 +01:00
wm4
3041ee8d6c core: add screenshot mode for actual VO window contents
The screenshot command normally converts the currently displayed video
frame to an image. Add support for an alternative screenshot mode
that is supposed to capture the real window contents. Such a
screenshot contains a possibly scaled version of the frame, the OSD,
and subtitles.

Add a default key binding Alt+s for taking screenshots in this mode.

This needs special VO support, and might not work with all VOs (this
commit does not yet contain an implementation for any VO, only the
infrastructure).
2011-11-25 23:56:28 +02:00
Uoti Urpala
8b5efd6455 libmenu: remove OSD menu functionality (--menu)
Something like the OSD menu functionality could be useful. However the
current implementation has several problems and would require a
relatively large amount of work to get into good shape. As far as I
know there are few users of the existing functionality. Nobody is
working on the existing code and keeping it compiling at all while
changing other code would require extra work. So delete the menu code
and some related code elsewhere that's used by nothing else.
2011-10-25 07:05:47 +03:00
wm4
75eab4f72a video, options: implement better YUV->RGB conversion control
Rewrite control of the colorspace and input/output level parameters
used in YUV-RGB conversions, replacing VO-specific suboptions with new
common options and adding configuration support to more cases.

Add new option --colormatrix which selects the colorspace the original
video is assumed to have in YUV->RGB conversions. The default
behavior changes from assuming BT.601 to colorspace autoselection
between BT.601 and BT.709 using a simple heuristic based on video
size. Add new options --colormatrix-input-range and
--colormatrix-output-range which select input YUV and output RGB range.
Disable the previously existing VO-specific colorspace and level
conversion suboptions in vo_gl and vo_vdpau. Remove the
"yuv_colorspace" property and replace it with one named "colormatrix"
and semantics matching the new option. Add new properties matching the
options for level conversion.

Colorspace selection is currently supported by vo_gl, vo_vdpau, vo_xv
and vf_scale, and all can change it at runtime (previously only
vo_vdpau and vo_xv could). vo_vdpau now uses the same conversion
matrix generation as vo_gl instead of libvdpau functionality; the main
functional difference is that the "contrast" equalizer control behaves
somewhat differently (it scales the Y component around 1/2 instead of
around 0, so that contrast 0 makes the image gray rather than black).
vo_xv does not support level conversion. vf_scale supports range
setting for input, but always outputs full-range RGB.

The value of the slave properties is the policy setting used for
conversions. This means they can be set to any value regardless of
whether the current VO supports that value or whether there currently
even is any video. Possibly separate properties could be added to
query the conversion actually used at the moment, if any.

Because the colorspace and level settings are now set with a single
VF/VO control call, the return value of that is no longer used to
signal whether all the settings are actually supported. Instead code
should set all the details it can support, and ignore the rest. The
core will use GET_YUV_COLORSPACE to check which colorspace details
have been set and which not. In other words, the return value for
SET_YUV_COLORSPACE only signals whether any kind of YUV colorspace
conversion handling exists at all, and VOs have to take care to return
the actual state with GET_YUV_COLORSPACE instead.

To be changed in later commits: add missing option documentation.
2011-10-16 21:11:11 +03:00
Uoti Urpala
79469244f7 input/ar.c, input/lirc.c: fix changes missing from 1916b95b8
1916b95b8 changed two function types from returning "void" to
returning "int", but was missing changes to add "return 0;" to the
functions. Fix.

The reason for the change in the original commit was that the
functions were called through a function pointer returning int anyway,
so the missing return probably made things no more likely to fail at
runtime than they were before that commit. However, it caused a
compilation failure with clang, which treats non-void function not
returning a value as a fatal error (in GCC it's just a warning).
2011-09-04 08:04:31 +03:00
harklu
9e6933440a options, subs: add --ass-vsfilter-aspect-compat
Add option --ass-vsfilter-aspect-compat and corresponding property
ass_vsfilter_aspect_compat. The setting controls whether to enable the
emulation of traditional VSFilter behavior where subtitles are
stretched if the video is anamorphic (previously always enabled for
native SSA/ASS subtitles). Enabled by default. Add 'V' as a new
default keybinding to toggle the property.
2011-08-12 14:19:10 +03:00
Uoti Urpala
fddb59a6c3 commands: parsing: fix string argument quoting/escaping
Parsing of commands with string arguments had several problems. First,
escape handling modified the original string, which broke keyboard
command definitions with strings containing escapes. Second, in an
argument like "\\" the second quote was incorrectly considered escaped
even though the preceding '\' was itself escaped. Third, an
unterminated quoted string resulted in the argument being set to NULL
even if this violated the declared the minimum number of arguments to
the command type; this could cause a crash in the code executing the
parsed commands. Fix by rewriting the string argument parsing. Also
change int/float argument parsing so that the whole command is
rejected on error.
2011-08-05 03:21:14 +03:00
Uoti Urpala
0958620591 bstr: rename BSTR() -> bstr()
Rename the BSTR() function to bstr(). The former caused a conflict
with some Windows OS name, and it's no longer a macro so uppercase
naming is less appropriate.
2011-07-27 08:38:12 +03:00
Uoti Urpala
d6890a7b53 input: fix input.conf parse errors
Commit df899f59be removing a write outside a buffer triggered another
problem, as for some reason the code did not 0-terminate its read
buffer in the specific case that it had encountered an EOF, and as a
result could parse contents left in the buffer for a second time.
Usually this resulted in parsing error messages. Fix the problem by
rewriting the offending code in a less hacky form.
2011-07-20 04:41:51 +03:00
Uoti Urpala
c2f5465bcc input: fix problem with key autorepeat
Recent commit 82b8f89bae ("input: rework event reading and command
queuing") had a problem in the handling of commands generated by
autorepeat code (this code is only used with joystick and Apple IR
remote input). Fix (still untested though).
2011-07-18 01:18:45 +03:00
Uoti Urpala
82b8f89bae input: rework event reading and command queuing
Rework much of the logic related to reading from event sources and
queuing commands. The two biggest architecture changes are:
- The code buffering keycodes in mp_fifo.c is gone. Instead key input
  is now immediately fed to input.c and interpreted as commands, and
  then the commands are buffered instead.
- mp_input_get_cmd() now always tries to read every available event
  from every event source and convert them to (buffered) commands.
  Before it would only process new events until one new command became
  available.

Some relevant behavior changes:
- Before commands could be lost when stream code called
  mp_input_check_interrupt() which read commands (to see if they were
  of types that triggered aborts during slow IO tasks) and then threw
  them away. This was especially an issue if cache was enabled and slow
  to read. Fixed - now it's possible to check whether there are queued
  commands which will abort playback of the current file without
  throwing other commands away.
- mp_input_check_interrupt() now prints a message if it returns
  true. This is especially useful because the failures caused by
  aborted stream reads can trigger error messages from other code that
  was doing the read; the new message makes it more obvious what the
  cause of the subsequent error messages is.
- It's now possible to again avoid making stdin non-blocking (which
  caused some issues) without reintroducing extra latency. The change
  will be done in a subsequent commit.
- Event sources that do not support select() should now have somewhat
  lower latency in certain situations as they will be checked both
  before and after select()/sleep in input reading; before the sleep
  always happened first even if such sources already had queued
  input. Before the key fifo was also handled in this manner (first
  key triggered select, but if multiple were read then rest could be
  delayed; however in most cases this didn't add latency in practice
  as after central code started doing command handling it queried for
  further commands with a max sleep time of 0).
- Key fifo limiting is more accurate now: it now counts actual
  commands intead of keycodes, and all queued keys are read
  immediately from input devices so they can be counted correctly.
- Since keypresses are now interpreted immediately, commands which
  change keybindings will no longer affect following keypresses that
  have already been read before the command is executed. This should
  not be an issue in practice with current keybinding behavior.
2011-07-17 07:36:09 +03:00
Uoti Urpala
1916b95b8d cleanup: remove some unnecessary input.[ch] typedefs
Remove some unnecessary typedefs and remove pointless mp_ prefix from
some internal struct names.

Change the type of the "close_func" pointers from "void f(int fd)" to
"int f(int fd)" so that using standard close() there is valid.

Delete some useless assert() statements.

Move internal MP_MAX_KEY_DOWN define from input.h to input.c.
2011-07-16 21:32:37 +03:00
Uoti Urpala
db4dee4584 cosmetics: reformat input.h, fix comments 2011-07-16 17:47:02 +03:00
Uoti Urpala
df899f59be input.c: remove write to buffer[-1] in parse_config() 2011-07-11 06:05:19 +03:00
Clément Bœsch
2174cbfa2f cleanup: silence most of the clang warnings 2011-07-09 04:23:24 +03:00
Uoti Urpala
a77e5f07ed Merge branch 'mplayer1_changes' 2011-06-29 11:39:06 +03:00
Uoti Urpala
4e1e23b2e9 input: clean up messages with button combination names
Previously messages that printed key/button names would have extra
names in button combinations appended after the main message,
resulting in output like:
No bind found for key 'MOUSE_BTN1'.-MOUSE_BTN3

Add a function that creates a complete combination name and use that
for all such messages. The above example changes to:
No bind found for key 'MOUSE_BTN1-MOUSE_BTN3'.

Other affected messages are a input.conf parsing error message and a
message about a bound command being invalid.
2011-06-29 08:54:15 +03:00
reimar
9737ae2196 input: support up to 20 mouse buttons
Increase the number of supported mouse buttons from 10 to 20. There
really seem to be input devices with at least 12.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33391 b3059339-0415-0410-9bf9-f77b7e298cf2
2011-06-29 07:46:58 +03:00
Grigori Goronzy
17db5cc98f input: add useful default pointer button bindings
Add two mouse button bindings:
1) left button double click toggles fullscreen
2) right button pauses/unpauses
2011-06-14 19:58:55 +03:00
Uoti Urpala
618f760866 input: make slave command file descriptors nonblocking
Neither fd 0 slave input (-slave) nor additional opened fds (-input
file=X) were set to nonblocking mode as they should have been. Fix.
Also rename the horribly generic USE_SELECT #define used for a
specific slave input detail.
2011-05-04 18:53:17 +03:00
Uoti Urpala
78dca64301 input/joystick.c: add #include missing from 23cb829072
There was a '#include "keycodes.h"' line missing from commit
23cb829072, which broke build with --enable-joystick.
2011-05-03 13:26:30 +03:00
Clément Bœsch
6506d4ad84 cleanup: remove more warnings 2011-05-02 00:46:48 +03:00