Commit Graph

62 Commits

Author SHA1 Message Date
wm4 94782e464d options: get rid of ambiguous option parsing
Options parsing used to be ambiguous, as in the splitting into option
and values pairs was ambiguous. Example:

    -option -something

It wasn't clear whether -option actually takes an argument or not. The
string "-something" could either be a separate option, or an argument
to "-option". The code had to call the option specific parser function
to resolve this.

This made everything complicated and didn't even have a real use. There
was only one case where this was actually used: string lists
(m_option_type_string_list) and options based on it. That is because
this option type actually turns a single option into a proxy for several
real arguments, e.g. "vf*" can handle "-vf-add" and "-vf-clr". Options
suffixed with "-clr" are the only options of this group which take no
arguments.

This is ambiguous only with the "old syntax" (as shown above). The "new"
option syntax always puts option name and value into same argument.
(E.g. "--option=--something" or "--option" "--something".)

Simplify the code by making it statically known whether an option takes
a parameter or not with the flag M_OPT_TYPE_OLD_SYNTAX_NO_PARAM. If it's
set, the option parser assumes the option takes no argument.

The only real ambiguity left, string list options that end on "-clr",
are special cased in the parser.

Remove some duplication of the logic in the command line parser by
moving all argument splitting logic into split_opt(). (It's arguable
whether that can be considered code duplication, but now the code is a
bit simpler anyway. This might be subjective.)

Remove the "ambiguous" parameter from all option parsing related code.

Make m_config unaware of the pre-parsing concept.

Make most CONF_NOCFG options also CONF_GLOBAL (except those explicitly
usable as per-file options.)
2012-08-05 23:51:49 +02:00
wm4 f7e9c15c7b m_config: always reject setting global options in per-file mode
Now the command line parser sets the m_config object into file local
mode, so that m_config can check for this condition. Makes trying to
set global options from a profile fail.

Note: global options can be considered read-only by m_config, so maybe
      there should be an additional check for this. Reusing the file-
      local check is more practical for now, though.
2012-08-04 19:59:56 +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 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
Uoti Urpala 9fbfac25da options: change -v parsing
Handle -v flags as a special case in command line preparsing stage,
and change the option entry into a dummy one. Specifying "v" in config
file no longer works (and the dummy entry shows an error in this
case); "msglevel" can still be used for that purpose. Because the flag
is now interpreted at an earlier parsing stage, it now affects the
printing of some early messages that were only affected by the
MPLAYER_VERBOSE environment variable before.

The main motivation for this change is to get rid of the last
CONF_TYPE_FUNC option.
2012-05-07 23:51:58 +03:00
Uoti Urpala 081e2d0b7b options: commandline: support "--no-opt" for flag options
When parsing the command line, map "--no-foo" to "--foo=no" if an
option named "foo" exists and is a flag option. Non-empty parameters
are not allowed with this syntax ("--no-foo=no" is invalid).

This implementation is different from the existing "--nofoo" variants
for most flag options. Those are implemented as completely separate
options; there's an option named "fs" and a separate option named
"nofs" (thus "--no-nofs" actually works after this change...). The
reason for adding the new syntax is to support the much more standard
"--no-" prefix and to allow eventually cleaning up the option handling
(though the "nofoo" variants of existing options can't be removed soon
due to backwards compatibility).
2011-09-01 18:32:11 +03:00
Uoti Urpala ce9ce9d0c3 options: commandline: don't set bogus playtree option params
The command line parsing code recorded the next commandline argument,
if any, as the parameter of any option recorded to playtree. Thus a
command line like "mplayer file -fs -aid 1" would record option "-fs"
with a bogus argument "-aid". Historically this triggered no visible
problems because such bogus arguments were silently ignored when
interpreting the options later. However after recent commit 507fa7e2c2
("options: indicate ambiguous option parameters explicitly")
parameters to flag options are no longer ignored, and the bogus values
now triggered parsing errors. Add a check to stop recording parameters
for old-style single-dash options if m_config_check_option() says the
option did not consume any arguments.
2011-07-31 01:19:13 +03:00
Uoti Urpala ad48f8038c options: commandline: print error type for parse failures
If parsing an option fails, print a string corresponding to the parse
function return value (M_OPT_MISSING_PARAM etc). The primary
motivation is that the parsing code already outputs messages
explaining most problems, but does not itself print anything in the
missing parameter case. Before double-dash --options such errors were
rare (or rather they resulted in the next commandline argument being
silently misinterpreted as an argument to the previous option
instead); but now an argument like "--ss" should give a better
indication about the problem than just "Error parsing option".
2011-07-29 07:58:56 +03:00
Uoti Urpala 5d5ca22a6d options: commandline: accept --foo=xyz style options
Allow writing commandline options with two leading dashes. In this
mode a parameter for the option, if any, follows after a '=';
following separate commandline arguments are never consumed as a
parameter to a previous double-dash option.

