Ejemplo n.º 1
0
EC_UICanvas::EC_UICanvas(Foundation::ModuleInterface* module) :
    Foundation::ComponentInterface(module->GetFramework()),
    entity_(0)
{
    Foundation::Framework* framework = module->GetFramework();

    boost::shared_ptr<OgreRenderer::Renderer> renderer = framework->GetServiceManager()->
            GetService<OgreRenderer::Renderer>(Foundation::Service::ST_Renderer).lock();
    if (renderer)
    {
        material_ = OgreRenderer::GetOrCreateLitTexturedMaterial(renderer->GetUniqueObjectName());
    }
}
Ejemplo n.º 2
0
    void VoiceSession::ClosePlaybackChannel()
    {
        Foundation::Framework* framework = ((Communication::CommunicationService*)(Communication::CommunicationService::GetInstance()))->GetFramework();
        if (!framework)
            return;
        ServiceManagerPtr service_manager = framework->GetServiceManager();
        if (!service_manager)
            return;
        boost::shared_ptr<ISoundService> soundsystem = service_manager->GetService<ISoundService>(Service::ST_Sound).lock();
        if (!soundsystem)
            return;   

        soundsystem->StopSound(audio_playback_channel_);
        audio_playback_channel_ = 0;
    }
Ejemplo n.º 3
0
    void VoiceSession::OnFarsightAudioDataAvailable(int count)
    {       
        if (count < AUDIO_BUFFER_PLAYBACK_MIN_SIZE)
            return;

        Foundation::Framework* framework = ((Communication::CommunicationService*)(Communication::CommunicationService::GetInstance()))->GetFramework();
        if (!framework)
            return;
        ServiceManagerPtr service_manager = framework->GetServiceManager();
        if (!service_manager)
            return;
        boost::shared_ptr<ISoundService> soundsystem = service_manager->GetService<ISoundService>(Service::ST_Sound).lock();
        if (!soundsystem)
            return;     
        if (!farsight_channel_)
            return;

        int size = farsight_channel_->GetAudioData(audio_buffer, AUDIO_BUFFER_SIZE);   

        bool stereo = false;
        int channel_count = farsight_channel_->GetChannelCount();
        if (channel_count == 2)
            stereo = true;
        int sample_width = farsight_channel_->GetSampleWidth();
        int sample_rate = farsight_channel_->GetSampleRate();

        ISoundService::SoundBuffer sound_buffer;
        sound_buffer.data_.resize(size);
        memcpy(&sound_buffer.data_[0], audio_buffer, size);
        sound_buffer.frequency_ = sample_rate;
        if (sample_width == 16)
            sound_buffer.sixteenbit_ = true;
        else
            sound_buffer.sixteenbit_ = false;
        sound_buffer.stereo_ = stereo;
        if (size > 0 && sample_rate != -1 && sample_width != -1 && (channel_count == 1 || channel_count == 2) )
        {
            if (spatial_audio_playback_)
                audio_playback_channel_ = soundsystem->PlaySoundBuffer3D(sound_buffer,  ISoundService::Voice, audio_playback_position_, audio_playback_channel_);
            else
                audio_playback_channel_ = soundsystem->PlaySoundBuffer(sound_buffer,  ISoundService::Voice, audio_playback_channel_);
        }
    }