Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ jobs:
- name: Install Perl and MHFS Perl dependencies
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: '5.38'
perl-version: '5.40'
working-directory: MHFS
install-modules-with: cpanm
install-modules-args: --with-develop --with-configure --with-recommends
- name: Setup emscripten
uses: mymindstorm/setup-emsdk@v14
with:
version: latest
version: '4.0.12'
actions-cache-folder: 'emsdk-cache'
- name: Build and package MHFS
run: |
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
- name: Install Perl and MHFS Perl dependencies
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: '5.38'
perl-version: '5.40'
working-directory: MHFS
install-modules-with: cpanm
install-modules: LWP::UserAgent LWP::Protocol::https Perl::Dist::APPerl
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:
strategy:
matrix:
os: ['ubuntu-latest']
emcc: ['1.40.1', '2.0.0', '2.0.34', '3.0.0', '3.1.17' ]
emcc: ['1.40.1', '2.0.34', '3.1.74', '4.0.0', 'latest']
runs-on: ${{ matrix.os }}
steps:
- name: Fetch repo and submodules
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ TARGET:=$(OUTDIR)/_mhfscl.js
EXPORTED_RUNTIME_METHODS := $(shell perl exported_runtime_methods.pl)
STACK_SIZE_NAME := $(shell perl stack_size_name.pl)

CFLAGS:=-Wall -Wextra -I$(DRFLACDIR) -I$(MINIAUDIODIR) -DMA_NO_DEVICE_IO -DMA_NO_THREADING -DMA_NO_ENCODING -DDR_FLAC_BUFFER_SIZE=65536 -DDR_FLAC_NO_OGG $(EXPORTED_RUNTIME_METHODS) -s'EXPORTED_FUNCTIONS=["_malloc", "_realloc", "_free"]' -sEXPORT_ES6=1 -s$(STACK_SIZE_NAME)=128KB -sALLOW_MEMORY_GROWTH=1 -sMODULARIZE=1 -sALLOW_TABLE_GROWTH=1
CFLAGS:=-Wall -Wextra -I$(DRFLACDIR) -I$(MINIAUDIODIR) -DMA_NO_DEVICE_IO -DMA_NO_THREADING -DMA_NO_ENCODING -DDR_FLAC_BUFFER_SIZE=65536 -DDR_FLAC_NO_OGG $(EXPORTED_RUNTIME_METHODS) -s'EXPORTED_FUNCTIONS=["_malloc", "_realloc", "_free"]' -sEXPORT_ES6=1 -s$(STACK_SIZE_NAME)=128KB -sALLOW_MEMORY_GROWTH=1 -sMODULARIZE=1 -sALLOW_TABLE_GROWTH=1 -sWASM_BIGINT=1

# a non zero value turns on Werrror
MHFS_CL_DEC_Werror?=0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
#!/usr/bin/perl
# EXTRA_EXPORTED_RUNTIME_METHODS was deprecated in emsdk 2.0.18
use strict; use warnings;
my @exported_runtime_methods = ("cwrap", "ccall");
my @extra_exported_runtime_methods = ("UTF8ToString", "addFunction", "removeFunction", "allocateUTF8");
my @extra_exported_runtime_methods = ("UTF8ToString", "addFunction", "removeFunction");

# determine configuration
open(my $emcc, "-|", 'emcc', '--version') or die("Failed to open emcc");
my $combine_extra;
my $line = <$emcc>;
if($line =~ /\s+(\d+)\.(\d+)\.(\d+)/) {
my ($maj, $min, $patch) = ($1, $2, $3);
$combine_extra = ($maj > 2) || (($maj == 2) && (($min > 0) || ($patch >= 18)));
my @version = $line =~ /\s+(\d+)\.(\d+)\.(\d+)/;
if (!@version) {
@version = (4, 0, 12);
warn "version parsing failed, assuming " . join('.', @version);
}
if(!defined($combine_extra)) {
warn "warn: Failed to find version, assuming combine_extra";
$combine_extra = 1;
# EXTRA_EXPORTED_RUNTIME_METHODS was deprecated
my $combine_extra = version_greater_than_or_equal(\@version, [2, 0, 18]);
# allocateUTF8 was deprecated in favor of stringToNewUTF8
if (version_greater_than_or_equal(\@version, [3, 1, 35])) {
push @exported_runtime_methods, 'stringToNewUTF8';
} else {
push @extra_exported_runtime_methods, 'allocateUTF8';
}
# HEAP* is no longer exported by default in emsdk 4.0.7
if (version_greater_than_or_equal(\@version, [4, 0, 7])) {
push @exported_runtime_methods, qw(HEAPU8 HEAPU16 HEAPU32);
}

# build the arrays
Expand All @@ -40,3 +47,15 @@
}

print $opts;

sub version_greater_than_or_equal {
my ($version, $expected) = @_;
@$version >= @$expected or die "expected has more version components";
my $i = 0;
foreach my $component (@$expected) {
return 0 if($version->[$i] < $component);
return 1 if($version->[$i] > $component);
$i++;
}
return 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -402,25 +402,23 @@ const MHFSCLTrack = async function(gsignal, theURL, DLMGR) {
if(!that.ptr) throw("failed malloc");
const rd = MHFSCL.mhfs_cl_track_return_data.from(that.ptr + alignedTrackSize);
const thatid = MHFSCLObjectMap.addData(that);
const pFullFilename = MHFSCL.Module.allocateUTF8(theURL);
const pFullFilename = MHFSCL.Module.stringToNewUTF8(theURL);
let pMime;
try {
// initialize the track
let start = 0;
const firstreq = await that._downloadChunk(start, gsignal);
const mime = firstreq.headers['Content-Type'] || '';
pMime = MHFSCL.Module.allocateUTF8(mime);
pMime = MHFSCL.Module.stringToNewUTF8(mime);
const totalPCMFrames = BigInt(firstreq.headers['X-MHFS-totalPCMFrameCount'] || 0);
const totalPCMFramesLo = Number(totalPCMFrames & BigInt(0xFFFFFFFF));
const totalPCMFramesHi = Number((totalPCMFrames >> BigInt(32)) & BigInt(0xFFFFFFFF));
MHFSCL.Module._mhfs_cl_track_init(that.ptr, that.CHUNKSIZE);
that.initialized = true;
that._storeChunk(firstreq, start);

// load enough of the track that the metadata loads
for(;;) {
that.picture = null;
const code = MHFSCL.Module._mhfs_cl_track_load_metadata(that.ptr, rd.ptr, pMime, pFullFilename, totalPCMFramesLo, totalPCMFramesHi, MHFSCL.pMHFSCLTrackOnMeta, thatid);
const code = MHFSCL.Module._mhfs_cl_track_load_metadata(that.ptr, rd.ptr, pMime, pFullFilename, totalPCMFrames, MHFSCL.pMHFSCLTrackOnMeta, thatid);
if(code === MHFSCL.MHFS_CL_SUCCESS) {
break;
}
Expand Down Expand Up @@ -732,6 +730,7 @@ const ExposeType_LoadTypes = function(BINDTO, wasmMod, loadType) {

Module().then(function(MHFSCLMod){
MHFSCL.Module = MHFSCLMod;
MHFSCL.Module.stringToNewUTF8 ||= MHFSCL.Module.allocateUTF8; // < 3.1.35 emcc compat

// Load types
ExposeType_LoadTypes(MHFSCL, MHFSCL.Module, MHFSCL.Module._mhfs_cl_et_load_type);
Expand Down
Loading