Commit Graph

50 Commits

Author SHA1 Message Date
wm4 1d1f59234b commands: move legacy property wrapper to m_property.c 2012-10-12 10:10:33 +02:00
wm4 8fc2aef3b7 commands: don't use dummy option declaration for properties
The property-to-option bridge (when properties change values normally
set by the command line parser) uses M_PROPERTY_GET_TYPE to get the
exact option type. In these cases, the entry in mp_properties[] is
unused, except for the name field and the property callback. Instead,
mp_property_generic_option() implements M_PROPERTY_GET_TYPE and returns
the m_option as defined in cfg-mplayer.h. However, if a property is
unavailable, mp_property_generic_option() is never actually called, and
M_PROPERTY_GET_TYPE will return the dummy option entry.

We could make sure that the dummy option entry equals the option entry
defined in cfg-mplayer.h. But this would duplicate all information.

Add a dummy option type m_option_type_dummy, which is used by entries
using the property-to-option bridge. Make M_PROPERTY_GET_TYPE fail if
this type is encountered.

This dummy should never be used, as it isn
2012-10-12 10:10:32 +02:00
wm4 32c5a87a01 commands: change property expansion format string
This affects property format strings like they are used in the
"show_text" input command, for --playing-msg, and other places.

To quote the documentation comment on m_properties_expand_string():

    ${NAME} is expanded to the value of property NAME.
    If NAME starts with '=', use the raw value of the property.
    ${NAME:STR} expands to the property, or STR if the property is not
    available.
    ${?NAME:STR} expands to STR if the property is available.
    ${!NAME:STR} expands to STR if the property is not available.
    STR is recursively expanded using the same rules.
    "$$" can be used to escape "$", and "$}" to escape "}".
    "$>" disables parsing of "$" for the rest of the string.

Most importantly, "?(property:str)" becomes "${?property:str}".

Make the simple fallback case easier, e.g. "${property:fallback}"
instead of "${property}?(!property:fallback)".

