Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
920 B

  1. #include "precomp.h"
  2. DevMediaQueue::DevMediaQueue ( void )
  3. {
  4. m_uBegin = 0;
  5. m_uEnd = 0;
  6. m_uMaxNum = 0;
  7. }
  8. DevMediaQueue::~DevMediaQueue ( void )
  9. {
  10. if (m_paPackets)
  11. {
  12. MemFree ((PVOID) m_paPackets);
  13. m_paPackets = NULL;
  14. }
  15. }
  16. void DevMediaQueue::SetSize ( UINT uMaxNum )
  17. {
  18. m_uMaxNum = uMaxNum + 8;
  19. // Allocate zero-filled media packets
  20. m_paPackets = (MediaPacket **) MemAlloc (m_uMaxNum * sizeof (MediaPacket *));
  21. }
  22. void DevMediaQueue::Put ( MediaPacket * p )
  23. {
  24. m_paPackets[m_uEnd++] = p;
  25. m_uEnd %= m_uMaxNum;
  26. }
  27. MediaPacket * DevMediaQueue::Get ( void )
  28. {
  29. MediaPacket * p = NULL;
  30. if (m_uBegin != m_uEnd)
  31. {
  32. p = m_paPackets[m_uBegin];
  33. m_paPackets[m_uBegin++] = NULL;
  34. m_uBegin %= m_uMaxNum;
  35. }
  36. return p;
  37. }
  38. MediaPacket * DevMediaQueue::Peek ( void )
  39. {
  40. return ((m_uBegin != m_uEnd) ? m_paPackets[m_uBegin] : NULL);
  41. }