diff options
author | Nicolas F <ovdev@fratti.ch> | 2017-10-31 21:39:15 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-12-01 21:13:48 +0100 |
commit | 2e24f5f1b5a39d00939d55343e3daad72687031b (patch) | |
tree | a8d44de96b6672fcd9634fe85a1735fba5907faa /player/scripting.c | |
parent | eb8957cea110a9aa652894d8bb897a9b1ff91e0b (diff) | |
download | mpv-2e24f5f1b5a39d00939d55343e3daad72687031b.tar.bz2 mpv-2e24f5f1b5a39d00939d55343e3daad72687031b.tar.xz |
scripting: report dlerror() output
dlopen() and dlsym() can fail in various ways, and we can find out
how it failed by calling dlerror(). This is particularly useful if
you typo the filename of a script when explicitly passing it with
--script, and dlopen actually tells you that the file doesn't exist
instead of leading you down a rabbit hole of disassembling your
shared object file to figure out why the thing won't load.
Diffstat (limited to 'player/scripting.c')
-rw-r--r-- | player/scripting.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/player/scripting.c b/player/scripting.c index 4073da765d..28f8fdd038 100644 --- a/player/scripting.c +++ b/player/scripting.c @@ -254,7 +254,7 @@ typedef int (*mpv_open_cplugin)(mpv_handle *handle); static int load_cplugin(struct mpv_handle *client, const char *fname) { - int r = -1; + MPContext *ctx = mp_client_get_core(client); void *lib = dlopen(fname, RTLD_NOW | RTLD_LOCAL); if (!lib) goto error; @@ -263,9 +263,12 @@ static int load_cplugin(struct mpv_handle *client, const char *fname) mpv_open_cplugin sym = (mpv_open_cplugin)dlsym(lib, MPV_DLOPEN_FN); if (!sym) goto error; - r = sym(client) ? -1 : 0; -error: - return r; + return sym(client) ? -1 : 0; +error: ; + char *err = dlerror(); + if (err) + MP_ERR(ctx, "C plugin error: '%s'\n", err); + return -1; } const struct mp_scripting mp_scripting_cplugin = { |