TEST_F(TestBufferQueue, testValidBuffer) {
    for (unsigned i = 0; i < sizeof(validNumBuffers) / sizeof(validNumBuffers[0]); ++i) {
        SLuint32 numBuffers = validNumBuffers[i];
        PrepareValidBuffer(numBuffers);
        DestroyPlayer();
    }
}
TEST_F(TestBufferQueue, testStateTransitionEmptyQueue) {
    static const SLuint32 newStates[] = {
        SL_PLAYSTATE_PAUSED,    // paused -> paused
        SL_PLAYSTATE_STOPPED,   // paused -> stopped
        SL_PLAYSTATE_PAUSED,    // stopped -> paused
        SL_PLAYSTATE_PLAYING,   // paused -> playing
        SL_PLAYSTATE_PLAYING,   // playing -> playing
        SL_PLAYSTATE_STOPPED,   // playing -> stopped
        SL_PLAYSTATE_STOPPED,   // stopped -> stopped
        SL_PLAYSTATE_PLAYING,   // stopped -> playing
        SL_PLAYSTATE_PAUSED     // playing -> paused
    };

    for (unsigned i = 0; i < sizeof(validNumBuffers) / sizeof(validNumBuffers[0]); ++i) {
        SLuint32 numBuffers = validNumBuffers[i];
        SLuint32 j;

        PrepareValidBuffer(numBuffers);
        /* Set initial state to paused*/
        SetPlayerState(SL_PLAYSTATE_PAUSED);

        for (j = 0; j < sizeof(newStates) / sizeof(newStates[0]); ++j) {
            SetPlayerState(newStates[j]);
            CheckBufferCount((SLuint32) 0, (SLuint32) 0);
        }
        DestroyPlayer();
    }
}
Exemplo n.º 3
0
/**
 * Stops the current wave instance and detaches it from the source.	
 */
void FSLESSoundSource::Stop( void )
{
	if( WaveInstance )
	{
		
		// set the player's state to stopped
		SLresult result = (*SL_PlayerPlayInterface)->SetPlayState(SL_PlayerPlayInterface, SL_PLAYSTATE_STOPPED);
		check(SL_RESULT_SUCCESS == result);
		
		// Unregister looping callback
		if( WaveInstance->LoopingMode != LOOP_Never ) 
		{
			result = (*SL_PlayerBufferQueue)->RegisterCallback(SL_PlayerBufferQueue, NULL, NULL);
		}
		
		DestroyPlayer();
		ReleaseResources();
		
		Paused = false;
		Playing = false;
		Buffer = NULL;
	}
	
	FSoundSource::Stop();
}
Exemplo n.º 4
0
/**
 * Clean up any hardware referenced by the sound source
 */
FSLESSoundSource::~FSLESSoundSource( void )
{

	DestroyPlayer();

	ReleaseResources();
}
TEST_F(TestBufferQueue, testMuteSolo) {
    // create audio player with buffer queue data source in stereo PCM format and ask for mute solo
    locator_bufferqueue.numBuffers = 1;
    SLresult result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audiosrc,
            &audiosnk, 2, ids_mutesolo, flags_mutesolo);
    ASSERT_EQ(SL_RESULT_SUCCESS, result);
    ASSERT_TRUE(NULL != playerObject);
    DestroyPlayer();
    // create audio player with buffer queue data source in mono PCM format and ask for mute solo
    pcm.numChannels = 1;
    pcm.channelMask = SL_SPEAKER_FRONT_CENTER;
    result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audiosrc, &audiosnk,
            2, ids_mutesolo, flags_mutesolo);
    ASSERT_EQ(SL_RESULT_FEATURE_UNSUPPORTED, result);
    ASSERT_EQ(NULL, playerObject);
    DestroyPlayer();
}
TEST_F(TestBufferQueue, testSeek) {
    // can create audio player with buffer queue data source and ask for seek
    locator_bufferqueue.numBuffers = 1;
    SLresult result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject,
                                                    &audiosrc, &audiosnk, 2, ids_seek, flags_seek);
    ASSERT_EQ(SL_RESULT_FEATURE_UNSUPPORTED, result);
    ASSERT_EQ(NULL, playerObject);
    DestroyPlayer();
}
TEST_F(TestBufferQueue, testEnqueueAtPaused) {
    for (unsigned i = 0; i < sizeof(validNumBuffers) / sizeof(validNumBuffers[0]); ++i) {
        SLuint32 numBuffers = validNumBuffers[i];
        PrepareValidBuffer(numBuffers);
        SetPlayerState(SL_PLAYSTATE_PAUSED);
        EnqueueMaxBuffer(numBuffers);
        CheckBufferCount(numBuffers, (SLuint32) 0);
        DestroyPlayer();
    }
}
TEST_F(TestBufferQueue, testEnqueueExtraBuffer) {
    for (unsigned i = 0; i < sizeof(validNumBuffers) / sizeof(validNumBuffers[0]); ++i) {
        SLuint32 numBuffers = validNumBuffers[i];
        PrepareValidBuffer(numBuffers);
        EnqueueMaxBuffer(numBuffers);
        EnqueueExtraBuffer(numBuffers);
        GetPlayerState(SL_PLAYSTATE_STOPPED);
        DestroyPlayer();
    }
}
//////////////////////////////////////////////////////////////////////
// fe_MultiplayerSetup::OnUpdate() //              \author Logan Jones
////////////////////////////////////                    \date 9/5/2002
//               
//====================================================================
//
void fe_MultiplayerSetup::OnUpdate()
{
	bool			bQueried;
	UINT32			Msg;
	gadget_ListBox*	pBox = (gadget_ListBox*)GetGadget("Output");

	net.SendRecv( &bQueried );

	if( bQueried )
		pBox->AddListBoxItem( "Something pinged at me" );

	while( net.Read().BytesToRead() )
		if( net.Read().Marker()==net_SystemMarker ) OnSystemMessage();
		else { net.Read() >> Msg; theApp.Console.Comment( CT_LOAD, "fe_MultiplayerSetup::OnUpdate(): Handling message, %d", Msg );switch(Msg){
			case fems_ClientLogin: OnClientLogin(); break;
			case fems_Resync: OnResync(); break;
			case fems_NewPlayer: OnNewPlayer(); break;
			case fems_RemovePlayer: DestroyPlayer(net.Read().GetUInt32()); break;
			case fems_Go: sound.PlaySound( guiResources.Sounds.BigButton ); SaveSettings(); theApp.SetStartMenu( "SelectGame" ); theApp.StartGame(); break;
			default:theApp.Console.Comment( CT_LOAD, "fe_MultiplayerSetup::OnUpdate(): Unknown message, %d", Msg );
		}}
}
Exemplo n.º 10
0
TEST_F(TestBufferQueue, testStateTransitionNonEmptyQueue) {
    static const SLuint32 newStates[] = {
        SL_PLAYSTATE_PAUSED,    // paused -> paused
        SL_PLAYSTATE_STOPPED,   // paused -> stopped
        SL_PLAYSTATE_STOPPED,   // stopped -> stopped
        SL_PLAYSTATE_PAUSED     // stopped -> paused
    };

    for (unsigned i = 0; i < sizeof(validNumBuffers) / sizeof(validNumBuffers[0]); ++i) {
        SLuint32 numBuffers = validNumBuffers[i];
        SLuint32 j;

        /* Prepare the player */
        PrepareValidBuffer(numBuffers);
        EnqueueMaxBuffer(numBuffers);
        SetPlayerState(SL_PLAYSTATE_PAUSED);

        for (j = 0; j < sizeof(newStates) / sizeof(newStates[0]); ++j) {
            SetPlayerState(newStates[j]);
            CheckBufferCount(numBuffers, (SLuint32) 0);
        }
        DestroyPlayer();
    }
}
Exemplo n.º 11
0
void UnloadLevel(void)
{
	//Destroy the textures
	DestroyTextureList();
	DestroyPlayer(&CurrentPlayer);
}
Exemplo n.º 12
0
/**
 * Initializes a source with a given wave instance and prepares it for playback.
 *
 * @param	WaveInstance	wave instace being primed for playback
 * @return	TRUE if initialization was successful, FALSE otherwise
 */
