void* CObjectMemoryPoolChunk::Allocate(size_t size) { _ASSERT(size > 0); // align the size up to size header (usually 8 bytes) size += sizeof(SHeader)-1; if ( sizeof(SHeader) & (sizeof(SHeader)-1) ) { // size of header is not power of 2 size -= size % sizeof(SHeader); } else { // size of header is power of 2 -> we can use bit operation size &= ~(sizeof(SHeader)-1); } // calculate new pointers SHeader* header = reinterpret_cast<SHeader*>(m_CurPtr); char* ptr = reinterpret_cast<char*>(header + 1); char* end = ptr + size; // check if space is enough if ( end > m_EndPtr ) { return 0; } // initialize the header header->m_ChunkPtr = this; header->m_Magic = SHeader::eMagicAllocated; // all checks are done, now we update chunk _ASSERT(m_CurPtr == header); m_CurPtr = end; // increment object counter in this chunk IncrementObjectCount(); return ptr; }
CGeometricMediaSource::CGeometricMediaSource(void) : OpQueue<CGeometricMediaSource, CSourceOperation>(_critSec.m_criticalSection) , _cRef(1) , _eSourceState(SourceState_Invalid) , _flRate(1.0f) { auto module = ::Microsoft::WRL::GetModuleBase(); if (module != nullptr) { module->IncrementObjectCount(); } }
CMPEG1Stream::CMPEG1Stream(CMPEG1Source *pSource, IMFStreamDescriptor *pSD) : m_cRef(1), m_state(STATE_STOPPED), m_fActive(false), m_fEOS(false), m_flRate(1.0f), m_spSource(pSource), m_spStreamDescriptor(pSD) { auto module = ::Microsoft::WRL::GetModuleBase(); if (module != nullptr) { module->IncrementObjectCount(); } assert(pSource != nullptr); assert(pSD != nullptr); }