Commit Graph

260 Commits

Author SHA1 Message Date
Kovensky bc63957551 windows support: include io.h when building on Cygwin 2012-09-30 15:16:53 +02:00
Rudolf Polzer a70adbfe65 getch2: request at least 1 byte of input each read
fixes issue with | less, where mplayer broke less's terminal
expectations and made less quit

Note this means that read() will be blocking again. Should be ok, as we
always check via select() before reading.
2012-09-19 14:57:35 +02:00
wm4 c5e2120e15 timer: remove timer_name
This was unreferenced and useless.
2012-09-07 16:06:36 +02:00
Stefano Pigozzi c15270d3b9 macosx_finder_args: fix file open order
When files are double clicked or drag and dropped to the mplayer2 icon they
can be in random order. This commit forces alphabetical order.

Opening them with command + down arrow already worked correctly.
2012-08-16 22:35:27 +02:00
Stefano Pigozzi 39e28570f1 macosx_finder_args: make work with recent changes 2012-08-16 22:32:26 +02:00
mplayer-svn bbc9fccd46 cache2: allow cache sizes up to 4 TB
Remove variable that is only assigned but never used.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34791 b3059339-0415-0410-9bf9-f77b7e298cf2

Allow using a cache size of up to 4 TB.
Obviously anything close to 4 GB will always fail
on 32 bit systems.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34792 b3059339-0415-0410-9bf9-f77b7e298cf2

Replace off_t by int64_t in cache code.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34793 b3059339-0415-0410-9bf9-f77b7e298cf2

Remove casts that are no longer necessary.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34794 b3059339-0415-0410-9bf9-f77b7e298cf2

Fix header file after r34793.

Patch by Stephen Sheldon, sfsheldo gmail com.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34802 b3059339-0415-0410-9bf9-f77b7e298cf2

Put #include <inttypes.h> into the header file where it should be.

Reported by Stephen Sheldon, sfsheldo gmail com.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34798 b3059339-0415-0410-9bf9-f77b7e298cf2

Correct r34798.

The header only needs stdint.h while the C file needs inttypes.h.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34799 b3059339-0415-0410-9bf9-f77b7e298cf2

Author: reimar
2012-08-03 01:52:40 +02:00
mplayer-svn 1764bfacca osdep:/glob-win.c: reformat
Use uncrustify on glob-win.c to fix the indentation mess in it.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34239 b3059339-0415-0410-9bf9-f77b7e298cf2
Author: reimar
2012-08-03 01:31:32 +02:00
wm4 b0e695cf79 Remove leftover BeOS support stuff
As by mplayer-svn commit 33972. Their BeOS removal was more thorough.
2012-08-03 01:20:51 +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 6e020e66e0 mp_msg: remove filename_recode
This was intended for translating filenames from filesystem charset to
the terminal charset. Modern sane platforms use UTF-8 for everything,
and on Windows we use unicode APIs, so this is not needed anymore.

Remove filename_recode, all uses of it, options and configure checks
related to terminal output charset, and code that tries to determine
the same.
2012-07-31 01:35:53 +02: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 3bb456b14d win32: simplify icon loading
I have no idea why the code used this roundabout method.
Also detab mplayer.rc.
2012-04-14 17:03:11 +02:00
wm4 47371bdb94 Merge remote-tracking branch 'origin/master'
Conflicts:
	libvo/vo_kva.c
