⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cachobj.cpp

📁 著名的 helix realplayer 基于手机 symbian 系统的 播放器全套源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    BOOL	bContiguousDataPointer = FALSE;
    UINT32	ulBytesWrote = 0;
    UINT32	ulBytesToWrite = 0;
    char*	pData = NULL;
    char*	pCursor = NULL;
#if !defined(HELIX_FEATURE_FULLGUID)
    GUID	tmp = IID_IHXClientPacket;
#endif
    if (!pClientPacket)
    {
	theErr = HXR_FAILED;
	goto cleanup;
    }

    // caculate the size of client packet
    ClientPacket::Pack(pClientPacket, NULL, ulBytesToWrite);
    ulBytesToWrite += sizeof(ChunkyCacheLayout);

    // check whether we have cont. memory chunk of the size needed
    if (HXR_OK == m_pChunkyRes->GetContiguousDataPointer(m_ulCurrentWritePosition,
							 pData,
							 ulBytesToWrite) && pData)
    {	
	bContiguousDataPointer = TRUE;
	pCursor = pData;
    }
    // otherwise we allocated our own
    else
    {
	pData = new char[ulBytesToWrite];
	pCursor = pData;
    }

    // total chunk bytes
    *pCursor++ = (BYTE)ulBytesToWrite; *pCursor++ = (BYTE)(ulBytesToWrite >> 8);
    ulBytesWrote += 2;
    // GUID
#if !defined(HELIX_FEATURE_FULLGUID)
    memcpy(pCursor, (char*)&tmp, sizeof(GUID)); /* Flawfinder: ignore */
#else
    memcpy(pCursor, (char*)&IID_IHXClientPacket, sizeof(GUID)); /* Flawfinder: ignore */
#endif
    pCursor += sizeof(GUID);
    ulBytesWrote += sizeof(GUID);

    // pack data
    ClientPacket::Pack(pClientPacket, pCursor, ulBytesWrote);	

    if (!bContiguousDataPointer)
    {
	// let the memory manager take care of the contingency
	theErr = m_pChunkyRes->SetData(m_ulCurrentWritePosition, pData, ulBytesWrote);
    }

    HX_ASSERT(ulBytesToWrite == ulBytesWrote);
    // advance the write cursor
    m_ulCurrentWritePosition += ulBytesToWrite;

cleanup:

    if (!bContiguousDataPointer)
    {
	HX_VECTOR_DELETE(pData);
    }

    return theErr;
}

HX_RESULT 
HXFIFOCache::CacheTimestampBuffer(IHXTimeStampedBuffer* pTimeStampBuffer)
{
    HX_RESULT	theErr = HXR_OK;
    BOOL	bContiguousDataPointer = FALSE;
    UINT32	ulBytesWrote = 0;
    UINT32	ulBytesToWrite = 0;
    char*	pData = NULL;
    char*	pCursor = NULL;
#if !defined(HELIX_FEATURE_FULLGUID)
    GUID	tmp = IID_IHXBuffer;
#endif

    if (!pTimeStampBuffer)
    {
	theErr = HXR_FAILED;
	goto cleanup;
    }

    // caculate the size of buffer
    CHXTimeStampedBuffer::Pack(pTimeStampBuffer, NULL, 0, ulBytesToWrite);
    ulBytesToWrite += sizeof(ChunkyCacheLayout);

    // check whether we have cont. memory chunk of the size needed
    if (HXR_OK == m_pChunkyRes->GetContiguousDataPointer(m_ulCurrentWritePosition,
							 pData,
							 ulBytesToWrite) && pData)
    {	
	bContiguousDataPointer = TRUE;
	pCursor = pData;
    }
    // otherwise we allocated our own
    else
    {
	pData = new char[ulBytesToWrite];
	pCursor = pData;
    }

    // total chunk bytes
    *pCursor++ = (BYTE)ulBytesToWrite; *pCursor++ = (BYTE)(ulBytesToWrite >> 8);
    ulBytesWrote += 2;
    // GUID
#if !defined(HELIX_FEATURE_FULLGUID)
    memcpy(pCursor, (char*)&tmp, sizeof(GUID)); /* Flawfinder: ignore */
#else
    memcpy(pCursor, (char*)&IID_IHXBuffer, sizeof(GUID)); /* Flawfinder: ignore */
#endif
    pCursor += sizeof(GUID);
    ulBytesWrote += sizeof(GUID);

    // pack data
    CHXTimeStampedBuffer::Pack(pTimeStampBuffer, pCursor,
                               ulBytesToWrite - ulBytesWrote, ulBytesWrote);	

    if (!bContiguousDataPointer)
    {
	// let the memory manager take care of the contingency
	theErr = m_pChunkyRes->SetData(m_ulCurrentWritePosition, pData, ulBytesWrote);
    }

    HX_ASSERT(ulBytesToWrite == ulBytesWrote);
    // advance the write cursor
    m_ulCurrentWritePosition += ulBytesToWrite;

cleanup:

    if (!bContiguousDataPointer)
    {
	HX_VECTOR_DELETE(pData);
    }

    return theErr;
}

