void COggStream::Update() { if (stopped) { return; } unsigned tick = SDL_GetTicks(); if (!paused) { if (UpdateBuffers()) { if (!IsPlaying()) { // source state changed if (!StartPlaying()) { // stream stopped ReleaseBuffers(); } else { // stream interrupted ReleaseBuffers(); } } } else if (!IsPlaying()) { // EOS and all chunks processed by OpenALs ReleaseBuffers(); } msecsPlayed += (tick - lastTick); } lastTick = tick; }
/* void SetupStars() { if (stars!=null && RPold.noStars == m_renderingParams->noStars && RPold.starStrength == m_renderingParams->starStrength && RPold.starSize == m_renderingParams->starSize && m_renderingParams->starSizeSpread == RPold.starSizeSpread) if (m_renderingParams->size == stars._width) return; stars = new ColorBuffer2D(m_renderingParams->size, m_renderingParams->size); stars.RenderStars(m_renderingParams->noStars, m_renderingParams->starSize/100f, m_renderingParams->starSizeSpread/100f,m_renderingParams->starStrength); RPold.starSizeSpread = m_renderingParams->starSizeSpread; RPold.starSize = m_renderingParams->starSize; RPold.noStars = m_renderingParams->noStars; RPold.starStrength = m_renderingParams->starStrength; } */ void Rasterizer::PrepareBuffer() { // Do not changes buffers if rendering! if (m_state == State::rendering) { qDebug() << "RETURNING STILL RENDERING"; return; } int size = m_renderingParams->size(); if (m_imageBuffer == nullptr || m_imageBuffer->width() != size || m_imageShadowBuffer->width()!=size) { ReleaseBuffers(); m_imageBuffer = new QImage(size,size,QImage::Format_ARGB32); m_renderBuffer = new Buffer2D(size); m_backBuffer = new Buffer2D(size); m_imageShadowBuffer = new QImage(size, size,QImage::Format_ARGB32); m_starsBuffer = new Buffer2D(size); RenderStars(); } m_imageBuffer->fill(QColor(0,0,0)); m_backBuffer->fill(QVector3D(0,0,0)); m_renderBuffer->fill(QVector3D(0,0,0)); m_imageShadowBuffer->fill(QColor(0,0,0)); }
bool CMMALRenderer::Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, ERenderFormat format, unsigned extended_format, unsigned int orientation) { CSingleLock lock(m_sharedSection); ReleaseBuffers(); m_sourceWidth = width; m_sourceHeight = height; m_renderOrientation = orientation; m_fps = fps; m_iFlags = flags; CLog::Log(LOGDEBUG, "%s::%s - %dx%d->%dx%d@%.2f flags:%x format:%d ext:%x orient:%d", CLASSNAME, __func__, width, height, d_width, d_height, fps, flags, format, extended_format, orientation); m_RenderUpdateCallBackFn = NULL; m_RenderUpdateCallBackCtx = NULL; // calculate the input frame aspect ratio CalculateFrameAspectRatio(d_width, d_height); SetViewMode(CMediaSettings::GetInstance().GetCurrentVideoSettings().m_ViewMode); ManageDisplay(); m_bMMALConfigured = init_vout(format); m_bConfigured = m_bMMALConfigured; assert(m_bConfigured); return m_bConfigured; }
bool CMMALRenderer::Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, ERenderFormat format, unsigned extended_format, unsigned int orientation) { CSingleLock lock(m_sharedSection); ReleaseBuffers(); m_sourceWidth = width; m_sourceHeight = height; m_renderOrientation = orientation; m_fps = fps; m_iFlags = flags; // cause SetVideoRect to trigger - needed after a hdmi mode change m_src_rect.SetRect(0, 0, 0, 0); m_dst_rect.SetRect(0, 0, 0, 0); CLog::Log(LOGDEBUG, "%s::%s - %dx%d->%dx%d@%.2f flags:%x format:%d ext:%x orient:%d", CLASSNAME, __func__, width, height, d_width, d_height, fps, flags, format, extended_format, orientation); if (format != RENDER_FMT_BYPASS && format != RENDER_FMT_MMAL) { CLog::Log(LOGERROR, "%s::%s - format:%d not supported", CLASSNAME, __func__, format); return false; } // calculate the input frame aspect ratio CalculateFrameAspectRatio(d_width, d_height); SetViewMode(CMediaSettings::GetInstance().GetCurrentVideoSettings().m_ViewMode); ManageRenderArea(); m_bMMALConfigured = init_vout(format, m_opaque); m_bConfigured = m_bMMALConfigured; assert(m_bConfigured); return m_bConfigured; }
void PreviewObject::Initialize() { bool result(true); //m_pInstancedObject = ContentManager::Load<ModelComponent>(_T("./Resources/Lemmings3D/models/LemmingsCube.ovm")); //m_pInstancedObject->Initialize(); // Load the texture for this model. result = LoadTexture(GraphicsDevice::GetInstance()->GetDevice(), m_TextureFile); ASSERT(result, _T("Couldn't Load the Texture of the instancedObject!")); if(!result) { Release(); return; } // Initialize the vertex and instance buffer that hold the geometry for the triangles. result = InitializeBuffers(GraphicsDevice::GetInstance()->GetDevice()); ASSERT(result, _T("Couldn't initialize buffers of the instancedObject!")); if(!result) { ReleaseBuffers(); return; } }
void PreviewObject::Release() { // Release the model texture. ReleaseTexture(); // Release the vertex and instance buffers. ReleaseBuffers(); }
void SkyBox::KillSafely() { // Release vertex and index buffer that were used for rendering sky box. ReleaseBuffers(); ReleaseSkyBoxModel(); return; }
bool CLR_RT_HeapBlock_I2CXAction::ReleaseWhenDeadEx() { NATIVE_PROFILE_CLR_I2C(); if(!IsReadyForRelease()) return false; ReleaseBuffers(); return ReleaseWhenDead(); }
void SkyDomeClass::Shutdown() { // Release the vertex and index buffer that were used for rendering the sky dome. ReleaseBuffers(); // Release the sky dome model. ReleaseSkyDomeModel(); return; }
void cSoundStreamRenderer::Release() { ClearDataBindings(); ReleaseSources(); ReleaseBuffers(); m_BufferManager = NULL; m_SourceManager = NULL; };
// open an Ogg stream from a given file and start playing it void COggStream::Play(const std::string& path, float volume) { if (!stopped) { // we're already playing another stream return; } vorbisTags.clear(); ov_callbacks vorbisCallbacks; vorbisCallbacks.read_func = VorbisCallbacks::VorbisStreamRead; vorbisCallbacks.close_func = VorbisCallbacks::VorbisStreamClose; vorbisCallbacks.seek_func = VorbisCallbacks::VorbisStreamSeek; vorbisCallbacks.tell_func = VorbisCallbacks::VorbisStreamTell; CFileHandler* buf = new CFileHandler(path); const int result = ov_open_callbacks(buf, &oggStream, NULL, 0, vorbisCallbacks); if (result < 0) { LOG_L(L_WARNING, "Could not open Ogg stream (reason: %s).", ErrorString(result).c_str()); return; } vorbisInfo = ov_info(&oggStream, -1); { vorbis_comment* vorbisComment; vorbisComment = ov_comment(&oggStream, -1); vorbisTags.resize(vorbisComment->comments); for (unsigned i = 0; i < vorbisComment->comments; ++i) { vorbisTags[i] = std::string(vorbisComment->user_comments[i], vorbisComment->comment_lengths[i]); } vendor = std::string(vorbisComment->vendor); // DisplayInfo(); } if (vorbisInfo->channels == 1) { format = AL_FORMAT_MONO16; } else { format = AL_FORMAT_STEREO16; } alGenBuffers(2, buffers); CheckError("COggStream::Play"); if (!StartPlaying()) { ReleaseBuffers(); } else { stopped = false; paused = false; } CheckError("COggStream::Play"); }
// stops the currently playing stream void COggStream::Stop() { if (stopped) { return; } ReleaseBuffers(); msecsPlayed = 0; vorbisInfo = NULL; lastTick = SDL_GetTicks(); }
// stops the currently playing stream void COggStream::Stop() { if (stopped) { return; } ReleaseBuffers(); msecsPlayed = spring_nulltime; vorbisInfo = NULL; lastTick = spring_gettime(); }
// open an Ogg stream from a given file and start playing it void COggStream::Play(const std::string& path, const float3& pos, float volume) { if (!stopped) { // we're already playing another stream return; } int result = 0; if (!(oggFile = fopen(path.c_str(), "rb"))) { logOutput.Print("Could not open Ogg file."); return; } if ((result = ov_open(oggFile, &oggStream, NULL, 0)) < 0) { fclose(oggFile); logOutput.Print("Could not open Ogg stream (reason: %s).", ErrorString(result).c_str()); return; } vorbisInfo = ov_info(&oggStream, -1); vorbisComment = ov_comment(&oggStream, -1); // DisplayInfo(); if (vorbisInfo->channels == 1) { format = AL_FORMAT_MONO16; } else { format = AL_FORMAT_STEREO16; } alGenBuffers(2, buffers); CheckErrors(); alGenSources(1, &source); CheckErrors(); SetVolume(volume, true); alSource3f(source, AL_POSITION, pos.x, pos.y, pos.z); alSource3f(source, AL_VELOCITY, 0.0f, 0.0f, 0.0f ); alSource3f(source, AL_DIRECTION, 0.0f, 0.0f, 0.0f ); alSourcef( source, AL_ROLLOFF_FACTOR, 0.0f ); alSourcei( source, AL_SOURCE_RELATIVE, false ); if (!StartPlaying()) { ReleaseBuffers(); } else { secsPlayed = 0; lastTick = SDL_GetTicks(); stopped = false; paused = false; } }
void COggStream::Update() { if (!stopped) { UpdateTimer(); if (!paused) { if (UpdateBuffers()) { if (!IsPlaying()) { // source state changed if (!StartPlaying()) { // stream stopped ReleaseBuffers(); } else { // stream interrupted ReleaseBuffers(); } } } else { // EOS, nothing left to do ReleaseBuffers(); } } } }
void CMMALRenderer::UnInitMMAL() { CSingleLock lock(m_sharedSection); CLog::Log(LOGDEBUG, "%s::%s pool(%p)", CLASSNAME, __func__, m_vout_input_pool); if (m_queue) { StopThread(true); mmal_queue_destroy(m_queue); m_queue = nullptr; } if (m_vout) { mmal_component_disable(m_vout); } if (m_vout_input) { mmal_port_flush(m_vout_input); mmal_port_disable(m_vout_input); } ReleaseBuffers(); if (m_vout_input_pool) { mmal_port_pool_destroy(m_vout_input, m_vout_input_pool); m_vout_input_pool = NULL; } m_vout_input = NULL; if (m_vout) { mmal_component_release(m_vout); m_vout = NULL; } m_src_rect.SetRect(0, 0, 0, 0); m_dst_rect.SetRect(0, 0, 0, 0); m_video_stereo_mode = RENDER_STEREO_MODE_OFF; m_display_stereo_mode = RENDER_STEREO_MODE_OFF; m_StereoInvert = false; m_format = RENDER_FMT_NONE; m_bConfigured = false; m_bMMALConfigured = false; }
void COggStream::Update() { if (stopped) { return; } spring_time tick = spring_gettime(); if (!paused) { UpdateBuffers(); if (!IsPlaying()) { ReleaseBuffers(); } msecsPlayed += (tick - lastTick); } lastTick = tick; }
HRESULT CLR_RT_HeapBlock_I2CXAction::AllocateXAction( CLR_UINT32 numXActionUnits ) { NATIVE_PROFILE_CLR_I2C(); TINYCLR_HEADER(); CLR_UINT32 index; if(IsPending()) { TINYCLR_SET_AND_LEAVE(CLR_E_INVALID_OPERATION); } m_xActionUnits = numXActionUnits; // allocate memory for the transaction m_HalXAction = (I2C_HAL_XACTION*)CLR_RT_Memory::Allocate_And_Erase( sizeof(I2C_HAL_XACTION) ); CHECK_ALLOCATION(m_HalXAction); ((HAL_CONTINUATION*)m_HalXAction)->Initialize(); ::I2C_XAction_SetState( m_HalXAction, I2C_HAL_XACTION::c_Status_Idle ); // initialize pointers to data buffers m_dataBuffers = (I2C_WORD**)CLR_RT_Memory::Allocate_And_Erase( sizeof(I2C_WORD*) * numXActionUnits ); CHECK_ALLOCATION(m_dataBuffers); // allocate memory for the transaction units m_HalXActionUnits = (I2C_HAL_XACTION_UNIT**)CLR_RT_Memory::Allocate_And_Erase( sizeof(I2C_HAL_XACTION_UNIT*) * numXActionUnits ); CHECK_ALLOCATION(m_HalXActionUnits); for(index = 0; index < numXActionUnits; ++index) { m_HalXActionUnits[ index ] = (I2C_HAL_XACTION_UNIT*)CLR_RT_Memory::Allocate_And_Erase( sizeof(I2C_HAL_XACTION_UNIT) ); CHECK_ALLOCATION(m_HalXActionUnits[ index ]); } TINYCLR_CLEANUP(); if(FAILED(hr)) { ReleaseBuffers(); } TINYCLR_CLEANUP_END(); }
void NuiKinfuOpenCLFeedbackFrame::AcquireBuffers(UINT nWidth, UINT nHeight) { if(nWidth == m_nWidth && nHeight == m_nHeight) { return; } ReleaseBuffers(); m_nWidth = nWidth; m_nHeight = nHeight; cl_int err = CL_SUCCESS; cl_context context = NuiOpenCLGlobal::instance().clContext(); m_verticesCL = NuiGPUMemManager::instance().CreateBufferCL(context, CL_MEM_READ_WRITE, m_nWidth*m_nHeight*3*sizeof(cl_float), NULL, &err); NUI_CHECK_CL_ERR(err); m_normalsCL = NuiGPUMemManager::instance().CreateBufferCL(context, CL_MEM_READ_WRITE, m_nWidth*m_nHeight*3*sizeof(cl_float), NULL, &err); NUI_CHECK_CL_ERR(err); m_colorsCL = NuiGPUMemManager::instance().CreateBufferCL(context, CL_MEM_READ_WRITE, m_nWidth*m_nHeight*sizeof(BGRQUAD), NULL, &err); NUI_CHECK_CL_ERR(err); }
void NuiKinfuOpenCLFrame::AcquireBuffers(UINT nWidth, UINT nHeight) { if(nWidth == m_nWidth && nHeight == m_nHeight) { return; } ReleaseBuffers(); m_nWidth = nWidth; m_nHeight = nHeight; cl_int err = CL_SUCCESS; cl_context context = NuiOpenCLGlobal::instance().clContext(); m_rawDepthsCL = NuiGPUMemManager::instance().CreateBufferCL(context, CL_MEM_READ_ONLY, m_nWidth*m_nHeight*sizeof(UINT16), NULL, &err); NUI_CHECK_CL_ERR(err); m_floatDepthsCL = NuiGPUMemManager::instance().CreateBufferCL(context, CL_MEM_READ_WRITE, m_nWidth*m_nHeight*sizeof(cl_float), NULL, &err); NUI_CHECK_CL_ERR(err); m_filteredDepthsCL = NuiGPUMemManager::instance().CreateBufferCL(context, CL_MEM_READ_WRITE, m_nWidth*m_nHeight*sizeof(cl_float), NULL, &err); NUI_CHECK_CL_ERR(err); m_verticesCL = NuiGPUMemManager::instance().CreateBufferCL(context, CL_MEM_READ_WRITE, m_nWidth*m_nHeight*3*sizeof(cl_float), NULL, &err); NUI_CHECK_CL_ERR(err); //if(m_nColorWidth * m_nColorHeight > 0) { /*m_colorUVsCL = NuiGPUMemManager::instance().CreateBufferCL(context, CL_MEM_READ_ONLY, m_nWidth*m_nHeight*sizeof(ColorSpacePoint), NULL, &err); NUI_CHECK_CL_ERR(err);*/ /*cl_image_format colorImgFormat; colorImgFormat.image_channel_order = CL_BGRA; colorImgFormat.image_channel_data_type = CL_UNSIGNED_INT8; m_colorImageCL = NuiGPUMemManager::instance().CreateImage2DCL(context, CL_MEM_READ_ONLY, &colorImgFormat, m_nColorWidth, m_nColorHeight, 0, NULL, &err); NUI_CHECK_CL_ERR(err);*/ /*m_colorImageCL = NuiGPUMemManager::instance().CreateBufferCL(context, CL_MEM_READ_ONLY, m_nColorWidth*m_nColorHeight*sizeof(BGRQUAD), NULL, &err); NUI_CHECK_CL_ERR(err);*/ m_colorsCL = NuiGPUMemManager::instance().CreateBufferCL(context, CL_MEM_READ_WRITE, m_nWidth*m_nHeight*sizeof(BGRQUAD), NULL, &err); NUI_CHECK_CL_ERR(err); } }
void LODManager::OnLostDevice() { ReleaseBuffers(); }
bool CMMALRenderer::Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, ERenderFormat format, unsigned extended_format, unsigned int orientation) { ReleaseBuffers(); m_sourceWidth = width; m_sourceHeight = height; m_renderOrientation = orientation; m_fps = fps; m_iFlags = flags; m_format = format; CLog::Log(LOGDEBUG, "%s::%s - %dx%d->%dx%d@%.2f flags:%x format:%d ext:%x orient:%d", CLASSNAME, __func__, width, height, d_width, d_height, fps, flags, format, extended_format, orientation); m_RenderUpdateCallBackFn = NULL; m_RenderUpdateCallBackCtx = NULL; // calculate the input frame aspect ratio CalculateFrameAspectRatio(d_width, d_height); ChooseBestResolution(fps); m_destWidth = g_graphicsContext.GetResInfo(m_resolution).iWidth; m_destHeight = g_graphicsContext.GetResInfo(m_resolution).iHeight; SetViewMode(CMediaSettings::Get().GetCurrentVideoSettings().m_ViewMode); ManageDisplay(); if (m_format == RENDER_FMT_MMAL|| m_format == RENDER_FMT_YUV420P) { MMAL_ES_FORMAT_T *es_format = mmal_format_alloc(); es_format->type = MMAL_ES_TYPE_VIDEO; es_format->es->video.crop.width = m_sourceWidth; es_format->es->video.crop.height = m_sourceHeight; if (m_format == RENDER_FMT_MMAL) { es_format->encoding = MMAL_ENCODING_OPAQUE; es_format->es->video.width = m_sourceWidth; es_format->es->video.height = m_sourceHeight; } else if (m_format == RENDER_FMT_YUV420P) { const int pitch = ALIGN_UP(m_sourceWidth, 32); const int aligned_height = ALIGN_UP(m_sourceHeight, 16); es_format->encoding = MMAL_ENCODING_I420; es_format->es->video.width = pitch; es_format->es->video.height = aligned_height; if (CONF_FLAGS_YUVCOEF_MASK(m_iFlags) == CONF_FLAGS_YUVCOEF_BT709) es_format->es->video.color_space = MMAL_COLOR_SPACE_ITUR_BT709; else if (CONF_FLAGS_YUVCOEF_MASK(m_iFlags) == CONF_FLAGS_YUVCOEF_BT601) es_format->es->video.color_space = MMAL_COLOR_SPACE_ITUR_BT601; else if (CONF_FLAGS_YUVCOEF_MASK(m_iFlags) == CONF_FLAGS_YUVCOEF_240M) es_format->es->video.color_space = MMAL_COLOR_SPACE_SMPTE240M; } if (m_bConfigured) UnInitMMAL(); m_bConfigured = init_vout(es_format); mmal_format_free(es_format); } else m_bConfigured = true; return m_bConfigured; }
bool mlrVoice::AllocateBuffers(void) { SOUNDLIST *Sample; if (gVoiceCount > g_nDynamicVoices){ ReleaseBuffers(); return(false); } // incase we already have what we need if (!DSoundBuffer){ // going to get info from Sample already loaded. if(gSoundDriver) { Sample=gSoundDriver->FindSample(sfx->handle); if( Sample && Sample->Buf[0].DSoundBuffer) // MLR 3/7/2004 - prevent CTDs { ///////////// gSoundDriver->DSound->DuplicateSoundBuffer(Sample->Buf[0].DSoundBuffer,&DSoundBuffer); if(DSoundBuffer) { gVoiceCount++; freq = Sample->Frequency; } } } } if(DSoundBuffer) { if( is3d ) { if(!DSound3dBuffer) { if( /*sfx->flags & SFX_FLAGS_3D && */ g3dVoiceCount<16 ) { DSoundBuffer->QueryInterface(IID_IDirectSound3DBuffer, (LPVOID *)&DSound3dBuffer); if ( DSound3dBuffer )// && // sfx && // (sfx->flags & SFX_POS_EXTERN) && // (sfx->flags & SFX_FLAGS_3D)) // only make external 3d sounds 3d { g3dVoiceCount++; float maxdist = (float) sqrt(sfx->maxDistSq); float mindist = sfx->min3ddist; if ( mindist == 0 ) mindist = maxdist / 20.0f; DSound3dBuffer->SetMaxDistance(maxdist, DS3D_DEFERRED); DSound3dBuffer->SetMinDistance(mindist, DS3D_DEFERRED); DSound3dBuffer->SetMode(DS3DMODE_NORMAL, DS3D_DEFERRED); return true; } else { ReleaseBuffers() return false; } } } else { if(DSound3dBuffer) { g3dVoiceCount--; DSound3dBuffer->Release(); DSound3dBuffer = 0; } } return true; }
mlrVoice::~mlrVoice(){ gVoiceManager.Lock(); ReleaseBuffers(); ANode::Remove(); gVoiceManager.Unlock(); }
NuiKinfuOpenCLFeedbackFrame::~NuiKinfuOpenCLFeedbackFrame() { ReleaseBuffers(); }
void LODManager::OnReleaseDevice() { ReleaseBuffers(); Reset(); }
// stops the currently playing stream void COggStream::Stop() { if (!stopped) { ReleaseBuffers(); } }
void LODManager::OnResetDevice() { ReleaseBuffers(); InitializeBuffers(); }
void FX_CSkinRenderer::Cleanup () { ReleaseBuffers(); return; }