Mercurial > sdl-ios-xcode
comparison src/audio/SDL_audio.c @ 2728:2768bd7281e0
Fixed Visual Studio compilation problems
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 26 Aug 2008 07:34:49 +0000 |
parents | f8f68f47285a |
children | 204be4fc2726 |
comparison
equal
deleted
inserted
replaced
2727:76c2fc9696ea | 2728:2768bd7281e0 |
---|---|
289 | 289 |
290 /* Initialize the stream by allocating the buffer and setting the read/write heads to the beginning */ | 290 /* Initialize the stream by allocating the buffer and setting the read/write heads to the beginning */ |
291 int | 291 int |
292 SDL_StreamInit(SDL_AudioStreamer * stream, int max_len, Uint8 silence) | 292 SDL_StreamInit(SDL_AudioStreamer * stream, int max_len, Uint8 silence) |
293 { | 293 { |
294 int i; | |
295 | |
296 /* First try to allocate the buffer */ | 294 /* First try to allocate the buffer */ |
297 stream->buffer = (Uint8 *) malloc(max_len); | 295 stream->buffer = (Uint8 *) SDL_malloc(max_len); |
298 if (stream->buffer == NULL) { | 296 if (stream->buffer == NULL) { |
299 return -1; | 297 return -1; |
300 } | 298 } |
301 | 299 |
302 stream->max_len = max_len; | 300 stream->max_len = max_len; |
303 stream->read_pos = 0; | 301 stream->read_pos = 0; |
304 stream->write_pos = 0; | 302 stream->write_pos = 0; |
305 | 303 |
306 /* Zero out the buffer */ | 304 /* Zero out the buffer */ |
307 for (i = 0; i < max_len; ++i) { | 305 SDL_memset(stream->buffer, silence, max_len); |
308 stream->buffer[i] = silence; | 306 |
309 } | 307 return 0; |
310 } | 308 } |
311 | 309 |
312 /* Deinitialize the stream simply by freeing the buffer */ | 310 /* Deinitialize the stream simply by freeing the buffer */ |
313 void | 311 void |
314 SDL_StreamDeinit(SDL_AudioStreamer * stream) | 312 SDL_StreamDeinit(SDL_AudioStreamer * stream) |
315 { | 313 { |
316 if (stream->buffer != NULL) { | 314 if (stream->buffer != NULL) { |
317 free(stream->buffer); | 315 SDL_free(stream->buffer); |
318 } | 316 } |
319 } | 317 } |
320 | 318 |
321 | 319 |
322 /* The general mixing thread function */ | 320 /* The general mixing thread function */ |