Exemplo n.º 1
0
void sslcExit(void)
{
	if (AtomicDecrement(&__sslc_refcount)) return;

	svcCloseHandle(__sslc_servhandle);
	__sslc_servhandle = 0;
}
Exemplo n.º 2
0
void srvExit(void)
{
	if (AtomicDecrement(&srvRefCount)) return;

	if (srvHandle != 0) svcCloseHandle(srvHandle);
	srvHandle = 0;
}
Exemplo n.º 3
0
 ~Instance() {
     ELock_lock(&m_prototype->m_interlock);
     if(!AtomicDecrement(&m_prototype->m_lock)) {
         m_prototype->m_tid = NULL;
     }
     ELock_unlock(&m_prototype->m_interlock);
 }
Exemplo n.º 4
0
long CDVDVideoCodecIMXBuffer::Release()
{
  long count = AtomicDecrement(&m_refs);
#ifdef TRACE_FRAMES
  CLog::Log(LOGDEBUG, "R- %02d  -  ref : %d  (VPU)\n", m_idx, count);
#endif
  if (count == 2)
  {
    // Only referenced by the coded and its next frame, release the previous
    SAFE_RELEASE(m_previousBuffer);
  }
  if (count == 1)
  {
    // If count drops to 1 then the only reference is being held by the codec
    // that it can be released in the next Decode call.
    if(m_frameBuffer != NULL)
    {
      m_rendered = true;
      SAFE_RELEASE(m_previousBuffer);
#ifdef TRACE_FRAMES
      CLog::Log(LOGDEBUG, "R  %02d  (VPU)\n", m_idx);
#endif
    }
  }
  else if (count == 0)
  {
    delete this;
  }

  return count;
}
Exemplo n.º 5
0
void
pxipmExit(void)
{
    if (AtomicDecrement(&pxipmRefCount))
        return;
    svcCloseHandle(pxipmHandle);
}
Exemplo n.º 6
0
HRESULT CTestAtomicHelpers::Run()
{
    HRESULT hr = S_OK;
    
    int value = -2000;
    int nextexpected = -2000;
    int result = 0;
    
    while (value < 2000)
    {
        nextexpected++;
        result = AtomicIncrement(&value);
        ChkIf(result != nextexpected, E_UNEXPECTED);
        ChkIf(result != value, E_UNEXPECTED);
    }
    
    value = 2000;
    nextexpected = 2000;
    while (value > -2000)
    {
        nextexpected--;
        result = AtomicDecrement(&value);
        ChkIf(result != nextexpected, E_UNEXPECTED);
        ChkIf(result != value, E_UNEXPECTED);
    }

Cleanup:
    return hr;
}
Exemplo n.º 7
0
Result pxiDevInit(void) {
	Result res;
	if (AtomicPostIncrement(&pxiDevRefCount)) return 0;
	res = srvGetServiceHandle(&pxiDevHandle, "pxi:dev");
	if (R_FAILED(res)) AtomicDecrement(&pxiDevRefCount);
	return res;
}
Exemplo n.º 8
0
    //! @brief Decrement the reference count
    //! @return True if that was the last reference.
    bool release( ) const
    {
        if( m_refCount == 0 )
            throw new std::invalid_argument("Released an interned symbol too many times!");

        return (AtomicDecrement( &m_refCount ) == 0);
    }
Exemplo n.º 9
0
void testAtomicOps() {
    volatile esint32 key = 0;
    EAssert(AtomicIncrement(&key) == 1, "key != 1");
    EAssert(AtomicDecrement(&key) == 0, "key != 0");
    AtomicCompareExchange(1, 0, &key);
    EAssert(AtomicIncrement(&key) == 2, "key != 2");
}
Exemplo n.º 10
0
Result ptmuxInit(void)
{
	if (AtomicPostIncrement(&ptmuxRefCount)) return 0;
	Result res = srvGetServiceHandle(&ptmuxHandle, "ptm:u");
	if (R_FAILED(res)) AtomicDecrement(&ptmuxRefCount);
	return res;
}
Exemplo n.º 11
0
Result hbInit(void)
{
	Result res=0;
	if (AtomicPostIncrement(&hbRefCount)) return 0;
	res = srvGetServiceHandle(&hbHandle, "hb:HB");
	if (R_FAILED(res)) AtomicDecrement(&hbRefCount);
	return res;
}
Exemplo n.º 12
0
Result psInit(void)
{
	Result res;
	if (AtomicPostIncrement(&psRefCount)) return 0;
	res = srvGetServiceHandle(&psHandle, "ps:ps");
	if (R_FAILED(res)) AtomicDecrement(&psRefCount);
	return res;
}
Exemplo n.º 13
0
Result gspLcdInit(void)
{
	Result res=0;
	if (AtomicPostIncrement(&gspLcdRefCount)) return 0;
	res = srvGetServiceHandle(&gspLcdHandle, "gsp::Lcd");
	if (R_FAILED(res)) AtomicDecrement(&gspLcdRefCount);
	return res;
}
Exemplo n.º 14
0
Result loaderInit(void)
{
	Result res;
	if (AtomicPostIncrement(&loaderRefCount)) return 0;
	res = srvGetServiceHandle(&loaderHandle, "Loader");
	if (R_FAILED(res)) AtomicDecrement(&loaderRefCount);
	return res;
}
Exemplo n.º 15
0
Result pmDbgInit(void)
{
	Result res;
	if (AtomicPostIncrement(&pmDbgRefcount)) return 0;
	res = srvGetServiceHandle(&pmDbgHandle, "pm:dbg");
	if (R_FAILED(res)) AtomicDecrement(&pmDbgRefcount);
	return res;
}
Exemplo n.º 16
0
Result miniSocInit()
{
    if(AtomicPostIncrement(&miniSocRefCount))
        return 0;

    u32 tmp = 0;
    Result ret = 0;
    bool isSocURegistered;

    ret = srvIsServiceRegistered(&isSocURegistered, "soc:U");
    if(ret != 0) goto cleanup;
    if(!isSocURegistered)
    {
        ret = -1;
        goto cleanup;
    }

    ret = srvGetServiceHandle(&SOCU_handle, "soc:U");
    if(ret != 0) goto cleanup;

    ret = svcControlMemory(&tmp, socContextAddr, 0, socContextSize, MEMOP_ALLOC, MEMPERM_READ | MEMPERM_WRITE);
    if(ret != 0) goto cleanup;

    socContextAddr = tmp;

    ret = svcCreateMemoryBlock(&socMemhandle, (u32)socContextAddr, socContextSize, 0, 3);
    if(ret != 0) goto cleanup;



    ret = SOCU_Initialize(socMemhandle, socContextSize);
    if(ret != 0) goto cleanup;

    svcKernelSetState(0x10000, 2);
    miniSocEnabled = true;
    return 0;

cleanup:
    AtomicDecrement(&miniSocRefCount);

    if(socMemhandle != 0)
    {
        svcCloseHandle(socMemhandle);
        socMemhandle = 0;
    }

    if(SOCU_handle != 0)
    {
        SOCU_Shutdown();
        svcCloseHandle(SOCU_handle);
        SOCU_handle = 0;
    }

    if(tmp != 0)
        svcControlMemory(&tmp, socContextAddr, socContextAddr, socContextSize, MEMOP_FREE, MEMPERM_DONTCARE);

    return ret;
}
Exemplo n.º 17
0
int CBasicRefCount::InternalRelease()
{
    int refcount = AtomicDecrement(&m_nRefs);
    if (refcount == 0)
    {
        OnFinalRelease();
    }
    return refcount;
}
long CDVDMediaCodecInfo::Release() {
  //REPORT_FUNCTION();
  long count = AtomicDecrement(&m_refs);
  if (count == 1)
    ReleaseOutputBuffer(false);
  if (count == 0)
    delete this;
  return count;
}
Exemplo n.º 19
0
Arquivo: ps.c Projeto: TuxSH/ctrulib
static Result _psInit(Handle handle)
{
	Result res=0;
	if (AtomicPostIncrement(&psRefCount)) return 0;
	if(handle==0)res = srvGetServiceHandle(&handle, "ps:ps");
	if (R_FAILED(res)) AtomicDecrement(&psRefCount);
	if (R_SUCCEEDED(res)) psHandle = handle;
	return res;
}
Exemplo n.º 20
0
long CDVDMsgGeneralSynchronize::Release()
{
  CSingleLock lock(m_p->section);
  long count = AtomicDecrement(&m_refs);
  m_p->condition.notifyAll();
  lock.Leave();
  if (count == 0)
    delete this;
  return count;
}
Exemplo n.º 21
0
void Event::Stop(EventData& data)
{
	data.Stop();

	if (data.description->isSampling)
	{
		if (EventStorage* storage = Core::storage)
			AtomicDecrement(&storage->isSampling);
	}
}
Exemplo n.º 22
0
Result ndspInit(void)
{
	Result rc = 0;
	if (AtomicPostIncrement(&ndspRefCount)) return 0;

	if (!componentBin && !ndspFindAndLoadComponent())
	{
		rc = MAKERESULT(RL_PERMANENT, RS_NOTFOUND, 41, RD_NOT_FOUND);
		goto _fail0;
	}

	LightLock_Init(&ndspMutex);
	ndspInitMaster();
	ndspiInitChn();

	rc = cfguInit();
	if (R_SUCCEEDED(rc))
	{
		u8 outMode;
		rc = CFGU_GetConfigInfoBlk2(sizeof(outMode), 0x70001, &outMode);
		if (R_SUCCEEDED(rc))
			ndspMaster.outputMode = outMode;
		cfguExit();
	}

	rc = dspInit();
	if (R_FAILED(rc)) return rc;

	rc = ndspInitialize(false);
	if (R_FAILED(rc)) goto _fail1;

	rc = svcCreateEvent(&sleepEvent, 0);
	if (R_FAILED(rc)) goto _fail2;

	ndspThread = threadCreate(ndspThreadMain, 0x0, NDSP_THREAD_STACK_SIZE, 0x18, -2, true);
	if (!ndspThread) goto _fail3;

	aptHook(&aptCookie, ndspAptHook, NULL);
	return 0;

_fail3:
	svcCloseHandle(sleepEvent);
_fail2:
	ndspFinalize(false);
_fail1:
	dspExit();
	if (componentFree)
	{
		free((void*)componentBin);
		componentBin = NULL;
	}
_fail0:
	AtomicDecrement(&ndspRefCount);
	return rc;
}
long CDVDMediaCodecInfo::Release()
{
  long count = AtomicDecrement(&m_refs);
  if (count == 0)
  {
    ReleaseOutputBuffer(false);
    delete this;
  }

  return count;
}
Exemplo n.º 24
0
long CMMALVideoBuffer::Release()
{
  long count = AtomicDecrement(&m_refs);
  if (g_advancedSettings.CanLogComponent(LOGVIDEO))
    CLog::Log(LOGDEBUG, "%s::%s %p (%p) ref:%ld", CLASSNAME, __func__, this, mmal_buffer, count);
  if (count == 0)
  {
    m_omv->ReleaseBuffer(this);
  }
  return count;
}
Exemplo n.º 25
0
Result acInit(void)
{
	Result ret;

	if (AtomicPostIncrement(&acRefCount)) return 0;

	ret = srvGetServiceHandle(&acHandle, "ac:u");
	if(R_FAILED(ret)) ret = srvGetServiceHandle(&acHandle, "ac:i");
	if(R_FAILED(ret)) AtomicDecrement(&acRefCount);

	return ret;
}
Exemplo n.º 26
0
Result cfguInit(void)
{
	Result ret;

	if (AtomicPostIncrement(&cfguRefCount)) return 0;

	// cfg:i has the most commands, then cfg:s, then cfg:u
	ret = srvGetServiceHandle(&cfguHandle, "cfg:i");
	if(R_FAILED(ret)) ret = srvGetServiceHandle(&cfguHandle, "cfg:s");
	if(R_FAILED(ret)) ret = srvGetServiceHandle(&cfguHandle, "cfg:u");
	if(R_FAILED(ret)) AtomicDecrement(&cfguRefCount);

	return ret;
}
Exemplo n.º 27
0
Result sslcInit(Handle session_handle)
{
	Result ret=0;

	if (AtomicPostIncrement(&__sslc_refcount)) return 0;

	__sslc_servhandle = session_handle;

	if(__sslc_servhandle==0)ret = srvGetServiceHandle(&__sslc_servhandle, "ssl:C");
	if(session_handle==0 && R_SUCCEEDED(ret))ret = sslcipc_Initialize();
	if (R_FAILED(ret)) AtomicDecrement(&__sslc_refcount);

	return ret;
}
Exemplo n.º 28
0
long CYUVVideoBuffer::Release()
{
  long count = AtomicDecrement(&m_refs);
#ifdef MMAL_DEBUG_VERBOSE
  CLog::Log(LOGDEBUG, "%s::%s omvb:%p mmal:%p ref:%ld", CLASSNAME, __func__, this, mmal_buffer, count);
#endif
  if (count == 0)
  {
    mmal_buffer_header_release(mmal_buffer);
    delete this;
  }
  else assert(count > 0);
  return count;
}
Exemplo n.º 29
0
Result amInit(void)
{
	Result ret;

	if (AtomicPostIncrement(&amRefCount)) return 0;

	ret = srvGetServiceHandle(&amHandle, "am:net");
	if (R_FAILED(ret)) ret = srvGetServiceHandle(&amHandle, "am:u");
	if (R_FAILED(ret)) ret = srvGetServiceHandle(&amHandle, "am:sys");
	if (R_FAILED(ret)) ret = srvGetServiceHandle(&amHandle, "am:app");
	if (R_FAILED(ret)) AtomicDecrement(&amRefCount);

	return ret;
}
Exemplo n.º 30
0
Result
pxipmInit(void)
{
    Result ret = 0;

    if (AtomicPostIncrement(&pxipmRefCount))
        return 0;

    ret = srvSysGetServiceHandle(&pxipmHandle, "PxiPM");

    if (R_FAILED(ret))
        AtomicDecrement(&pxipmRefCount);
    return ret;
}