Skip to content

Commit ec920e4

Browse files
committed
BugFix: MIX_LoadAudioWithProperties() requires MIX_PROP_AUDIO_LOAD_IOSTREAM_POINTER, so we set dummy SDL_IOStream.
1 parent a4b9c63 commit ec920e4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/SDL_mixer.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1262,7 +1262,13 @@ MIX_Audio *MIX_CreateSineWaveAudio(MIX_Mixer *mixer, int hz, float amplitude)
12621262
if (!props) {
12631263
return NULL;
12641264
}
1265-
1265+
// BugFix: MIX_LoadAudioWithProperties() require MIX_PROP_AUDIO_LOAD_IOSTREAM_POINTER, so we set dummy SDL_IOStream.
1266+
static uint8_t dummy[4] = {0, 0, 0, 0};
1267+
SDL_IOStream* io = SDL_IOFromConstMem(dummy, sizeof(dummy));
1268+
if (!io) {
1269+
return NULL;
1270+
}
1271+
SDL_SetPointerProperty(props, MIX_PROP_AUDIO_LOAD_IOSTREAM_POINTER, io); // required!
12661272
SDL_SetPointerProperty(props, MIX_PROP_AUDIO_LOAD_PREFERRED_MIXER_POINTER, mixer);
12671273
SDL_SetStringProperty(props, MIX_PROP_AUDIO_DECODER_STRING, "SINEWAVE");
12681274
SDL_SetNumberProperty(props, MIX_PROP_DECODER_SINEWAVE_HZ_NUMBER, hz);

0 commit comments

Comments
 (0)