summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorMateusz Łukasik <mati75@linuxmint.pl>2016-03-13 23:31:21 +0100
committerMateusz Łukasik <mati75@linuxmint.pl>2016-03-13 23:31:21 +0100
commitfe66d42debb01fbb0e0c85679d1aaed2ccbc531b (patch)
treeac2481f12e78eb56a597824f5bd52e3bb19e6233 /misc
parentee91c4184837d9ecc2ab4a699c870baa4f79bb68 (diff)
Imported Upstream version 0.16.0
Diffstat (limited to 'misc')
-rw-r--r--misc/bstr.c2
-rw-r--r--misc/bstr.h2
-rw-r--r--misc/charset_conv.c23
-rw-r--r--misc/charset_conv.h1
-rw-r--r--misc/dispatch.c27
-rw-r--r--misc/json.c14
-rw-r--r--misc/json.h14
-rw-r--r--misc/ring.c16
-rw-r--r--misc/ring.h14
9 files changed, 64 insertions, 49 deletions
diff --git a/misc/bstr.c b/misc/bstr.c
index b168acc..13441ee 100644
--- a/misc/bstr.c
+++ b/misc/bstr.c
@@ -24,7 +24,7 @@
#include <libavutil/common.h>
-#include "talloc.h"
+#include "mpv_talloc.h"
#include "common/common.h"
#include "misc/ctype.h"
diff --git a/misc/bstr.h b/misc/bstr.h
index ef5591a..f565166 100644
--- a/misc/bstr.h
+++ b/misc/bstr.h
@@ -24,7 +24,7 @@
#include <stdbool.h>
#include <stdarg.h>
-#include "talloc.h"
+#include "mpv_talloc.h"
#include "osdep/compiler.h"
/* NOTE: 'len' is size_t, but most string-handling functions below assume
diff --git a/misc/charset_conv.c b/misc/charset_conv.c
index 3e7e47c..fcc346b 100644
--- a/misc/charset_conv.c
+++ b/misc/charset_conv.c
@@ -5,18 +5,18 @@
* of MPlayer (GPL).
* Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@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/>.
*/
#include <stdlib.h>
@@ -52,6 +52,13 @@ bool mp_charset_is_utf8(const char *user_cp)
strcasecmp(user_cp, "utf-8") == 0);
}
+bool mp_charset_is_utf16(const char *user_cp)
+{
+ bstr s = bstr0(user_cp);
+ return bstr_case_startswith(s, bstr0("utf16")) ||
+ bstr_case_startswith(s, bstr0("utf-16"));
+}
+
// Split the string on ':' into components.
// out_arr is at least max entries long.
// Return number of out_arr entries filled.
@@ -179,6 +186,8 @@ static const char *mp_uchardet(void *talloc_ctx, struct mp_log *log, bstr buf)
iconv_close(icdsc);
}
}
+ if (!res && bstr_validate_utf8(buf) >= 0)
+ res = "utf-8";
uchardet_delete(det);
return res;
}
diff --git a/misc/charset_conv.h b/misc/charset_conv.h
index 3d3520f..ddfabbe 100644
--- a/misc/charset_conv.h
+++ b/misc/charset_conv.h
@@ -13,6 +13,7 @@ enum {
};
bool mp_charset_is_utf8(const char *user_cp);
+bool mp_charset_is_utf16(const char *user_cp);
bool mp_charset_requires_guess(const char *user_cp);
const char *mp_charset_guess(void *talloc_ctx, struct mp_log *log, bstr buf,
const char *user_cp, int flags);
diff --git a/misc/dispatch.c b/misc/dispatch.c
index 502742b..2ddac2c 100644
--- a/misc/dispatch.c
+++ b/misc/dispatch.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 <stdbool.h>
@@ -62,10 +62,15 @@ static void queue_dtor(void *p)
pthread_mutex_destroy(&queue->exclusive_lock);
}
-// A dispatch queue lets other threads runs callbacks in a target thread.
-// The target thread is the thread which created the queue and which calls
-// mp_dispatch_queue_process().
-// Free the dispatch queue with talloc_free(). (It must be empty.)
+// A dispatch queue lets other threads run callbacks in a target thread.
+// The target thread is the thread which calls mp_dispatch_queue_process().
+// Free the dispatch queue with talloc_free(). At the time of destruction,
+// the queue must be empty. The easiest way to guarantee this is to
+// terminate all potential senders, then call mp_dispatch_run() with a
+// function that e.g. makes the target thread exit, then pthread_join() the
+// target thread, and finally destroy the queue. Another way is calling
+// mp_dispatch_queue_process() after terminating all potential senders, and
+// then destroying the queue.
struct mp_dispatch_queue *mp_dispatch_create(void *ta_parent)
{
struct mp_dispatch_queue *queue = talloc_ptrtype(ta_parent, queue);
diff --git a/misc/json.c b/misc/json.c
index b0be746..2a7c164 100644
--- a/misc/json.c
+++ b/misc/json.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/>.
*/
/* JSON parser:
diff --git a/misc/json.h b/misc/json.h
index f5ad4cf..0a9f8d7 100644
--- a/misc/json.h
+++ b/misc/json.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_JSON_H
diff --git a/misc/ring.c b/misc/ring.c
index 41c9c6a..9ba4306 100644
--- a/misc/ring.c
+++ b/misc/ring.c
@@ -3,24 +3,24 @@
* Copyright (c) 2012 wm4
* 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/>.
*/
#include <inttypes.h>
#include <libavutil/common.h>
#include <assert.h>
-#include "talloc.h"
+#include "mpv_talloc.h"
#include "osdep/atomics.h"
#include "ring.h"
diff --git a/misc/ring.h b/misc/ring.h
index e93baea..604b95f 100644
--- a/misc/ring.h
+++ b/misc/ring.h
@@ -3,18 +3,18 @@
* Copyright (c) 2012 wm4
* 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 MPV_MP_RING_H