[vlc-commits] contribs: port libflac to WinRT

Bastien Penavayre git at videolan.org
Mon May 16 14:39:47 CEST 2016


vlc | branch: master | Bastien Penavayre <swac31 at gmail.com> | Mon May 16 13:48:07 2016 +0200| [4b79110a1a83ee98ece0af948e437def194bac24] | committer: Jean-Baptiste Kempf

contribs: port libflac to WinRT

Create two patches that remove calls to forbiden funtions in libflac and replace
with authorized function if necessary

Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4b79110a1a83ee98ece0af948e437def194bac24
---

 contrib/src/flac/console_write.patch               |   39 ++++++++++++++++++++
 .../remove_blocking_code_useless_flaclib.patch     |   38 +++++++++++++++++++
 contrib/src/flac/rules.mak                         |    4 ++
 3 files changed, 81 insertions(+)

diff --git a/contrib/src/flac/console_write.patch b/contrib/src/flac/console_write.patch
new file mode 100644
index 0000000..5ebfc37
--- /dev/null
+++ b/contrib/src/flac/console_write.patch
@@ -0,0 +1,39 @@
+--- flac/src/share/win_utf8_io/win_utf8_io.c.orig	2016-05-13 11:27:58.508525189 +0200
++++ flac/src/share/win_utf8_io/win_utf8_io.c	2016-05-13 12:16:51.951811662 +0200
+@@ -162,33 +162,14 @@
+ /* get the console width in characters */
+ int win_get_console_width(void)
+ {
+-	int width = 80;
+-	CONSOLE_SCREEN_BUFFER_INFO csbi;
+-	HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
+-	if (GetConsoleScreenBufferInfo(hOut, &csbi) != 0) width = csbi.dwSize.X;
+-	return width;
++    return 80;
+ }
+ 
+ /* print functions */
+-
+ int print_console(FILE *stream, const wchar_t *text, size_t len)
+ {
+-	static HANDLE hOut;
+-	static HANDLE hErr;
+-	DWORD out;
+-	hOut = GetStdHandle(STD_OUTPUT_HANDLE);
+-	hErr = GetStdHandle(STD_ERROR_HANDLE);
+-	if (stream == stdout && hOut != INVALID_HANDLE_VALUE && GetFileType(hOut) == FILE_TYPE_CHAR) {
+-		if (WriteConsoleW(hOut, text, len, &out, NULL) == 0) return -1;
+-		return out;
+-	} else if (stream == stderr && hErr != INVALID_HANDLE_VALUE && GetFileType(hErr) == FILE_TYPE_CHAR) {
+-		if (WriteConsoleW(hErr, text, len, &out, NULL) == 0) return -1;
+-		return out;
+-	} else {
+-		int ret = fputws(text, stream);
+-		if (ret < 0) return ret;
+-		return len;
+-	}
++    (void)stream, (void)text;
++    return len;
+ }
+ 
+ int printf_utf8(const char *format, ...)
diff --git a/contrib/src/flac/remove_blocking_code_useless_flaclib.patch b/contrib/src/flac/remove_blocking_code_useless_flaclib.patch
new file mode 100644
index 0000000..620773a
--- /dev/null
+++ b/contrib/src/flac/remove_blocking_code_useless_flaclib.patch
@@ -0,0 +1,38 @@
+--- flac/src/share/grabbag/file.c.orig	2014-11-27 02:19:47.048799991 +0100
++++ flac/src/share/grabbag/file.c	2016-05-13 16:32:33.727811662 +0200
+@@ -117,34 +117,7 @@
+ FLAC__bool grabbag__file_are_same(const char *f1, const char *f2)
+ {
+ #if defined _MSC_VER || defined __MINGW32__
+-	/* see
+-	 * http://www.hydrogenaudio.org/forums/index.php?showtopic=49439&pid=444300&st=0
+-	 *  http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/getfileinformationbyhandle.asp
+-	 *  http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/by_handle_file_information_str.asp
+-	 *  http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/createfile.asp
+-	 * apparently both the files have to be open at the same time for the comparison to work
+-	 */
+-	FLAC__bool same = false;
+-	BY_HANDLE_FILE_INFORMATION info1, info2;
+-	HANDLE h1, h2;
+-	BOOL ok = 1;
+-	h1 = CreateFile_utf8(f1, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+-	h2 = CreateFile_utf8(f2, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+-	if(h1 == INVALID_HANDLE_VALUE || h2 == INVALID_HANDLE_VALUE)
+-		ok = 0;
+-	ok &= GetFileInformationByHandle(h1, &info1);
+-	ok &= GetFileInformationByHandle(h2, &info2);
+-	if(ok)
+-		same =
+-			info1.dwVolumeSerialNumber == info2.dwVolumeSerialNumber &&
+-			info1.nFileIndexHigh == info2.nFileIndexHigh &&
+-			info1.nFileIndexLow == info2.nFileIndexLow
+-		;
+-	if(h1 != INVALID_HANDLE_VALUE)
+-		CloseHandle(h1);
+-	if(h2 != INVALID_HANDLE_VALUE)
+-		CloseHandle(h2);
+-	return same;
++    return true;
+ #else
+ 	struct flac_stat_s s1, s2;
+ 	return f1 && f2 && flac_stat(f1, &s1) == 0 && flac_stat(f2, &s2) == 0 && s1.st_ino == s2.st_ino && s1.st_dev == s2.st_dev;
diff --git a/contrib/src/flac/rules.mak b/contrib/src/flac/rules.mak
index 85b1080..b578131 100644
--- a/contrib/src/flac/rules.mak
+++ b/contrib/src/flac/rules.mak
@@ -15,6 +15,10 @@ $(TARBALLS)/flac-$(FLAC_VERSION).tar.xz:
 
 flac: flac-$(FLAC_VERSION).tar.xz .sum-flac
 	$(UNPACK)
+ifdef HAVE_WINRT
+	$(APPLY) $(SRC)/flac/console_write.patch
+	$(APPLY) $(SRC)/flac/remove_blocking_code_useless_flaclib.patch
+endif
 ifdef HAVE_DARWIN_OS
 	cd $(UNPACK_DIR) && sed -e 's,-dynamiclib,-dynamiclib -arch $(ARCH),' -i.orig configure
 endif



More information about the vlc-commits mailing list