summaryrefslogtreecommitdiff
path: root/test/testresample.c
diff options
context:
space:
mode:
authorRyan C. Gordon <icculus@icculus.org>2017-01-08 16:18:49 -0500
committerRyan C. Gordon <icculus@icculus.org>2017-01-08 16:18:49 -0500
commitcf65ec71c6b7ec4ceb59d95be09c6b678a856ffc (patch)
tree3ccbaed5355c0f7e60a83d0cf8c5a29781da4992 /test/testresample.c
parenteca4d36584497805519f55960a30c5dd997edefa (diff)
downloadsdl-cf65ec71c6b7ec4ceb59d95be09c6b678a856ffc.tar.gz
audio: Improvements in channel conversion code.
Diffstat (limited to 'test/testresample.c')
-rw-r--r--test/testresample.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/test/testresample.c b/test/testresample.c
index 96e46f038..85a8eb71f 100644
--- a/test/testresample.c
+++ b/test/testresample.c
@@ -20,6 +20,7 @@ main(int argc, char **argv)
Uint32 len = 0;
Uint8 *data = NULL;
int cvtfreq = 0;
+ int cvtchans = 0;
int bitsize = 0;
int blockalign = 0;
int avgbytes = 0;
@@ -28,12 +29,13 @@ main(int argc, char **argv)
/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
- if (argc != 4) {
- SDL_Log("USAGE: %s in.wav out.wav newfreq\n", argv[0]);
+ if (argc != 5) {
+ SDL_Log("USAGE: %s in.wav out.wav newfreq newchans\n", argv[0]);
return 1;
}
cvtfreq = SDL_atoi(argv[3]);
+ cvtchans = SDL_atoi(argv[4]);
if (SDL_Init(SDL_INIT_AUDIO) == -1) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
@@ -47,7 +49,7 @@ main(int argc, char **argv)
}
if (SDL_BuildAudioCVT(&cvt, spec.format, spec.channels, spec.freq,
- spec.format, spec.channels, cvtfreq) == -1) {
+ spec.format, cvtchans, cvtfreq) == -1) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to build CVT: %s\n", SDL_GetError());
SDL_FreeWAV(data);
SDL_Quit();
@@ -83,7 +85,7 @@ main(int argc, char **argv)
}
bitsize = SDL_AUDIO_BITSIZE(spec.format);
- blockalign = (bitsize / 8) * spec.channels;
+ blockalign = (bitsize / 8) * cvtchans;
avgbytes = cvtfreq * blockalign;
SDL_WriteLE32(io, 0x46464952); /* RIFF */
@@ -92,7 +94,7 @@ main(int argc, char **argv)
SDL_WriteLE32(io, 0x20746D66); /* fmt */
SDL_WriteLE32(io, 16); /* chunk size */
SDL_WriteLE16(io, 1); /* uncompressed */
- SDL_WriteLE16(io, spec.channels); /* channels */
+ SDL_WriteLE16(io, cvtchans); /* channels */
SDL_WriteLE32(io, cvtfreq); /* sample rate */
SDL_WriteLE32(io, avgbytes); /* average bytes per second */
SDL_WriteLE16(io, blockalign); /* block align */