-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[AUDIO_WORKET] Add support for setting the render quantum size #25747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
c2952bb
c013e88
1af27ca
d7e40b7
e455f22
50e4a04
d7136ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -77,12 +77,7 @@ var LibraryWebAudio = { | |||||||||
|
|
||||||||||
| // Performs the work of getting the AudioContext's render quantum size. | ||||||||||
| $emscriptenGetContextQuantumSize: (contextHandle) => { | ||||||||||
| // TODO: in a future release this will be something like: | ||||||||||
| // return EmAudio[contextHandle].renderQuantumSize || 128; | ||||||||||
| // It comes two caveats: it needs the hint when generating the context adding to | ||||||||||
| // emscripten_create_audio_context(), and altering the quantum requires a secure | ||||||||||
| // context and fallback implementing. Until then we simply use the 1.0 API value: | ||||||||||
| return 128; | ||||||||||
| return EmAudio[contextHandle].renderQuantumSize || 128; | ||||||||||
cwoffenden marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| }, | ||||||||||
|
|
||||||||||
| // emscripten_create_audio_context() does not itself use the | ||||||||||
|
|
@@ -100,9 +95,15 @@ var LibraryWebAudio = { | |||||||||
| #endif | ||||||||||
| #endif | ||||||||||
|
|
||||||||||
| // AUDIO_CONTEXT_RENDER_SIZE_DEFAULT and AUDIO_CONTEXT_RENDER_SIZE_HARDWARE | ||||||||||
| // into their AudioContextRenderSizeCategory enum, or take the positive int. | ||||||||||
|
||||||||||
| function readRenderSizeHint(val) { | ||||||||||
| return (val == 0) ? "default" : ((val < 0) ? "hardware" : val); | ||||||||||
|
||||||||||
| return (val == 0) ? "default" : ((val < 0) ? "hardware" : val); | |
| if (val == 0) return "default"; | |
| if (val == -1) return "hardware"; | |
| return val; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, it's terrible to read, but @juj would've had something to say about the extra bytes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Replaced with something less hideous)
cwoffenden marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -1269,7 +1269,8 @@ | |||
| "structs": { | ||||
| "EmscriptenWebAudioCreateAttributes": [ | ||||
| "latencyHint", | ||||
| "sampleRate" | ||||
| "sampleRate", | ||||
| "renderSizeHint" | ||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I copied what the JS API now calls it: emscripten/src/lib/libwebaudio.js Line 106 in e455f22
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if there are any users of this API yet, could we rename
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The spec mixes the two, even for the Currently there's no reason to use this call, since it's always been 128. It's handy before the callback for calculating the stack size, and I should write an example of this. |
||||
| ], | ||||
| "WebAudioParamDescriptor": [ | ||||
| "defaultValue", | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,10 +19,16 @@ extern "C" { | |
|
|
||
| typedef int EMSCRIPTEN_WEBAUDIO_T; | ||
|
|
||
| // Default render size of 128 frames | ||
| #define AUDIO_CONTEXT_RENDER_SIZE_DEFAULT 0 | ||
| // Let the hardware determine the best render size | ||
| #define AUDIO_CONTEXT_RENDER_SIZE_HARDWARE -1 | ||
|
|
||
| typedef struct EmscriptenWebAudioCreateAttributes | ||
| { | ||
| const char *latencyHint; // Specify one of "balanced", "interactive" or "playback" | ||
| uint32_t sampleRate; // E.g. 44100 or 48000 | ||
| int32_t renderSizeHint; // AUDIO_CONTEXT_RENDER_SIZE_* or number of samples | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I presume since this is a hint, the context creation is allowed to not honor it?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
From the spec: https://webaudio.github.io/web-audio-api/#dom-audiocontextoptions-rendersizehint "It is a hint that might not be honored." |
||
| } EmscriptenWebAudioCreateAttributes; | ||
|
|
||
| // Creates a new Web Audio AudioContext, and returns a handle to it. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.