Flag options may omit parameter and behave like old single-dash
syntax. "--fs=yes", "--fs=no" and "--fs" are all valid; the first two
behave like configuration file "fs=yes" and "fs=no", and last is the
same as old "-fs" (same effect as "--fs=yes").
2011-07-29 07:24:09 +03:00
Uoti Urpala 0010ffefc4 options: commandline: allow "--" without filenames after it
A "--" argument on the command line is used to indicate that all
following arguments should be interpreted as filenames, not options.
Specifying it as the last argument was considered an error. I see no
particular reason to forbid the following filename list to be empty,
nor do other programs with similar functionalitly I know about treat
it that way. So just ignore a "--" with no more arguments.
2011-07-29 05:50:38 +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 ea4cc89f36 options: move command line preparse together with parse 2011-07-26 06:02:03 +03:00
Uoti Urpala 02b99bd5ba cleanup: reformat parser-mpcmd.c
Also remove some redundant code.
2011-07-26 04:28:37 +03:00
Uoti Urpala 00323c06e2 Delete things related to old translation system
Remove the help/ subdirectory, configure code to create toplevel
help_mp.h, and all the '#include "help_mp.h"' lines from .c files.
2010-03-10 03:47:14 +02:00
Uoti Urpala acdce0176a Merge svn changes up to r30732 2010-03-10 01:25:15 +02:00
Uoti Urpala 12d3caebc7 Merge svn changes up to r30475 2010-03-09 19:18:43 +02:00
diego 5405958e34 Add header for macosx_finder_args() instead of forward declaring it.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30717 b3059339-0415-0410-9bf9-f77b7e298cf2
2010-02-23 07:54:10 +00:00
diego 99c1bbca2a Add license header to all top-level files missing them.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30471 b3059339-0415-0410-9bf9-f77b7e298cf2
2010-01-30 23:24:23 +00:00
Uoti Urpala 287b62163e Merge svn changes up to r29912 2009-11-16 07:01:46 +02:00
reimar 92ac5a8c20 Support the range syntax (like dvd://2-5) also for dvdnav.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29892 b3059339-0415-0410-9bf9-f77b7e298cf2
2009-11-11 09:03:39 +00:00
Uoti Urpala 0eb321bf2c Remove trailing whitespace from most files 2009-07-07 02:34:35 +03:00
Amar Takhar e306174952 Translation system changes part 2: replace macros by strings
Replace all MSGTR_ macros in the source by the corresponding English
string.
2009-07-07 01:38:20 +03:00
Amar Takhar b5972d6f14 Translation system changes part 1: wrap translated strings
Replace mp_msg() calls which have a translated string as the format
argument with mp_tmsg and add _() around all other translated strings.
2009-07-07 01:28:07 +03:00
diego 6e9cbdc104 whitespace cosmetics: Remove all trailing whitespace.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29305 b3059339-0415-0410-9bf9-f77b7e298cf2
2009-05-13 02:58:57 +00:00
Uoti Urpala 8c144171bb Merge svn changes up to r28087
Conflicts:
	command.c
	libao2/ao_ivtv.c
	libao2/ao_v4l2.c
	libmpcodecs/dec_video.h
	libvo/aspect.h
	libvo/sub.c
	libvo/sub.h
	libvo/vo_directx.c
	libvo/vo_macosx.m
	libvo/vo_quartz.c
	mp_core.h
	mplayer.c
	mplayer.h
	osdep/getch2.h
	osdep/timer.h
2008-12-04 01:55:52 +02:00
diego 0864f92e7a Get rid of pointless 'extern' keywords.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28085 b3059339-0415-0410-9bf9-f77b7e298cf2
2008-12-03 23:01:03 +00:00
Uoti Urpala 17d3e4b36d Merge svn changes up to r27441
Conflicts:

	cfg-common-opts.h
	command.c
	configure
	input/input.c
	libmpcodecs/dec_video.c
	libmpcodecs/vd.c
	libmpdemux/stheader.h
	libvo/sub.c
	libvo/video_out.c
	libvo/vo_xv.c
	libvo/vosub_vidix.c
	libvo/x11_common.c
	libvo/x11_common.h
	mp_core.h
	mplayer.c
	stream/stream.h
2008-08-08 02:13:09 +03:00
diego e0b1c9a6b7 Give a CONFIG_ prefix to preprocessor directives that lacked one and
change arbitrary prefixes to CONFIG_.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27429 b3059339-0415-0410-9bf9-f77b7e298cf2
2008-08-07 12:20:50 +00:00
diego 5641e60698 Ahem, the MACOSX_FINDER_SUPPORT directive was renamed to MACOSX_FINDER.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27426 b3059339-0415-0410-9bf9-f77b7e298cf2
2008-08-07 10:57:40 +00:00
Uoti Urpala fb33e286b5 Move global mconfig to mpctx
The global was used in the function cfg_include which handles the
-include option. Make the address available in that function by
creating a new dynamically allocated option in m_config_new that has
the address in the option's private data.

asxparser.c also used the global. Making it available through all ways
the code could get called required a number of relatively straightforward
changes to playtree and menu code.
2008-04-26 10:44:59 +03:00
uau 03bb309e4e Include some .h files in corresponding .c files
Include the corresponding .h file in command.c, parser-cfg.c and
parser-mpcmd.c. This allows the compiler to check that the
declarations in the .h file match the actual defition.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26295 b3059339-0415-0410-9bf9-f77b7e298cf2
2008-03-28 01:07:59 +00:00
reimar 8373b55173 Mark more m_option_t uses as const
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25255 b3059339-0415-0410-9bf9-f77b7e298cf2
2007-12-02 15:46:44 +00:00
ptt c846ef4a98 localization of parser-m*cmd.c messages
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@21328 b3059339-0415-0410-9bf9-f77b7e298cf2
2006-11-27 15:46:36 +00:00
albeu 400a9fab2e Doxygen Attack! - Chapter 3
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18266 b3059339-0415-0410-9bf9-f77b7e298cf2
2006-04-25 01:26:10 +00:00
reynaldo 889eedb39e Small fix, incorrect MSGL at fatal error
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18210 b3059339-0415-0410-9bf9-f77b7e298cf2
2006-04-22 21:30:34 +00:00
reimar 5c332bb395 also print an error when parsing fails with M_OPT_INVALID or M_OPT_PARSER_ERR.
fixes MPlayer exiting without message for e.g. "mplayer -ao"


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18149 b3059339-0415-0410-9bf9-f77b7e298cf2
2006-04-19 15:50:37 +00:00
reimar 86acb156cf avoid crash when running "mplayer -loop" (dereferencing uninitialize pointer).
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18098 b3059339-0415-0410-9bf9-f77b7e298cf2
2006-04-14 21:51:45 +00:00
albeu 7f28974433 Make -list-options work in both MPlayer and MEncoder.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17473 b3059339-0415-0410-9bf9-f77b7e298cf2
2006-01-24 11:34:24 +00:00
gpoirier 43844d090c allow multiple help clauses on the command line, Patch by kiriuja " mplayer-patches AH en-directo POUM net "
This one makes

mplayer -vo help -ao help -ac help -vc help -pphelp -af help -vfm help -vf help -afm help -fstype help

produce the desired output.

From the thread:
Date: Jul 16, 2005 8:25 PM
Subject: [MPlayer-dev-eng] [PATCH] allow multiple help clauses on the command line


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@16346 b3059339-0415-0410-9bf9-f77b7e298cf2
2005-09-02 08:29:30 +00:00
reimar c6e32e91b1 when somebody specifies e.g. --loop, the message says that a -loop option
does not exist. So add an extra - to the message.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@15743 b3059339-0415-0410-9bf9-f77b7e298cf2
2005-06-17 08:11:56 +00:00
reimar 1390092640 Make "mplayer -- --a" play the file --a instead of bailing out with a useless
error message


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@15246 b3059339-0415-0410-9bf9-f77b7e298cf2
2005-04-23 20:41:19 +00:00
diego 6974dfae6b Clarify confusing error message.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14542 b3059339-0415-0410-9bf9-f77b7e298cf2
2005-01-19 18:24:53 +00:00
reimar 8fb512dbf0 fix: when doing -loop 0 -shuffle, the arg after shuffle was skipped
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13933 b3059339-0415-0410-9bf9-f77b7e298cf2
2004-11-14 11:09:56 +00:00
nplourde 2cc1ec3ea4 add support for macosx finder argument support (let you bundle mplayer to be a finder compliant .app) patch by Chris Roccati <roccati@pobox.com>
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13910 b3059339-0415-0410-9bf9-f77b7e298cf2
2004-11-10 16:43:40 +00:00
diego de22e52855 -use-stdin renamed to -noconsolecontrols.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@12817 b3059339-0415-0410-9bf9-f77b7e298cf2
2004-07-14 09:27:04 +00:00
rtognimp 1d0ac71ae8 Support dvd://start_title-end_title as requested on wishlist
Patch by adland


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@12544 b3059339-0415-0410-9bf9-f77b7e298cf2
2004-06-07 18:58:08 +00:00
rtognimp a6cf371922 Fail if empty or nonexitant playlist
Patch by adland


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@12268 b3059339-0415-0410-9bf9-f77b7e298cf2
2004-04-24 13:15:31 +00:00
alex 1c4586e8f9 100l to albeu for his english grammar, and 10l to me becouse I noticed that lately (my backward compatibilty macro uses M_OPT_UNKNOWN)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@10596 b3059339-0415-0410-9bf9-f77b7e298cf2
2003-08-13 16:45:02 +00:00
alex 2283b6305f Removed the historic cfgparser and switched full to the new config parser (altought some macros still remain for compatibility). As a side effect 90% of the warning messages are gone from the core. Things should be cleaner now and less confusing for newbies.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@10595 b3059339-0415-0410-9bf9-f77b7e298cf2
2003-08-13 16:29:32 +00:00