diff options
author | Martin Herkt <lachs0r@srsfckn.biz> | 2016-02-28 23:31:51 +0100 |
---|---|---|
committer | Martin Herkt <lachs0r@srsfckn.biz> | 2016-02-28 23:31:51 +0100 |
commit | 21cd4ff05bb46b375a9ad38c9f0b7f8e71a5d979 (patch) | |
tree | b9679cc1d2c7c3cab0f88c370015f34f6d0b27ca /osdep | |
parent | d1d6257731866934717353fce484f5f472f845d1 (diff) | |
parent | 1f436f65f2ee4df6419ca68bd6426b8283db6d22 (diff) | |
download | mpv-21cd4ff05bb46b375a9ad38c9f0b7f8e71a5d979.tar.bz2 mpv-21cd4ff05bb46b375a9ad38c9f0b7f8e71a5d979.tar.xz |
Merge branch 'master' into release/current
Diffstat (limited to 'osdep')
-rw-r--r-- | osdep/android/strnlen.c | 40 | ||||
-rw-r--r-- | osdep/android/strnlen.h | 33 | ||||
-rw-r--r-- | osdep/atomics.h | 14 | ||||
-rw-r--r-- | osdep/glob-win.c | 14 | ||||
-rw-r--r-- | osdep/io.c | 14 | ||||
-rw-r--r-- | osdep/io.h | 14 | ||||
-rw-r--r-- | osdep/macosx_events.m | 3 | ||||
-rw-r--r-- | osdep/path-macosx.m | 14 | ||||
-rw-r--r-- | osdep/path-unix.c | 14 | ||||
-rw-r--r-- | osdep/path-win.c | 14 | ||||
-rw-r--r-- | osdep/strnlen.h | 29 | ||||
-rw-r--r-- | osdep/subprocess-posix.c | 14 | ||||
-rw-r--r-- | osdep/subprocess-win.c | 14 | ||||
-rw-r--r-- | osdep/subprocess.c | 26 | ||||
-rw-r--r-- | osdep/subprocess.h | 14 | ||||
-rw-r--r-- | osdep/threads.c | 15 | ||||
-rw-r--r-- | osdep/timer.c | 14 | ||||
-rw-r--r-- | osdep/windows_utils.c | 59 | ||||
-rw-r--r-- | osdep/windows_utils.h | 2 |
19 files changed, 266 insertions, 95 deletions
diff --git a/osdep/android/strnlen.c b/osdep/android/strnlen.c new file mode 100644 index 0000000000..c8c9d3d4b8 --- /dev/null +++ b/osdep/android/strnlen.c @@ -0,0 +1,40 @@ +/*- + * Copyright (c) 2009 David Schultz <das@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <stddef.h> +#include "osdep/android/strnlen.h" + +size_t +freebsd_strnlen(const char *s, size_t maxlen) +{ + size_t len; + + for (len = 0; len < maxlen; len++, s++) { + if (!*s) + break; + } + return (len); +} diff --git a/osdep/android/strnlen.h b/osdep/android/strnlen.h new file mode 100644 index 0000000000..c1f3391d4d --- /dev/null +++ b/osdep/android/strnlen.h @@ -0,0 +1,33 @@ +/*- + * Copyright (c) 2009 David Schultz <das@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef MP_OSDEP_ANDROID_STRNLEN +#define MP_OSDEP_ANDROID_STRNLEN + +size_t +freebsd_strnlen(const char *s, size_t maxlen); + +#endif diff --git a/osdep/atomics.h b/osdep/atomics.h index 1cac2d5700..c4f31286cc 100644 --- a/osdep/atomics.h +++ b/osdep/atomics.h @@ -2,18 +2,18 @@ * This file is part of mpv. * Copyright (c) 2013 Stefano Pigozzi <stefano.pigozzi@gmail.com> * - * mpv is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * mpv is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * * mpv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with mpv. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MP_ATOMICS_H diff --git a/osdep/glob-win.c b/osdep/glob-win.c index cca226ae7a..a3485cdbd1 100644 --- a/osdep/glob-win.c +++ b/osdep/glob-win.c @@ -1,18 +1,18 @@ /* * This file is part of mpv. * - * mpv is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * mpv is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * * mpv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with mpv. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ #include <windows.h> diff --git a/osdep/io.c b/osdep/io.c index 5f46cdb69b..5952f21980 100644 --- a/osdep/io.c +++ b/osdep/io.c @@ -5,18 +5,18 @@ * * This file is part of mpv. * - * mpv is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * mpv is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * * mpv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with mpv. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ #include <unistd.h> diff --git a/osdep/io.h b/osdep/io.h index 8d3e24f551..541e36aeea 100644 --- a/osdep/io.h +++ b/osdep/io.h @@ -3,18 +3,18 @@ * * This file is part of mpv. * - * mpv is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * mpv is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * * mpv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with mpv. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MPLAYER_OSDEP_IO diff --git a/osdep/macosx_events.m b/osdep/macosx_events.m index 51aaf2aca4..6090a1937e 100644 --- a/osdep/macosx_events.m +++ b/osdep/macosx_events.m @@ -451,7 +451,8 @@ void cocoa_set_input_context(struct input_ctx *input_context) else chars = [event charactersIgnoringModifiers]; - int key = convert_key([event keyCode], *[chars UTF8String]); + struct bstr t = bstr0([chars UTF8String]); + int key = convert_key([event keyCode], bstr_decode_utf8(t, &t)); if (key > -1) [self handleMPKey:key withMask:[self keyModifierMask:event]]; diff --git a/osdep/path-macosx.m b/osdep/path-macosx.m index f011289e36..73abb0d305 100644 --- a/osdep/path-macosx.m +++ b/osdep/path-macosx.m @@ -1,18 +1,18 @@ /* * This file is part of mpv. * - * mpv is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * mpv is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * * mpv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with mpv. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ #import <Foundation/Foundation.h> diff --git a/osdep/path-unix.c b/osdep/path-unix.c index cea4235c15..d9a49ab06d 100644 --- a/osdep/path-unix.c +++ b/osdep/path-unix.c @@ -1,18 +1,18 @@ /* * This file is part of mpv. * - * mpv is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * mpv is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * * mpv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with mpv. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ #include <string.h> diff --git a/osdep/path-win.c b/osdep/path-win.c index 6e09e3861b..de7c0936f7 100644 --- a/osdep/path-win.c +++ b/osdep/path-win.c @@ -1,18 +1,18 @@ /* * This file is part of mpv. * - * mpv is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * mpv is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * * mpv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with mpv. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ #include <windows.h> diff --git a/osdep/strnlen.h b/osdep/strnlen.h new file mode 100644 index 0000000000..0a971d0ab0 --- /dev/null +++ b/osdep/strnlen.h @@ -0,0 +1,29 @@ +/* + * strnlen wrapper + * + * This file is part of mpv. + * + * mpv is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * mpv is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with mpv. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef MP_OSDEP_STRNLEN +#define MP_OSDEP_STRNLEN + +#ifdef __ANDROID__ +// strnlen is broken on current android ndk, see https://code.google.com/p/android/issues/detail?id=74741 +#include "osdep/android/strnlen.h" +#define strnlen freebsd_strnlen +#endif + +#endif diff --git a/osdep/subprocess-posix.c b/osdep/subprocess-posix.c index 16f9735fe7..163559edbc 100644 --- a/osdep/subprocess-posix.c +++ b/osdep/subprocess-posix.c @@ -1,18 +1,18 @@ /* * This file is part of mpv. * - * mpv is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * mpv is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * * mpv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with mpv. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ #include <spawn.h> diff --git a/osdep/subprocess-win.c b/osdep/subprocess-win.c index 76e4964183..614cae663f 100644 --- a/osdep/subprocess-win.c +++ b/osdep/subprocess-win.c @@ -1,18 +1,18 @@ /* * This file is part of mpv. * - * mpv is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * mpv is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * * mpv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with mpv. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ #include <windows.h> diff --git a/osdep/subprocess.c b/osdep/subprocess.c index 84a1b52fe6..dbd6100d2c 100644 --- a/osdep/subprocess.c +++ b/osdep/subprocess.c @@ -1,22 +1,24 @@ /* * This file is part of mpv. * - * mpv is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * mpv is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * * mpv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with mpv. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ #include <pthread.h> +#include "config.h" + #include "common/common.h" #include "common/msg.h" #include "common/msg_control.h" @@ -55,3 +57,13 @@ void mp_subprocess_detached(struct mp_log *log, char **args) if (pthread_create(&thread, NULL, run_subprocess, p)) talloc_free(p); } + +#if !HAVE_SUBPROCESS +int mp_subprocess(char **args, struct mp_cancel *cancel, void *ctx, + subprocess_read_cb on_stdout, subprocess_read_cb on_stderr, + char **error) +{ + *error = "unsupported"; + return -1; +} +#endif diff --git a/osdep/subprocess.h b/osdep/subprocess.h index 33c4013f6d..a32e7911c8 100644 --- a/osdep/subprocess.h +++ b/osdep/subprocess.h @@ -1,18 +1,18 @@ /* * This file is part of mpv. * - * mpv is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * mpv is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * * mpv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with mpv. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MP_SUBPROCESS_H_ diff --git a/osdep/threads.c b/osdep/threads.c index cccce85d1c..e4bd0b7758 100644 --- a/osdep/threads.c +++ b/osdep/threads.c @@ -1,19 +1,20 @@ /* * This file is part of mpv. * - * mpv is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * mpv is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * * mpv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with mpv. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ + #include <stdio.h> #include <errno.h> #include <pthread.h> diff --git a/osdep/timer.c b/osdep/timer.c index 32f0172b0b..f75aec76f3 100644 --- a/osdep/timer.c +++ b/osdep/timer.c @@ -1,18 +1,18 @@ /* * This file is part of mpv. * - * mpv is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * mpv is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * * mpv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with mpv. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ #include <stdlib.h> diff --git a/osdep/windows_utils.c b/osdep/windows_utils.c index ee80a18ef4..a1ea32191a 100644 --- a/osdep/windows_utils.c +++ b/osdep/windows_utils.c @@ -21,6 +21,7 @@ #include <windows.h> #include <errors.h> #include <audioclient.h> +#include <d3d9.h> #include "windows_utils.h" @@ -83,15 +84,69 @@ static char *hresult_to_str(const HRESULT hr) E(AUDCLNT_S_BUFFER_EMPTY) E(AUDCLNT_S_THREAD_ALREADY_REGISTERED) E(AUDCLNT_S_POSITION_STALLED) + E(D3DERR_WRONGTEXTUREFORMAT) + E(D3DERR_UNSUPPORTEDCOLOROPERATION) + E(D3DERR_UNSUPPORTEDCOLORARG) + E(D3DERR_UNSUPPORTEDALPHAOPERATION) + E(D3DERR_UNSUPPORTEDALPHAARG) + E(D3DERR_TOOMANYOPERATIONS) + E(D3DERR_CONFLICTINGTEXTUREFILTER) + E(D3DERR_UNSUPPORTEDFACTORVALUE) + E(D3DERR_CONFLICTINGRENDERSTATE) + E(D3DERR_UNSUPPORTEDTEXTUREFILTER) + E(D3DERR_CONFLICTINGTEXTUREPALETTE) + E(D3DERR_DRIVERINTERNALERROR) + E(D3DERR_NOTFOUND) + E(D3DERR_MOREDATA) + E(D3DERR_DEVICELOST) + E(D3DERR_DEVICENOTRESET) + E(D3DERR_NOTAVAILABLE) + E(D3DERR_OUTOFVIDEOMEMORY) + E(D3DERR_INVALIDDEVICE) + E(D3DERR_INVALIDCALL) + E(D3DERR_DRIVERINVALIDCALL) + E(D3DERR_WASSTILLDRAWING) + E(D3DOK_NOAUTOGEN) + E(D3DERR_DEVICEREMOVED) + E(D3DERR_DEVICEHUNG) + E(S_NOT_RESIDENT) + E(S_RESIDENT_IN_SHARED_MEMORY) + E(S_PRESENT_MODE_CHANGED) + E(S_PRESENT_OCCLUDED) + E(D3DERR_UNSUPPORTEDOVERLAY) + E(D3DERR_UNSUPPORTEDOVERLAYFORMAT) + E(D3DERR_CANNOTPROTECTCONTENT) + E(D3DERR_UNSUPPORTEDCRYPTO) + E(D3DERR_PRESENT_STATISTICS_DISJOINT) default: return "<Unknown>"; } #undef E } +static char *fmtmsg_buf(char *buf, size_t buf_size, DWORD errorID) +{ + DWORD n = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, errorID, 0, buf, buf_size, NULL); + if (!n && GetLastError() == ERROR_MORE_DATA) { + snprintf(buf, buf_size, + "<Insufficient buffer size (%zd) for error message>", + buf_size); + } else { + if (n > 0 && buf[n-1] == '\n') + buf[n-1] = '\0'; + if (n > 1 && buf[n-2] == '\r') + buf[n-2] = '\0'; + } + return buf; +} +#define fmtmsg(hr) fmtmsg_buf((char[243]){0}, 243, (hr)) + char *mp_HRESULT_to_str_buf(char *buf, size_t buf_size, HRESULT hr) { - snprintf(buf, buf_size, "%s (0x%"PRIx32")", - hresult_to_str(hr), (uint32_t) hr); + char* msg = fmtmsg(hr); + msg = msg[0] ? msg : hresult_to_str(hr); + snprintf(buf, buf_size, "%s (0x%"PRIx32")", msg, (uint32_t)hr); return buf; } diff --git a/osdep/windows_utils.h b/osdep/windows_utils.h index 851eb1b4e3..6c750ded2a 100644 --- a/osdep/windows_utils.h +++ b/osdep/windows_utils.h @@ -23,7 +23,7 @@ char *mp_GUID_to_str_buf(char *buf, size_t buf_size, const GUID *guid); #define mp_GUID_to_str(guid) mp_GUID_to_str_buf((char[40]){0}, 40, (guid)) char *mp_HRESULT_to_str_buf(char *buf, size_t buf_size, HRESULT hr); -#define mp_HRESULT_to_str(hr) mp_HRESULT_to_str_buf((char[60]){0}, 60, (hr)) +#define mp_HRESULT_to_str(hr) mp_HRESULT_to_str_buf((char[256]){0}, 256, (hr)) #define mp_LastError_to_str() mp_HRESULT_to_str(HRESULT_FROM_WIN32(GetLastError())) #endif |