Commit Graph

44 Commits

Author SHA1 Message Date
wm4 19f56e2097 player: load .ac3 files as external files
Fixes #1759.
2015-04-02 23:15:12 +02:00
Jaime Marquínez Ferrándiz aa98049877 find_subfiles: Add 'vtt' to subtitle extensions 2015-02-18 21:12:55 +01:00
wm4 c07e046bfa player: add external audio file auto-loading
Apparently some people want this. Not enabled by default.

Fixes #967.
2015-02-02 21:23:12 +01:00
wm4 e36f4b6bc1 sub: load .mks files as external subtitles 2014-11-06 00:18:58 +01:00
wm4 f8c2dd1b78 build: include <strings.h> for strcasecmp()
It happens to work without strings.h on glibc or with _GNU_SOURCE, but
the POSIX standard requires including <strings.h>.

Hopefully fixes OSX build.
2014-07-10 08:29:32 +02:00
wm4 9a210ca2d5 Audit and replace all ctype.h uses
Something like "char *s = ...; isdigit(s[0]);" triggers undefined
behavior, because char can be signed, and thus s[0] can be a negative
value. The is*() functions require unsigned char _or_ EOF. EOF is a
special value outside of unsigned char range, thus the argument to the
is*() functions can't be a char.

This undefined behavior can actually trigger crashes if the
implementation of these functions e.g. uses lookup tables, which are
then indexed with out-of-range values.

Replace all <ctype.h> uses with our own custom mp_is*() functions added
with misc/ctype.h. As a bonus, these functions are locale-independent.
(Although currently, we _require_ C locale for other reasons.)
2014-07-01 23:11:08 +02:00
Kenneth Zhou cb250d490c Basic xdg directory implementation
Search $XDG_CONFIG_HOME and $XDG_CONFIG_DIRS for config files.
This also negates the need to have separate user and global variants of
mp_find_config_file()

Closes #864, #109.

Signed-off-by: wm4 <wm4@nowhere>
2014-06-26 19:37:25 +02:00
wm4 99f5fef0ea Add more const
While I'm not very fond of "const", it's important for declarations
(it decides whether a symbol is emitted in a read-only or read/write
section). Fix all these cases, so we have writeable global data only
when we really need.
2014-06-11 00:39:14 +02:00
wm4 94441ed139 options: merge ---sub-auto-match with --sub-auto
There's no reason why these should be separate.
2014-05-04 10:31:24 +02:00
wm4 7041d8cd37 vo: dropping subtitle files on the VO window adds them as subtitle files
Note that we don't try to be clever about detecting the files as
subtitles: we just check the file extension. We could go all the way and
check the files by opening them with a demuxer, but that would probably
do more bad than good.
2014-01-04 01:27:29 +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 92f9b51426 find_subfiles: mp_msg conversions 2013-12-21 20:50:13 +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 ce4d1f461a sub: respect detected language for fuzzy-matched external subtitles
Solve this by passing through the language to the player, which then
uses the generic subtitle selection code to make a choice.

Fixes #367.
2013-11-25 23:41:02 +01:00
wm4 e5311586ab Rename sub.c/.h to osd.c/.h
This was way too misleading. osd.c merely calls the subtitle renderers,
instead of actually dealing with subtitles.
2013-11-24 14:44:58 +01:00
wm4 82de39b7d5 find_subfiles: fix really dumb bug causing segfaults
NULL pointer deref when a .sub file with the same filename as the video
file was present.

I was probably half asleep when writing this code.
2013-09-17 15:41:23 +02:00
Gabriel Peixoto 856c58aa9c find_subfiles: fix off-by-1 error
This could lead to a segfault, fixes #219

Signed-off-by: Gabriel Peixoto <gabrielrcp@gmail.com>
Signed-off-by: wm4 <wm4@nowhere>
2013-09-08 07:44:08 +02:00
wm4 c7ab8ea513 mplayer: don't auto-load explicitly loaded subtitle files
Even if a subtitle was explicitly loaded with -sub, it was still auto-
loaded (if auto-loading applied to that file). Fix this by explicitly
checking whether a file is already loaded.

