return;\r
}\r
\r
-static void SBCallback(void *uudata, unsigned char *Buffer, int Length)\r
+static void SBCallback(void *uudata, signed short *Buffer, int Length)\r
{\r
+ int i;\r
unsigned short Pos, Cur, Left;\r
\r
Pos = 0;\r
+ Length /= 2;\r
while(Length > 0)\r
{\r
if(SoundBufferPos >= (SB_SIZE >> 1))\r
}\r
Left = (SB_SIZE >> 1) - SoundBufferPos;\r
Cur = (Length > Left)?Left:Length;\r
- memcpy(Buffer + Pos, SoundBuffer + SoundBufferPos, Cur);\r
+ for(i = 0; i < Cur; i++)\r
+ Buffer[Pos + i] = (((signed char)SoundBuffer[SoundBufferPos + i]) - 128) * 255;\r
Pos += Cur;\r
SoundBufferPos += Cur;\r
Length -= Cur;\r
\r
SoundBufferPos = SB_SIZE;\r
my.freq = 44100;\r
- my.format = AUDIO_U8;\r
+ my.format = AUDIO_S16;\r
my.channels = 1;\r
my.samples = SB_SIZE >> 1;\r
- my.callback = SBCallback;\r
+ my.callback = (void (*)(void *, unsigned char *, int))SBCallback;\r
if(SDL_OpenAudio(&my, &got) < 0)\r
{\r
printf("Could not open SDL audio: %s\n", SDL_GetError());\r
return(1);\r
}\r
if((got.freq != 44100) ||\r
- (got.format != AUDIO_U8) ||\r
+ (got.format != AUDIO_S16) ||\r
(got.channels != 1))\r
{\r
printf("Audio format mismatch(%i %i %i)!\n", got.freq, got.format, got.channels);\r