-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[ports] SDL3_mixer 3.2.0 #26571
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
Open
onesixromcom
wants to merge
12
commits into
emscripten-core:main
Choose a base branch
from
onesixromcom:sdl3-mixer-port
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[ports] SDL3_mixer 3.2.0 #26571
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
59372d4
Update SDL3 to latest 3.4.2 version
onesixromcom 33906c8
Simple SDL3_mixer port implementation
onesixromcom 3bae82e
Tests for sdl3_mixer
onesixromcom 317a13c
[ports] revert sdl3 update
onesixromcom e467103
[ports] SDL3_mixer fix archive link
onesixromcom bd28c37
[ports] SDL3_mixer add ogg and mp3 formats, tests updates
onesixromcom 17affb5
[ports] SDL3_mixer fix other tests
onesixromcom f787d0c
Merge branch 'main' into sdl3-mixer-port
onesixromcom 320a752
Changelog updates
onesixromcom 4c549ea
[ports] SDL3_mixer codestyle fixes
onesixromcom 3835624
Merge branch 'main' into sdl3-mixer-port
onesixromcom 2fcdbc8
[ports] SDL3_mixer codestyle fixes
onesixromcom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| /* | ||
| * Copyright 2025 The Emscripten Authors. All rights reserved. | ||
| * Emscripten is available under two separate licenses, the MIT license and the | ||
| * University of Illinois/NCSA Open Source License. Both these licenses can be | ||
| * found in the LICENSE file. | ||
| */ | ||
|
|
||
| #include <stdio.h> | ||
| #include <SDL3/SDL.h> | ||
| #include <SDL3/SDL_main.h> | ||
| #include <SDL3_mixer/SDL_mixer.h> | ||
| #include <emscripten.h> | ||
|
|
||
| SDL_Window *window = NULL; | ||
| SDL_Renderer *renderer = NULL; | ||
| MIX_Audio *audio = NULL; | ||
| MIX_Track *track = NULL; | ||
| MIX_Mixer *mixer = NULL; | ||
|
|
||
| #define WIDTH 640 | ||
| #define HEIGHT 480 | ||
|
|
||
| #ifndef SOUND_PATH | ||
| #error "must define SOUND_PATH" | ||
| #endif | ||
|
|
||
| void sound_loop_then_quit() { | ||
| if (MIX_TrackPlaying(track)) | ||
| return; | ||
|
|
||
| MIX_DestroyAudio(audio); | ||
| MIX_DestroyTrack(track); | ||
| MIX_DestroyMixer(mixer); | ||
|
|
||
| emscripten_cancel_main_loop(); | ||
| printf("Shutting down\n"); | ||
| exit(0); | ||
| } | ||
|
|
||
| int main(int argc, char *argv[]) { | ||
| SDL_Init(SDL_INIT_VIDEO); | ||
|
|
||
| if (!MIX_Init()) { | ||
| printf("MIX_Init failed: %s\n", SDL_GetError()); | ||
| return 1; | ||
| } | ||
|
|
||
| if (!SDL_CreateWindowAndRenderer("SDL3 MIXER", WIDTH, HEIGHT, 0, &window, &renderer)) { | ||
| printf("SDL_CreateWindowAndRenderer: %s\n", SDL_GetError()); | ||
| return 1; | ||
| } | ||
|
|
||
| mixer = MIX_CreateMixerDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, NULL); | ||
| if (!mixer) { | ||
| printf("Couldn't create mixer on default device: %s", SDL_GetError()); | ||
| return 1; | ||
| } | ||
|
|
||
| audio = MIX_LoadAudio(mixer, SOUND_PATH, false); | ||
| if (!audio) { | ||
| printf("MIX_LoadAudio: %s\n", SDL_GetError()); | ||
| return 1; | ||
| } | ||
|
|
||
| track = MIX_CreateTrack(mixer); | ||
| if (!track) { | ||
| printf("MIX_CreateTrack: %s\n", SDL_GetError()); | ||
| return 1; | ||
| } | ||
|
|
||
| MIX_SetTrackAudio(track, audio); | ||
| SDL_PropertiesID props = SDL_CreateProperties(); | ||
| SDL_SetNumberProperty(props, MIX_PROP_PLAY_LOOPS_NUMBER, 0); | ||
|
|
||
| printf("Starting sound play loop\n"); | ||
| MIX_PlayTrack(track, props); | ||
|
|
||
| emscripten_set_main_loop(sound_loop_then_quit, 0, 1); | ||
|
|
||
| return 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| # Copyright 2025 The Emscripten Authors. All rights reserved. | ||
| # Emscripten is available under two separate licenses, the MIT license and the | ||
| # University of Illinois/NCSA Open Source License. Both these licenses can be | ||
| # found in the LICENSE file. | ||
|
|
||
| import os | ||
|
|
||
| VERSION = '3.2.0' | ||
| TAG = f'release-{VERSION}' | ||
| HASH = '96f374b3ca96202973fca84228e7775db3d6e38888888573d0ba0d045bc1d3cc6f876984e50dcce1b65875c80f8e263b5ff687570f4b4c720f48ca3cfaff0648' | ||
| SUBDIR = f'SDL3_mixer-{TAG}' | ||
|
|
||
| deps = ['sdl3'] | ||
|
|
||
| variants = { | ||
| 'sdl3_mixer-ogg': {'SDL3_MIXER_FORMATS': ['ogg']}, | ||
| 'sdl3_mixer-none': {'SDL3_MIXER_FORMATS': []}, | ||
| 'sdl3_mixer-ogg-mt': {'SDL3_MIXER_FORMATS': ['ogg'], 'PTHREADS': 1}, | ||
| 'sdl3_mixer-none-mt': {'SDL3_MIXER_FORMATS': [], 'PTHREADS': 1}, | ||
| } | ||
|
|
||
| OPTIONS = { | ||
| 'formats': 'A comma separated list of formats (ex: --use-port=sdl3_mixer:formats=ogg,mp3)', | ||
| } | ||
|
|
||
| SUPPORTED_FORMATS = {'ogg', 'mp3'} | ||
|
|
||
| # user options (from --use-port) | ||
| opts: dict[str, set] = { | ||
| 'formats': set(), | ||
| } | ||
|
|
||
|
|
||
| def needed(settings): | ||
| return settings.USE_SDL_MIXER == 3 | ||
|
|
||
|
|
||
| def get_formats(settings): | ||
| return opts['formats'].union(settings.SDL3_MIXER_FORMATS) | ||
|
|
||
|
|
||
| def get_lib_name(settings): | ||
| formats = '-'.join(sorted(get_formats(settings))) | ||
|
|
||
| libname = 'libSDL3_mixer' | ||
| if formats != '': | ||
| libname += '-' + formats | ||
| if settings.PTHREADS: | ||
| libname += '-mt' | ||
| libname += '.a' | ||
|
|
||
| return libname | ||
|
|
||
|
|
||
| def get(ports, settings, shared): | ||
| ports.fetch_project('sdl3_mixer', f'https://github.com/libsdl-org/SDL_mixer/archive/{TAG}.zip', sha512hash=HASH) | ||
| libname = get_lib_name(settings) | ||
|
|
||
| def create(final): | ||
| src_root = ports.get_dir('sdl3_mixer', 'SDL_mixer-' + TAG) | ||
| ports.install_header_dir(os.path.join(src_root, 'include'), target='.') | ||
| srcs = [ | ||
| 'src/SDL_mixer.c', | ||
| 'src/SDL_mixer_metadata_tags.c', | ||
| 'src/SDL_mixer_spatialization.c', | ||
| 'src/decoder_raw.c', | ||
| 'src/decoder_sinewave.c', | ||
| 'src/decoder_wav.c', | ||
| ] | ||
|
|
||
| flags = ['-sUSE_SDL=3', '-DDECODER_WAV','-Wno-format-security', '-Wno-experimental'] | ||
|
|
||
| if settings.PTHREADS: | ||
| flags += ['-pthread'] | ||
|
|
||
| formats = get_formats(settings) | ||
|
|
||
| if 'ogg' in formats: | ||
| flags += [ | ||
| '-sUSE_VORBIS', | ||
| '-DDECODER_OGGVORBIS_VORBISFILE', | ||
| ] | ||
| srcs += ['src/decoder_vorbis.c',] | ||
|
|
||
| if 'mp3' in formats: | ||
| flags += [ | ||
| '-sUSE_MPG123', | ||
| '-DDECODER_MP3_MPG123', | ||
| ] | ||
| srcs += ['src/decoder_mpg123.c',] | ||
|
|
||
| ports.build_port(src_root, final, 'sdl3_mixer', flags=flags, srcs=srcs) | ||
| return [shared.cache.get_lib(libname, create, what='port')] | ||
|
|
||
|
|
||
| def clear(ports, settings, shared): | ||
| shared.cache.erase_lib(get_lib_name(settings)) | ||
|
|
||
|
|
||
| def process_dependencies(settings): | ||
| settings.USE_SDL = 3 | ||
| formats = get_formats(settings) | ||
| if 'ogg' in formats: | ||
| deps.append('vorbis') | ||
| settings.USE_VORBIS = 1 | ||
| if 'mp3' in formats: | ||
| deps.append('mpg123') | ||
| settings.USE_MPG123 = 1 | ||
|
|
||
|
|
||
| def handle_options(options, error_handler): | ||
| formats = options['formats'].split(',') | ||
| for format in formats: | ||
| format = format.lower().strip() | ||
| if format not in SUPPORTED_FORMATS: | ||
| error_handler(f'{format} is not a supported format') | ||
| else: | ||
| opts['formats'].add(format) | ||
|
|
||
|
|
||
| def show(): | ||
| return 'sdl3_mixer (-sUSE_SDL_MIXER=3 or --use-port=sdl3_mixer; zlib license)' | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,7 @@ | |
| 'USE_FREETYPE', | ||
| 'SDL2_MIXER_FORMATS', | ||
| 'SDL2_IMAGE_FORMATS', | ||
| 'SDL3_MIXER_FORMATS', | ||
| 'USE_SQLITE3', | ||
| } | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Does this library actually use threading (or atomics)?
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've copied this part from sdl2_mixer.py
not sure.
there are no -pthreads flag check in cmakelists.txt.
only set(WAVPACK_ENABLE_THREADS FALSE) for wavpack which is not supported.
Should we remove this option?
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 think maybe because SDL3 itself has a threaded variant its required that all the sub-libraries do it.. but I can't remember the exact rationale.
Maybe leave it as is.