Add the ability to escape the format meta characters. "$" is used for
escaping, because escaping with "\" is taken by the commands parser in
the layer below. "$>" can be used to disable interpretation of format
strings (of course escapes by the commands parser can't be canceled).

By default, properties which are unavailable or don't exist are turned
into a string signaling the status (e.g. "(unavailable)"), instead of
an empty string. If an empty string is desired, this has to be done
explicitly: "${property:}" (the fallback part is an empty string). Raw
properties still return an empty string on error.

m_properties_expand_string() now returns a talloc'ed pointer, instead of
a malloc'ed one.
2012-10-12 10:10:32 +02:00
wm4 d232012287 input: handle escapes always in command parser
Previously, both the command parser and property expansion
(m_properties_expand_string) handled escapes with '\'. Move all escape
handling into the command parser, and remove it from the property code.

This removes the need to escape strings twice for commands that use
property expansion.

The command parser is practically rewritten: it uses m_option for the
actual parsing, and reduces hackish C-string handling.
2012-10-12 10:10:32 +02:00
wm4 84af173380 commands: cosmetics: rename things
This is Better (tm).

The only actual change is that with M_PROPERTY_SET_STRING, the option
parser will use the property name, instead whatever was set in the
name field of the option returned by M_PROPERTY_GET_TYPE. In most cases,
these should be the same, though.
2012-10-12 10:10:32 +02:00
wm4 45b432f4c3 commands: replace "switch" with "add" and "cycle"
Now it depends on the command whether a property wraps around, or stops
at min/max valid property value.

For practically all properties, it's quite unambiguous what the "switch"
command should have done, and there's technically no need to replace it
with these new commands. More over, most properties that cycle are
boolean anyway. But it seems more orthogonal to make the difference
explicit, rather than hardcoding it. Having different commands also
makes it more explicit to the user what these commands do, both just due
to the naming, and what wrapping policy is used. The code is simpler
too.
2012-10-12 10:10:31 +02:00
wm4 d356219824 commands: remove M_PROPERTY_SWITCH from edition property
Instead, communicate the new value range with M_PROPERTY_GET_TYPE. Add
M_PROPERTY_GET_WRAP to allow properties to enable cycling instead of
stopping at min/max.
2012-10-12 10:10:31 +02:00
wm4 74adc534b9 commands: make M_PROPERTY_GET_TYPE return an option copy
Change the type of the arg for this action from m_option** to m_option*.
This makes it easier to change some aspects of the option dynamically.
2012-10-12 10:10:31 +02:00
wm4 ed8e738e0f commands: cosmetic changes mostly to m_property.h
The Doxygen-style documentation comments were nothing but bloat.

Also move mp_property_do() and mp_property_print() to command.h, where
they should belong, and fix their argument types. m_property.c/h is
supposed to be generic, while command.h provides declarations specific
to the mplayer core.
2012-10-12 10:10:31 +02:00
wm4 d6dad9e934 commands: remove fallback for M_PROPERTY_PARSE and M_PROPERTY_TO_STRING
These should never be overridden by property implementations anyway,
because it would likely result in inconsistencies. The right way to do
this is adding a new m_option type.

Also some cosmetics.
2012-10-12 10:10:31 +02:00
wm4 dec53f760e commands: add more property-option bridge uses, rename some options
Make more properties use the property-to-option bridge to reduce code
size and to enforce consistency. Some options are renamed to the same
as the properties (the property names are better in all cases).

Do some other minor cleanups. One bigger issue was memory management of
strings: M_PROPERTY_TO_STRING assumed the strings were statically
allocated, and no dynamic allocations could be returned. Fix this in
case the need for such properties arises in the future. Get rid of
m_property_string_ro(), because it's not always clear that the "action"
parameter is M_PROPERTY_SET and the string argument will be used.
2012-10-12 10:10:31 +02:00
wm4 86ed6efd8a commands: handle property clamping in m_option
Instead of clamping property values to the valid range in each property
implementation, handle it in the property layer. The functionality to
handle clamping for each type is in m_option.c.

It's not really clear whether this is really needed. Normally, the raw
values for M_PROPERTY_SET come only from m_option_type.parse (setting
properties as string) or from m_option_parse.add (using the "switch"
input command). However, since this was already done before, and since
we _really_ want to be sure only to write valid values, add this code
anyway. The newly added warnings/error messages should never actually
be printed during normal operation and are for debugging (if they
happen, we definitely want to see them).
2012-10-12 10:10:31 +02:00
wm4 426640204b options: simplify somewhat by introducing a union for option values
The m_option_value union is supposed to contain a field for each
possible option type (as long as it actually stores data). This helps
avoiding silly temporary memory alocations. Using a pointer to an union
and to a field of the union interchangeably should be allowed by
standard C.
2012-10-12 10:10:31 +02:00
wm4 69ce4591d0 commands: generally handle property formatting with m_option
Use the m_option code by default to format property values, instead of
having separate code in m_property.

To facilitate that, add a pretty_print callback to option types. These
format values in a more human readable and user friendly way, as opposed
to the print callback, which produces parseable values.

This also changes the strings used with flags. Instead of "enabled" and
"disabled", flags are formatted as "yes" and "no". (We could use the
pretty_print callback to deal with this, but we don't for consistency.)
2012-10-12 10:10:31 +02:00
wm4 f607d104b6 commands: remove pointless NULL checks
Most property implementations checked whether the "arg" parameter was
NULL. This is entirely pointless, because NULL is actually never pased.
It was inconsistently done, too. Remove the checks.
2012-10-12 10:10:31 +02:00
wm4 cac7702565 commands: handle property stepping in a generic way
Instead of forcing each property implementation implement its own logic
for M_PROPERTY_STEP_UP/M_PROPERTY_STEP_DOWN, handle it in the generic
property code.

Rename the M_PROPERTY_STEP_UP command to M_PROPERTY_SWITCH (the other
property command, M_PROPERTY_STEP_DOWN, isn't needed anymore: stepping
downwards is done by passing a negative argument). Always use double as
argument type; it makes the code easier, and covers all property types.
Move the code which does the actual type-specific value stepping to
m_option.c (the idea is that m_option handles types).

Some properties still have custom handlers implemented with
M_PROPERTY_SWITCH. They can't be mapped to the generic mechanism,
because their value range is dynamic or entirely unknown.

For some properties, the default step stride is changed to 1. This is no
issue, because the default bindings in input.conf all use an explicit
stride in the affected cases.
2012-10-12 10:10:31 +02:00
wm4 10437c35df commands: rename "osdlevel" option and property, make it a choice
Rename both the option and property to "osd-level", which fits a bit
better with the general naming scheme. Make it a choice instead of an
integer range. I failed to come up with good names for the various
levels, so leave them as-is.

Remove the useless property handler for the "loop" property too.
2012-10-12 10:10:30 +02:00
wm4 b248692034 commands: allow printing raw properties
Extend m_properties_expand_string() so that it can print properties as
unformatted string. Normally, properties will be pretty-printed
(intended for OSD and user interface purposes). Add the '=' modifier to
the format string syntax that disables pretty-printing and returns them
"raw".

For example, "${=switch_audio}" will print the track number, instead of
returning an OSD friendly string containing additional information like
track title and language.
2012-09-18 21:08:20 +02:00
wm4 53bfaecd40 core: remove duplicated format_time() functions
This was an on-going transition to make mplayer format all times in the
same format.
2012-09-18 21:04:47 +02:00
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 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 2b5fd80253 core: change format of time properties to match the OSD time format
Time property values converted to strings via M_PROPERTY_PRINT resulted in
a string different to what the OSD displays (if the OSD level is >= 2).

Change it to match the OSD.
2012-07-28 20:56:53 +02:00
harklu a5c6428882 commands: osd_show_property_text: fix \xNN escapes
When handling escapes of the form '\xNN', m_properties_expand_string()
incorrectly copied the last N to the output. Fix.
2011-08-05 03:46:06 +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 c5364305be commands: change property mechanism to use talloc strings 2011-07-03 20:04:21 +03:00
Uoti Urpala 774bb252aa cosmetics: reformat demux_lavf.c, m_option.[ch] and m_property.c 2011-07-03 18:39:26 +03:00
cboesch 74c285e090 cleanup: define ROUND() macro in mpcommon.h
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32751 b3059339-0415-0410-9bf9-f77b7e298cf2
2011-01-31 16:03:10 +02: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 12d3caebc7 Merge svn changes up to r30475 2010-03-09 19:18:43 +02:00
Uoti Urpala 5234c72e28 Restore collapsed whitespace in output messages
For some reason commit e306174952, which
replaced translation macro names with the corresponding English
strings, also collapsed multiple consecutive space characters into
one. Change most of these back. In a couple of cases the amount of
whitespace is important for alignment, and for the rest it at least
keeps the strings closer to the existing translations.
2010-03-07 21:34:54 +02: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 c5bd47f543 translations: corrently translate most OSD output
Add various fixes needed to actually produce translated OSD output.
About every OSD string that had a translation macro under the old
system should be translatable now.
2010-01-12 12:17:41 +02: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
reimar 70901aa006 Add a m_property_flag_ro function for the default behaviour of a
read-only flag.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27679 b3059339-0415-0410-9bf9-f77b7e298cf2
2008-10-01 17:05:18 +00:00
reimar b6fb4c23fd All the m_property stuff works fine with constant m_option_t
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25744 b3059339-0415-0410-9bf9-f77b7e298cf2
2008-01-13 16:59:21 +00:00
ulion 2b517dc714 Support ?(!NAME:TEXT) format for expanding string by property.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25529 b3059339-0415-0410-9bf9-f77b7e298cf2
2007-12-26 04:15:56 +00:00
ulion d2cef4c240 Move two variable to the scope where they are indeed used.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25488 b3059339-0415-0410-9bf9-f77b7e298cf2
2007-12-22 03:45:14 +00:00
albeu be63729ba5 Move the time printing code out of the length property.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23434 b3059339-0415-0410-9bf9-f77b7e298cf2
2007-05-31 12:42:02 +00:00
albeu a3a73031d5 Fix fallback on the default GET_TYPE for unvailable/disabled
properties.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23413 b3059339-0415-0410-9bf9-f77b7e298cf2
2007-05-30 06:39:21 +00:00
albeu c5362c72da Make all the info available via the metadata API available via properties.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23412 b3059339-0415-0410-9bf9-f77b7e298cf2
2007-05-29 22:14:41 +00:00
albeu 1654c2bd80 Rework the property API to allow sub properties such as
metadata/title, etc.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23411 b3059339-0415-0410-9bf9-f77b7e298cf2
2007-05-29 21:49:39 +00:00
uau d5d4c6c7e2 Split command/property handling from mplayer.c to a new file command.c.
Move some global and static variables under a struct that can be given
as a parameter. Add a context argument to the property functions so that
they do not have to depend on global/static variables.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@22298 b3059339-0415-0410-9bf9-f77b7e298cf2
2007-02-21 00:49:24 +00:00
albeu f0f01dd903 Doxygen attack!
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18259 b3059339-0415-0410-9bf9-f77b7e298cf2
2006-04-24 19:20:04 +00:00
albeu 77f6c35f35 100L too many arguments to mp_msg().
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17928 b3059339-0415-0410-9bf9-f77b7e298cf2
2006-03-23 00:41:22 +00:00
albeu 0fd651ff1a Add an option to list the properties: -list-properties
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17915 b3059339-0415-0410-9bf9-f77b7e298cf2
2006-03-22 16:35:17 +00:00
albeu 7ccf483026 Add the new property API and implement a couple properties.
Move the volume and mute command to the command to property
bridge.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17912 b3059339-0415-0410-9bf9-f77b7e298cf2
2006-03-22 00:19:02 +00:00