Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Windows Media Format SDK IWMSyncReader Problem

Windows Media Format SDK IWMSyncReader Problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpdebuggingperformancetutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    ytod
    wrote on last edited by
    #1

    I've followed the MSDN sample codes to read samples from a wmv file. But what's different is that I need to call SetRange() each time when I enter a while loop to grab only sample in a specific range (Ex: every 1 second). But even if I called INSSBuffer::Release() to release the buffer interface after calling IWMSyncReader::GetNextSample(), the memory seemd not release at once. I used the taskmgr.exe to peek my memory usage. Codes are as follows: QWORD qwRange = 0; int nIndex = 0; while( qwRange < m_qwFileDuration ) { QWORD cnsSampleTime = 0; QWORD cnsDuration = 0; DWORD dwFlags = 0; DWORD dwOutputNum = 0; DWORD dwLength = 0; LPBYTE pBuf = NULL; INSSBuffer* pMyBuffer = NULL; HRESULT hr = S_OK; UINT nIndex = 0; hr |= m_pSyncReader->SetRange( qwRange,0 ); if( FAILED(hr)) return; hr |= m_pSyncReader->GetNextSample( m_wStreamNumber, &pMyBuffer, &cnsSampleTime, &cnsDuration, &dwFlags, &dwOutputNum, NULL ); if( FAILED(hr)) return; hr |= pMyBuffer->GetBufferAndLength( &pBuf, &dwLength ); if( FAILED(hr)) return; memcpy( m_ppBuf[nIndex], pBuf, dwLength ); pMyBuffer->Release(); pMyBuffer = NULL; qwRange += 10000000; nIndex++; } First loop: SetRange() would increase the memory usage, GetNextSample() would further increase the memory usage. After First loop: SetRange() would decrease the memory usage, but more than that of the previous loop, and GetNextSample() would increase the memory usage again. After using taskmgr.exe and run my code in debug mode to examine the memory usage, I found the memory usage only changed after these 2 lines. If I tried to delete the local buffer pBuf after Realese() would result in a memory exception... Why and how to prevent memory leak? Can somebody help me? Thanks!

    A 1 Reply Last reply
    0
    • Y ytod

      I've followed the MSDN sample codes to read samples from a wmv file. But what's different is that I need to call SetRange() each time when I enter a while loop to grab only sample in a specific range (Ex: every 1 second). But even if I called INSSBuffer::Release() to release the buffer interface after calling IWMSyncReader::GetNextSample(), the memory seemd not release at once. I used the taskmgr.exe to peek my memory usage. Codes are as follows: QWORD qwRange = 0; int nIndex = 0; while( qwRange < m_qwFileDuration ) { QWORD cnsSampleTime = 0; QWORD cnsDuration = 0; DWORD dwFlags = 0; DWORD dwOutputNum = 0; DWORD dwLength = 0; LPBYTE pBuf = NULL; INSSBuffer* pMyBuffer = NULL; HRESULT hr = S_OK; UINT nIndex = 0; hr |= m_pSyncReader->SetRange( qwRange,0 ); if( FAILED(hr)) return; hr |= m_pSyncReader->GetNextSample( m_wStreamNumber, &pMyBuffer, &cnsSampleTime, &cnsDuration, &dwFlags, &dwOutputNum, NULL ); if( FAILED(hr)) return; hr |= pMyBuffer->GetBufferAndLength( &pBuf, &dwLength ); if( FAILED(hr)) return; memcpy( m_ppBuf[nIndex], pBuf, dwLength ); pMyBuffer->Release(); pMyBuffer = NULL; qwRange += 10000000; nIndex++; } First loop: SetRange() would increase the memory usage, GetNextSample() would further increase the memory usage. After First loop: SetRange() would decrease the memory usage, but more than that of the previous loop, and GetNextSample() would increase the memory usage again. After using taskmgr.exe and run my code in debug mode to examine the memory usage, I found the memory usage only changed after these 2 lines. If I tried to delete the local buffer pBuf after Realese() would result in a memory exception... Why and how to prevent memory leak? Can somebody help me? Thanks!

      A Offline
      A Offline
      aasikRaja
      wrote on last edited by
      #2

      Instead of using Range Values, Try to get samples until the hresult from the GetNextSample method becomes NS_E_NO_MORE_SAMPLES. Don't release the INSSBuffer until reading process will complete.. Thank u..

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups