Commit Graph

11 Commits

Author SHA1 Message Date
wm4 d646d78ccb lua: allow scripts to snoop messages
Adds the following Lua function to enable message events:

    mp.enable_messages(size, level)

size is the maximum number of messages the ringbuffer consists of. level
is the minimum log level for a message to be added to the ringbuffer,
and uses the same values as the mp.log() function. (Actually not yet,
but this will be fixed in the following commit.)

The messages will be delivered via the mp_event() in the user script,
using "message" as event name. The event argument is a table with the
following fields:

    level: log level of the message (string as in mp.log())
    prefix: string identifying the module of origin
    text: contents of the message

As of currently, the message text will contain newline characters. A
message can consist of several lines. It is also possible that a
message doesn't end with a newline, and a caller can use multiple
messages to "build" a line. Most messages will contain exactly 1 line
ending with a single newline character, though.

If the message buffer overflows (messages are not read quickly enough),
new messages are lost until the queued up messages are read. At the
point of the overflow, a special overflow message is inserted. It will
have prefix set to "overflow", and the message text is set to "".

Care should be taken not to print any messages from the message event
handler. This would lead to an infinite loop (the event handler would be
called again after returning, because a new message is available). This
includes mp.log() and all mp.msg.* functions. Keep in mind that the Lua
print() function is mapped to mp.msg.info().
2014-01-16 23:06:40 +01:00
wm4 eef36f03ea msg: rename mp_msg_log -> mp_msg
Same for companion functions.
2013-12-21 22:13:04 +01:00
wm4 eba5d025d2 msg: convert defines to enum
Also get rid of MSGL_HINT and the many MSGL_DBG* levels.
2013-12-21 22:13:04 +01:00
wm4 ad2199128d path lookup functions: mp_msg conversions
There's a single mp_msg() in path.c, but all path lookup functions seem
to depend on it, so we get a rat-tail of stuff we have to change. This
is probably a good thing though, because we can have the path lookup
functions also access options, so we could allow overriding the default
config path, or ignore the MPV_HOME environment variable, and such
things.

Also take the chance to consistently add talloc_ctx parameters to the
path lookup functions.

Also, this change causes a big mess on configfiles.c. It's the same
issue: everything suddenly needs a (different) context argument. Make it
less wild by providing a mp_load_auto_profiles() function, which
isolates most of it to configfiles.c.
2013-12-21 21:43:17 +01:00
wm4 57359a1d62 lua: minor simplification
Using m_property_do() is more complicated, and will have to be changed
later for mp_msg conversions.
2013-12-21 20:50:11 +01:00
wm4 18930ba7dd input, lua: add functions to take pre-split input commands
So you can pass a command as list of strings (each item is an argument),
instead of having to worry about escaping and such.

These functions also take an argument for the default command flags. In
particular, this allows setting saner defaults for commands sent by
program code.

Expose this to Lua as mp.send_commandv command (suggestions for a better
name welcome). The Lua version doesn't allow setting the default command
flags, but it can still use command prefixes. The default flags are
different from input.conf, and disable OSD and property expansion.
2013-12-20 18:01:04 +01:00
wm4 5e0c4ec3e8 player: replace some overlooked mp_msgs
There are still some using IDENTIFY, and some without context in
configfiles.c.
2013-12-19 21:31:18 +01:00
wm4 0112143fda Split mpvcore/ into common/, misc/, bstr/ 2013-12-17 02:39:45 +01:00
wm4 eb15151705 Move options/config related files from mpvcore/ to options/
Since m_option.h and options.h are extremely often included, a lot of
files have to be changed.

Moving path.c/h to options/ is a bit questionable, but since this is
mainly about access to config files (which are also handled in
options/), it's probably ok.
2013-12-17 02:07:57 +01:00
wm4 8d5214de0a Move mpvcore/input/ to input/ 2013-12-17 01:23:09 +01:00
wm4 053c743724 Rename mp_lua.c/h to lua.c/h 2013-12-17 01:15:48 +01:00