Comments (14)
@sbc100
Sam could you help me?
from emscripten.
I think with wasm workers you allocate your own stack explicitly right? What size are you using? Have you tried upping it?
from emscripten.
@sbc100 Size?
I don't know. I guess default value.
Added -sALLOW_MEMORY_GROWTH=1 to raise memory automatically if it is needed.
As for stack size in documentation it's said that there is no way to enlarge the stack.
Tried to use -sSTACK_SIZE=5mb and other values but still nothing.
from emscripten.
I mean when you create you wasm worker you specify a stack right? What does the code you have for wasm worker creation look like?
from emscripten.
https://github.com/mackron/miniaudio/issues/816
@mackron There is another issue with miniaudio as well.
from emscripten.
I mean when you create you wasm worker you specify a stack right? What does the code you have for wasm worker creation look like?
I'm trying to make work miniaudio and emscripten together. In miniaudio documentation is said to use these flags to make it work.
-sAUDIO_WORKLET=1 -sWASM_WORKERS=1 -sASYNCIFY
It automatically creates wask-worker and audio worklet and I guess it specify stack by itself. I'm not sure.
My code of initialization of sound
Sound engine initialization
void _KBSoundHelper::Init()
{
// init auidio context
ma_engine* engine = new ma_engine();
ma_result result = ma_engine_init(NULL, engine);
if (result != MA_SUCCESS)
{
LOG("[SoundHelper] Cannot initalize engine, result %d", result);
return; // Failed to initialize the engine.
}
LOG("[SoundHelper] Engine has been initialized");
_engine = engine;
_initialized = true;
}
Sound load & play
/// load sound into context (or prepare it as stream audio)
int _KBSoundHelper::Load(const char*name, int sampleLimit, bool buffered, bool loopable)
{
if(!_initialized) return -1;
_KBSound* sound = new _KBSound(_engine, _lastSoundId++, sampleLimit, name, buffered, loopable);
// if(buffered) sound->Buffering();
_sounds[sound->GetId()] = sound;
return sound->GetId();
}
/// play preloaded sound with attributes
void _KBSoundHelper::Play(int soundId, float volume, float rate, float overDuration, bool changeIfExist)
{
if(!_initialized) return;
auto it = _sounds.find(soundId);
if(it == _sounds.end()) return;
LOG("play in helper");
it->second->Play(volume, rate, overDuration, changeIfExist);
}
Sound-files are buffered here
ma_sound* _KBSound::Buffering()
{
ma_sound* sound = new ma_sound();
ma_sound_config soundConfig;
soundConfig = ma_sound_config_init_2(_engine);
soundConfig.pFilePath = _fileName; // Set this to load from a file path.
soundConfig.endCallback = &soundPlaybackEnd;
soundConfig.pEndCallbackUserData = this;
soundConfig.flags = MA_SOUND_FLAG_NO_SPATIALIZATION | MA_SOUND_FLAG_NO_PITCH;// | MA_SOUND_FLAG_STREAM;
soundConfig.isLooping = _loopable;
soundConfig.pInitialAttachment = NULL;
soundConfig.pDoneFence = NULL;
soundConfig.channelsOut = 0;
ma_result result = ma_sound_init_ex(_engine, &soundConfig, sound);
if (result != MA_SUCCESS)
{
LOG("Sound %d cannot be buffered, result %d", _id, result);
return 0;
}
_nativeSounds.push_back(sound);
return sound;
}
Maybe I'm missing something but don't know what.
from emscripten.
Sounds like a question for the developers of miniaudio perhaps.
from emscripten.
Sounds like a question for the developers of miniaudio perhaps.
Yeah. I asked for his help as well =)
Hoped you both could help me)
from emscripten.
miniaudio defaults to a stack size of 16384. I can't remember how I came up with that number, but it can be configured to anything you like via the MA_AUDIO_WORKLETS_THREAD_STACK_SIZE
define. Either define it on the command line, or in code like this:
#define MA_AUDIO_WORKLETS_THREAD_STACK_SIZE 32768
#define MINIAUDIO_IMPLEMENTATION
#include "miniaudio.h"
It needs to be visible to the implementation section of miniaudio.h, and it must be a multiple of 16.
If you play around with that and find a value that works for you, I'd be happy to consider upping the default value. The AudioWorklets path of miniaudio is not enabled by default, so I don't think many people are using it which might be why this hasn't been discovered yet.
from emscripten.
miniaudio defaults to a stack size of 16384. I can't remember how I came up with that number, but it can be configured to anything you like via the
MA_AUDIO_WORKLETS_THREAD_STACK_SIZE
define. Either define it on the command line, or in code like this:#define MA_AUDIO_WORKLETS_THREAD_STACK_SIZE 32768 #define MINIAUDIO_IMPLEMENTATION #include "miniaudio.h"It needs to be visible to the implementation section of miniaudio.h, and it must be a multiple of 16.
If you play around with that and find a value that works for you, I'd be happy to consider upping the default value. The AudioWorklets path of miniaudio is not enabled by default, so I don't think many people are using it which might be why this hasn't been discovered yet.
Unfortunately, MA_AUDIO_WORKLETS_THREAD_STACK_SIZE 32768 doesn't help. Error remains.
from emscripten.
Can you try setting it to 5MB?
Does the error message change? What does it say for the values in the (Attempt to set SP to 0x00065260, with stack limits [0x00065a50 - 0x00069a40]
message?
from emscripten.
I set to
#define MA_AUDIO_WORKLETS_THREAD_STACK_SIZE 81920
and error is gone.
from emscripten.
Great! Seems like a straight forward fox. I guess we can close this issue now?
from emscripten.
Yeah I guess so.
Thanks for your help guys. Really appreciate it =)
from emscripten.
Related Issues (20)
- Using emscripten_sleep for waiting to be finished HOT 5
- [wasm-split] Reconstruct production stackTrace HOT 3
- -sSUPPORT_ERRNO=0 has regressed HOT 3
- `--embind-emit-tsd` breaks with `-fwasm-exceptions` on latest version of `node`
- Missing methods on INCOMING_MODULE_JS_API, like `onMalloc` HOT 7
- Enable the use of inline class fields declarations
- add expat and dbus support HOT 1
- Audio support using SDL_Mixer
- Should `FS.mkdirTree` throw if path points to a file? HOT 3
- Consistent mapping of JS async APIs to native C/C++ APIs HOT 19
- emscripten_get_orientation_status breaks with ASSERTIONS
- emscripten_set_orientationchange_callback does not work HOT 1
- --embind-emit-tsd fails when linking dynamic libraries
- How does emscripten generate additional warnings? HOT 1
- 3.1.55 does not contain ports changes HOT 2
- Embuilder fails to build when using the `--lto` flag HOT 4
- glProvokingVertexWEBGL HOT 2
- TypeScript declarations should generate `MainModule` type name based on user inputs HOT 1
- [v3.1.55]: `stringToNewUTF8` is not defined error HOT 2
- ASYNCIFY, EXIT_RUNTIME and std::process::exit() HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from emscripten.