void cDBusHelper::ToUtf8(cString &text) { if ((cCharSetConv::SystemCharacterTable() == NULL) || (strcmp(cCharSetConv::SystemCharacterTable(), "UTF-8") == 0)) { if (!cDBusHelper::IsValidUtf8(*text)) { static const char *fromCharSet = "ISO6937"; static const char *charSetOverride = getenv("VDR_CHARSET_OVERRIDE"); if (charSetOverride) fromCharSet = charSetOverride; d4syslog("dbus2vdr: ToUtf8: create charset converter from %s to UTF-8", fromCharSet); static cCharSetConv converter(fromCharSet); static cMutex mutex; mutex.Lock(); text = converter.Convert(*text); mutex.Unlock(); } } else { d4syslog("dbus2vdr: ToUtf8: create charset converter to UTF-8"); static cCharSetConv converter(NULL, "UTF-8"); static cMutex mutex; mutex.Lock(); text = converter.Convert(*text); mutex.Unlock(); } }
bool rend_framePending() { mtx_rqueue.Lock(); TA_context* rv = rqueue; mtx_rqueue.Unlock(); return rv != 0; }
cDevice* cSwitchLive::Switch(cDevice *Device, const cChannel *Channel) { mutex.Lock(); device = Device; channel = Channel; mutex.Unlock(); switched.Wait(); return device; }
bool SCDEVICE::SetPid(cPidHandle *Handle, int Type, bool On) { DEBUGLOG("%s: on=%d", __FUNCTION__, On); tsMutex.Lock(); if (tsBuffer) tsBuffer->SetActive(ScActive()); tsMutex.Unlock(); return DVBDEVICE::SetPid(Handle, Type, On); }
void FinishRender(TA_context* ctx) { verify(rqueue == ctx); mtx_rqueue.Lock(); rqueue = 0; mtx_rqueue.Unlock(); tactx_Recycle(ctx); }
TA_context* DequeueRender() { mtx_rqueue.Lock(); TA_context* rv = rqueue; mtx_rqueue.Unlock(); if (rv) FrameCount++; return rv; }
void SCDEVICE::CloseDvr(void) { DEBUGLOG("%s", __FUNCTION__); tsMutex.Lock(); delete tsBuffer; tsBuffer = 0; tsMutex.Unlock(); if (fd_dvr >= 0) { close(fd_dvr); fd_dvr = -1; } }
bool SCDEVICE::OpenDvr(void) { DEBUGLOG("%s", __FUNCTION__); CloseDvr(); fd_dvr = cScDevices::DvbOpen(DEV_DVB_DVR, DVB_DEV_SPEC, O_RDONLY | O_NONBLOCK, true); if (fd_dvr >= 0) { tsMutex.Lock(); tsBuffer = new DeCsaTsBuffer(fd_dvr, MEGABYTE(4), CardIndex() + 1, sCCIAdapter->GetDeCSA(), ScActive()); tsMutex.Unlock(); } return fd_dvr >= 0; }
bool QueueRender(TA_context* ctx) { verify(ctx != 0); if (FrameSkipping && frameskip) { frameskip=1-frameskip; tactx_Recycle(ctx); fskip++; return false; } //Try to limit speed to a "sane" level //Speed is also limited via audio, but audio //is sometimes not accurate enough (android, vista+) u32 cycle_span = sh4_sched_now64() - last_cyces; last_cyces = sh4_sched_now64(); double time_span = os_GetSeconds() - last_frame; last_frame = os_GetSeconds(); bool too_fast = (cycle_span / time_span) > (SH4_MAIN_CLOCK * 1.2); if (rqueue && too_fast && settings.pvr.SynchronousRender) { //wait for a frame if // we have another one queue'd and // sh4 run at > 120% on the last slice // and SynchronousRendering is enabled frame_finished.Wait(); verify(!rqueue); } if (rqueue) { tactx_Recycle(ctx); fskip++; return false; } frame_finished.Reset(); mtx_rqueue.Lock(); TA_context* old = rqueue; rqueue=ctx; mtx_rqueue.Unlock(); verify(!old); return true; }
void tactx_Recycle(TA_context* poped_ctx) { mtx_pool.Lock(); { if (ctx_pool.size()>2) { poped_ctx->Free(); delete poped_ctx; } else { poped_ctx->Reset(); ctx_pool.push_back(poped_ctx); } } mtx_pool.Unlock(); }
bool VramLockedWrite(u8* address) { size_t offset=address-vram.data; if (offset<VRAM_SIZE) { size_t addr_hash = offset/PAGE_SIZE; vector<vram_block*>* list=&VramLocks[addr_hash]; { vramlist_lock.Lock(); for (size_t i=0;i<list->size();i++) { if ((*list)[i]) { libPvr_LockedBlockWrite((*list)[i],(u32)offset); if ((*list)[i]) { msgboxf("Error : pvr is supposed to remove lock",MBX_OK); dbgbreak; } } } list->clear(); vram.UnLockRegion((u32)offset&(~(PAGE_SIZE-1)),PAGE_SIZE); //TODO: Fix this for 32M wrap as well if (_nvmem_enabled() && VRAM_SIZE == 0x800000) { vram.UnLockRegion((u32)offset&(~(PAGE_SIZE-1)) + VRAM_SIZE,PAGE_SIZE); } vramlist_lock.Unlock(); } return true; } else return false; }
bool QueueRender(TA_context* ctx) { verify(ctx != 0); if (rqueue) { tactx_Recycle(ctx); fskip++; return false; } mtx_rqueue.Lock(); TA_context* old = rqueue; rqueue=ctx; mtx_rqueue.Unlock(); verify(!old); return true; }
vram_block* libCore_vramlock_Lock(u32 start_offset64,u32 end_offset64,void* userdata) { vram_block* block=(vram_block* )malloc(sizeof(vram_block)); if (end_offset64>(VRAM_SIZE-1)) { msgboxf("vramlock_Lock_64: end_offset64>(VRAM_SIZE-1) \n Tried to lock area out of vram , possibly bug on the pvr plugin",MBX_OK); end_offset64=(VRAM_SIZE-1); } if (start_offset64>end_offset64) { msgboxf("vramlock_Lock_64: start_offset64>end_offset64 \n Tried to lock negative block , possibly bug on the pvr plugin",MBX_OK); start_offset64=0; } block->end=end_offset64; block->start=start_offset64; block->len=end_offset64-start_offset64+1; block->userdata=userdata; block->type=64; { vramlist_lock.Lock(); vram.LockRegion(block->start,block->len); //TODO: Fix this for 32M wrap as well if (_nvmem_enabled() && VRAM_SIZE == 0x800000) { vram.LockRegion(block->start + VRAM_SIZE, block->len); } vramlock_list_add(block); vramlist_lock.Unlock(); } return block; }
TA_context* tactx_Alloc() { TA_context* rv = 0; mtx_pool.Lock(); if (ctx_pool.size()) { rv = ctx_pool[ctx_pool.size()-1]; ctx_pool.pop_back(); } mtx_pool.Unlock(); if (!rv) { rv = new TA_context(); rv->Alloc(); printf("new tactx\n"); } return rv; }
void cSwitchLive::Switch(void) { mutex.Lock(); if (channel && device) { #if APIVERSNUM >= 10726 cChannel *current = Channels.GetByNumber(cDevice::CurrentChannel()); cDevice *newdev = cServerConnection::CheckDevice(current, 0, true, device); if (!newdev) { if (StreamdevServerSetup.SuspendMode == smAlways) { Channels.SwitchTo(channel->Number()); Skins.Message(mtInfo, tr("Streaming active")); } else { esyslog("streamdev: Can't receive channel %d (%s) from device %d. Moving live TV to other device failed (PrimaryDevice=%d, ActualDevice=%d)", channel->Number(), channel->Name(), device->CardIndex(), cDevice::PrimaryDevice()->CardIndex(), cDevice::ActualDevice()->CardIndex()); device = NULL; } } else { newdev->SwitchChannel(current, true); } #else cDevice::SetAvoidDevice(device); if (!Channels.SwitchTo(cDevice::CurrentChannel())) { if (StreamdevServerSetup.SuspendMode == smAlways) { Channels.SwitchTo(channel->Number()); Skins.Message(mtInfo, tr("Streaming active")); } else { esyslog("streamdev: Can't receive channel %d (%s) from device %d. Moving live TV to other device failed (PrimaryDevice=%d, ActualDevice=%d)", channel->Number(), channel->Name(), device->CardIndex(), cDevice::PrimaryDevice()->CardIndex(), cDevice::ActualDevice()->CardIndex()); device = NULL; } } #endif // make sure we don't come in here next time channel = NULL; switched.Signal(); } mutex.Unlock(); }
void LogStatsUp(void) { logstatsMutex.Lock(); if(LOG(L_CORE_AUSTATS) && !logstats) logstats=new cLogStats; logstatsMutex.Unlock(); }
void LogStatsDown(void) { logstatsMutex.Lock(); if(logstats) { delete logstats; logstats=0; } logstatsMutex.Unlock(); }
//unlocks mem //also frees the handle void libCore_vramlock_Unlock_block(vram_block* block) { vramlist_lock.Lock(); libCore_vramlock_Unlock_block_wb(block); vramlist_lock.Unlock(); }