SharedSurface* SurfaceStream_TripleBuffer_Copy::SwapProducer(SurfaceFactory* factory, const gfxIntSize& size) { MonitorAutoLock lock(mMonitor); RecycleScraps(factory); if (mProducer) { if (mStaging && mStaging->Type() != factory->Type()) Recycle(factory, mStaging); if (!mStaging) New(factory, mProducer->Size(), mStaging); if (!mStaging) return nullptr; SharedSurface::Copy(mProducer, mStaging, factory); // Fence now, before we start (maybe) juggling Prod around. mStaging->Fence(); if (mProducer->Size() != size) Recycle(factory, mProducer); } // The old Prod (if there every was one) was invalid, // so we need a new one. if (!mProducer) { New(factory, size, mProducer); } return mProducer; }
void GSDevice11::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1 (&iaVertices)[4], bool datm) { const GSVector2i& size = rt->GetSize(); if(GSTexture* t = CreateRenderTarget(size.x, size.y, rt->IsMSAA())) { // sfex3 (after the capcom logo), vf4 (first menu fading in), ffxii shadows, rumble roses shadows, persona4 shadows BeginScene(); ClearStencil(ds, 0); // om OMSetDepthStencilState(m_date.dss, 1); OMSetBlendState(m_date.bs, 0); OMSetRenderTargets(t, ds); // ia IASetVertexBuffer(iaVertices, sizeof(iaVertices[0]), countof(iaVertices)); IASetInputLayout(m_convert.il); IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); // vs VSSetShader(m_convert.vs, NULL); // gs GSSetShader(NULL); // ps GSTexture* rt2 = rt->IsMSAA() ? Resolve(rt) : rt; PSSetShaderResources(rt2, NULL); PSSetSamplerState(m_convert.pt, NULL); PSSetShader(m_convert.ps[datm ? 2 : 3], NULL); // DrawPrimitive(); // EndScene(); Recycle(t); if(rt2 != rt) Recycle(rt2); } }
char* nsInstallUninstall::toString() { char* buffer = new char[1024]; char* rsrcVal = nsnull; if (buffer == nsnull || !mInstall) return buffer; char* temp = ToNewCString(mUIName); if (temp) { rsrcVal = mInstall->GetResourcedString(NS_LITERAL_STRING("Uninstall")); if (rsrcVal) { sprintf( buffer, rsrcVal, temp); nsCRT::free(rsrcVal); } } if (temp) Recycle(temp); return buffer; }
bool IOBuffer::WriteToTCPFd(int32_t fd, uint32_t size, int32_t &sentAmount) { SANITY_INPUT_BUFFER; bool result = true; if (size == 0) return true; sentAmount = send(fd, (char *) (_pBuffer + _consumed), //_published - _consumed, size > _published - _consumed ? _published - _consumed : size, MSG_NOSIGNAL); if (sentAmount < 0) { int err = LASTSOCKETERROR; if ((err != SOCKERROR_EAGAIN)&&(err != SOCKERROR_EINPROGRESS)) { FATAL("Unable to send %"PRIu32" bytes of data data. Size advertised by network layer was %"PRIu32". Permanent error: %d", _published - _consumed, size, err); result = false; } } else { _consumed += sentAmount; } if (result) Recycle(); SANITY_INPUT_BUFFER; return result; }
bool GSDevice10::CopyOffscreen(Texture& src, const GSVector4& sr, Texture& dst, int w, int h, int format) { dst = Texture(); if(format == 0) { format = DXGI_FORMAT_R8G8B8A8_UNORM; } if(format != DXGI_FORMAT_R8G8B8A8_UNORM && format != DXGI_FORMAT_R16_UINT) { ASSERT(0); return false; } Texture rt; if(CreateRenderTarget(rt, w, h, format)) { GSVector4 dr(0, 0, w, h); StretchRect(src, sr, rt, dr, m_convert.ps[format == DXGI_FORMAT_R16_UINT ? 1 : 0], NULL); if(CreateOffscreen(dst, w, h, format)) { m_dev->CopyResource(dst, rt); } } Recycle(rt); return !!dst; }
SharedSurface* SurfaceStream_TripleBuffer_Copy::SwapProducer(SurfaceFactory* factory, const gfxIntSize& size) { MonitorAutoLock lock(mMonitor); RecycleScraps(factory); if (mProducer) { if (mStaging) { // We'll re-use this for a new mProducer later on if // the size remains the same Recycle(factory, mStaging); } Move(mProducer, mStaging); mStaging->Fence(); New(factory, size, mProducer); if (mProducer && mStaging->Size() == mProducer->Size()) SharedSurface::Copy(mStaging, mProducer, factory); } else { New(factory, size, mProducer); } return mProducer; }
bool IOBuffer::WriteToTCPFd(int32_t fd, uint32_t size, int32_t &sentAmount) { SANITY_INPUT_BUFFER; bool result = true; sentAmount = send(fd, (char *) (_pBuffer + _consumed), //_published - _consumed, size > _published - _consumed ? _published - _consumed : size, MSG_NOSIGNAL); int err = LASTSOCKETERROR; if (sentAmount < 0) { if (err != SOCKERROR_SEND_IN_PROGRESS) { FATAL("Unable to send %u bytes of data data. Size advertised by network layer was %u [%d: %s]", _published - _consumed, size, err, strerror(err)); FATAL("Permanent error!"); result = false; } } else { _consumed += sentAmount; } if (result) Recycle(); SANITY_INPUT_BUFFER; return result; }
bool FairnessChecker::CheckInstanceSatisfaction(u32 Instance, u32 CmdID, const ProductState* ReachedState) const { // Do we even need to look at the cmd and the state? if (CheckInstanceSatisfaction(Instance)) { return true; } // Assumes that we're not trivially satisfied if (IsStrong || !DisabledPerInstance.Test(Instance)) { return GCmdsToRespondTo[Instance].Test(CmdID); } else { for (auto CmdID : GCmdIDsToRespondTo[Instance]) { bool Exception; ExpT NEPred; auto NSVec = TryExecuteCommand(Checker->GuardedCommands[CmdID], ReachedState->GetSVPtr(), Exception, NEPred); if (NSVec != nullptr) { NSVec->Recycle(); return false; } } return true; } }
status_t DPCQueue::Add(void (*function)(void*), void* argument) { if (function == NULL) return B_BAD_VALUE; // get a free callback InterruptsSpinLocker locker(fLock); DPCCallback* callback = fUnusedFunctionCallbacks.RemoveHead(); if (callback == NULL) return B_NO_MEMORY; locker.Unlock(); // init the callback FunctionDPCCallback* functionCallback = static_cast<FunctionDPCCallback*>(callback); functionCallback->SetTo(function, argument); // add it status_t error = Add(functionCallback); if (error != B_OK) Recycle(functionCallback); return error; }
BOOL Obj_Item::HeartBeat(UINT uTime/* =0 */) { __ENTER_FUNCTION BOOL bResult = Obj_Static::HeartBeat( uTime ); if ( !bResult ) return FALSE; UpdateZone(); if( m_RecycleTimer.CountingTimer(uTime) ) { //回收操作 // Recycle(); return TRUE; } return TRUE; __LEAVE_FUNCTION return FALSE; }
NS_METHOD LocalSearchDataSource::parseResourceIntoFindTokens(nsIRDFResource *u, findTokenPtr tokens) { const char *uri = nsnull; char *id, *token, *value, *newstr; int loop; nsresult rv; if (NS_FAILED(rv = u->GetValueConst(&uri))) return(rv); #ifdef DEBUG printf("Find: %s\n", (const char*) uri); #endif if (!(id = PL_strdup(uri + sizeof(kFindProtocol) - 1))) return(NS_ERROR_OUT_OF_MEMORY); /* parse ID, build up token list */ if ((token = nsCRT::strtok(id, "&", &newstr)) != NULL) { while (token != NULL) { if ((value = strstr(token, "=")) != NULL) { *value++ = '\0'; } for (loop=0; tokens[loop].token != NULL; loop++) { if (!strcmp(token, tokens[loop].token)) { if (!strcmp(token, "text")) { nsCOMPtr<nsITextToSubURI> textToSubURI = do_GetService(kTextToSubURICID, &rv); if (NS_SUCCEEDED(rv) && (textToSubURI)) { PRUnichar *uni = nsnull; if (NS_SUCCEEDED(rv = textToSubURI->UnEscapeAndConvert("UTF-8", value, &uni)) && (uni)) { tokens[loop].value = uni; Recycle(uni); } } } else { nsAutoString valueStr; valueStr.AssignWithConversion(value); tokens[loop].value = valueStr; } break; } } token = nsCRT::strtok(newstr, "&", &newstr); } } PL_strfree(id); return(NS_OK); }
bool IOBuffer::Ignore(uint32_t size) { SANITY_INPUT_BUFFER; _consumed += size; Recycle(); SANITY_INPUT_BUFFER; return true; }
bool IOBuffer::IgnoreAll() { SANITY_INPUT_BUFFER; _consumed = _published; Recycle(); SANITY_INPUT_BUFFER; return true; }
BOOL Obj_ItemBox::HeartBeat(UINT uTime/* =0 */) { __ENTER_FUNCTION BOOL bResult = Obj_Static::HeartBeat( uTime ); if ( !bResult ) return FALSE; // temp code { UpdateZone(); // } if( m_RecycleTimer.CountingTimer(uTime) ) { //回收操作 // Recycle(); return TRUE; } if(m_LifeTimer.CountingTimer(uTime)) { INT ItemBoxType = GetType(); _GROW_POINT_INFO* pGET = g_GrowPointInfoTbl.Get(ItemBoxType); Assert(pGET); if(pGET->m_ScriptID>0) { _MY_TRY { if(getScene() && getScene()->GetGrowPointManager()->CallScriptRecycleFunc(pGET->m_ScriptID,GetOwner(),GetID(),getScene()->SceneID())) { //可以Recycle Recycle(); } } _MY_CATCH { //可以Recycle SaveCodeLog( ) ; Recycle(); } }
void GSDevice::Merge(GSTexture* sTex[2], GSVector4* sRect, GSVector4* dRect, const GSVector2i& fs, bool slbg, bool mmod, const GSVector4& c) { if(m_merge == NULL || m_merge->GetSize() != fs) { Recycle(m_merge); m_merge = CreateRenderTarget(fs.x, fs.y, false); } // TODO: m_1x1 // KH:COM crashes at startup when booting *through the bios* due to m_merge being NULL. // (texture appears to be non-null, and is being re-created at a size around like 1700x340, // dunno if that's relevant) -- air if(m_merge) { GSTexture* tex[2] = {NULL, NULL}; for(size_t i = 0; i < countof(tex); i++) { if(sTex[i] != NULL) { tex[i] = sTex[i]->IsMSAA() ? Resolve(sTex[i]) : sTex[i]; } } DoMerge(tex, sRect, m_merge, dRect, slbg, mmod, c); for(size_t i = 0; i < countof(tex); i++) { if(tex[i] != sTex[i]) { Recycle(tex[i]); } } } else { printf("GSdx: m_merge is NULL!\n"); } m_current = m_merge; }
void SurfaceStream::RecycleScraps(SurfaceFactory* factory) { while (!mScraps.empty()) { SharedSurface* cur = mScraps.top(); mScraps.pop(); Recycle(factory, cur); } }
// In-order tree traversal to delete cells. Called by ~BST. void BST::Autumn(BasePtr &Node) { if (Node) {//Note: Node->Right may be lost on the "delete Node" BasePtr Hold = Node->Right; Autumn(Node->Left); Recycle(Node); // Note that this NULLs out Node Autumn(Hold); } }
GSTexture* GSDevice11::CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format, int ps_shader) { GSTexture* dst = NULL; if(format == 0) { format = DXGI_FORMAT_R8G8B8A8_UNORM; } if(format != DXGI_FORMAT_R8G8B8A8_UNORM && format != DXGI_FORMAT_R16_UINT) { ASSERT(0); return false; } if(GSTexture* rt = CreateRenderTarget(w, h, false, format)) { GSVector4 dRect(0, 0, w, h); if(GSTexture* src2 = src->IsMSAA() ? Resolve(src) : src) { StretchRect(src2, sRect, rt, dRect, m_convert.ps[format == DXGI_FORMAT_R16_UINT ? 1 : 0], NULL); if(src2 != src) Recycle(src2); } dst = CreateOffscreen(w, h, format); if(dst) { m_ctx->CopyResource(*(GSTexture11*)dst, *(GSTexture11*)rt); } Recycle(rt); } return dst; }
UartDevice::TxBuffer::Block& UartDevice::TxBuffer::Block::operator=(Block &&rhs) { if (this != &rhs) { Byte* const data_ = rhs.data.byte_; bool is_mem_owned_ = rhs.is_mem_owned; Recycle(); rhs.data.byte_ = nullptr; rhs.is_mem_owned = false; data.byte_ = data_; type = rhs.type; size = rhs.size; it = rhs.it; is_mem_owned = is_mem_owned_; } return *this; }
SharedSurface* SurfaceStream_TripleBuffer::SwapProducer(SurfaceFactory* factory, const gfxIntSize& size) { MutexAutoLock lock(mMutex); if (mProducer) { RecycleScraps(factory); if (mStaging) Recycle(factory, mStaging); Move(mProducer, mStaging); mStaging->Fence(); } MOZ_ASSERT(!mProducer); New(factory, size, mProducer); return mProducer; }
bool IOBuffer::WriteToStdio(int32_t fd, uint32_t size, int32_t &sentAmount) { SANITY_INPUT_BUFFER; bool result = true; sentAmount = WRITE_FD(fd, (char *) (_pBuffer + _consumed), _published - _consumed); //size > _published - _consumed ? _published - _consumed : size, int err = errno; if (sentAmount < 0) { FATAL("Unable to send %"PRIu32" bytes of data data. Size advertised by network layer was %"PRIu32". Permanent error: (%d) %s", _published - _consumed, size, err, strerror(err)); result = false; } else { _consumed += sentAmount; } if (result) Recycle(); SANITY_INPUT_BUFFER; return result; }
SharedSurface* SurfaceStream_SingleBuffer::SwapProducer(SurfaceFactory* factory, const gfxIntSize& size) { MonitorAutoLock lock(mMonitor); if (mConsumer) { Recycle(factory, mConsumer); } if (mProducer) { // Fence now, before we start (maybe) juggling Prod around. mProducer->Fence(); // Size mismatch means we need to squirrel the current Prod // into Cons, and leave Prod empty, so it gets a new surface below. bool needsNewBuffer = mProducer->Size() != size; // Even if we're the right size, if the type has changed, and we don't // need to preserve, we should switch out for (presumedly) better perf. if (mProducer->Type() != factory->Type() && !factory->Caps().preserve) { needsNewBuffer = true; } if (needsNewBuffer) { Move(mProducer, mConsumer); } } // The old Prod (if there every was one) was invalid, // so we need a new one. if (!mProducer) { New(factory, size, mProducer); } return mProducer; }
/* 功能描述 : 开始服务 返回值 : 成功为0,失败为-1 参数 : 无 日期 : 2015年5月26日 15:45:53 */ int Session::Serve() { struct sockaddr_un client_address; int bytes_received = 0; static char buf[BUF_SIZE]; socklen_t address_length = 0; while (1) { memset(&client_address,0,sizeof(client_address)); bytes_received = recvfrom(socket_fd, buf, BUF_SIZE, 0, (struct sockaddr *) &client_address, &address_length); if (0 < bytes_received) { if (0 != strcmp(client_address.sun_path, ClientSockPath)) { printf("ci client sock path wrong:%s\n",client_address.sun_path); continue; } } /* * 若session过期则进行回收并重新利用 * 因为recvfrom超时后会返回,所以保证了当链接中断时,内存当中的数据很快被同步到硬盘上 */ if (CheckExpired() || ConsumeManualRecycle()) { Recycle(); } if (0 < bytes_received) { Write(buf, bytes_received); gettimeofday(&last_ac_time,NULL); } } return 0; }
LRESULT WINAPI ShellTrayWndProc( HWND hWnd, UINT nMessage, WPARAM wParam, LPARAM lParam ) { switch( nMessage ) { case WM_COPYDATA: { PCOPYDATASTRUCT pcds; pcds = (PCOPYDATASTRUCT) lParam; if( pcds->dwData != 1 ) return FALSE; return SystrayMessage( (PSHELLTRAYDATA) pcds->lpData ); } case LM_HIDETRAY: { ShowWindow( hSystray, SW_HIDE ); return 0; } case LM_SHOWTRAY: { ShowWindow( hSystray, SW_SHOWNOACTIVATE ); return 0; } case LM_RECYCLETRAY: { Recycle(); return 0; } } return DefWindowProc( hWnd, nMessage, wParam, lParam ); }
TEST_F(GlobalAllocatorTest, RequestBlock) { auto instance = gcix::GlobalAllocator::Instance; ASSERT_NE(nullptr, instance); // Check internals ASSERT_EQ(0, instance->Chunks.Count()); // Request a memory block auto blockData0 = instance->RequestBlock(false); ASSERT_EQ(1, instance->Chunks.Count()); // Gets the chunk auto chunk0 = instance->Chunks[0]; ASSERT_NE(nullptr, chunk0); // Check that a chunk has the same address as the first block data EXPECT_EQ((void*)chunk0, (void*)blockData0); EXPECT_TRUE(chunk0->IsFree()); EXPECT_TRUE(chunk0->HasFreeBlocks()); EXPECT_FALSE(chunk0->HasRecyclableBlocks()); // Check block count per chunk EXPECT_EQ(Constants::BlockCountPerChunk, chunk0->GetBlockCount()); // Check allocated blocks for (int i = 0; i < chunk0->GetBlockCount(); i++) { auto block = chunk0->GetBlock(i); if (i == 0) { EXPECT_EQ(block, blockData0); } EXPECT_TRUE(block->IsFree()); EXPECT_FALSE(block->IsRecyclable()); EXPECT_FALSE(block->IsUnavailable()); // Check that all block data are aligned on a block size EXPECT_EQ(0, (intptr_t)block & Constants::BlockSizeInBytesMask); // Check line flags are empty for (uint32_t lineIndex = Constants::HeaderLineCount; lineIndex < Constants::LineCount; lineIndex++) { EXPECT_EQ(LineFlags::Empty, block->Header.LineFlags[lineIndex]); // Check line datas are empty for (uint32_t columnIndex = 0; columnIndex < Constants::LineSizeInBytes; columnIndex++) { EXPECT_EQ(0, block->Lines[lineIndex][columnIndex]); } } } // Check Bump cursor in BlockData, must be equal to the header size EXPECT_EQ(Constants::HeaderSizeInBytes, blockData0->Header.Info.BumpCursor); // Check BumpCursorLimit = 0 EXPECT_EQ(0, blockData0->Header.Info.BumpCursorLimit); // Check Chunk min/max memory auto minChunkAddress = chunk0; auto maxChunkAddress = (Chunk*)((intptr_t)chunk0 + Constants::BlockSizeInBytes * Constants::BlockCountPerChunk); // Check pointers inside the chunk EXPECT_TRUE(instance->Chunks.Contains(chunk0)); EXPECT_TRUE(instance->Chunks.Contains((Chunk*)((intptr_t)maxChunkAddress - 1))); // Check pointers outside the chunk EXPECT_FALSE(instance->Chunks.Contains((Chunk*)((intptr_t)chunk0 - 1))); EXPECT_FALSE(instance->Chunks.Contains(maxChunkAddress)); // Allocate remaining blocks into the chunk for (int i = 1; i < chunk0->GetBlockCount(); i++) { auto nextBlock = instance->RequestBlock(false); EXPECT_TRUE(instance->Chunks.Contains((Chunk*)nextBlock)); } // Reallocate a new block from a new chunk auto nextBlockOfNextChunj = instance->RequestBlock(false); auto nextChunk = (Chunk*)nextBlockOfNextChunj; EXPECT_TRUE(nextChunk < minChunkAddress || nextChunk > maxChunkAddress); // Recycle freshly allocated block, as they have not been marked, the nextChunk must be freed by the recycle // while the firstChunk must be kept for future allocation. instance->Recycle(); EXPECT_EQ(1, instance->Chunks.Count()); // TODO Add tests after recycle }
ECode InputEvent::RecycleIfNeededAfterDispatch() { return Recycle(); }
int CMMALVideo::Decode(uint8_t* pData, int iSize, double dts, double pts) { //if (g_advancedSettings.CanLogComponent(LOGVIDEO)) // CLog::Log(LOGDEBUG, "%s::%s - %-8p %-6d dts:%.3f pts:%.3f dts_queue(%d) ready_queue(%d) busy_queue(%d)", // CLASSNAME, __func__, pData, iSize, dts == DVD_NOPTS_VALUE ? 0.0 : dts*1e-6, pts == DVD_NOPTS_VALUE ? 0.0 : pts*1e-6, m_dts_queue.size(), m_output_ready.size(), m_output_busy); unsigned int demuxer_bytes = 0; uint8_t *demuxer_content = NULL; MMAL_BUFFER_HEADER_T *buffer; MMAL_STATUS_T status; while (buffer = mmal_queue_get(m_dec_output_pool->queue), buffer) Recycle(buffer); // we need to queue then de-queue the demux packet, seems silly but // mmal might not have an input buffer available when we are called // and we must store the demuxer packet and try again later. // try to send any/all demux packets to mmal decoder. unsigned space = mmal_queue_length(m_dec_input_pool->queue) * m_dec_input->buffer_size; if (pData && m_demux_queue.empty() && space >= (unsigned int)iSize) { demuxer_bytes = iSize; demuxer_content = pData; } else if (pData && iSize) { mmal_demux_packet demux_packet; demux_packet.dts = dts; demux_packet.pts = pts; demux_packet.size = iSize; demux_packet.buff = new uint8_t[iSize]; memcpy(demux_packet.buff, pData, iSize); m_demux_queue_length += demux_packet.size; m_demux_queue.push(demux_packet); } uint8_t *buffer_to_free = NULL; while (1) { while (buffer = mmal_queue_get(m_dec_output_pool->queue), buffer) Recycle(buffer); space = mmal_queue_length(m_dec_input_pool->queue) * m_dec_input->buffer_size; if (!demuxer_bytes && !m_demux_queue.empty()) { mmal_demux_packet &demux_packet = m_demux_queue.front(); if (space >= (unsigned int)demux_packet.size) { // need to lock here to retrieve an input buffer and pop the queue m_demux_queue_length -= demux_packet.size; m_demux_queue.pop(); demuxer_bytes = (unsigned int)demux_packet.size; demuxer_content = demux_packet.buff; buffer_to_free = demux_packet.buff; dts = demux_packet.dts; pts = demux_packet.pts; } } if (demuxer_content) { // 500ms timeout buffer = mmal_queue_timedwait(m_dec_input_pool->queue, 500); if (!buffer) { CLog::Log(LOGERROR, "%s::%s - mmal_queue_get failed", CLASSNAME, __func__); return VC_ERROR; } mmal_buffer_header_reset(buffer); buffer->cmd = 0; if (m_startframe && pts == DVD_NOPTS_VALUE) pts = 0; buffer->pts = pts == DVD_NOPTS_VALUE ? MMAL_TIME_UNKNOWN : pts; buffer->dts = dts == DVD_NOPTS_VALUE ? MMAL_TIME_UNKNOWN : dts; buffer->length = demuxer_bytes > buffer->alloc_size ? buffer->alloc_size : demuxer_bytes; buffer->user_data = (void *)m_decode_frame_number; // set a flag so we can identify primary frames from generated frames (deinterlace) buffer->flags = MMAL_BUFFER_HEADER_FLAG_USER0; // Request decode only (maintain ref frames, but don't return a picture) if (m_drop_state) buffer->flags |= MMAL_BUFFER_HEADER_FLAG_DECODEONLY; memcpy(buffer->data, demuxer_content, buffer->length); demuxer_bytes -= buffer->length; demuxer_content += buffer->length; if (demuxer_bytes == 0) buffer->flags |= MMAL_BUFFER_HEADER_FLAG_FRAME_END; if (g_advancedSettings.CanLogComponent(LOGVIDEO)) CLog::Log(LOGDEBUG, "%s::%s - %-8p %-6d/%-6d dts:%.3f pts:%.3f flags:%x dts_queue(%d) ready_queue(%d) busy_queue(%d) demux_queue(%d) space(%d)", CLASSNAME, __func__, buffer, buffer->length, demuxer_bytes, dts == DVD_NOPTS_VALUE ? 0.0 : dts*1e-6, pts == DVD_NOPTS_VALUE ? 0.0 : pts*1e-6, buffer->flags, m_dts_queue.size(), m_output_ready.size(), m_output_busy, m_demux_queue_length, mmal_queue_length(m_dec_input_pool->queue) * m_dec_input->buffer_size); assert((int)buffer->length > 0); status = mmal_port_send_buffer(m_dec_input, buffer); if (status != MMAL_SUCCESS) { CLog::Log(LOGERROR, "%s::%s Failed send buffer to decoder input port (status=%x %s)", CLASSNAME, __func__, status, mmal_status_to_string(status)); return VC_ERROR; } if (demuxer_bytes == 0) { m_decode_frame_number++; m_startframe = true; if (m_drop_state) { m_droppedPics += m_deint ? 2:1; } else { // only push if we are successful with feeding mmal pthread_mutex_lock(&m_output_mutex); m_dts_queue.push(dts); assert(m_dts_queue.size() < 5000); pthread_mutex_unlock(&m_output_mutex); } if (m_changed_count_dec != m_changed_count) { if (g_advancedSettings.CanLogComponent(LOGVIDEO)) CLog::Log(LOGDEBUG, "%s::%s format changed frame:%d(%d)", CLASSNAME, __func__, m_changed_count_dec, m_changed_count); m_changed_count_dec = m_changed_count; if (!change_dec_output_format()) { CLog::Log(LOGERROR, "%s::%s - change_dec_output_format() failed", CLASSNAME, __func__); return VC_ERROR; } } EDEINTERLACEMODE deinterlace_request = CMediaSettings::Get().GetCurrentVideoSettings().m_DeinterlaceMode; EINTERLACEMETHOD interlace_method = g_renderManager.AutoInterlaceMethod(CMediaSettings::Get().GetCurrentVideoSettings().m_InterlaceMethod); bool deinterlace = m_interlace_mode != MMAL_InterlaceProgressive; if (deinterlace_request == VS_DEINTERLACEMODE_OFF) deinterlace = false; else if (deinterlace_request == VS_DEINTERLACEMODE_FORCE) deinterlace = true; if (((deinterlace && interlace_method != m_interlace_method) || !deinterlace) && m_deint) DestroyDeinterlace(); if (deinterlace && !m_deint) CreateDeinterlace(interlace_method); if (buffer_to_free) { delete [] buffer_to_free; buffer_to_free = NULL; demuxer_content = NULL; continue; } while (buffer = mmal_queue_get(m_dec_output_pool->queue), buffer) Recycle(buffer); } } if (!demuxer_bytes) break; } int ret = 0; if (!m_output_ready.empty()) { if (g_advancedSettings.CanLogComponent(LOGVIDEO)) CLog::Log(LOGDEBUG, "%s::%s - got space for output: demux_queue(%d) space(%d)", CLASSNAME, __func__, m_demux_queue_length, mmal_queue_length(m_dec_input_pool->queue) * m_dec_input->buffer_size); ret |= VC_PICTURE; } if (mmal_queue_length(m_dec_input_pool->queue) > 0 && !m_demux_queue_length) { if (g_advancedSettings.CanLogComponent(LOGVIDEO)) CLog::Log(LOGDEBUG, "%s::%s - got output picture:%d", CLASSNAME, __func__, m_output_ready.size()); ret |= VC_BUFFER; } if (!ret) { if (g_advancedSettings.CanLogComponent(LOGVIDEO)) CLog::Log(LOGDEBUG, "%s::%s - Nothing to do: dts_queue(%d) ready_queue(%d) busy_queue(%d) demux_queue(%d) space(%d)", CLASSNAME, __func__, m_dts_queue.size(), m_output_ready.size(), m_output_busy, m_demux_queue_length, mmal_queue_length(m_dec_input_pool->queue) * m_dec_input->buffer_size); Sleep(10); // otherwise we busy spin } return ret; }
HRESULT IN_PROCESS_APPLICATION::ExecuteApplication( VOID ) { HRESULT hr = S_OK; HMODULE hModule; hostfxr_main_fn pProc; DBG_ASSERT(m_status == APPLICATION_STATUS::STARTING); hModule = LoadLibraryW(m_pConfig->QueryHostFxrFullPath()); if (hModule == NULL) { // .NET Core not installed (we can log a more detailed error message here) hr = ERROR_BAD_ENVIRONMENT; goto Finished; } // Get the entry point for main pProc = (hostfxr_main_fn)GetProcAddress(hModule, "hostfxr_main"); if (pProc == NULL) { hr = ERROR_BAD_ENVIRONMENT; goto Finished; } if (FAILED(hr = SetEnvironementVariablesOnWorkerProcess())) { goto Finished; } // There can only ever be a single instance of .NET Core // loaded in the process but we need to get config information to boot it up in the // first place. This is happening in an execute request handler and everyone waits // until this initialization is done. // We set a static so that managed code can call back into this instance and // set the callbacks s_Application = this; hr = RunDotnetApplication(m_pConfig->QueryHostFxrArgCount(), m_pConfig->QueryHostFxrArguments(), pProc); Finished: // // this method is called by the background thread and should never exit unless shutdown // If main returned and shutdown was not called in managed, we want to block native from calling into // managed. To do this, we can say that shutdown was called from managed. // Don't bother locking here as there will always be a race between receiving a native shutdown // notification and unexpected managed exit. // m_status = APPLICATION_STATUS::SHUTDOWN; m_fShutdownCalledFromManaged = TRUE; FreeLibrary(hModule); if (!m_fShutdownCalledFromNative) { LogErrorsOnMainExit(hr); if (m_fInitialized) { // // If the inprocess server was initialized, we need to cause recycle to be called on the worker process. // Recycle(); } } return hr; }
~Block() { Recycle(); }
void ParticleSystem::Update() { if(paused) { return; } if(rate > 0.0f) { toEmit += rate * GetGame()->time->deltaTime; // Log("ParticleSystem updating, toEmit = ", toEmit); if(toEmit >= 1.0f) { Emit(floor(toEmit)); toEmit -= floor(toEmit); } } for(uint i = 0; i < particles.size(); ++i) { if(!&particles[i]) { particles.erase(particles.begin()+i); --i; continue; } if(particles[i].active) { particles[i].Update(GetGame()->time->deltaTime); if(particles[i].lifetime <= 0.0f) { Recycle(&particles[i]); } // vertexBuffer[i] = particles[i]->position; // colorBuffer[i] = particles[i]->GetColor(); // sizeBuffer[i] = particles[i]->GetSize(); particleBuffer[i].position = particles[i].position; particleBuffer[i].color = (u8vec4)round(particles[i].GetColor()*255.0f); particleBuffer[i].size = particles[i].GetSize(); if(gravity != vec3(0)) { particles[i].ApplyForce(gravity, GetGame()->time->deltaTime); } } } for(uint i = 0; i < bursts.size(); ++i) { if(bursts[i].current <= 0.0f) { Emit(bursts[i].particles); bursts[i].current = bursts[i].time; } bursts[i].current -= GetGame()->time->deltaTime; } if(GetGame()->input->GetButtonDown("ShowFPS")) { GetGame()->Log("Current particle count: ", GetCount()); } }