Skip to content

Commit

Permalink
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS …
Browse files Browse the repository at this point in the history
…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
Original file line number Original file line Diff line number Diff line change
@@ -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"> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="Debug|Win32">
Expand Down Expand Up @@ -105,7 +105,8 @@
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
</Link> </Link>
<PostBuildEvent> <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>
<PostBuildEvent> <PostBuildEvent>
<Message>Copy SDL</Message> <Message>Copy SDL</Message>
Expand Down Expand Up @@ -139,7 +140,8 @@
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
</Link> </Link>
<PostBuildEvent> <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>
<PostBuildEvent> <PostBuildEvent>
<Message>Copy SDL</Message> <Message>Copy SDL</Message>
Expand Down Expand Up @@ -174,7 +176,8 @@
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
</Link> </Link>
<PostBuildEvent> <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>
<PostBuildEvent> <PostBuildEvent>
<Message>Copy SDL</Message> <Message>Copy SDL</Message>
Expand Down Expand Up @@ -208,7 +211,8 @@
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
</Link> </Link>
<PostBuildEvent> <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>
<PostBuildEvent> <PostBuildEvent>
<Message>Copy SDL</Message> <Message>Copy SDL</Message>
Expand Down
12 changes: 8 additions & 4 deletions VisualC/tests/loopwave/loopwave_VS2012.vcxproj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
</Link> </Link>
<PostBuildEvent> <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>
<PostBuildEvent> <PostBuildEvent>
<Message>Copy SDL</Message> <Message>Copy SDL</Message>
Expand Down Expand Up @@ -143,7 +144,8 @@
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
</Link> </Link>
<PostBuildEvent> <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>
<PostBuildEvent> <PostBuildEvent>
<Message>Copy SDL</Message> <Message>Copy SDL</Message>
Expand Down Expand Up @@ -178,7 +180,8 @@
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
</Link> </Link>
<PostBuildEvent> <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>
<PostBuildEvent> <PostBuildEvent>
<Message>Copy SDL</Message> <Message>Copy SDL</Message>
Expand Down Expand Up @@ -212,7 +215,8 @@
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
</Link> </Link>
<PostBuildEvent> <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>
<PostBuildEvent> <PostBuildEvent>
<Message>Copy SDL</Message> <Message>Copy SDL</Message>
Expand Down
13 changes: 8 additions & 5 deletions test/checkkeys.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ PrintKey(SDL_Keysym * sym, SDL_bool pressed, SDL_bool repeat)
static void static void
PrintText(char *text) PrintText(char *text)
{ {
unsigned char *spot, expanded[1024]; char *spot, expanded[1024];


expanded[0] = '\0'; expanded[0] = '\0';
for ( spot = text; *spot; ++spot ) for ( spot = text; *spot; ++spot )
{ {
size_t length = SDL_strlen(expanded); 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); 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_Window *window;
SDL_Event event; SDL_Event event;
int done; int done;

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


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


Expand All @@ -146,7 +149,7 @@ main(int argc, char *argv[])
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
640, 480, 0); 640, 480, 0);
if (!window) { 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()); SDL_GetError());
quit(2); quit(2);
} }
Expand All @@ -166,7 +169,7 @@ main(int argc, char *argv[])
switch (event.type) { switch (event.type) {
case SDL_KEYDOWN: case SDL_KEYDOWN:
case SDL_KEYUP: 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; break;
case SDL_TEXTINPUT: case SDL_TEXTINPUT:
PrintText(event.text.text); PrintText(event.text.text);
Expand Down
20 changes: 9 additions & 11 deletions test/loopwave.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -80,9 +80,12 @@ main(int argc, char *argv[])
{ {
int i; int i;


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

/* Load the SDL library */ /* Load the SDL library */
if (SDL_Init(SDL_INIT_AUDIO) < 0) { 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); return (1);
} }


Expand All @@ -91,7 +94,7 @@ main(int argc, char *argv[])
} }
/* Load the wave file into memory */ /* Load the wave file into memory */
if (SDL_LoadWAV(argv[1], &wave.spec, &wave.sound, &wave.soundlen) == NULL) { 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); quit(1);
} }


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


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


/* Initialize fillerup() variables */ /* Initialize fillerup() variables */
if (SDL_OpenAudio(&wave.spec, NULL) < 0) { 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); SDL_FreeWAV(wave.sound);
quit(2); quit(2);
} }


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


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

0 comments on commit 6572847

Please sign in to comment.