Commit Graph

122 Commits

Author SHA1 Message Date
James Ross-Gowan ac7ecbe30c win32: use a platform-specific unicode entry-point
Add a platform-specific entry-point for Windows. This will allow some
platform-specific initialization to be added without the need for ugly
ifdeffery in main.c.

As an immediate advantage, mpv can now use a unicode entry-point and
convert the command line arguments to UTF-8 before passing them to
mpv_main, so osdep_preinit can be simplified a little bit.
2015-04-11 14:27:25 +10:00
wm4 cf55fa6471 player: use config parser for setting up pseudo-gui profile 2015-04-10 20:40:50 +02:00
wm4 1e692cb043 player: change pseudo-gui settings
Remove --keep-open. Switch to --idle=once. This effectively makes the
player quit after end of playback, but still shows the idle screen if it
was started with no files.
2015-04-10 20:31:21 +02:00
wm4 46eb04f3c2 player: do not accidentally init terminal
Starting the command line player with --no-terminal, the terminal was
sitll initialized. This happened because update_logging() used the
option value before the options were parsed. Fix by moving down the
initialization to before the point where it's actually needed.
2015-04-10 13:07:24 +02:00
wm4 83bd128016 player: add --idle --keep-open to pseudo-gui profile 2015-04-02 00:09:43 +02:00
wm4 550d908ba8 player: add "pseudo-gui" profile
This can be set to select a number of default settings that help mpv
pretend that it has a GUI.

I haven't decided yet whether I really want to use the profile mechanism
for this. There are a number of weird details that are not so easy to
handle with profiles, such as disabling pseudo-gui mode again (you can't
unset profiles directly). So this might change. But for now it will do.

There also should be a better way to store builtin profiles.
Unfortunately, the old crappy MPlayer config file parser needs on-disk
files, so just use a bunch of function calls for now.
2015-04-02 00:08:38 +02:00
wm4 331b21f267 encode: make --audio-channels=auto work
Basically requested. Not that anyone cares.
2015-03-23 17:41:50 +01:00
wm4 8a4239e0c2 player: dump list of satisfied deps instead of config.h with -v
Starting to get tired of seeing the full config.h in verbose output
every time. Make it slightly more elegant by outputting the list of
satisfied dependencies instead.
2015-03-11 23:33:05 +01:00
wm4 30b0a5b98a player: restore --dump-stats
Since the recent refactoring, it was initialized _before_ the command
line player options were set, and consequently could not be enabled.
2015-03-10 09:50:32 +01:00
wm4 90496f3088 player: fix operation if command line is empty
main() being called with argc==0 is probably possible. Fix by skipping
the program name early. (I already changed and reverted this once, but
this time we make sure that it's less likely to confuse the skipped argv
with main()'s argv by naming it "options".)
2015-03-06 11:31:05 +01:00
wm4 2e26639155 player, client API: refactor cplayer init, reduce client API differences
Move the command line parsing and some other things to the common init
routine shared between command line player and client API. This means
they're using almost exactly the same code now.

The main intended side effect is that the client API will load mpv.conf;
though still only if config loading is enabled.

(The cplayer still avoids creating an extra thread, passes a command
line, and prints an exit status to the terminal. It also has some
different defaults.)
2015-03-05 11:22:15 +01:00
wm4 dcabceb626 player: minor simplification
argv is always terminated with a NULL, so we don't need to drag argc
along. Simplifies the following commit a little bit.
2015-03-05 10:57:38 +01:00
wm4 636d6d724d encoding: allow encoding to channel configurations other than stereo
A while ago, we made mpv output the native number of channels by
default, instead of stereo. I assumed this was not wanted for encode
mode.

This commit keeps the assumption, but allows setting the number of audio
output channels at all, instead of always forcing stereo. (Pretty much a
hack.)
2015-02-23 16:25:12 +01:00
wm4 96547a810e encoding: fixed-vo option was removed 2015-02-13 00:18:54 +01:00
wm4 c59a4f12db osx: move code to unset input context to the right place
Setting the input context is always called, both in cplayer and libmpv,
and under HAVE_COCOA. Unsetting the input context was done only the
cplayer uninit call. Also it was under HAVE_COCOA_APPLICATION, so it was
not unset in libmpv (dangling pointer).
2015-02-12 21:18:23 +01:00
wm4 b8de478f51 osx: move cocoa specific call out of common code
This is almost equivalent, and gets rid of the ifdef.
2015-02-12 21:18:12 +01:00
wm4 e920a00eba player: drop explicit exit() calls
The code in main.c calls exit() explicitly, but the code is actually
easier to follow by simply exiting from main() instead. The exit() call
in av_log.c happens only on severely broken builds, so replace it with
abort().

(Shuts up rpmlint warnings.)
2015-02-12 17:28:22 +01:00
wm4 7bbc617019 Revert "player: make --force-window create the window immediately on start"
This reverts commit acc5e8f574.

As expected, some didn't like this. Others won't like this revert.
Whatever.

See #1561.

This should go into mpv 0.8.0 before it's released.
2015-02-12 12:01:12 +01:00
wm4 acc5e8f574 player: make --force-window create the window immediately on start
Before this change, window creation was delayed until the video was
initialized. This guaranteed that the first window size was that of the
video, so the WM would place it correctly.

Some time ago, it was requested on the IRC channel that --force-window
should not do this. Sometimes, it can take a while until video is
initialized, e.g. when youtube-dl is used (which incurs lots of network
delay). In this case, it's awkward that it takes so long until a window
(any window) is shown.

On the other hand, this can cause incorrect window placement with some
WMs. We simply hope that this won't happen with modern WMs. (Although it
does with the WM I use, crappy old IceWM.)
2015-02-03 23:19:38 +01:00
wm4 c3c714b059 player: remove --fixed-vo
In ancient times, this was needed because it was not default, and many
VOs had problems with it. But it was always default in mpv, and all VOs
are required to deal with it. Also, running --fixed-vo=no is not useful
and just creates weird corner cases. Get rid of it.
2015-02-03 23:11:08 +01:00
wm4 6b24cb2756 win32: remove check for SetPriorityClass()
This function is always available, which is reflected by the fact that
the configure check doesn't actually bother to check for its existence.
Instead, MinGW and Cygwin imply it. The check was probably "needed" when
the priority code was still in a separate source file.

