-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Support formats option in sdl2 mixer
#24158
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
a2bf445
912b81d
1e934fd
f4b0d37
9ce7b66
7a0bc49
26fd69f
e9d44c3
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 |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| # found in the LICENSE file. | ||
|
|
||
| import os | ||
| from typing import Dict, Set | ||
|
|
||
| TAG = 'release-2.8.0' | ||
| HASH = '494ccd74540f74e717f7e4f1dc7f96398c0f4b1883ab00c4a76b0c7239bd2c185cb4358a35ef47819c49e7c14dac7c37b98a29c7b5237478121571f5e7ac4dfc' | ||
|
|
@@ -16,14 +17,28 @@ | |
| 'sdl2_mixer-none-mt': {'SDL2_MIXER_FORMATS': [], 'PTHREADS': 1}, | ||
| } | ||
|
|
||
| OPTIONS = { | ||
| 'formats': 'A comma separated list of formats (ex: --use-port=sdl2_mixer:formats=ogg,mp3)' | ||
| } | ||
|
|
||
| SUPPORTED_FORMATS = {'ogg', 'mp3', 'mod', 'mid'} | ||
|
|
||
| # user options (from --use-port) | ||
| opts: Dict[str, Set] = { | ||
| 'formats': set() | ||
| } | ||
|
|
||
|
|
||
| def needed(settings): | ||
| return settings.USE_SDL_MIXER == 2 | ||
|
|
||
|
|
||
| def get_formats(settings): | ||
| return set(settings.SDL2_MIXER_FORMATS).union(opts['formats']) | ||
|
||
|
|
||
|
|
||
| def get_lib_name(settings): | ||
| settings.SDL2_MIXER_FORMATS.sort() | ||
| formats = '-'.join(settings.SDL2_MIXER_FORMATS) | ||
| formats = '-'.join(sorted(get_formats(settings))) | ||
|
|
||
| libname = 'libSDL2_mixer' | ||
| if formats != '': | ||
|
|
@@ -41,30 +56,33 @@ def get(ports, settings, shared): | |
|
|
||
| def create(final): | ||
| source_path = ports.get_dir('sdl2_mixer', 'SDL_mixer-' + TAG) | ||
|
|
||
| formats = get_formats(settings) | ||
|
|
||
| flags = [ | ||
| '-sUSE_SDL=2', | ||
| '-DMUSIC_WAV', | ||
| ] | ||
|
|
||
| if "ogg" in settings.SDL2_MIXER_FORMATS: | ||
| if "ogg" in formats: | ||
| flags += [ | ||
| '-sUSE_VORBIS', | ||
| '-DMUSIC_OGG', | ||
| ] | ||
|
|
||
| if "mp3" in settings.SDL2_MIXER_FORMATS: | ||
| if "mp3" in formats: | ||
| flags += [ | ||
| '-sUSE_MPG123', | ||
| '-DMUSIC_MP3_MPG123', | ||
| ] | ||
|
|
||
| if "mod" in settings.SDL2_MIXER_FORMATS: | ||
| if "mod" in formats: | ||
| flags += [ | ||
| '-sUSE_MODPLUG', | ||
| '-DMUSIC_MOD_MODPLUG', | ||
| ] | ||
|
|
||
| if "mid" in settings.SDL2_MIXER_FORMATS: | ||
| if "mid" in formats: | ||
| flags += [ | ||
| '-DMUSIC_MID_TIMIDITY', | ||
| ] | ||
|
|
@@ -107,16 +125,27 @@ def clear(ports, settings, shared): | |
|
|
||
| def process_dependencies(settings): | ||
| settings.USE_SDL = 2 | ||
| if "ogg" in settings.SDL2_MIXER_FORMATS: | ||
| formats = get_formats(settings) | ||
| if "ogg" in formats: | ||
| deps.append('vorbis') | ||
| settings.USE_VORBIS = 1 | ||
| if "mp3" in settings.SDL2_MIXER_FORMATS: | ||
| if "mp3" in formats: | ||
| deps.append('mpg123') | ||
| settings.USE_MPG123 = 1 | ||
| if "mod" in settings.SDL2_MIXER_FORMATS: | ||
| if "mod" in formats: | ||
| deps.append('libmodplug') | ||
| settings.USE_MODPLUG = 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 'sdl2_mixer (-sUSE_SDL_MIXER=2 or --use-port=sdl2_mixer; zlib license)' | ||
Uh oh!
There was an error while loading. Please reload this page.