ref: 522639f7682c3a0e5d7cffbb792390281fcd1479
parent: bee0d7d23030ab8c493640bb9fef3d73670f9320
author: Brion Vibber <[email protected]>
date: Thu Jul 2 08:24:32 EDT 2015
Allow compilation to JavaScript via emscripten Currently the emscripten JavaScript environment for C/C++ programs cannot do multithreading, and doesn't have a sysctl implementation to get hardware CPU count. Hardcode to 1. Using the Linux OS settings works, so not adding a platform file. To build with emscripten (tested 1.30.0): emmake make OS=emscripten ARCH=asmjs The resulting libopenh264.so is LLVM bitcode which can be further linked into an emscripten project for final JavaScript output.
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -30,6 +30,7 @@
Sawyer Shan
Siping Tao
Martin Storsjö
+Brion Vibber
James Wang
Juanny Wang
Zhiliang Wang
--- a/codec/common/src/WelsThreadLib.cpp
+++ b/codec/common/src/WelsThreadLib.cpp
@@ -483,6 +483,12 @@
return WELS_THREAD_ERROR_OK;
+#elif defined(__EMSCRIPTEN__)
+
+ // There is not yet a way to determine CPU count in emscripten JS environment.
+ pInfo->ProcessorCount = 1;
+ return WELS_THREAD_ERROR_OK;
+
#else
size_t len = sizeof (pInfo->ProcessorCount);