HX_RESULT 
HXFIFOCache::CacheBuffer(IHXBuffer* pBuffer)
{
    HX_RESULT	theErr = HXR_OK;
    BOOL	bContiguousDataPointer = FALSE;
    UINT32	ulBytesWrote = 0;
    UINT32	ulBytesToWrite = 0;
    char*	pData = NULL;
    char*	pCursor = NULL;
#if !defined(HELIX_FEATURE_FULLGUID)
    GUID	tmp = IID_IHXBuffer;
#endif

    if (!pBuffer)
    {
	theErr = HXR_FAILED;
	goto cleanup;
    }

    // caculate the size of client packet
    ulBytesToWrite = pBuffer->GetSize();
    ulBytesToWrite += sizeof(ChunkyCacheLayout);

    // check whether we have cont. memory chunk of the size needed
    if (HXR_OK == m_pChunkyRes->GetContiguousDataPointer(m_ulCurrentWritePosition,
							 pData,
							 ulBytesToWrite) && pData)
    {	
	bContiguousDataPointer = TRUE;
	pCursor = pData;
    }
    // otherwise we allocated our own
    else
    {
	pData = new char[ulBytesToWrite];
	pCursor = pData;
    }

    // total chunk bytes
    *pCursor++ = (BYTE)ulBytesToWrite; *pCursor++ = (BYTE)(ulBytesToWrite >> 8);
    ulBytesWrote += 2;
    // GUID
#if !defined(HELIX_FEATURE_FULLGUID)
    memcpy(pCursor, (char*)&tmp, sizeof(GUID)); /* Flawfinder: ignore */
#else
    memcpy(pCursor, (char*)&IID_IHXBuffer, sizeof(GUID)); /* Flawfinder: ignore */
#endif
    pCursor += sizeof(GUID);
    ulBytesWrote += sizeof(GUID);

    // pack data
    memcpy(pCursor, (char*)pBuffer->GetBuffer(), pBuffer->GetSize()); /* Flawfinder: ignore */

    if (!bContiguousDataPointer)
    {
	// let the memory manager take care of the contingency
	theErr = m_pChunkyRes->SetData(m_ulCurrentWritePosition, pData, ulBytesWrote);
    }

    HX_ASSERT(ulBytesToWrite == ulBytesWrote);
    // advance the write cursor
    m_ulCurrentWritePosition += ulBytesToWrite;

cleanup:

    if (!bContiguousDataPointer)
    {
	HX_VECTOR_DELETE(pData);
    }

    return theErr;
}

HX_RESULT 
HXFIFOCache::CachePacket(IHXPacket* pPacket)
{
    HX_RESULT	theErr = HXR_OK;
    BOOL	bContiguousDataPointer = FALSE;
    UINT32	ulBytesWrote = 0;
    UINT32	ulBytesToWrite = 0;
    char*	pData = NULL;
    char*	pCursor = NULL;
#if !defined(HELIX_FEATURE_FULLGUID)
    GUID	tmp = IID_IHXPacket;
#endif

    if (!pPacket)
    {
	theErr = HXR_FAILED;
	goto cleanup;
    }

    // caculate the size of client packet
    CHXPacket::Pack(pPacket, NULL, ulBytesToWrite);
    ulBytesToWrite += sizeof(ChunkyCacheLayout);

    // check whether we have cont. memory chunk of the size needed
    if (HXR_OK == m_pChunkyRes->GetContiguousDataPointer(m_ulCurrentWritePosition,
							 pData,
							 ulBytesToWrite) && pData)
    {	
	bContiguousDataPointer = TRUE;
	pCursor = pData;
    }
    // otherwise we allocated our own
    else
    {
	pData = new char[ulBytesToWrite];
	pCursor = pData;
    }

    // total chunk bytes
    *pCursor++ = (BYTE)ulBytesToWrite; *pCursor++ = (BYTE)(ulBytesToWrite >> 8);
    ulBytesWrote += 2;
    // GUID
#if !defined(HELIX_FEATURE_FULLGUID)
    memcpy(pCursor, (char*)&tmp, sizeof(GUID)); /* Flawfinder: ignore */
#else
    memcpy(pCursor, (char*)&IID_IHXPacket, sizeof(GUID)); /* Flawfinder: ignore */
#endif
    pCursor += sizeof(GUID);
    ulBytesWrote += sizeof(GUID);

    // pack data
    CHXPacket::Pack(pPacket, pCursor, ulBytesWrote);	

    if (!bContiguousDataPointer)
    {
	// let the memory manager take care of the contingency
	theErr = m_pChunkyRes->SetData(m_ulCurrentWritePosition, pData, ulBytesWrote);
    }

    HX_ASSERT(ulBytesToWrite == ulBytesWrote);
    // advance the write cursor
    m_ulCurrentWritePosition += ulBytesToWrite;

cleanup:

    if (!bContiguousDataPointer)
    {
	HX_VECTOR_DELETE(pData);
    }

    return theErr;
}

HX_RESULT 
HXFIFOCache::CacheValues(IHXValues* pValues)
{
    // TBD
    HX_RESULT theErr = HXR_NOTIMPL;
    return theErr;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -