Skip to content

Commit b18d7b3

Browse files
committed
Initialize SDL_AudioSpec before using it to create an audio stream
1 parent 2c28b9d commit b18d7b3

13 files changed

+14
-0
lines changed

src/codecs/music_drflac.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ static void *DRFLAC_CreateFromIO(SDL_IOStream *src, SDL_bool closeio)
184184
}
185185

186186
/* We should have channels and sample rate set up here */
187+
SDL_zero(srcspec);
187188
srcspec.format = SDL_AUDIO_S16;
188189
srcspec.channels = music->channels;
189190
srcspec.freq = music->sample_rate;

src/codecs/music_flac.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ static void flac_metadata_music_cb(
421421

422422
/* We check for NULL stream later when we get data */
423423
SDL_assert(!music->stream);
424+
SDL_zero(srcspec);
424425
srcspec.format = SDL_AUDIO_S16;
425426
srcspec.channels = channels;
426427
srcspec.freq = (int)music->sample_rate;

src/codecs/music_fluidsynth.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ static FLUIDSYNTH_Music *FLUIDSYNTH_LoadMusic(void *data)
234234
goto fail;
235235
}
236236

237+
SDL_zero(srcspec);
237238
srcspec.format = src_format;
238239
srcspec.channels = channels;
239240
srcspec.freq = (int) samplerate;

src/codecs/music_gme.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ static void *GME_CreateFromIO(struct SDL_IOStream *src, SDL_bool closeio)
218218
music->tempo = 1.0;
219219
music->gain = 1.0;
220220

221+
SDL_zero(srcspec);
221222
srcspec.format = SDL_AUDIO_S16;
222223
srcspec.channels = 2;
223224
srcspec.freq = music_spec.freq;

src/codecs/music_minimp3.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ static void *MINIMP3_CreateFromIO(SDL_IOStream *src, SDL_bool closeio)
100100
return NULL;
101101
}
102102

103+
SDL_zero(file_spec);
103104
file_spec.format = SDL_AUDIO_S16;
104105
file_spec.channels = (Uint8)music->dec.info.channels;
105106
file_spec.freq = (int)music->dec.info.hz;

src/codecs/music_modplug.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ void *MODPLUG_CreateFromIO(SDL_IOStream *src, SDL_bool closeio)
179179

180180
music->volume = MIX_MAX_VOLUME;
181181

182+
SDL_zero(srcspec);
182183
srcspec.format = (settings.mBits == 8) ? SDL_AUDIO_U8 : SDL_AUDIO_S16;
183184
srcspec.channels = settings.mChannels;
184185
srcspec.freq = settings.mFrequency;

src/codecs/music_mpg123.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ static void *MPG123_CreateFromIO(SDL_IOStream *src, SDL_bool closeio)
322322
SDL_assert(format != -1);
323323
music->sample_rate = rate;
324324

325+
SDL_zero(srcspec);
325326
srcspec.format = (SDL_AudioFormat)format;
326327
srcspec.channels = channels;
327328
srcspec.freq = (int)rate;
@@ -410,6 +411,7 @@ static int MPG123_GetSome(void *context, void *data, int bytes, SDL_bool *done)
410411
SDL_DestroyAudioStream(music->stream);
411412
}
412413

414+
SDL_zero(srcspec);
413415
srcspec.format = (SDL_AudioFormat)format;
414416
srcspec.channels = channels;
415417
srcspec.freq = (int)rate;

src/codecs/music_ogg.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ static int OGG_UpdateSection(OGG_music *music)
220220
music->stream = NULL;
221221
}
222222

223+
SDL_zero(srcspec);
223224
srcspec.format = SDL_AUDIO_S16;
224225
srcspec.channels = vi->channels;
225226
srcspec.freq = (int)vi->rate;

src/codecs/music_ogg_stb.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ static int OGG_UpdateSection(OGG_music *music)
142142
music->stream = NULL;
143143
}
144144

145+
SDL_zero(srcspec);
145146
srcspec.format = SDL_AUDIO_F32;
146147
srcspec.channels = vi.channels;
147148
srcspec.freq = (int)vi.sample_rate;

src/codecs/music_opus.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ static int OPUS_UpdateSection(OPUS_music *music)
191191
music->stream = NULL;
192192
}
193193

194+
SDL_zero(srcspec);
194195
srcspec.format = SDL_AUDIO_S16;
195196
srcspec.channels = op_info->channel_count;
196197
srcspec.freq = 48000;

0 commit comments

Comments
 (0)