Skip to content

Commit 46ad68a

Browse files
committed
Updated for SDL3 change of SDL_SetError returning SDL_FALSE, not -1
1 parent bcd5770 commit 46ad68a

13 files changed

+80
-40
lines changed

src/codecs/mp3utils.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ int MP3_IOinit(struct mp3file_t *fil, SDL_IOStream *src) {
4141
fil->length = SDL_SeekIO(src, 0, SDL_IO_SEEK_END) - fil->start;
4242
fil->pos = 0;
4343
if (fil->start < 0 || fil->length < 0) {
44-
return Mix_SetError("Error seeking in datastream");
44+
Mix_SetError("Error seeking in datastream");
45+
return -1;
4546
}
4647
SDL_SeekIO(src, fil->start, SDL_IO_SEEK_SET);
4748
return 0;

src/codecs/music_cmd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ static int MusicCMD_Play(void *context, int play_count)
167167
switch(music->pid) {
168168
/* Failed fork() system call */
169169
case -1:
170-
return Mix_SetError("fork() failed");
170+
Mix_SetError("fork() failed");
171+
return -1;
171172

172173
/* Child process - executes here */
173174
case 0: {

src/codecs/music_drflac.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ static int DRFLAC_GetSome(void *context, void *data, int bytes, SDL_bool *done)
262262

263263
if (music->loop_flag) {
264264
if (!drflac_seek_to_pcm_frame(music->dec, music->loop_start)) {
265-
return Mix_SetError("drflac_seek_to_pcm_frame() failed");
265+
Mix_SetError("drflac_seek_to_pcm_frame() failed");
266+
return -1;
266267
} else {
267268
int play_count = -1;
268269
if (music->play_count > 0) {

src/codecs/music_flac.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,15 +654,17 @@ static int FLAC_GetSome(void *context, void *data, int bytes, SDL_bool *done)
654654
}
655655

656656
if (!flac.FLAC__stream_decoder_process_single(music->flac_decoder)) {
657-
return Mix_SetError("FLAC__stream_decoder_process_single() failed");
657+
Mix_SetError("FLAC__stream_decoder_process_single() failed");
658+
return -1;
658659
}
659660

660661
if (music->loop_flag) {
661662
music->pcm_pos = music->loop_start;
662663
if (flac.FLAC__stream_decoder_seek_absolute(music->flac_decoder, (FLAC__uint64)music->loop_start) ==
663664
FLAC__STREAM_DECODER_SEEK_ERROR) {
664665
flac.FLAC__stream_decoder_flush(music->flac_decoder);
665-
return Mix_SetError("FLAC__stream_decoder_seek_absolute() failed");
666+
Mix_SetError("FLAC__stream_decoder_seek_absolute() failed");
667+
return -1;
666668
} else {
667669
int play_count = -1;
668670
if (music->play_count > 0) {
@@ -711,7 +713,8 @@ static int FLAC_Seek(void *context, double position)
711713
flac.FLAC__stream_decoder_flush(music->flac_decoder);
712714
}
713715

714-
return Mix_SetError("Seeking of FLAC stream failed: libFLAC seek failed.");
716+
Mix_SetError("Seeking of FLAC stream failed: libFLAC seek failed.");
717+
return -1;
715718
}
716719
return 0;
717720
}

src/codecs/music_fluidsynth.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,8 @@ static int FLUIDSYNTH_GetSome(void *context, void *data, int bytes, SDL_bool *do
311311
}
312312

313313
if (music->synth_write(music->synth, 4096/*music_spec.samples*/, music->buffer, 0, 2, music->buffer, 1, 2) != FLUID_OK) {
314-
return Mix_SetError("Error generating FluidSynth audio");
314+
Mix_SetError("Error generating FluidSynth audio");
315+
return -1;
315316
}
316317
if (!SDL_PutAudioStreamData(music->stream, music->buffer, music->buffer_size)) {
317318
return -1;

src/codecs/music_gme.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ static int initialize_from_track_info(GME_Music *music, int track)
161161

162162
err = gme.gme_track_info(music->game_emu, &musInfo, track);
163163
if (err != 0) {
164-
return Mix_SetError("GME: %s", err);
164+
Mix_SetError("GME: %s", err);
165+
return -1;
165166
}
166167

167168
music->track_length = musInfo->length;
@@ -397,7 +398,8 @@ static int GME_StartTrack(void *music_p, int track)
397398

398399
err = gme.gme_start_track(music->game_emu, track);
399400
if (err != 0) {
400-
return Mix_SetError("GME: %s", err);
401+
Mix_SetError("GME: %s", err);
402+
return -1;
401403
}
402404

403405
GME_Play(music, music->play_count);

src/codecs/music_mpg123.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ static int MPG123_Open(const SDL_AudioSpec *spec)
225225
{
226226
(void)spec;
227227
if (mpg123.mpg123_init() != MPG123_OK) {
228-
return Mix_SetError("mpg123_init() failed");
228+
Mix_SetError("mpg123_init() failed");
229+
return -1;
229230
}
230231
return 0;
231232
}
@@ -397,7 +398,8 @@ static int MPG123_GetSome(void *context, void *data, int bytes, SDL_bool *done)
397398
case MPG123_NEW_FORMAT:
398399
result = mpg123.mpg123_getformat(music->handle, &rate, &channels, &encoding);
399400
if (result != MPG123_OK) {
400-
return Mix_SetError("mpg123_getformat: %s", mpg_err(music->handle, result));
401+
Mix_SetError("mpg123_getformat: %s", mpg_err(music->handle, result));
402+
return -1;
401403
}
402404
#ifdef DEBUG_MPG123
403405
printf("MPG123 format: %s, channels: %d, rate: %ld\n",
@@ -443,7 +445,8 @@ static int MPG123_GetSome(void *context, void *data, int bytes, SDL_bool *done)
443445
}
444446
break;
445447
default:
446-
return Mix_SetError("mpg123_read: %s", mpg_err(music->handle, result));
448+
Mix_SetError("mpg123_read: %s", mpg_err(music->handle, result));
449+
return -1;
447450
}
448451
return 0;
449452
}
@@ -459,7 +462,8 @@ static int MPG123_Seek(void *context, double secs)
459462
off_t offset = (off_t)(music->sample_rate * secs);
460463

461464
if ((offset = mpg123.mpg123_seek(music->handle, offset, SEEK_SET)) < 0) {
462-
return Mix_SetError("mpg123_seek: %s", mpg_err(music->handle, (int)-offset));
465+
Mix_SetError("mpg123_seek: %s", mpg_err(music->handle, (int)-offset));
466+
return -1;
463467
}
464468
return 0;
465469
}
@@ -472,7 +476,8 @@ static double MPG123_Tell(void *context)
472476
return 0.0;
473477
}
474478
if ((offset = mpg123.mpg123_tell(music->handle)) < 0) {
475-
return Mix_SetError("mpg123_tell: %s", mpg_err(music->handle, (int)-offset));
479+
Mix_SetError("mpg123_tell: %s", mpg_err(music->handle, (int)-offset));
480+
return -1.0;
476481
}
477482
return (double)offset / music->sample_rate;
478483
}

src/codecs/music_ogg.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ static int OGG_UpdateSection(OGG_music *music)
202202

203203
vi = vorbis.ov_info(&music->vf, -1);
204204
if (!vi) {
205-
return Mix_SetError("ov_info returned NULL");
205+
Mix_SetError("ov_info returned NULL");
206+
return -1;
206207
}
207208

208209
if (vi->channels == music->vi.channels && vi->rate == music->vi.rate) {

src/codecs/music_opus.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ static int OPUS_UpdateSection(OPUS_music *music)
173173

174174
op_info = opus.op_head(music->of, -1);
175175
if (!op_info) {
176-
return Mix_SetError("op_head returned NULL");
176+
Mix_SetError("op_head returned NULL");
177+
return -1;
177178
}
178179

179180
if (music->op_info && op_info->channel_count == music->op_info->channel_count) {

src/codecs/music_wav.c

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -455,23 +455,27 @@ static int MS_ADPCM_Init(ADPCM_DecoderState *state, const Uint8 *chunk_data, Uin
455455
* about supporting more than stereo anyway.
456456
*/
457457
if (channels > 2) {
458-
return Mix_SetError("Invalid number of channels");
458+
Mix_SetError("Invalid number of channels");
459+
return -1;
459460
}
460461

461462
if (bitspersample != 4) {
462-
return Mix_SetError("Invalid MS ADPCM bits per sample of %u", (unsigned int)bitspersample);
463+
Mix_SetError("Invalid MS ADPCM bits per sample of %u", (unsigned int)bitspersample);
464+
return -1;
463465
}
464466

465467
/* The block size must be big enough to contain the block header. */
466468
if (blockalign < blockheadersize) {
467-
return Mix_SetError("Invalid MS ADPCM block size (nBlockAlign)");
469+
Mix_SetError("Invalid MS ADPCM block size (nBlockAlign)");
470+
return -1;
468471
}
469472

470473
/* There are wSamplesPerBlock, wNumCoef, and at least 7 coefficient pairs in
471474
* the extended part of the header.
472475
*/
473476
if (chunk_length < 22) {
474-
return Mix_SetError("Could not read MS ADPCM format header");
477+
Mix_SetError("Could not read MS ADPCM format header");
478+
return -1;
475479
}
476480

477481
cbExtSize = SDL_Swap16LE(fmt->cbSize);
@@ -487,11 +491,14 @@ static int MS_ADPCM_Init(ADPCM_DecoderState *state, const Uint8 *chunk_data, Uin
487491
}
488492

489493
if (chunk_length < 22 + coeffcount * 4) {
490-
return Mix_SetError("Could not read custom coefficients in MS ADPCM format header");
494+
Mix_SetError("Could not read custom coefficients in MS ADPCM format header");
495+
return -1;
491496
} else if (cbExtSize < 4 + coeffcount * 4) {
492-
return Mix_SetError("Invalid MS ADPCM format header (too small)");
497+
Mix_SetError("Invalid MS ADPCM format header (too small)");
498+
return -1;
493499
} else if (coeffcount < 7) {
494-
return Mix_SetError("Missing required coefficients in MS ADPCM format header");
500+
Mix_SetError("Missing required coefficients in MS ADPCM format header");
501+
return -1;
495502
}
496503

497504
coeffdata = (MS_ADPCM_CoeffData *)SDL_malloc(sizeof(MS_ADPCM_CoeffData) + coeffcount * 4);
@@ -509,7 +516,8 @@ static int MS_ADPCM_Init(ADPCM_DecoderState *state, const Uint8 *chunk_data, Uin
509516
c -= 0x10000;
510517
}
511518
if (i < 14 && c != presetcoeffs[i]) {
512-
return Mix_SetError("Wrong preset coefficients in MS ADPCM format header");
519+
Mix_SetError("Wrong preset coefficients in MS ADPCM format header");
520+
return -1;
513521
}
514522
coeffdata->coeff[i] = (Sint16)c;
515523
}
@@ -537,7 +545,8 @@ static int MS_ADPCM_Init(ADPCM_DecoderState *state, const Uint8 *chunk_data, Uin
537545
* A truncated block header with just one sample is not supported.
538546
*/
539547
if (samplesperblock == 1 || blockdatasamples < (size_t)(samplesperblock - 2)) {
540-
return Mix_SetError("Invalid number of samples per MS ADPCM block (wSamplesPerBlock)");
548+
Mix_SetError("Invalid number of samples per MS ADPCM block (wSamplesPerBlock)");
549+
return -1;
541550
}
542551

543552
state->blocksize = blockalign;
@@ -614,7 +623,8 @@ static int MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
614623
MS_ADPCM_CoeffData *ddata = (MS_ADPCM_CoeffData *)state->ddata;
615624

616625
if (state->block.size < state->blockheadersize) {
617-
return Mix_SetError("Invalid ADPCM header");
626+
Mix_SetError("Invalid ADPCM header");
627+
return -1;
618628
}
619629

620630
for (c = 0; c < channels; c++) {
@@ -623,7 +633,8 @@ static int MS_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
623633
/* Load the coefficient pair into the channel state. */
624634
coeffindex = state->block.data[o];
625635
if (coeffindex > ddata->coeffcount) {
626-
return Mix_SetError("Invalid MS ADPCM coefficient index in block header");
636+
Mix_SetError("Invalid MS ADPCM coefficient index in block header");
637+
return -1;
627638
}
628639
cstate[c].coeff1 = ddata->coeff[coeffindex * 2];
629640
cstate[c].coeff2 = ddata->coeff[coeffindex * 2 + 1];
@@ -725,16 +736,19 @@ static int IMA_ADPCM_Init(ADPCM_DecoderState *state, const Uint8 *chunk_data, Ui
725736

726737
/* IMA ADPCM can also have 3-bit samples, but it's not supported by SDL at this time. */
727738
if (bitspersample == 3) {
728-
return Mix_SetError("3-bit IMA ADPCM currently not supported");
739+
Mix_SetError("3-bit IMA ADPCM currently not supported");
740+
return -1;
729741
} else if (bitspersample != 4) {
730-
return Mix_SetError("Invalid IMA ADPCM bits per sample of %u", (unsigned int)bitspersample);
742+
Mix_SetError("Invalid IMA ADPCM bits per sample of %u", (unsigned int)bitspersample);
743+
return -1;
731744
}
732745

733746
/* The block size is required to be a multiple of 4 and it must be able to
734747
* hold a block header.
735748
*/
736749
if (blockalign < blockheadersize || blockalign % 4) {
737-
return Mix_SetError("Invalid IMA ADPCM block size (nBlockAlign)");
750+
Mix_SetError("Invalid IMA ADPCM block size (nBlockAlign)");
751+
return -1;
738752
}
739753

740754
if (formattag == EXTENSIBLE_CODE) {
@@ -767,7 +781,8 @@ static int IMA_ADPCM_Init(ADPCM_DecoderState *state, const Uint8 *chunk_data, Ui
767781
* not enforced here as there are no compatibility issues.
768782
*/
769783
if (blockdatasamples < (size_t)(samplesperblock - 1)) {
770-
return Mix_SetError("Invalid number of samples per IMA ADPCM block (wSamplesPerBlock)");
784+
Mix_SetError("Invalid number of samples per IMA ADPCM block (wSamplesPerBlock)");
785+
return -1;
771786
}
772787

773788
state->blocksize = blockalign;
@@ -874,7 +889,8 @@ static int IMA_ADPCM_DecodeBlockHeader(ADPCM_DecoderState *state)
874889
Uint8 *cstate = (Uint8 *)state->cstate;
875890

876891
if (state->block.size < state->blockheadersize) {
877-
return Mix_SetError("Invalid ADPCM header");
892+
Mix_SetError("Invalid ADPCM header");
893+
return -1;
878894
}
879895

880896
for (c = 0; c < state->channels; c++) {

0 commit comments

Comments
 (0)