Rev 1 | Rev 5 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1 | Rev 2 | ||
---|---|---|---|
Line 344... | Line 344... | ||
344 | /* |
344 | /* |
345 | * Load a sound. |
345 | * Load a sound. |
346 | */ |
346 | */ |
347 | sound_t *syssnd_load (char *name) |
347 | sound_t *syssnd_load (char *name) |
348 | { |
348 | { |
- | 349 | char *soundfile_fullpathname; |
|
349 | sound_t *s; |
350 | sound_t *s; |
350 | SDL_RWops *context; |
351 | SDL_RWops *context; |
351 | SDL_AudioSpec audiospec; |
352 | SDL_AudioSpec audiospec; |
- | 353 | ||
- | 354 | /* alloc space for sound file's full pathname and build it */ |
|
- | 355 | soundfile_fullpathname = (char *) malloc (1024); |
|
- | 356 | sprintf_s (soundfile_fullpathname, 1024, "%s/%s", sys_getbasepath (), name); |
|
352 | 357 | ||
353 | /* alloc context */ |
358 | /* alloc context */ |
354 | context = malloc (sizeof (SDL_RWops)); |
359 | context = malloc (sizeof (SDL_RWops)); |
355 | context->seek = sdlRWops_seek; |
360 | context->seek = sdlRWops_seek; |
356 | context->read = sdlRWops_read; |
361 | context->read = sdlRWops_read; |
357 | context->write = sdlRWops_write; |
362 | context->write = sdlRWops_write; |
358 | context->close = sdlRWops_close; |
363 | context->close = sdlRWops_close; |
359 | 364 | ||
360 | /* open */ |
365 | /* open */ |
361 | if (sdlRWops_open (context, |
366 | if (sdlRWops_open (context, soundfile_fullpathname) == -1) |
- | 367 | { |
|
- | 368 | free (soundfile_fullpathname); |
|
362 | return NULL; |
369 | return NULL; |
- | 370 | } |
|
- | 371 | free (soundfile_fullpathname); |
|
363 | 372 | ||
364 | /* alloc sound */ |
373 | /* alloc sound */ |
365 | s = malloc (sizeof (sound_t)); |
374 | s = malloc (sizeof (sound_t)); |
366 | 375 | ||
367 | /* read */ |
376 | /* read */ |