Add missing VS2012 test projects; update VS2010 and VS2012 solutions; update keybord suite for VS compiler warnings
2 Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
15 static SDL_AudioSpec spec;
16 static Uint8 *sound = NULL; /* Pointer to wave data */
17 static Uint32 soundlen = 0; /* Length of wave data */
21 SDL_AudioDeviceID dev;
27 play_through_once(void *arg, Uint8 * stream, int len)
29 callback_data *cbd = (callback_data *) arg;
30 Uint8 *waveptr = sound + cbd->soundpos;
31 int waveleft = soundlen - cbd->soundpos;
36 SDL_memcpy(stream, waveptr, cpy);
41 SDL_memset(stream, spec.silence, len);
47 test_multi_audio(int devcount)
49 callback_data cbd[64];
54 fprintf(stderr, "Too many devices (%d), clamping to 64...\n",
59 spec.callback = play_through_once;
61 for (i = 0; i < devcount; i++) {
62 const char *devname = SDL_GetAudioDeviceName(i, 0);
63 printf("playing on device #%d: ('%s')...", i, devname);
66 SDL_memset(&cbd[0], '\0', sizeof(callback_data));
67 spec.userdata = &cbd[0];
68 cbd[0].dev = SDL_OpenAudioDevice(devname, 0, &spec, NULL, 0);
69 if (cbd[0].dev == 0) {
70 printf("\nOpen device failed: %s\n", SDL_GetError());
72 SDL_PauseAudioDevice(cbd[0].dev, 0);
75 SDL_PauseAudioDevice(cbd[0].dev, 1);
77 SDL_CloseAudioDevice(cbd[0].dev);
81 SDL_memset(cbd, '\0', sizeof(cbd));
83 printf("playing on all devices...\n");
84 for (i = 0; i < devcount; i++) {
85 const char *devname = SDL_GetAudioDeviceName(i, 0);
86 spec.userdata = &cbd[i];
87 cbd[i].dev = SDL_OpenAudioDevice(devname, 0, &spec, NULL, 0);
88 if (cbd[i].dev == 0) {
89 printf("Open device %d failed: %s\n", i, SDL_GetError());
93 for (i = 0; i < devcount; i++) {
95 SDL_PauseAudioDevice(cbd[i].dev, 0);
101 for (i = 0; i < devcount; i++) {
102 if ((cbd[i].dev) && (!cbd[i].done)) {
109 for (i = 0; i < devcount; i++) {
111 SDL_PauseAudioDevice(cbd[i].dev, 1);
112 SDL_CloseAudioDevice(cbd[i].dev);
116 printf("All done!\n");
121 main(int argc, char **argv)
125 /* Load the SDL library */
126 if (SDL_Init(SDL_INIT_AUDIO) < 0) {
127 fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
131 printf("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
133 devcount = SDL_GetNumAudioDevices(0);
135 fprintf(stderr, "Don't see any specific audio devices!\n");
137 if (argv[1] == NULL) {
138 argv[1] = "sample.wav";
141 /* Load the wave file into memory */
142 if (SDL_LoadWAV(argv[1], &spec, &sound, &soundlen) == NULL) {
143 fprintf(stderr, "Couldn't load %s: %s\n", argv[1],
146 test_multi_audio(devcount);