Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS …
…solution: copy missing dependency
  • Loading branch information
ferzkopp committed Aug 15, 2013
1 parent 67367be commit 6572847
Show file tree
Hide file tree
Showing 47 changed files with 616 additions and 505 deletions.
14 changes: 9 additions & 5 deletions VisualC/tests/loopwave/loopwave_VS2010.vcxproj
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
Expand Down Expand Up @@ -105,7 +105,8 @@
<SubSystem>Windows</SubSystem>
</Link>
<PostBuildEvent>
<Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
<Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copy SDL</Message>
Expand Down Expand Up @@ -139,7 +140,8 @@
<SubSystem>Windows</SubSystem>
</Link>
<PostBuildEvent>
<Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
<Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copy SDL</Message>
Expand Down Expand Up @@ -174,7 +176,8 @@
<SubSystem>Windows</SubSystem>
</Link>
<PostBuildEvent>
<Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
<Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copy SDL</Message>
Expand Down Expand Up @@ -208,7 +211,8 @@
<SubSystem>Windows</SubSystem>
</Link>
<PostBuildEvent>
<Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
<Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copy SDL</Message>
Expand Down
12 changes: 8 additions & 4 deletions VisualC/tests/loopwave/loopwave_VS2012.vcxproj
Expand Up @@ -109,7 +109,8 @@
<SubSystem>Windows</SubSystem>
</Link>
<PostBuildEvent>
<Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
<Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copy SDL</Message>
Expand Down Expand Up @@ -143,7 +144,8 @@
<SubSystem>Windows</SubSystem>
</Link>
<PostBuildEvent>
<Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
<Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copy SDL</Message>
Expand Down Expand Up @@ -178,7 +180,8 @@
<SubSystem>Windows</SubSystem>
</Link>
<PostBuildEvent>
<Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
<Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copy SDL</Message>
Expand Down Expand Up @@ -212,7 +215,8 @@
<SubSystem>Windows</SubSystem>
</Link>
<PostBuildEvent>
<Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
<Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copy SDL</Message>
Expand Down
13 changes: 8 additions & 5 deletions test/checkkeys.c
Expand Up @@ -117,13 +117,13 @@ PrintKey(SDL_Keysym * sym, SDL_bool pressed, SDL_bool repeat)
static void
PrintText(char *text)
{
unsigned char *spot, expanded[1024];
char *spot, expanded[1024];

expanded[0] = '\0';
for ( spot = text; *spot; ++spot )
{
size_t length = SDL_strlen(expanded);
SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", *spot);
SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", (unsigned char)*spot);
}
SDL_Log("Text (%s): \"%s%s\"\n", expanded, *text == '"' ? "\\" : "", text);
}
Expand All @@ -134,10 +134,13 @@ main(int argc, char *argv[])
SDL_Window *window;
SDL_Event event;
int done;

/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);

/* Initialize SDL */
if (SDL_Init(SDL_INIT_VIDEO) < 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);
}

Expand All @@ -146,7 +149,7 @@ main(int argc, char *argv[])
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
640, 480, 0);
if (!window) {
fprintf(stderr, "Couldn't create 640x480 window: %s\n",
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create 640x480 window: %s\n",
SDL_GetError());
quit(2);
}
Expand All @@ -166,7 +169,7 @@ main(int argc, char *argv[])
switch (event.type) {
case SDL_KEYDOWN:
case SDL_KEYUP:
PrintKey(&event.key.keysym, event.key.state, event.key.repeat);
PrintKey(&event.key.keysym, (event.key.state == SDL_PRESSED) ? SDL_TRUE : SDL_FALSE, (event.key.repeat) ? SDL_TRUE : SDL_FALSE);
break;
case SDL_TEXTINPUT:
PrintText(event.text.text);
Expand Down
20 changes: 9 additions & 11 deletions test/loopwave.c
Expand Up @@ -80,9 +80,12 @@ main(int argc, char *argv[])
{
int i;

/* 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);
}

Expand All @@ -91,7 +94,7 @@ main(int argc, char *argv[])
}
/* Load the wave file into memory */
if (SDL_LoadWAV(argv[1], &wave.spec, &wave.sound, &wave.soundlen) == NULL) {
fprintf(stderr, "Couldn't load %s: %s\n", argv[1], SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", argv[1], SDL_GetError());
quit(1);
}

Expand All @@ -109,24 +112,19 @@ main(int argc, char *argv[])
#endif /* HAVE_SIGNAL_H */

/* Show the list of available drivers */
printf("Available audio drivers: ");
SDL_Log("Available audio drivers:");
for (i = 0; i < SDL_GetNumAudioDrivers(); ++i) {
if (i == 0) {
printf("%s", SDL_GetAudioDriver(i));
} else {
printf(", %s", SDL_GetAudioDriver(i));
}
SDL_Log("%i: %s", i, SDL_GetAudioDriver(i));
}
printf("\n");

/* Initialize fillerup() variables */
if (SDL_OpenAudio(&wave.spec, NULL) < 0) {
fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError());
SDL_FreeWAV(wave.sound);
quit(2);
}

printf("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());

/* Let the audio run */
SDL_PauseAudio(0);
Expand Down

0 comments on commit 6572847

Please sign in to comment.