comparison decoders/mp3.c @ 54:6df2f69e037e

Fixes by Torbj�rn...now the thing actually works! :) See the CHANGELOG entry for 09242001 for an explanation of what the problem was.
author Ryan C. Gordon <icculus@icculus.org>
date Mon, 24 Sep 2001 07:55:22 +0000
parents 6e13fcc178da
children b13fafb976be
comparison
equal deleted inserted replaced
53:f3f8e2a0fe76 54:6df2f69e037e
171 SMPEG_enablevideo(smpeg, 0); 171 SMPEG_enablevideo(smpeg, 0);
172 SMPEG_enableaudio(smpeg, 1); 172 SMPEG_enableaudio(smpeg, 1);
173 SMPEG_loop(smpeg, 0); 173 SMPEG_loop(smpeg, 0);
174 174
175 SMPEG_wantedSpec(smpeg, &spec); 175 SMPEG_wantedSpec(smpeg, &spec);
176 /*
177 * One of the MP3:s I tried wouldn't work unless I added this line
178 * to tell SMPEG that yes, it may have the spec it wants.
179 */
180 SMPEG_actualSpec(smpeg, &spec);
176 sample->actual.format = spec.format; 181 sample->actual.format = spec.format;
177 sample->actual.rate = spec.freq; 182 sample->actual.rate = spec.freq;
178 sample->actual.channels = spec.channels; 183 sample->actual.channels = spec.channels;
179 sample->flags = SOUND_SAMPLEFLAG_NONE; 184 sample->flags = SOUND_SAMPLEFLAG_NONE;
180 internal->decoder_private = smpeg; 185 internal->decoder_private = smpeg;
195 { 200 {
196 Uint32 retval; 201 Uint32 retval;
197 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; 202 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
198 SMPEG *smpeg = (SMPEG *) internal->decoder_private; 203 SMPEG *smpeg = (SMPEG *) internal->decoder_private;
199 204
205 /*
206 * We have to clear the buffer because apparently SMPEG_playAudio()
207 * will mix the decoded audio with whatever's already in it. Nasty.
208 */
209 memset(internal->buffer, 0, internal->buffer_size);
200 retval = SMPEG_playAudio(smpeg, internal->buffer, internal->buffer_size); 210 retval = SMPEG_playAudio(smpeg, internal->buffer, internal->buffer_size);
201 if (retval < internal->buffer_size) 211 if (retval < internal->buffer_size)
202 { 212 {
203 char *errMsg = SMPEG_error(smpeg); 213 char *errMsg = SMPEG_error(smpeg);
204 if (errMsg == NULL) 214 if (errMsg == NULL)