diff -urN ../VisualBoyAdvance-1.7.2-orig/src/sdl/SDL.cpp src/sdl/SDL.cpp --- ../VisualBoyAdvance-1.7.2-orig/src/sdl/SDL.cpp 2006-12-05 14:05:28 +0900 +++ src/sdl/SDL.cpp 2006-12-05 14:06:41 +0900 @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include @@ -257,6 +259,7 @@ SDL_sem *sdlBufferEmpty = NULL; u8 sdlBuffer[4096]; int sdlSoundLen = 0; +int soundOutfile = -1; char *arg0; @@ -359,6 +362,7 @@ { "save-none", no_argument, &cpuSaveType, 5 }, { "show-speed-normal", no_argument, &showSpeed, 1 }, { "show-speed-detailed", no_argument, &showSpeed, 2 }, + { "sound-outfile", required_argument, 0, 's'<<8|'o' }, { "throttle", required_argument, 0, 'T' }, { "verbose", required_argument, 0, 'v' }, { "video-1x", no_argument, &sizeOption, 0 }, @@ -2143,6 +2147,19 @@ case '4': sizeOption = 3; break; + case 's'<<8|'o': + if (optarg) { + soundOutfile = open(optarg, O_WRONLY|O_CREAT|O_TRUNC, 0666); + if (soundOutfile == -1) { + fprintf(stderr, "--sound-outfile: open(%s): %s\n", optarg, + strerror(errno)); + exit(-1); + } + } else { + fprintf(stderr, "Missing argument to --sound-outfile (getopt bug?)\n"); + exit(-1); + } + break; case '?': sdlPrintUsage = 1; break; @@ -2938,6 +2955,8 @@ SDL_SemWait (sdlBufferLock); memcpy (stream, sdlBuffer, len); + if (soundOutfile != -1) + write(soundOutfile, stream, len); sdlSoundLen = 0; SDL_SemPost (sdlBufferLock);