Remove the check, and use _WIN32 for testing for the win32 API (in a
bunch of other places too).
2015-01-20 15:18:51 +01:00
wm4 3b091995a0 win32: drop hacks for possibly broken static pthreads-win32 linking
We now use threads and other pthread API a lot, and not always we use it
from threads created with pthread_create() (or the main thread). As I
understand, with static linking we would have to use
pthread_win32_thread_attach/detach_np() every time we enter or leave a
foreign thread. We don't do this, and it's not feasible either, so it's
just broken.

This still should work with dynamic pthreads-win32. The MinGW pthread
implementation should be unaffected from all of this.
2015-01-11 02:23:02 +01:00
wm4 f5ed13bcd4 video: better pipelining with vf_vapoursynth
Most of this is explained in the code comments. This change should
improve performance with vapoursynth, especially if concurrent requests
are used.

This should change nothing if vf_vapoursynth is not in the filter chain,
since non-threaded filters obviously can not asynchronously finish
filtering of frames.
2015-01-03 03:01:58 +01:00
wm4 f12b70d77d player: move terminal input init to a better place
Mostly of cosmetic nature. Move initialization to the same place where
another component (cocoa) will start accessing the input context from a
foreign thread.
2015-01-02 03:09:17 +01:00
wm4 a2d790b3a4 player: print config.h contents in verbose mode
It was requested that mpv should print what features etc. have been
enabled at compile time. It can print the configure command line, but it
obviously doesn't include autodetected features.

I tried to think of a nicer way than dumping the config.h as text, but
this was still the simplest way.
2015-01-02 03:06:06 +01:00
wm4 39548ad9e9 Update copyright year 2015-01-01 00:00:00 +01:00
wm4 282e3202d5 video: pass some VO params as struct
Not particularly elegant, but better than adding more and more stuff to
the relevant function signatures.
2014-12-31 19:01:28 +01:00
Stefano Pigozzi 0fa9986a98 options: expand ~ for the include option
Fixes #1406
2014-12-30 09:23:36 +01:00
wm4 6618e5d69a player: make --shuffle/--merge-files affect runtime loaded playlists
Until now, these options took effect only at program start. This could
be confusing when e.g. doing "mpv list.m3u --shuffle". Make them always
take effect when a playlist is loaded either via a playlist file, or
with the "loadlist" command.
2014-12-29 22:08:22 +01:00
wm4 bde7fa5a46 player: force stereo as default when encoding
I think the new default for this option might be rather bad in encoding
mode. For starters, we don't even know what layers an encoder supports
at all.
2014-12-27 12:25:39 +01:00
wm4 16a5971d28 vo_opengl_cb: free context on exit
Minor memory leak.

