Skip to content

Commit

Permalink
Updated for SDL3 change to use SDL_bool instead of int return code
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Aug 27, 2024
1 parent e2cdd80 commit 1541acc
Show file tree
Hide file tree
Showing 16 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion examples/playmus.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ int main(int argc, char *argv[])
}

/* Initialize the SDL library */
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
if (!SDL_Init(SDL_INIT_AUDIO)) {
SDL_Log("Couldn't initialize SDL: %s\n",SDL_GetError());
return 255;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/playwave.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ int main(int argc, char *argv[])
}

/* Initialize the SDL library */
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
if (!SDL_Init(SDL_INIT_AUDIO)) {
SDL_Log("Couldn't initialize SDL: %s\n",SDL_GetError());
return 255;
}
Expand Down
2 changes: 1 addition & 1 deletion external/SDL
Submodule SDL updated 1171 files
2 changes: 1 addition & 1 deletion src/codecs/music_drflac.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ static int DRFLAC_GetSome(void *context, void *data, int bytes, SDL_bool *done)
amount -= (music->dec->currentPCMFrame - music->loop_end);
music->loop_flag = SDL_TRUE;
}
if (SDL_PutAudioStreamData(music->stream, music->buffer, (int)amount * sizeof(drflac_int16) * music->channels) < 0) {
if (!SDL_PutAudioStreamData(music->stream, music->buffer, (int)amount * sizeof(drflac_int16) * music->channels)) {
return -1;
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/codecs/music_fluidsynth.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ static int FLUIDSYNTH_GetSome(void *context, void *data, int bytes, SDL_bool *do
if (music->synth_write(music->synth, 4096/*music_spec.samples*/, music->buffer, 0, 2, music->buffer, 1, 2) != FLUID_OK) {
return Mix_SetError("Error generating FluidSynth audio");
}
if (SDL_PutAudioStreamData(music->stream, music->buffer, music->buffer_size) < 0) {
if (!SDL_PutAudioStreamData(music->stream, music->buffer, music->buffer_size)) {
return -1;
}
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/codecs/music_gme.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ static int GME_GetSome(void *context, void *data, int bytes, SDL_bool *done)
return 0;
}

if (SDL_PutAudioStreamData(music->stream, music->buffer, (int)music->buffer_size) < 0) {
if (!SDL_PutAudioStreamData(music->stream, music->buffer, (int)music->buffer_size)) {
return -1;
}
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/codecs/music_minimp3.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ static int MINIMP3_GetSome(void *context, void *data, int bytes, SDL_bool *done)

amount = (int)mp3dec_ex_read(&music->dec, music->buffer, 4096/*music_spec.samples*/ * music->channels);
if (amount > 0) {
if (SDL_PutAudioStreamData(music->stream, music->buffer, (int)amount * sizeof(mp3d_sample_t)) < 0) {
if (!SDL_PutAudioStreamData(music->stream, music->buffer, (int)amount * sizeof(mp3d_sample_t))) {
return -1;
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/codecs/music_modplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ static int MODPLUG_GetSome(void *context, void *data, int bytes, SDL_bool *done)

amount = modplug.ModPlug_Read(music->file, music->buffer, music->buffer_size);
if (amount > 0) {
if (SDL_PutAudioStreamData(music->stream, music->buffer, amount) < 0) {
if (!SDL_PutAudioStreamData(music->stream, music->buffer, amount)) {
return -1;
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/codecs/music_mpg123.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ static int MPG123_GetSome(void *context, void *data, int bytes, SDL_bool *done)
result = mpg123.mpg123_read(music->handle, music->buffer, music->buffer_size, &amount);
switch (result) {
case MPG123_OK:
if (SDL_PutAudioStreamData(music->stream, music->buffer, (int)amount) < 0) {
if (!SDL_PutAudioStreamData(music->stream, music->buffer, (int)amount)) {
return -1;
}
break;
Expand Down Expand Up @@ -424,7 +424,7 @@ static int MPG123_GetSome(void *context, void *data, int bytes, SDL_bool *done)

case MPG123_DONE:
if (amount > 0) {
if (SDL_PutAudioStreamData(music->stream, music->buffer, (int)amount) < 0) {
if (!SDL_PutAudioStreamData(music->stream, music->buffer, (int)amount)) {
return -1;
}
break;
Expand Down
2 changes: 1 addition & 1 deletion src/codecs/music_ogg.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ static int OGG_GetSome(void *context, void *data, int bytes, SDL_bool *done)
}

if (amount > 0) {
if (SDL_PutAudioStreamData(music->stream, music->buffer, amount) < 0) {
if (!SDL_PutAudioStreamData(music->stream, music->buffer, amount)) {
return -1;
}
} else if (!looped) {
Expand Down
2 changes: 1 addition & 1 deletion src/codecs/music_ogg_stb.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ static int OGG_GetSome(void *context, void *data, int bytes, SDL_bool *done)
}

if (amount > 0) {
if (SDL_PutAudioStreamData(music->stream, music->buffer, amount) < 0) {
if (!SDL_PutAudioStreamData(music->stream, music->buffer, amount)) {
return -1;
}
} else if (!looped) {
Expand Down
2 changes: 1 addition & 1 deletion src/codecs/music_opus.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ static int OPUS_GetSome(void *context, void *data, int bytes, SDL_bool *done)

if (samples > 0) {
filled = samples * music->op_info->channel_count * 2;
if (SDL_PutAudioStreamData(music->stream, music->buffer, filled) < 0) {
if (!SDL_PutAudioStreamData(music->stream, music->buffer, filled)) {
return -1;
}
} else if (!looped) {
Expand Down
2 changes: 1 addition & 1 deletion src/codecs/music_timidity.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ static int TIMIDITY_GetSome(void *context, void *data, int bytes, SDL_bool *done
if (music->stream) {
expected = music->buffer_size;
amount = Timidity_PlaySome(music->song, music->buffer, music->buffer_size);
if (SDL_PutAudioStreamData(music->stream, music->buffer, amount) < 0) {
if (!SDL_PutAudioStreamData(music->stream, music->buffer, amount)) {
return -1;
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/codecs/music_wavpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ static int WAVPACK_GetSome(void *context, void *data, int bytes, SDL_bool *done)
amount *= sizeof(Sint32);
break;
}
if (SDL_PutAudioStreamData(music->stream, music->buffer, amount) < 0) {
if (!SDL_PutAudioStreamData(music->stream, music->buffer, amount)) {
return -1;
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/codecs/music_xmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ static int XMP_GetSome(void *context, void *data, int bytes, SDL_bool *done)
amount = music->buffer_size;

if (ret == 0) {
if (SDL_PutAudioStreamData(music->stream, music->buffer, amount) < 0) {
if (!SDL_PutAudioStreamData(music->stream, music->buffer, amount)) {
return -1;
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ int Mix_OpenAudio(SDL_AudioDeviceID devid, const SDL_AudioSpec *spec)
int i;

if (!SDL_WasInit(SDL_INIT_AUDIO)) {
if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
if (!SDL_InitSubSystem(SDL_INIT_AUDIO)) {
return -1;
}
}
Expand Down Expand Up @@ -841,7 +841,7 @@ Mix_Chunk *Mix_LoadWAV_IO(SDL_IOStream *src, SDL_bool closeio)

if (!loaded) {
if (SDL_memcmp(magic, "WAVE", 4) == 0 || SDL_memcmp(magic, "RIFF", 4) == 0) {
loaded = (SDL_LoadWAV_IO(src, closeio, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen) == 0) ? &wavespec : NULL;
loaded = SDL_LoadWAV_IO(src, closeio, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen) ? &wavespec : NULL;
} else if (SDL_memcmp(magic, "FORM", 4) == 0) {
loaded = Mix_LoadAIFF_IO(src, closeio, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen);
} else if (SDL_memcmp(magic, "Crea", 4) == 0) {
Expand Down Expand Up @@ -872,7 +872,7 @@ Mix_Chunk *Mix_LoadWAV_IO(SDL_IOStream *src, SDL_bool closeio)
Uint8 *dst_data = NULL;
int dst_len = 0;

if (SDL_ConvertAudioSamples(&wavespec, chunk->abuf, chunk->alen, &mixer, &dst_data, &dst_len) < 0) {
if (!SDL_ConvertAudioSamples(&wavespec, chunk->abuf, chunk->alen, &mixer, &dst_data, &dst_len)) {
SDL_free(chunk->abuf);
SDL_free(chunk);
return NULL;
Expand Down

0 comments on commit 1541acc

Please sign in to comment.