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.

49 lines
1003 B

  1. /*
  2. riff.c
  3. This module contains functions which deal with RIFF files
  4. */
  5. #include <windows.h>
  6. #include <mmsystem.h>
  7. #include "sbtest.h"
  8. BOOL IsRiffWaveFormat(PUCHAR pView)
  9. {
  10. PRIFFHDR pHdr;
  11. pHdr = (PRIFFHDR) pView;
  12. // validate it's a wave file
  13. if ((pHdr->rifftag != ckidRIFF)
  14. || (pHdr->wavetag != ckidWAVE)) {
  15. return FALSE;
  16. }
  17. return TRUE;
  18. }
  19. PUCHAR FindRiffChunk(PULONG pChunkSize, PUCHAR pView, FOURCC Tag)
  20. {
  21. PRIFFHDR pHdr;
  22. PRIFFCHUNKHDR pChHdr;
  23. FOURCC ChTag;
  24. ULONG Size;
  25. pHdr = (PRIFFHDR) pView;
  26. Size = pHdr->Size;
  27. pView += sizeof(RIFFHDR); // point to the first chunk
  28. while (Size) {
  29. pChHdr = (PRIFFCHUNKHDR) pView;
  30. ChTag = pChHdr->rifftag;
  31. if (ChTag == Tag) {
  32. *pChunkSize = pChHdr->Size;
  33. return pView + sizeof(RIFFCHUNKHDR);
  34. }
  35. pView += pChHdr->Size + sizeof(RIFFCHUNKHDR);
  36. Size -= (pChHdr->Size + sizeof(RIFFCHUNKHDR));
  37. }
  38. return NULL;
  39. }