Actually, this also exposes some problems in the QtQuick example. This
will have to be fixed in the example.
2014-12-22 12:45:43 +01:00
wm4 f984b79720 client API: allow multiple mpv instances with terminal=yes
This is simply not allowed, and doing it triggered an assertion. It's
still not allowed, because the terminal and related functionality is a
global resource, and there doesn't seem to be a sane way to manage the
signal handlers.

But be a bit nicer, and just the terminal if it's already in use.

Note that terminal _output_ happens anyway. This becomes usable with
this commit. To facilitate logging-only usage further, also explicitly
disable terminal input, so that "terminal=yes" can be used for logging
without much interference with other things. (It'll still overwrite some
signal handlers, though.)
2014-12-02 20:36:55 +01:00
wm4 6ddd2b8e03 player: improve exit message in some scenarios
If you played e.g. an audio-only file and something bad happened that
interrupted playback, the exit message could say "No files played".
This was awkward, so show a different message in this case.

Also overhaul how the exit status is reported in order to make this
easier. This includes things such as not reporting a playback error
when loading playlists (playlists contain no video or audio, which
was considered an error).

Not sure if I'm happy with this, but for now it seems like a slight
improvement.
2014-10-31 00:51:52 +01:00
wm4 db86eaad3d player: adjust uninit order of components
Most things should be allowed to access the client API unconditionally
(for example for sending events), so move destroying the client API
down. Also, mp_uninit_ipc() should happen before the point at which all
clients are shutdown, or there will be a small time window in which new
clients can be created after destroying them all.
2014-10-24 15:34:04 +02:00
wm4 2f559ac70b player: shutdown all clients before actual uninit
This seems safer. It might be possible that commands sent by the clients
could recreate e.g. audio or video outputs.
2014-10-19 22:34:37 +02:00
wm4 f4c589418c ipc: decouple from MPContext
Just a minor refactor to keep unneeded dependencies on the core low.
2014-10-19 20:44:29 +02:00
Alessandro Ghedini 13039414f5 input: implement JSON-based IPC protocol 2014-10-17 20:46:31 +02:00
wm4 edad4fc29b audio: change internal device listing API
Now we run ao_driver->list_devs on a dummy AO instance, which will
probably confuse everyone. This is done for the sake of PulseAudio.
2014-10-10 18:27:21 +02:00
Stefano Pigozzi ca353fcf92 libmpv/cocoa: make global events work and get rid of is_cplayer
After @frau's split of macosx_events from macosx_application, `is_cplayer' is
not needed anymore. At the moment only global events such as Media Keys and
Apple Remote work, because the VO-level ones were hardcoded to be disabled.
(that will be fix in a later commit ).
2014-10-09 22:14:41 +02:00
wm4 35649a990a audio: add device selection & listing with --audio-device
Not sure how good of an idea this is.

This commit doesn't add support for this to any AO yet; the AO
implementations will follow later.
2014-10-09 21:21:31 +02:00
wm4 d26104351b m_config: add function to copy all options
Needed to copy the global option struct in the next commit.
2014-10-06 21:49:26 +02:00
wm4 cc9973f4e0 player: move some libass setup code to sub.c
Also recreate ASS_Library on every file played. This means we can move
the code out of main.c as well.

Recreating the ASS_Library object has no disadvantages, because it
literally stores only the message callback, the (per-file) font
attachment as byte arrays, and the set of style overrides. Hopefully
this thing can be removed from the libass API entirely at some point.

