Skip to content

Commit 500c3a9

Browse files
committed
extensions: Added AL_EXT_32bit_formats.
In practice, this is just mono/stereo 32-bit int format support. If we add support for the AL_EXT_MCFORMATS extension later, we'll expand this out. Reference Issue #36.
1 parent 08353b9 commit 500c3a9

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

mojoal.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@
7979
#define AL_FORMAT_STEREO_FLOAT32 0x10011
8080
#endif
8181

82+
// AL_EXT_32bit_formats support...
83+
// (this doesn't cover the AL_EXT_MCFORMATS items at the moment, per spec).
84+
#ifndef AL_FORMAT_MONO_I32
85+
#define AL_FORMAT_MONO_I32 0x19DB
86+
#endif
87+
88+
#ifndef AL_FORMAT_STEREO_I32
89+
#define AL_FORMAT_STEREO_I32 0x19DC
90+
#endif
91+
8292
// ALC_EXT_DISCONNECTED support...
8393
#ifndef ALC_CONNECTED
8494
#define ALC_CONNECTED 0x313
@@ -1883,7 +1893,8 @@ static ALCenum null_device_error = ALC_NO_ERROR;
18831893
ALC_EXTENSION_ITEM(ALC_EXT_DISCONNECT)
18841894

18851895
#define AL_EXTENSION_ITEMS \
1886-
AL_EXTENSION_ITEM(AL_EXT_FLOAT32)
1896+
AL_EXTENSION_ITEM(AL_EXT_FLOAT32) \
1897+
AL_EXTENSION_ITEM(AL_EXT_32bit_formats)
18871898

18881899

18891900
static void set_alc_error(ALCdevice *device, const ALCenum error)
@@ -2090,6 +2101,16 @@ static ALCboolean alcfmt_to_sdlfmt(const ALCenum alfmt, SDL_AudioFormat *sdlfmt,
20902101
*channels = 2;
20912102
*framesize = 8;
20922103
break;
2104+
case AL_FORMAT_MONO_I32:
2105+
*sdlfmt = SDL_AUDIO_S32;
2106+
*channels = 1;
2107+
*framesize = 4;
2108+
break;
2109+
case AL_FORMAT_STEREO_I32:
2110+
*sdlfmt = SDL_AUDIO_S32;
2111+
*channels = 2;
2112+
*framesize = 8;
2113+
break;
20932114
default:
20942115
return ALC_FALSE;
20952116
}
@@ -3256,6 +3277,8 @@ static ALenum _alGetEnumValue(const ALchar *enumname)
32563277
ENUM_TEST(AL_EXPONENT_DISTANCE_CLAMPED);
32573278
ENUM_TEST(AL_FORMAT_MONO_FLOAT32);
32583279
ENUM_TEST(AL_FORMAT_STEREO_FLOAT32);
3280+
ENUM_TEST(AL_FORMAT_MONO_I32);
3281+
ENUM_TEST(AL_FORMAT_STEREO_I32);
32593282
#undef ENUM_TEST
32603283

32613284
set_al_error(ctx, AL_INVALID_VALUE);

tests/testposition.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ static ALenum get_openal_format(const SDL_AudioSpec *spec)
5252
return alIsExtensionPresent("AL_EXT_FLOAT32") ? alGetEnumValue("AL_FORMAT_MONO_FLOAT32") : AL_NONE;
5353
} else if ((spec->channels == 2) && (spec->format == SDL_AUDIO_F32)) {
5454
return alIsExtensionPresent("AL_EXT_FLOAT32") ? alGetEnumValue("AL_FORMAT_STEREO_FLOAT32") : AL_NONE;
55+
} else if ((spec->channels == 1) && (spec->format == SDL_AUDIO_S32)) {
56+
return alIsExtensionPresent("AL_EXT_32bit_formats") ? alGetEnumValue("AL_FORMAT_MONO_I32") : AL_NONE;
57+
} else if ((spec->channels == 2) && (spec->format == SDL_AUDIO_F32)) {
58+
return alIsExtensionPresent("AL_EXT_32bit_formats") ? alGetEnumValue("AL_FORMAT_STEREO_I32") : AL_NONE;
5559
}
5660
return AL_NONE;
5761
}

tests/testqueueing.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ static ALenum get_openal_format(const SDL_AudioSpec *spec)
3939
return alIsExtensionPresent("AL_EXT_FLOAT32") ? alGetEnumValue("AL_FORMAT_MONO_FLOAT32") : AL_NONE;
4040
} else if ((spec->channels == 2) && (spec->format == SDL_AUDIO_F32)) {
4141
return alIsExtensionPresent("AL_EXT_FLOAT32") ? alGetEnumValue("AL_FORMAT_STEREO_FLOAT32") : AL_NONE;
42+
} else if ((spec->channels == 1) && (spec->format == SDL_AUDIO_S32)) {
43+
return alIsExtensionPresent("AL_EXT_32bit_formats") ? alGetEnumValue("AL_FORMAT_MONO_I32") : AL_NONE;
44+
} else if ((spec->channels == 2) && (spec->format == SDL_AUDIO_F32)) {
45+
return alIsExtensionPresent("AL_EXT_32bit_formats") ? alGetEnumValue("AL_FORMAT_STEREO_I32") : AL_NONE;
4246
}
4347
return AL_NONE;
4448
}

0 commit comments

Comments
 (0)