Ejemplo n.º 1
0
SoundInstance * Sound::Play()
{
	if(TYPE_STREAMED == type && soundInstances.size())
	{
		return soundInstances.front();
	}

	SoundChannel * ch = SoundSystem::Instance()->FindChannel(priority);
	if(!ch)
	{
		return 0;
	}

	if(TYPE_STREAMED == type)
	{
		provider->Init();
		provider->Rewind();
		PrepareDynamicBuffers();
	}

	SoundInstance * inst = new SoundInstance();
	inst->buddyChannel = ch;
	AddSoundInstance(inst);
	ch->SetVolume(volume);
	ch->Play(this, looping);
	return inst;
}
Ejemplo n.º 2
0
SoundInstance * Sound::Play()
{
#ifdef __DAVAENGINE_ANDROID__
    SLresult result;
    
    if(TYPE_STATIC == type)
    {
        result = (*playerBufferQueue)->Clear(playerBufferQueue);
        DVASSERT(SL_RESULT_SUCCESS == result);
        
        buffer->FullFill(provider, playerBufferQueue);
    }
    
    if(TYPE_STREAMED == type)
    {
        result = (*playerSeek)->SetPosition(playerSeek, 0, SL_SEEKMODE_FAST);
        DVASSERT(SL_RESULT_SUCCESS == result);
    }

    result = (*playerPlay)->SetPlayState(playerPlay, SL_PLAYSTATE_PLAYING);
    DVASSERT(SL_RESULT_SUCCESS == result);
    
    soundInstances.clear();
    
    SoundInstance * inst = new SoundInstance(this);
    AddSoundInstance(inst);
    
    return soundInstances.front();
#else
    
	if(TYPE_STREAMED == type && soundInstances.size())
	{
		return soundInstances.front();
	}

	SoundChannel * ch = SoundSystem::Instance()->FindChannel(priority);
	if(!ch)
	{
		return 0;
	}

	if(TYPE_STREAMED == type)
	{
		PrepareDynamicBuffers();
	}

	SoundInstance * inst = new SoundInstance();
	inst->buddyChannel = ch;
	AddSoundInstance(inst);
	ch->SetVolume(volume);
	ch->Play(this, looping);
	return inst;
#endif //#ifdef __DAVAENGINE_ANDROID__
}