The only reason why the player core creates the ASS_Renderer, instead
of the subtitle renderer, is because we want to cache the loaded fonts
across ordered chapter transitions, so this probably still has to stay
around for now.
2014-10-03 23:10:18 +02:00
wm4 9d5d031b6d player: remove central uninit_player() function and flags mess
Each subsystem (or similar thing) had an INITIALIZED_ flag assigned. The
main use of this was that you could pass a bitmask of these flags to
uninit_player(). Except in some situations where you wanted to
uninitialize nearly everything, this wasn't really useful. Moreover, it
was quite annoying that subsystems had most of the code in a specific
file, but the uninit code in loadfile.c (because that's where
uninit_player() was implemented).

Simplify all this. Remove the flags; e.g. instead of testing for the
INITIALIZED_AO flag, test whether mpctx->ao is set. Move uninit code
to separate functions, e.g. uninit_audio_out().
2014-10-03 23:05:09 +02:00
wm4 b4d1494336 input: separate creation and loading of config
Until now, creating the input_ctx was delayed until the command line
and config files were parsed. Separate creation and loading so that
input_ctx is available from start.

This should make it possible to simplify some things. For example,
some complications with Cocoa were apparently only because input_ctx
was available only "later". (Although I'm not sure if this is still
relevant, or if the Cocoa code should even be organized this way.)
2014-09-27 16:01:55 +02:00
wm4 2e91d44e20 stream: redo playback abort handling
This mechanism originates from MPlayer's way of dealing with blocking
network, but it's still useful. On opening and closing, mpv waits for
network synchronously, and also some obscure commands and use-cases can
lead to such blocking. In these situations, the stream is asynchronously
forced to stop by "interrupting" it.

The old design interrupting I/O was a bit broken: polling with a
callback, instead of actively interrupting it. Change the direction of
this. There is no callback anymore, and the player calls
mp_cancel_trigger() to force the stream to return.

libavformat (via stream_lavf.c) has the old broken design, and fixing it
would require fixing libavformat, which won't happen so quickly. So we
have to keep that part. But everything above the stream layer is
prepared for a better design, and more sophisticated methods than
mp_cancel_test() could be easily introduced.

There's still one problem: commands are still run in the central
playback loop, which we assume can block on I/O in the worst case.
That's not a problem yet, because we simply mark some commands as being
able to stop playback of the current file ("quit" etc.), so input.c
could abort playback as soon as such a command is queued. But there are
also commands abort playback only conditionally, and the logic for that
is in the playback core and thus "unreachable". For example,
"playlist_next" aborts playback only if there's a next file. We don't
want it to always abort playback.

As a quite ugly hack, abort playback only if at least 2 abort commands
are queued - this pretty much happens only if the core is frozen and
doesn't react to input.
2014-09-13 16:09:51 +02:00
wm4 f5af596237 player: some more input refactoring
Continues commit 348dfd93. Replace other places where input was manually
fetched with common code.

demux_was_interrupted() was a weird function; I'm not entirely sure
about its original purpose, but now we can just replace it with simpler
code as well. One difference is that we always look at the command
queue, rather than just when cache initialization failed. Also, instead
of discarding all but quit/playlist commands (aka abort command), run
all commands. This could possibly lead to unwanted side-effects, like
just ignoring commands that have no effect (consider pressing 'f' for
fullscreen right on start: since the window is not created yet, it would
get discarded). But playlist navigation still works as intended, and
some if not all these problems already existed before that in some
forms, so it should be ok.
2014-09-07 20:44:54 +02:00
wm4 12509fabc7 options: compatibility hack for --slave-broken
Seems some programs were still relying on it. Whatever, it's not hard to
support.

CC: @mpv-player/stable
2014-08-25 00:48:55 +02:00
wm4 5890e59dbc terminal: some cleanups
In particular, remove all the stupid debug printfs from the win code.
2014-08-21 22:45:58 +02:00
Stefano Pigozzi c8cf864bff cocoa: fix build by using the correct HAVE_* macro
This builds but both the libmpv example and the cplayer block infinitely when
building libmpv. That's because we wait inifinitely in `dispatch_sync` as
there's no event loop in the main thread that allows for libdispatch to work..

Whiel we are at it, we should probably investigate how to use mp_dispatch
instead since it is a little lower level and could give us higher control in
building and event loop.
2014-08-06 09:31:59 +02:00
FRAU KOUJIRO 4fc8dcde2a cocoa: move set_input_context to macosx_events 2014-08-06 09:31:58 +02:00