bool FSLESSoundSource::Init( FWaveInstance* InWaveInstance )
{
	// don't do anything if no volume! THIS APPEARS TO HAVE THE VOLUME IN TIME, CHECK HERE THOUGH IF ISSUES
	if( InWaveInstance && ( InWaveInstance->Volume * InWaveInstance->VolumeMultiplier ) <= 0 )
	{
		return false;
	}

	if (Buffer && Buffer->ResourceID == 0)
	{
		UE_LOG( LogAndroidAudio, Warning, TEXT(" InitSoundSouce with Buffer already allocated"));
		delete Buffer;
		Buffer = 0;
	}

	if (SL_PlayerObject)
	{
		UE_LOG( LogAndroidAudio, Warning, TEXT(" InitSoundSouce with PlayerObject not NULL, possible leak"));
	}
	
	WaveInstance = InWaveInstance;

	// Find matching buffer.
	Buffer = FSLESSoundBuffer::Init( (FSLESAudioDevice *)AudioDevice, InWaveInstance->WaveData );

	if( Buffer && InWaveInstance->WaveData->NumChannels <= 2 && InWaveInstance->WaveData->SampleRate <= 48000 )
	{
		SCOPE_CYCLE_COUNTER( STAT_AudioSourceInitTime );
		
		bool bFailedSetup = false;

		if (CreatePlayer())
		{
			switch( Buffer->Format)
			{
				case SoundFormat_PCM:
					bFailedSetup |= !EnqueuePCMBuffer( InWaveInstance->LoopingMode != LOOP_Never );
					break;
				case SoundFormat_PCMRT:
					bFailedSetup |= !EnqueuePCMRTBuffer( InWaveInstance->LoopingMode != LOOP_Never );
					break;
				default:
					bFailedSetup = true;
			}
		}
		else
		{
			bFailedSetup = true;
		}
		
		// clean up the madness if anything we need failed
		if( bFailedSetup )
		{
			UE_LOG( LogAndroidAudio, Warning, TEXT(" Setup failed %s"), *InWaveInstance->WaveData->GetName());
			DestroyPlayer();
			return false;
		}
		
		Update();
		
		// Initialization was successful.
		return true;
	}
	else
	{
		// Failed to initialize source.
		// These occurences appear to potentially lead to leaks
		UE_LOG( LogAndroidAudio, Warning, TEXT("Init SoundSource failed on %s"), *InWaveInstance->WaveData->GetName());
		UE_LOG( LogAndroidAudio, Warning, TEXT("  SampleRate %d"), InWaveInstance->WaveData->SampleRate);
		UE_LOG( LogAndroidAudio, Warning, TEXT("  Channels %d"), InWaveInstance->WaveData->NumChannels);

		if (Buffer && Buffer->ResourceID == 0)
		{
			delete Buffer;
			Buffer = 0;
		} 
	}
	return false;
}