XBox 360 Audio Support -> loopwave Sample


#1

I’ve got the loopwave sample running on an XBox 360 after starting with and modifying the SDL XAUDIO2 audio driver.

The Audio Data byte order is different on XBox 360 so I had to make the following changes to loopwave.c:-

void memcpy_reverse(Uint8 *waveptr, Uint8 * stream, int len)
{
Uint16 * pWavePtrShort, * pBufferShort;
Uint32 i;

pWavePtrShort = ( Uint16* )waveptr;
pBufferShort = ( Uint16* )stream;

for( i = 0; i < len / sizeof( Uint16 ); i++ )
	pWavePtrShort[i] = shortReverse( 0, &pBufferShort[i] );

}

void SDLCALL
fillerup(void *unused, Uint8 * stream, int len)
{
Uint8 *waveptr;
int waveleft;

/* Set up the pointers */
waveptr = wave.sound + wave.soundpos;
waveleft = wave.soundlen - wave.soundpos;

/* Go! */
while (waveleft <= len) {
    **memcpy_reverse**(stream, waveptr, waveleft);
    stream += waveleft;
    len -= waveleft;
    waveptr = wave.sound;
    waveleft = wave.soundlen;
    wave.soundpos = 0;
}
**memcpy_reverse**(stream, waveptr, len);

wave.soundpos += len;

}

Although this works, it feels like that the byte order conversion should be taken care of by the driver and not rely on the users own callback.

What are your thoughts? Is there an API in the driver I should be using?

Thanks,

-A


#2

Ok, figured it out…

I just call the conversion routine immediately before I call IXAudio2SourceVoice_SubmitSourceBuffer from the driver code.

Now to get the Gamepad working…

Thanks,

-A