710 lines
22 KiB
C++
710 lines
22 KiB
C++
#include "Precompiled.h"
|
|
|
|
#include "RakiEngine/Data/MemoryBlock/MemoryBlock.h"
|
|
#include "RakiEngine/Data/Stream/MemoryStream/MemoryStream.h"
|
|
#include "RakiEngine/Data/Stream/SeekableStreamPart.h"
|
|
#include "RakiEngine/Data/Stream/AsyncReadStreamer.h"
|
|
#include "RakiEngine/Data/WaveFile/BinWaveData/BinWaveData.h"
|
|
#include "RakiEngine/Data/WaveFile/RiffChunkManager.h"
|
|
#include "RakiEngine/Sounds/Sequencer/Sequencer.h"
|
|
#include "RakiEngine/Sounds/Sequencer/SineNoteMemBlock.h"
|
|
#include "RakiEngine/Sounds/StreamBufferInfo.h"
|
|
#include "RakiEngine/System/Streaming/StreamingThread.h"
|
|
#include "RakiEngine/Utils/Calcs.h"
|
|
#include "RakiTests/Sounds/PCMDataProvider.h"
|
|
#include "RakiTests/Stream/ReadFileStream.h"
|
|
|
|
#include "RakiEngine/Utils/Calcs.h"
|
|
|
|
#if defined ( RAKI_USING_XAUDIO2 )
|
|
|
|
#include "RakiEngine/Sounds/_XAudio2/BufferSoundNative.h"
|
|
#include "RakiEngine/Sounds/_XAudio2/PCMStreamSoundNative.h"
|
|
#include "RakiEngine/Sounds/_XAudio2/XMA2StreamSoundNative_X360.h"
|
|
#include "RakiEngine/Specific/_XB360/Specific_X360.h"
|
|
#include "RakiTests/Sounds/XMA2DataProvider.h"
|
|
|
|
#elif defined ( RAKI_PLATFORM_PS3 )
|
|
|
|
#include <cell/mstream.h>
|
|
#include "RakiEngine/Sounds/_PS3/BufferSoundNative_PS3.h"
|
|
#include "RakiEngine/Sounds/_PS3/MP3StreamSoundNative_PS3.h"
|
|
#include "RakiTests/Sounds/MP3DataProvider.h"
|
|
|
|
#elif defined ( RAKI_PLATFORM_WII )
|
|
|
|
#include <revolution/vi.h>
|
|
|
|
#include "RakiTests/Sounds/ADPCMDataProvider_Wii.h"
|
|
#include "RakiEngine/Sounds/_Wii/BufferSoundNative_Wii.h"
|
|
#include "RakiEngine/Sounds/_Wii/ADPCMStreamSoundNative_Wii.h"
|
|
#include "RakiEngine/Sounds/_Wii/PCMStreamSoundNative_Wii.h"
|
|
|
|
#elif defined ( RAKI_PLATFORM_CAFE )
|
|
|
|
#include "RakiTests/Sounds/ADPCMDataProvider_Cafe.h"
|
|
#include "RakiEngine/Sounds/_Cafe/ADPCMStreamSoundNative_Cafe.h"
|
|
|
|
#include "RakiTests/_Cafe/Memory/SimpleHeap_Cafe.h"
|
|
|
|
#endif
|
|
|
|
#if defined ( RAKI_PLATFORM_WIN32 )
|
|
|
|
#include "RakiTests/_Win32/CoInitializeInitObject.h"
|
|
|
|
#endif // ( RAKI_PLATFORM_WIN32 )
|
|
|
|
|
|
|
|
#include "RakiTests/Initializer/TestInitializer.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace raki
|
|
{
|
|
|
|
extern void SystemAllocator_Initialize();
|
|
|
|
|
|
#if defined ( RAKI_PLATFORM_WII ) || defined ( RAKI_PLATFORM_CAFE )
|
|
#define BUFFER_PREFETCH_SIZE 55040
|
|
#else
|
|
#define BUFFER_PREFETCH_SIZE ( 2 * 0x10000 )
|
|
//#define BUFFER_PREFETCH_SIZE ( 2 * 0x1000 )
|
|
#endif
|
|
|
|
|
|
|
|
void TestPrepareAndStream( const char * _path );
|
|
void TestPrepareAndStream( const char * _path )
|
|
{
|
|
|
|
StreamingThread streamingThread;
|
|
streamingThread.start();
|
|
|
|
ReadFileStream fileStream;
|
|
|
|
bool opened = fileStream.open( _path );
|
|
RAKI_ASSERT_WITH_MESSAGE( opened, "Invalid path" );
|
|
|
|
BinWaveData binWaveData( MemoryBlock::ms_nativeMemoryType );
|
|
|
|
bool readOK = binWaveData.readOnlyHeader( &fileStream );
|
|
RAKI_ASSERT( readOK );
|
|
|
|
SoundStreamDataProvider * dataProvider = NULL;
|
|
SeekableStreamPart * seekableStreamPart = NULL;
|
|
AsyncReadStreamer * asyncReader = RAKI_NEW( AsyncReadStreamer );
|
|
|
|
bool buffersAllocated = false;
|
|
|
|
#if defined ( RAKI_PLATFORM_WIN32 )
|
|
|
|
PCMStreamSoundNative pcmStreamSound;
|
|
// pcmStreamSound.getStreamBufferInfo()->setStreamUpdateClient( &testUpdateClient );
|
|
buffersAllocated = pcmStreamSound.allocateBuffers( BUFFER_PREFETCH_SIZE );
|
|
RAKI_ASSERT( buffersAllocated );
|
|
|
|
#elif defined ( RAKI_PLATFORM_XB360 )
|
|
|
|
XMA2StreamSoundNative xma2StreamSound;
|
|
// xma2StreamSound.getStreamBufferInfo()->setStreamUpdateClient( &testUpdateClient );
|
|
buffersAllocated = xma2StreamSound.allocateBuffers( 0x20000 );
|
|
RAKI_ASSERT( buffersAllocated );
|
|
|
|
#elif defined ( RAKI_PLATFORM_WII )
|
|
|
|
WiiAdpcmSoundStreamDataProvider * adpcmDataProvider = NULL;
|
|
ADPCMStreamSoundNative adpcmStreamSound( 2 );
|
|
// adpcmStreamSound.getStreamBufferInfo()->setStreamUpdateClient( &testUpdateClient );
|
|
buffersAllocated = adpcmStreamSound.allocateBuffers( BUFFER_PREFETCH_SIZE );
|
|
RAKI_ASSERT( buffersAllocated );
|
|
|
|
#elif defined ( RAKI_PLATFORM_CAFE )
|
|
|
|
ADPCMDataProvider * adpcmDataProvider = NULL;
|
|
ADPCMStreamSoundNative adpcmStreamSound( 2 );
|
|
// pcmStreamSound.getStreamBufferInfo()->setStreamUpdateClient( &testUpdateClient );
|
|
buffersAllocated = adpcmStreamSound.allocateBuffers( BUFFER_PREFETCH_SIZE );
|
|
RAKI_ASSERT( buffersAllocated );
|
|
|
|
#elif defined ( RAKI_PLATFORM_PS3 )
|
|
|
|
MP3StreamSoundNative mp3StreamSound;
|
|
// mp3StreamSound.getStreamBufferInfo()->setStreamUpdateClient( &testUpdateClient );
|
|
buffersAllocated = mp3StreamSound.allocateBuffers( 0x20000 );
|
|
RAKI_ASSERT( buffersAllocated );
|
|
|
|
#endif
|
|
|
|
const bool isMusic = false;
|
|
const bool isLooping = false;
|
|
SoundParams soundParams( isMusic, isLooping );
|
|
|
|
WAVEFORMATEX * waveFormat = (WAVEFORMATEX*) binWaveData.getChunkData( RiffChunkManager::ms_riffTagFmt );
|
|
u32 waveFormatSize = binWaveData.getChunkSize( RiffChunkManager::ms_riffTagFmt );
|
|
RAKI_ASSERT( binWaveData.isStreamed() );
|
|
|
|
u16 formatTag = waveFormat->wFormatTag;
|
|
const u64 seekSamplePosition = 0x2000;
|
|
|
|
switch ( formatTag )
|
|
{
|
|
#if defined ( RAKI_PLATFORM_WII )
|
|
|
|
case WAVE_FORMAT_ADPCM:
|
|
{
|
|
RAKI_ASSERT( waveFormat->nChannels <= 2 );
|
|
RAKI_ASSERT( waveFormat->wBitsPerSample <= 16 );
|
|
RAKI_ASSERT( waveFormat->nSamplesPerSec <= 48000 );
|
|
|
|
bool create = adpcmStreamSound.createVoice( &binWaveData, soundParams );
|
|
RAKI_ASSERT( create );
|
|
|
|
seekableStreamPart = RAKI_NEW( SeekableStreamPart )( &fileStream, binWaveData.getDataOffset(), binWaveData.getDataSize() );
|
|
|
|
asyncReader->allocateBuffers( BUFFER_PREFETCH_SIZE );
|
|
asyncReader->setStreamData( NULL, 0, seekableStreamPart, NULL );
|
|
|
|
asyncReader->setStreamingThread( &streamingThread );
|
|
|
|
const u32 nbChannels = binWaveData.getChunkData( RiffChunkManager::ms_riffTagDspR ) ? 2 : 1;
|
|
|
|
adpcmDataProvider = RAKI_NEW( ADPCMDataProvider )( asyncReader, NULL, nbChannels, binWaveData.getChunkData( RiffChunkManager::ms_riffTagDspL ), binWaveData.getChunkData( RiffChunkManager::ms_riffTagDspR ) );
|
|
|
|
adpcmStreamSound.prepare( adpcmDataProvider );
|
|
|
|
for ( int s = 0 ; s < 100 ; ++s )
|
|
{
|
|
asyncReader->update( true );
|
|
Thread::sleep( 10 );
|
|
}
|
|
|
|
RAKI_ASSERT( asyncReader->isReadyToStart() );
|
|
|
|
RAKI_OUTPUT("Stream is ready to start, requesting start!");
|
|
|
|
adpcmStreamSound.updateRouting( true );
|
|
adpcmStreamSound.start();
|
|
|
|
bool isPlaying = adpcmStreamSound.isPlaying();
|
|
RAKI_ASSERT( isPlaying );
|
|
|
|
}
|
|
break;
|
|
|
|
#endif // RAKI_PLATFORM_WII
|
|
|
|
|
|
#if defined ( RAKI_PLATFORM_CAFE )
|
|
|
|
case WAVE_FORMAT_ADPCM:
|
|
{
|
|
RAKI_ASSERT( waveFormat->nChannels <= 2 );
|
|
RAKI_ASSERT( waveFormat->wBitsPerSample <= 16 );
|
|
RAKI_ASSERT( waveFormat->nSamplesPerSec <= 48000 );
|
|
|
|
bool create = adpcmStreamSound.createVoice( &binWaveData, soundParams );
|
|
RAKI_ASSERT( create );
|
|
|
|
seekableStreamPart = RAKI_NEW( SeekableStreamPart )( &fileStream, binWaveData.getDataOffset(), binWaveData.getDataSize() );
|
|
|
|
asyncReader->allocateBuffers( BUFFER_PREFETCH_SIZE );
|
|
|
|
asyncReader->setStreamData( NULL, 0, seekableStreamPart, NULL );
|
|
|
|
asyncReader->setStreamingThread( &streamingThread );
|
|
|
|
const u64 seekBytePosition = dataProvider->getByteBlockPosition( seekSamplePosition );
|
|
asyncReader->seek( seekBytePosition, SeekableStream::fromBeginning );
|
|
|
|
const u32 nbChannels = binWaveData.getChunkData( RiffChunkManager::ms_riffTagDspR ) ? 2 : 1;
|
|
RAKI_ASSERT( nbChannels == 2 ); // ADPCMStreamSoundNative adpcmStreamSound( 2 );
|
|
|
|
u32 * debug = (u32*)binWaveData.getChunkData( RiffChunkManager::ms_riffTagDspL );
|
|
RAKI_OUTPUT("binWaveData1.getChunkData( dspL ) %.8x %.8x %.8x %.8x", debug[8], debug[9], debug[10], debug[11] );
|
|
|
|
debug = (u32*)binWaveData.getChunkData( RiffChunkManager::ms_riffTagDspR );
|
|
RAKI_OUTPUT("binWaveData1.getChunkData( dspR ) %.8x %.8x %.8x %.8x", debug[8], debug[9], debug[10], debug[11] );
|
|
|
|
adpcmDataProvider = RAKI_NEW( ADPCMDataProvider )( asyncReader, (void*)1, nbChannels, true, binWaveData.getChunkData( RiffChunkManager::ms_riffTagDspL ), binWaveData.getChunkData( RiffChunkManager::ms_riffTagDspR ) );
|
|
|
|
adpcmStreamSound.prepare( adpcmDataProvider );
|
|
|
|
adpcmStreamSound.updateRouting( true );
|
|
adpcmStreamSound.start();
|
|
|
|
bool isPlaying = adpcmStreamSound.isPlaying();
|
|
RAKI_ASSERT( isPlaying );
|
|
|
|
}
|
|
break;
|
|
|
|
#endif // RAKI_PLATFORM_CAFE
|
|
|
|
|
|
|
|
#if defined ( RAKI_PLATFORM_WIN32 )
|
|
|
|
case WAVE_FORMAT_PCM:
|
|
{
|
|
// hello bill...
|
|
WAVEFORMATEX pcmFormat = { 0 };
|
|
RAKI_ASSERT( waveFormatSize <= sizeof( WAVEFORMATEX ) );
|
|
memcpy( &pcmFormat, waveFormat, waveFormatSize );
|
|
pcmFormat.cbSize = 0;
|
|
|
|
RAKI_ASSERT( pcmFormat.nChannels <= 2 );
|
|
RAKI_ASSERT( pcmFormat.wBitsPerSample <= 16 );
|
|
RAKI_ASSERT( pcmFormat.nSamplesPerSec <= 48000 );
|
|
|
|
bool create = pcmStreamSound.createVoice( &binWaveData, soundParams );
|
|
RAKI_ASSERT( create );
|
|
|
|
seekableStreamPart = RAKI_NEW( SeekableStreamPart )( &fileStream, binWaveData.getDataOffset(), binWaveData.getDataSize() );
|
|
|
|
asyncReader->allocateBuffers( BUFFER_PREFETCH_SIZE );
|
|
|
|
asyncReader->setStreamData( NULL, 0, seekableStreamPart, NULL );
|
|
|
|
dataProvider = RAKI_NEW( PCMDataProvider )( asyncReader, (void*)1, (u64) pcmFormat.nBlockAlign, pcmFormat.nChannels, true );
|
|
|
|
const u64 seekBytePosition = dataProvider->getByteBlockPosition( seekSamplePosition );
|
|
asyncReader->seek( seekBytePosition , SeekableStream::fromBeginning );
|
|
|
|
asyncReader->setStreamingThread( &streamingThread );
|
|
|
|
pcmStreamSound.prepare( dataProvider );
|
|
pcmStreamSound.updateRouting( true );
|
|
|
|
for ( int s = 0 ; s < 100 ; ++s )
|
|
{
|
|
asyncReader->update( true );
|
|
Thread::sleep( 10 );
|
|
}
|
|
|
|
RAKI_ASSERT( asyncReader->isReadyToStart() );
|
|
|
|
RAKI_OUTPUT("Stream is ready to start, requesting start!");
|
|
|
|
pcmStreamSound.start();
|
|
|
|
bool isPlaying = pcmStreamSound.isPlaying();
|
|
RAKI_ASSERT( isPlaying );
|
|
}
|
|
break;
|
|
#endif // defined ( RAKI_PLATFORM_WIN32 )
|
|
|
|
|
|
#if defined ( RAKI_PLATFORM_XB360 )
|
|
|
|
case WAVE_FORMAT_XMA2:
|
|
{
|
|
RAKI_ASSERT( waveFormatSize >= sizeof( XMA2WAVEFORMATEX ) );
|
|
|
|
// MS HACK !!
|
|
XMA2WAVEFORMATEX * xma2waveFormat = (XMA2WAVEFORMATEX *)waveFormat;
|
|
xma2waveFormat->PlayBegin = xma2waveFormat->LoopBegin;
|
|
xma2waveFormat->PlayLength = xma2waveFormat->LoopLength;
|
|
|
|
bool create = xma2StreamSound.createVoice( &binWaveData, soundParams );
|
|
RAKI_ASSERT( create );
|
|
|
|
seekableStreamPart = RAKI_NEW( SeekableStreamPart )( &fileStream, binWaveData.getDataOffset(), binWaveData.getDataSize() );
|
|
asyncReader->allocateBuffers( BUFFER_PREFETCH_SIZE / 2 );
|
|
u64 prefetchSize = 0;//dataBlock.getSize() > BUFFER_PREFETCH_SIZE ? BUFFER_PREFETCH_SIZE : dataBlock.getSize();
|
|
|
|
asyncReader->setStreamData( NULL, 0, seekableStreamPart, NULL );
|
|
|
|
u32 * seekTable = (u32*)binWaveData.getChunkData( RiffChunkManager::ms_riffTagSeek );
|
|
u32 seekTableSize = binWaveData.getChunkSize( RiffChunkManager::ms_riffTagSeek );
|
|
|
|
//dataProvider = RAKI_NEW( XMA2DataProvider )( asyncReader, xma2waveFormat, seekTable, seekTableSize, sizeInTicks, sizeInBars, nbBeatsPerBar, xma2waveFormat->wfx.nChannels );
|
|
dataProvider = RAKI_NEW( XMA2DataProvider )( asyncReader, xma2waveFormat, seekTable, seekTableSize, 0, 0, 0, xma2waveFormat->wfx.nChannels, seekSamplePosition );
|
|
const u64 seekBytePosition = dataProvider->getByteBlockPosition( seekSamplePosition );
|
|
const u64 playStartSamplePositionInBuffer = dataProvider->getSampleOffsetInBuffer( seekBytePosition, seekSamplePosition );
|
|
|
|
asyncReader->seek( seekBytePosition, SeekableStream::fromBeginning );
|
|
|
|
asyncReader->setStreamingThread( &streamingThread );
|
|
|
|
((XMA2DataProvider*)dataProvider)->setNextStream( seekableStreamPart, NULL/*&clientData*/ );
|
|
|
|
xma2StreamSound.prepare( dataProvider, playStartSamplePositionInBuffer );
|
|
|
|
xma2StreamSound.setDecibelVolume( 0.f );
|
|
xma2StreamSound.updateRouting( true );
|
|
xma2StreamSound.start();
|
|
}
|
|
break;
|
|
#endif // ( RAKI_PLATFORM_XB360 )
|
|
|
|
|
|
|
|
#if defined ( RAKI_PLATFORM_PS3 )
|
|
|
|
case WAVE_FORMAT_MPEGLAYER3:
|
|
{
|
|
/* void * mp3Data = waveFile.getChunkData( dataChunck );
|
|
unsigned int tSize = 0;
|
|
unsigned int offset = 0;
|
|
float tTime = 0.f;
|
|
|
|
while(1)
|
|
{
|
|
CellMSMP3FrameHeader header;
|
|
|
|
int ret = cellMSMP3GetFrameInfo( mp3Data, &header );
|
|
if ( ret == -1 )
|
|
{
|
|
printf("Invalid MP3 header\n");
|
|
printf("Offset=0x%x\n",offset);
|
|
break;
|
|
}
|
|
|
|
tSize += header.PacketSize; // Update total file size
|
|
if ((header.ID3==0)&&(header.Tag==0))
|
|
tTime+=header.PacketTime; // Update total playing time (in seconds)
|
|
mp3Data = (void*)( header.PacketSize + (u32)mp3Data ); // Move forward to next packet
|
|
offset+=header.PacketSize;
|
|
|
|
// ** Display packet information **
|
|
// Using the packet size and packet time information, it is possible to build "Seek Tables".
|
|
// Then, by knowing approximately what time (in seconds) you require to playback from,
|
|
// you can start playback from the closest data packet by searching for the closest record in the table.
|
|
|
|
if (header.ID3!=0)
|
|
{
|
|
printf("Found ID3 Info\n");
|
|
printf("Version: %x.%x\n",header.ID3>>8, header.ID3&255);
|
|
}
|
|
else if (header.Tag!=0)
|
|
{
|
|
printf("Found Tag info\n");
|
|
}
|
|
else
|
|
{
|
|
printf("Sync: 0x%x\n",header.Sync);
|
|
printf("ID: 0x%x\n",header.ID);
|
|
printf("Layer: 0x%x\n",header.Layer);
|
|
printf("ProtBit: 0x%x\n",header.ProtBit);
|
|
printf("BitRate: %d\n",header.BitRate);
|
|
printf("Frequency: %d\n",header.Frequency);
|
|
printf("PadBit: 0x%x\n",header.PadBit);
|
|
printf("PrivBit: 0x%x\n",header.PrivBit);
|
|
printf("Mode: 0x%x\n",header.Mode);
|
|
printf("Copy: 0x%x\n",header.Copy);
|
|
printf("Home: 0x%x\n",header.Home);
|
|
printf("Emphasis: 0x%x\n",header.Emphesis);
|
|
printf("Packet Time (secs): %f\n",header.PacketTime);
|
|
}
|
|
printf("Packet Size (bytes): 0x%x\n",header.PacketSize);
|
|
|
|
if ( tSize == waveFile.getChunkSize( dataChunck ) )
|
|
{
|
|
printf("MP3 File is valid.\n");
|
|
printf("Total Playback Time at %d Hz = (secs): %f\n",header.Frequency,tTime);
|
|
break;
|
|
}
|
|
else if (tSize > waveFile.getChunkSize( dataChunck ) )
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
*/
|
|
|
|
|
|
bool create = mp3StreamSound.createVoice( &binWaveData, soundParams );
|
|
RAKI_ASSERT( create );
|
|
seekableStreamPart = RAKI_NEW( SeekableStreamPart )( &fileStream, binWaveData.getDataOffset(), binWaveData.getDataSize() );
|
|
asyncReader->allocateBuffers( BUFFER_PREFETCH_SIZE / 2 );
|
|
asyncReader->setStreamData( NULL, 0, seekableStreamPart, NULL );
|
|
|
|
dataProvider = RAKI_NEW( MP3DataProvider )( asyncReader, NULL, waveFormat->nChannels );
|
|
|
|
const u64 seekBytePosition = dataProvider->getByteBlockPosition( seekSamplePosition );
|
|
const u64 playStartSamplePositionInBuffer = dataProvider->getSampleOffsetInBuffer( seekBytePosition, seekSamplePosition );
|
|
|
|
asyncReader->seek( seekBytePosition, SeekableStream::fromBeginning );
|
|
|
|
asyncReader->setStreamingThread( &streamingThread );
|
|
|
|
mp3StreamSound.prepare( dataProvider, playStartSamplePositionInBuffer );
|
|
|
|
for ( int s = 0 ; s < 100 ; ++s )
|
|
{
|
|
asyncReader->update( true );
|
|
Thread::sleep( 10 );
|
|
}
|
|
|
|
RAKI_ASSERT( asyncReader->isReadyToStart() );
|
|
|
|
RAKI_OUTPUT("Stream is ready to start, requesting start!");
|
|
|
|
mp3StreamSound.updateRouting( true );
|
|
mp3StreamSound.start();
|
|
}
|
|
break;
|
|
#endif // ( RAKI_PLATFORM_PS3 )
|
|
|
|
default:
|
|
RAKI_ASSERT_FALSE;
|
|
}
|
|
|
|
#define COUNT_LOOP 50
|
|
#define COUNT_STOP 20
|
|
#define COUNT_START 34
|
|
|
|
int count = 0;
|
|
|
|
for ( ;; )
|
|
{
|
|
bool isPlaying = false;
|
|
|
|
#ifdef RAKI_PLATFORM_WII
|
|
VIWaitForRetrace();
|
|
#else // RAKI_PLATFORM_WII
|
|
Thread::sleep( 25 );
|
|
#endif // RAKI_PLATFORM_WII
|
|
|
|
|
|
#if defined ( RAKI_PLATFORM_WIN32 )
|
|
|
|
pcmStreamSound.update();
|
|
isPlaying |= pcmStreamSound.isPlaying();
|
|
|
|
#elif defined ( RAKI_PLATFORM_XB360 )
|
|
|
|
xma2StreamSound.update();
|
|
isPlaying |= xma2StreamSound.isPlaying();
|
|
|
|
#elif defined ( RAKI_PLATFORM_WII ) || defined ( RAKI_PLATFORM_CAFE )
|
|
|
|
adpcmStreamSound.update();
|
|
isPlaying |= adpcmStreamSound.isPlaying();
|
|
|
|
#elif defined ( RAKI_PLATFORM_PS3 )
|
|
|
|
mp3StreamSound.update();
|
|
isPlaying |= mp3StreamSound.isPlaying();
|
|
|
|
#endif
|
|
|
|
asyncReader->update( true );
|
|
/*
|
|
if ( ( count % COUNT_LOOP ) == COUNT_STOP )
|
|
xma2StreamSound.stop();
|
|
|
|
if ( ( count % COUNT_LOOP ) == COUNT_START )
|
|
xma2StreamSound.play();
|
|
*/
|
|
++count;
|
|
|
|
if ( !isPlaying )
|
|
break;
|
|
}
|
|
|
|
#if defined ( RAKI_PLATFORM_WIN32 )
|
|
pcmStreamSound.stop();
|
|
#elif defined ( RAKI_PLATFORM_XB360 )
|
|
xma2StreamSound.stop();
|
|
#elif defined ( RAKI_PLATFORM_WII ) || defined ( RAKI_PLATFORM_CAFE )
|
|
adpcmStreamSound.stop();
|
|
#elif defined ( RAKI_PLATFORM_PS3 )
|
|
mp3StreamSound.stop();
|
|
#endif
|
|
|
|
// XAudio2 doc: Stop is always asynchronous, even if called within a callback
|
|
Thread::sleep( 5000 );
|
|
|
|
#if defined ( RAKI_PLATFORM_WIN32 )
|
|
pcmStreamSound.destroyVoice();
|
|
#elif defined ( RAKI_PLATFORM_XB360 )
|
|
xma2StreamSound.destroyVoice();
|
|
#elif defined ( RAKI_PLATFORM_WII )
|
|
adpcmStreamSound.destroyVoice();
|
|
#elif defined ( RAKI_PLATFORM_PS3 )
|
|
mp3StreamSound.destroyVoice();
|
|
#endif
|
|
|
|
Thread::sleep( 500 );
|
|
|
|
RAKI_DELETE( asyncReader );
|
|
asyncReader = NULL;
|
|
|
|
RAKI_DELETE( seekableStreamPart );
|
|
seekableStreamPart = NULL;
|
|
|
|
if ( dataProvider )
|
|
RAKI_DELETE( dataProvider );
|
|
dataProvider = NULL;
|
|
|
|
streamingThread.stop();
|
|
|
|
Thread::sleep( 500 );
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace raki
|
|
|
|
|
|
|
|
#if defined ( RAKI_PLATFORM_CAFE )
|
|
|
|
|
|
u32 running_core;
|
|
u32 main_core;
|
|
u32 first_subcore;
|
|
u32 second_subcore;
|
|
u32 wait_main_core;
|
|
u32 wait_first_subcore;
|
|
u32 wait_second_subcore;
|
|
OSRendezvous rendezvous;
|
|
|
|
void
|
|
SetupCoreIds(void)
|
|
{
|
|
running_core = OSGetCoreId();
|
|
main_core = OSGetMainCoreId();
|
|
|
|
first_subcore = 0;
|
|
second_subcore = 2;
|
|
wait_main_core = OS_WAIT_CORE_MAIN;
|
|
wait_first_subcore = OS_WAIT_CORE_SUB1;
|
|
wait_second_subcore = OS_WAIT_CORE_SUB2;
|
|
|
|
if (main_core == 0)
|
|
{
|
|
first_subcore = 1;
|
|
second_subcore = 2;
|
|
wait_main_core = OS_WAIT_CORE_SUB1;
|
|
wait_first_subcore = OS_WAIT_CORE_MAIN;
|
|
wait_second_subcore = OS_WAIT_CORE_SUB2;
|
|
}
|
|
else
|
|
if (main_core == 2)
|
|
{
|
|
first_subcore = 0;
|
|
second_subcore = 1;
|
|
wait_main_core = OS_WAIT_CORE_SUB2;
|
|
wait_first_subcore = OS_WAIT_CORE_SUB1;
|
|
wait_second_subcore = OS_WAIT_CORE_MAIN;
|
|
}
|
|
}
|
|
|
|
int run_demo (int intArg, void *ptrArg)
|
|
{
|
|
raki::SimpleHeap_Cafe::init();
|
|
|
|
raki::TestInitializer initializer;
|
|
|
|
//const char path[] = "DoubleSweep.wav.cafe";
|
|
const char path[] = "/vol/content/_raki_/Mus_Jun_Cage_Free_04_2M.wav.cafe";
|
|
//const char path[] = "Mus_lod_poursuite_01_18M_low_stream.wav.cafe";
|
|
//const char path1[] = "sine10secHIGH.wav.cafe";
|
|
//const char path2[] = "sine10secLOW.wav.cafe";
|
|
|
|
raki::TestPrepareAndStream( path );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined ( RAKI_USING_XAUDIO2 )
|
|
int _tmain( int /*argc*/, _TCHAR* /*argv[]*/ )
|
|
#else // RAKI_USING_XAUDIO2
|
|
int main( int /*argc*/, char * /*argv[]*/ )
|
|
#endif // RAKI_USING_XAUDIO2
|
|
{
|
|
#if defined ( RAKI_PLATFORM_WII )
|
|
DVDInit();
|
|
VIInit();
|
|
|
|
raki::SystemAllocator_Initialize();
|
|
|
|
#elif defined ( RAKI_PLATFORM_WIN32 )
|
|
|
|
raki::CoInitializeInitObject coInitializeInitObject;
|
|
|
|
#elif defined ( RAKI_PLATFORM_CAFE )
|
|
|
|
u32 gx2InitAttribs[] =
|
|
{
|
|
GX2_INIT_ATTRIB_NULL // terminates the list
|
|
};
|
|
GX2Init(gx2InitAttribs);
|
|
|
|
// launch test on Core 0 if present
|
|
if (OSGetCoreCount() == 3)
|
|
{
|
|
OSThread* defaultThread0;
|
|
|
|
SetupCoreIds();
|
|
|
|
OSReport("Running Core == %d\n", running_core);
|
|
OSReport("OS Main Core == %d\n\n", main_core);
|
|
|
|
OSInitRendezvous(&rendezvous);
|
|
|
|
//
|
|
// Restart default thread on 1st subcore, core0
|
|
//
|
|
|
|
defaultThread0 = OSGetDefaultThread(first_subcore);
|
|
OSRunThread(defaultThread0,
|
|
run_demo,
|
|
0,
|
|
(void*) 0x23232323);
|
|
|
|
OSWaitRendezvous(&rendezvous, wait_first_subcore);
|
|
}
|
|
else
|
|
{
|
|
run_demo(0, NULL);
|
|
}
|
|
|
|
GX2Shutdown();
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
|
|
#if !defined ( RAKI_PLATFORM_CAFE )
|
|
|
|
|
|
#if defined ( RAKI_PLATFORM_WIN32 )
|
|
const char path[] = "Y:/JD5/JD/main/extern/Raki/TestData/Mus_Jun_Cage_Free_04_2M.wav.w32pcm";
|
|
#elif defined ( RAKI_PLATFORM_XB360 )
|
|
const char path[] = "game:\\Mus_Jun_Cage_Free_04_2M_LP.wav.x360";
|
|
#elif defined ( RAKI_PLATFORM_PS3 )
|
|
const char path[] = "/app_home/Y:/JD5/JD/main/extern/Raki/TestData/Mus_Jun_Cage_Free_04_2M.wav.ps3";
|
|
#elif defined ( RAKI_PLATFORM_WII )
|
|
const char path[] = "_raki_/Mus_Jun_Cage_Free_04_2M.wav.wii";
|
|
#endif
|
|
|
|
raki::TestInitializer initializer;
|
|
|
|
raki::TestPrepareAndStream( path );
|
|
|
|
return 0;
|
|
|
|
#endif // !defined ( RAKI_PLATFORM_CAFE )
|
|
}
|
|
|
|
|
|
|
|
|