test/testresample.c
changeset 7639 9406b7dd2f2d
parent 7517 965d57022c01
child 7663 53fe1b64eb2d
     1.1 --- a/test/testresample.c	Mon Aug 12 22:00:21 2013 -0700
     1.2 +++ b/test/testresample.c	Wed Aug 14 23:30:10 2013 -0700
     1.3 @@ -9,7 +9,7 @@
     1.4    including commercial applications, and to alter it and redistribute it
     1.5    freely.
     1.6  */
     1.7 -#include <stdio.h>
     1.8 +
     1.9  #include "SDL.h"
    1.10  
    1.11  int
    1.12 @@ -25,27 +25,30 @@
    1.13      int avgbytes = 0;
    1.14      SDL_RWops *io = NULL;
    1.15  
    1.16 +	/* Enable standard application logging */
    1.17 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
    1.18 +
    1.19      if (argc != 4) {
    1.20 -        fprintf(stderr, "USAGE: %s in.wav out.wav newfreq\n", argv[0]);
    1.21 +        SDL_Log("USAGE: %s in.wav out.wav newfreq\n", argv[0]);
    1.22          return 1;
    1.23      }
    1.24  
    1.25      cvtfreq = SDL_atoi(argv[3]);
    1.26  
    1.27      if (SDL_Init(SDL_INIT_AUDIO) == -1) {
    1.28 -        fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError());
    1.29 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
    1.30          return 2;
    1.31      }
    1.32  
    1.33      if (SDL_LoadWAV(argv[1], &spec, &data, &len) == NULL) {
    1.34 -        fprintf(stderr, "failed to load %s: %s\n", argv[1], SDL_GetError());
    1.35 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to load %s: %s\n", argv[1], SDL_GetError());
    1.36          SDL_Quit();
    1.37          return 3;
    1.38      }
    1.39  
    1.40      if (SDL_BuildAudioCVT(&cvt, spec.format, spec.channels, spec.freq,
    1.41                            spec.format, spec.channels, cvtfreq) == -1) {
    1.42 -        fprintf(stderr, "failed to build CVT: %s\n", SDL_GetError());
    1.43 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to build CVT: %s\n", SDL_GetError());
    1.44          SDL_FreeWAV(data);
    1.45          SDL_Quit();
    1.46          return 4;
    1.47 @@ -54,7 +57,7 @@
    1.48      cvt.len = len;
    1.49      cvt.buf = (Uint8 *) SDL_malloc(len * cvt.len_mult);
    1.50      if (cvt.buf == NULL) {
    1.51 -        fprintf(stderr, "Out of memory.\n");
    1.52 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory.\n");
    1.53          SDL_FreeWAV(data);
    1.54          SDL_Quit();
    1.55          return 5;
    1.56 @@ -62,7 +65,7 @@
    1.57      SDL_memcpy(cvt.buf, data, len);
    1.58  
    1.59      if (SDL_ConvertAudio(&cvt) == -1) {
    1.60 -        fprintf(stderr, "Conversion failed: %s\n", SDL_GetError());
    1.61 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Conversion failed: %s\n", SDL_GetError());
    1.62          SDL_free(cvt.buf);
    1.63          SDL_FreeWAV(data);
    1.64          SDL_Quit();
    1.65 @@ -72,7 +75,7 @@
    1.66      /* write out a WAV header... */
    1.67      io = SDL_RWFromFile(argv[2], "wb");
    1.68      if (io == NULL) {
    1.69 -        fprintf(stderr, "fopen('%s') failed: %s\n", argv[2], SDL_GetError());
    1.70 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "fopen('%s') failed: %s\n", argv[2], SDL_GetError());
    1.71          SDL_free(cvt.buf);
    1.72          SDL_FreeWAV(data);
    1.73          SDL_Quit();
    1.74 @@ -99,7 +102,7 @@
    1.75      SDL_RWwrite(io, cvt.buf, cvt.len_cvt, 1);
    1.76  
    1.77      if (SDL_RWclose(io) == -1) {
    1.78 -        fprintf(stderr, "fclose('%s') failed: %s\n", argv[2], SDL_GetError());
    1.79 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "fclose('%s') failed: %s\n", argv[2], SDL_GetError());
    1.80          SDL_free(cvt.buf);
    1.81          SDL_FreeWAV(data);
    1.82          SDL_Quit();