Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency

This commit is contained in:
Andreas Schiffler 2013-08-14 23:30:10 -07:00
parent a0bc602061
commit 16a40598f6
47 changed files with 616 additions and 505 deletions

View file

@ -10,7 +10,6 @@
freely.
*/
#include "SDL.h"
#include <stdio.h>
static SDL_AudioSpec spec;
static Uint8 *sound = NULL; /* Pointer to wave data */
@ -51,7 +50,7 @@ test_multi_audio(int devcount)
int i;
if (devcount > 64) {
fprintf(stderr, "Too many devices (%d), clamping to 64...\n",
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Too many devices (%d), clamping to 64...\n",
devcount);
devcount = 64;
}
@ -60,33 +59,33 @@ test_multi_audio(int devcount)
for (i = 0; i < devcount; i++) {
const char *devname = SDL_GetAudioDeviceName(i, 0);
printf("playing on device #%d: ('%s')...", i, devname);
SDL_Log("playing on device #%d: ('%s')...", i, devname);
fflush(stdout);
SDL_memset(&cbd[0], '\0', sizeof(callback_data));
spec.userdata = &cbd[0];
cbd[0].dev = SDL_OpenAudioDevice(devname, 0, &spec, NULL, 0);
if (cbd[0].dev == 0) {
printf("\nOpen device failed: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Open device failed: %s\n", SDL_GetError());
} else {
SDL_PauseAudioDevice(cbd[0].dev, 0);
while (!cbd[0].done)
SDL_Delay(100);
SDL_PauseAudioDevice(cbd[0].dev, 1);
printf("done.\n");
SDL_Log("done.\n");
SDL_CloseAudioDevice(cbd[0].dev);
}
}
SDL_memset(cbd, '\0', sizeof(cbd));
printf("playing on all devices...\n");
SDL_Log("playing on all devices...\n");
for (i = 0; i < devcount; i++) {
const char *devname = SDL_GetAudioDeviceName(i, 0);
spec.userdata = &cbd[i];
cbd[i].dev = SDL_OpenAudioDevice(devname, 0, &spec, NULL, 0);
if (cbd[i].dev == 0) {
printf("Open device %d failed: %s\n", i, SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Open device %d failed: %s\n", i, SDL_GetError());
}
}
@ -113,7 +112,7 @@ test_multi_audio(int devcount)
}
}
printf("All done!\n");
SDL_Log("All done!\n");
}
@ -122,17 +121,20 @@ main(int argc, char **argv)
{
int devcount = 0;
/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Load the SDL library */
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return (1);
}
printf("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
devcount = SDL_GetNumAudioDevices(0);
if (devcount < 1) {
fprintf(stderr, "Don't see any specific audio devices!\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Don't see any specific audio devices!\n");
} else {
if (argv[1] == NULL) {
argv[1] = "sample.wav";
@ -140,7 +142,7 @@ main(int argc, char **argv)
/* Load the wave file into memory */
if (SDL_LoadWAV(argv[1], &spec, &sound, &soundlen) == NULL) {
fprintf(stderr, "Couldn't load %s: %s\n", argv[1],
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", argv[1],
SDL_GetError());
} else {
test_multi_audio(devcount);