2012-04-13 17:45:27 +02:00
wm4 a659429f86 win32: use more unicode functions
Use the *W variants instead of the implicit *A functions. (One could
define the UNICODE macro to switch the functions without suffix from
A to W, but I'm too lazy to figure out how portable that is, etc.)

Also make sure io.h defines a unicode aware printf().
2012-04-06 23:56:30 +02:00
Uoti Urpala e2fc1f640f build: remove OS/2 support 2012-04-06 17:45:56 +03:00
Uoti Urpala b93ed27836 input: stop trying to read terminal input on EOF
Stop trying to read terminal input if a read attempt returns EOF. The
most important case where this matters is when someone runs the player
with stdin redirected from /dev/null and without specifying
--no-consolecontrols. This used to cause 100% CPU load while paused,
as select() would continuously trigger on stdin (the need for
--no-consolecontrols was not apparent to people with older mplayer
versions, as input reading was less efficient and latencies like
hardcoded sleeps kept CPU use well below 100%). Now this will only
cause a "Dead key input" error message.
2012-04-06 14:34:56 +03: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
Stefano Pigozzi ae0a38ddf8 macosx_finder_args: use a custom logfile instead of system.log
Change the macosx_finder_args function so that when mplayer2 is
invoked from the Finder in a Mac application bundle, it redirects the
output to ~/Library/Logs/mplayer2.log instead of cluttering the global
system.log.

This doesn't affect terminal use which keeps writing to stdout and
stderr.
2012-03-25 22:30:37 +03:00
Stefano Pigozzi 24e08eb5f2 macosx_finder_args: use cocoa instead of carbon
macosx_finder_args was using Carbon and wasn't usable any longer on
modern versions of MacOSX. This is very useful to embed mplayer in a
mac application bundle.

When using application bundles, the operating system will call the
main function with only one argument that identifies the process
serial number (this is some additional process identifier in osx other
than the pid). File open events are then dispatched to the application
through events that must be handled accordingly.
2012-03-25 22:30:37 +03:00
wm4 7ea5c4c26c input: handle UTF-8 terminal input
This assumes the terminal uses UTF-8. If invalid UTF-8 is encountered (for
example because the terminal uses a legacy encoding), the code falls back
to the old method and feeds each byte as key code to the input code.

In theory, UTF-8 input could randomly fail, because the code in getch2.c
doesn't try to fill the input buffer correctly with input sequences
longer than a byte. This is a problem with the design of the existing
code.
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
Martin Herkt f891939b4d windows: terminal: unicode, --msgcolor, size change
Make mp_msg() support unicode output, --msgcolor and variable screen
sizes.

Patch reintegrated by wm4.
2012-03-09 20:48:54 +02: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 24be34f1e9 cleanup: Silence compilation warnings on MinGW-w64
Some of the code, especially the dshow and windows codec loader parts,
are extremely hacky and likely full of bugs. The goal is merely getting
rid of warnings that could obscure more important warnings and actual
bugs, instead of fixing actual problems. This reduces the number of
warnings from over 500 to almost the same as when compiling on Linux.

Note that many problems stem from using the ancient wine-derived
windows headers. There are some differences to the "proper" windows
header. Changing the code to compile with the proper headers would be
too much trouble, and it still has to work on Unix.

Some of the changes might actually break compilation on legacy MinGW,
but we don't support that anymore. Always use MinGW-w64, even when
compiling to 32 bit.

Fixes some warnings in the win32 loader code on Linux too.
2012-03-01 00:22:30 +02:00
wm4 c8efb6d566 input: restore terminal attributes after resume
Install a signal handler on SIGCONT, and restore the terminal
attributes with tcsetattr() if it happens. This is needed with some
shells (such as tcsh) that don't restore the terminal attributes set
by mplayer. Without this, terminal I/O doesn't work as intended after
resume with these shells.

Fixes #155.
2012-02-25 16:40:14 +01:00
wm4 9371753dc4 Merge remote-tracking branch 'origin/master' into my_master 2012-02-19 17:34:28 +01:00
wm4 3b68a774b9 input: fix "enter" on console
The commit "input: handle UTF-8 terminal input" accidentally messed up
the handling of certain special keys. Apparently only KEY_ENTER was
affected by this, because the code was valid UTF-8, but didn't directly
map to the keycode.
2012-02-19 16:51:52 +01:00
Uoti Urpala 637d6b7c8e Update copyright year 2012-01-28 13:49:13 +02:00
wm4 e722967580 input: handle UTF-8 terminal input
This assumes the terminal uses UTF-8. If invalid UTF-8 is encountered (for
example because the terminal uses a legacy encoding), the code falls back
to the old method and feeds each byte as key code to the input code.

In theory, UTF-8 input could randomly fail, because the code in getch2.c
doesn't try to fill the input buffer correctly with input sequences
longer than a byte. This is a problem with the design of the existing
code.
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
Uoti Urpala 318559056f getch2.c: fix negative keycodes returned for non-ascii
getch2.c read data into a "char" array, and returned values other than
escape sequences directly from there. This meant that it could return
negative values (except on platforms where "char" is unsigned) if the
input contained bytes >= 128. This would break later parsing in
input.c as the values would be interpreted as having the MP_KEY_DOWN
flag set, which would make the key binding code think a key is held
down (and never released). Fix by changing the buffer type to unsigned
char.

The bug itself was very old, but started triggering visible breakage
more easily after commit 82b8f89bae ("input: rework event reading and
command queuing"). Before that the key values would be passed through
the input.c "key read function" interface, which (mis)interpreted the
negative values as errors from the function, and in most cases
discarded them without much visible effect.
2011-10-03 04:12:15 +03:00
Martin Herkt 47f5d53d85 osdep/mplayer.rc: change to use "mplayer2" name 2011-08-21 02:18:00 +03:00
Uoti Urpala b33bb28ea3 build: fix --enable-debug, remove some "#ifdef MP_DEBUG"
Recent commit 5d5ca22a6d ("options: commandline: accept --foo=xyz
style options") left some bad code under "#ifdef MP_DEBUG" in
playtree.c, which caused a compilation failure if configured with
"--enable-debug". Fix this. Having the "#ifdef MP_DEBUG" there was
completely unnecessary; it only increased the risk for this kind of
problems for no real benefit - executing the asserts under it would
have no noticeable performance or other penalty in default builds
either. Remove several cases of such harmful "#ifdef MP_DEBUG".
2011-07-30 19:03:20 +03:00
Uoti Urpala e873d703e9 options: change option parsing to use bstr
Using bstr allows simpler parsing code, especially because it avoids
the need to modify or copy strings just to terminate extracted
substrings.
2011-07-29 05:50:38 +03:00
Uoti Urpala 507fa7e2c2 options: indicate ambiguous option parameters explicitly
Command line options like "-foo xyz" are ambiguous: "xyz" may be a
parameter to the option "foo" or an unrelated argument. Instead of
relying on the struct m_config mode field (commandline/file) pass
parameters to specify ambiguous mode explicitly. Meant for "--foo"
options which are never ambiguous on command line either.
2011-07-29 05:02:05 +03:00
Uoti Urpala c3e46833c2 input: don't make fd 0 nonblocking
Setting O_NONBLOCK on a file descriptor also affects all other fds
that share the same underlying open file description, and in case of
stdin such sharing is likely. Making stdin nonblocking can also make
stdout nonblocking (they may be the same connection to a terminal),
and it can also affect other processes (in "program1 | program2", the
shell may give the same terminal connection to program1 as stdin and
to program2 as stdout, thus program1 making its stdin nonblocking also
turns program2's stdout nonblocking).

To avoid these problems stop making fd 0 nonblocking. After the
previous commit this should no longer cause problems as long as
select() does not spuriously report the fd as readable.
2011-07-17 17:05:08 +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 23cb829072 input: move all key code lists to input/keycodes.h
Move the definitions of all special key codes (those not passed by
ASCII value) to input/keycodes.h. Before they were spread between
osdep/keycodes.h, input/joystick.h, input/mouse.h and input/ar.h, plus
some special values in input.h. This was especially inconvenient as
the codes had to be coordinated to not conflict between the files.

The change requires a bit of ugliness as appleir.c includes
<linux/input.h> which contains various conflicting KEY_* definitions.
Work around this by adding a special preprocessor variable which can
be used to avoid defining these in keycodes.h.
2011-05-02 00:43:31 +03:00
Uoti Urpala 40234b1a3c input: make stdin non-blocking for terminal input
getch2.c did not make stdin non-blocking, and relied on only being
called after select() had shown readability. Stop relying on that
assumption and set stdin to non-blocking mode. Hopefully no relevant
platform has problems with this...
2011-04-28 12:52:00 +03:00
Uoti Urpala 5e0a163886 tl_matroska.c: move the find_files() function here
Move the find_files() function from findfiles.c to tl_matroska.c.
Delete the findfiles.c file. Add a check against opendir() failure in
find_files().
2011-03-03 21:38:52 +02:00
Uoti Urpala 962eec0440 bstr.[ch], path.[ch]: add string and path handling functions
Add some new string and path handling functions to be used in
following commits.

Use new path handling functions to simplify find_files().
2011-02-26 16:40:31 +02:00
diego 359e85c234 osdep: tweak some #includes
Add/remove a few standard header #includes in osdep files.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32762 b3059339-0415-0410-9bf9-f77b7e298cf2
2011-01-31 16:03:10 +02:00
reimar c46bd9a252 build: cygwin: don't rely on _WIN32 being defined
configure: Compilation fixes for current Cygwin

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32724 b3059339-0415-0410-9bf9-f77b7e298cf2

Do not #define _WIN32 on the command line for Cygwin.

Newer Cygwin versions no longer do this and hopefully we should be able
to survive without this hack as well.  This change necessitates adapting
two #ifdefs in the MPlayer codebase.  It is committed untested as I do
not have access to a Cygwin system.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32763 b3059339-0415-0410-9bf9-f77b7e298cf2
2011-01-29 04:04:53 +02:00
Uoti Urpala 0afb326035 Merge branch 'hr-seek'
* hr-seek:
  input: add default keybindings Shift+[arrow] for small exact seeks
  input: support bindings with modifier keys for X input
  core: audio: make ogg missing audio timing workaround more complex
  core: add support for precise non-keyframe-limited seeks
  core: add struct for queued seek info
  commands: add generic option -> property wrapper
  options: add "choice" option type, use for -pts-association-mode
  core: remove looping in update_video(), modify command handling a bit
  core: seek: use accurate seek mode with audio-only files
  core: avoid using sh_video->pts as "current pts"
  libvo: register X11 connection fd in input event system
  core: timing: add special handling of long frame intervals
  core: move central play loop to a separate function

Conflicts:
	DOCS/tech/slave.txt
2010-12-20 19:17:43 +02:00
Uoti Urpala 67fd58d6f0 input: support bindings with modifier keys for X input
Add support for binding commands to modifier+key combinations like
"Shift+Left" or "Ctrl+Alt+x", and support reading such combinations
from the output window of X VOs.

The recognized modifier names are Shift, Ctrl, Alt and Meta. Any
combination of those and then a non-modifier key name, separated by
'+', is accepted as a key name in input.conf. For non-special keys
that produce characters shift is ignored as a modifier. For example
"A" is handled as a key without modifiers even if you use shift to
write the capital letter; 'a' vs 'A' already distinguishes the
combinations with a normal keymap, and having separate 'a', 'Shift+A'
and 'A' (written with caps lock for example) would bring more
confusion than benefit.

Currently reading the modifier+key combinations is only supported in
the output window of those VOs that use x11_common.c event
handling. It's not possible to input the key combinations in other VOs
or in a terminal window.
2010-12-20 19:02:24 +02:00
Uoti Urpala 2bc2399797 vd_ffmpeg: set thread count to number of cores on machine by default
Make "-lavdopts threads=0" mean an autodetected number of threads, and
make that the default value of the option. Also increase the upper
limit of the option from 8 to 16. Add new file osdep/numcores.c which
tries to determine the number of cores available on the machine.

numcores.c is based (heavily modified) on public domain numcpus.c by
Philip Willoughby <pgw99@doc.ic.ac.uk>, downloaded from
http://csgsoft.doc.ic.ac.uk/numcpus/
2010-12-20 05:53:28 +02:00
cboesch fe3c4810e1 cleanup: remove NULL checks before free() all over the code
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32624 b3059339-0415-0410-9bf9-f77b7e298cf2
2010-11-14 13:11:20 +02:00
diego 956d11235c osdep/macosx_finder_args.h: include required header m_config.h
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32166 b3059339-0415-0410-9bf9-f77b7e298cf2
2010-11-02 04:16:46 +02:00