The check is maximal naive and just compares the filenames as strings.
The change in find_subfiles.c is so that "-sub something.ass" happens to
work (auto-loading prepended a "./" to it, so the naive filename
comparison check didn't work).
2013-09-07 20:34:49 +02:00
wm4 dc475728e0 find_subfiles: don't auto-load .sub file if .idx file exists
External vobsubs usually come as .idx/.sub pairs. Loading the .idx file
implicitly loads the .sub file, whereas loading the .sub file will kind
of work, but miss important information such as subtitle resolution. Or
in other words, if the .idx file exists, adding the .sub file as track
is useless and confusing.

Explicitly remove .sub file from the auto-load suntitle list in these
cases. Standalone .sub files are still loaded.

We also drop that weird logic that excluded .utf8 files from being
loaded if -subcp was in use. I hope the associated use case didn't make
much sense to begin with. If not, we could still implement it properly,
instead of this weird hack.
2013-09-07 20:34:49 +02:00
wm4 580e925011 find_subfiles: some cleanups
Remove a crap assert() (what... either it can't happen, or it should
error or at least abort() if it can't be handled).

Remove some dead definitions.
2013-09-07 20:34:49 +02:00
wm4 fde0f40e87 find_subfiles: use stat() instead of opening the file to check existence
Use mp_path_exists() to check for existence of a file (which in turn
uses stat()), instead of opening and closing it. The difference is that
if we don't have sufficient permissions to read the subtitle files, we
will loudly complain. Personally, I prefer this behavior.
2013-09-07 20:34:49 +02:00
wm4 9d0d2443fb find_subfiles: don't try to open URLs as directories
Did things like opendir("http://..."). Makes no sense, and just
generates noise.
2013-09-07 20:34:49 +02:00
Stefano Pigozzi 406241005e core: move contents to mpvcore (2/2)
Followup commit. Fixes all the files references.
2013-08-06 22:52:31 +02:00
wm4 28116b8a79 sub: remove some global variables 2013-05-30 22:44:18 +02:00
wm4 885c6a2610 Fix some cppcheck / scan-build warnings
These were found by the cppcheck and scan-build static analyzers. Most
of these aren't interesting (the 2 previous commits fix some interesting
cases found by these analyzers), and they don't nearly fix all warnings.
(Most of the unfixed warnings are spam, things MPlayer never cared
about, or false positives.)
2013-05-06 23:11:11 +02:00
Stefano Pigozzi fab9febdc3 path: add mp_find_config_file and reorganize some of the code
Add `mp_find_config_file` to search different known paths and use that in
ass_mp to look for the fontconfig configuration file.

Some incidental changes spawned by this feature where:

 * Buffer allocation for the strings containing the paths is now performed
   with talloc. All of the allocations are done on a NULL context, but it still
   improves readability of the code.
 * Move the OSX function for lookup inside of a bundle: this code path was
   currently not used by the bundle generated with `make osxbundle`. The plan
   is to use it again in a future commit to get a fontconfig config file.
2012-12-15 17:38:00 +01:00
wm4 5bf8706d1f sub: remove vobsub reader in favor of ffmpeg vobsub demuxer
ffmpeg recently added a demuxer that can read vobsubs (pairs of .sub and
.idx files). Get rid of the internal vobsub reader, and use the ffmpeg
demuxer instead.

Sneak in an unrelated manpage change (autosub default).
2012-12-11 00:37:54 +01:00
wm4 4873b32c59 Rename directories, move files (step 2 of 2)
Finish renaming directories and moving files. Adjust all include
statements to make the previous commit compile.

The two commits are separate, because git is bad at tracking renames
and content changes at the same time.

Also take this as an opportunity to remove the separation between
"common" and "mplayer" sources in the Makefile. ("common" used to be
shared between mplayer and mencoder.)
2012-11-12 20:08:18 +01:00
wm4 2afd7ebb4e options: remove subtitle related options that did nothing
Most of these cased working when the OSD was switched to libass, or
didn't do anything even before that.

Also don't recursively include subreader.h in sub.h.
2012-10-24 21:56:35 +02:00
wm4 93de744a2b sub: silence output of subtitle search message
This message is not so interesting.
2012-07-30 01:45:07 +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 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
Uoti Urpala 0958620591 bstr: rename BSTR() -> bstr()
Rename the BSTR() function to bstr(). The former caused a conflict
with some Windows OS name, and it's no longer a macro so uppercase
naming is less appropriate.
2011-07-27 08:38:12 +03:00
Uoti Urpala 3b401fb07f find_subfiles: fix unintended modification of global filename
Commit a2d28010cc ("cleanup: find_subfiles.c: simplify (mainly using
bstr)") was missing a bstrdup() in subtitle search code, and thus the
code erroneously modified the original filename string passed in. As a
result anything which printed or otherwise used the filename after
that would use a lowercase-converted version instead of the actual
file name. Fix by adding the bstrdup() to operate on a local copy of
the name instead.
2011-04-28 09:44:37 +03:00
Uoti Urpala a2d28010cc cleanup: find_subfiles.c: simplify (mainly using bstr) 2011-04-20 04:22:53 +03:00
Clément Bœsch 52d60a7334 cleanup: find_subfiles.c: simplify declarations and allocations
Also clarify compare_sub_priority() and remove a typedef for the subfn
structure in the process.
2011-04-20 04:22:53 +03:00
Clément Bœsch 549177c105 find_subfiles: select subtitle files matching -slang
Also simplify subtitle selection a bit.
2011-04-20 04:22:53 +03:00
Clément Bœsch 1a152eadaf find_subfiles: try to determine if a .sub file is text or vobsub
A file with the ambiguous extension .sub could be either VOBsub or
MicroDVD. If there's a corresponding .idx file it's certainly VOBsub,
so don't add it to the list of potential text subtitles. This will
avoid the annoying warning "SUB: Could not determine file format".
2011-04-20 04:22:53 +03:00
Clément Bœsch 1c6995d76c subs: options: add -sub-paths 2011-04-20 04:22:52 +03:00
Clément Bœsch acc187cd20 find_subfiles: allow subtitle search in multiple directories 2011-04-20 04:22:52 +03:00
Uoti Urpala bdfdece245 subs: move vobsub loading logic down to find_subfiles.c
Analogously to the previous commit, move path handling logic for
loading external vobsub files from mplayer.c to find_subfiles.c.

Based on a commit from Clément Bœsch but fixed and simplified.
2011-04-20 04:22:52 +03:00
Clément Bœsch 7221e28fe3 subs: move text sub loading logic down to find_subfiles.c
Move path handling for loading external subtitle files from mplayer.c
to find_subfiles.c. Now the remaining code in mplayer.c only gets a
list of potential filenames and tries opening those.
2011-04-20 04:22:52 +03:00
Clément Bœsch 9bcfbe4d4f find_subfiles: move sub_filenames() here
Move sub_filenames() and related code from subreader.c to new file
find_subfiles.c. This function is used to find subtitle files that
should be loaded for the current video; this functionality is not
specific to the particular kind of text subtitle handling implemented
in subreader.c.

Also reindent and prettify the moved code a bit.
2011-04-20 04:22:52 +03:00