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.

132 lines
4.8 KiB

  1. //-----------------------------------------------------------------------------
  2. // File: dsutil.cpp
  3. //
  4. // Desc: Routines for dealing with sounds from resources
  5. //
  6. // Copyright (C) 1995-1999 Microsoft Corporation. All Rights Reserved.
  7. //-----------------------------------------------------------------------------
  8. #ifndef DSUTIL_H
  9. #define DSUTIL_H
  10. //-----------------------------------------------------------------------------
  11. // Helper routines
  12. //-----------------------------------------------------------------------------
  13. HRESULT DSUtil_FillSoundBuffer( LPDIRECTSOUNDBUFFER pDSB, BYTE* pbWaveData,
  14. DWORD dwWaveSize );
  15. HRESULT DSUtil_ParseWaveResource( VOID* pvRes, WAVEFORMATEX** ppWaveHeader,
  16. BYTE** ppbWaveData, DWORD* pdwWaveSize );
  17. //-----------------------------------------------------------------------------
  18. // Name: DSUtil_LoadSoundBuffer()
  19. // Desc: Loads an IDirectSoundBuffer from a Win32 resource in the current
  20. // application.
  21. //-----------------------------------------------------------------------------
  22. LPDIRECTSOUNDBUFFER DSUtil_LoadSoundBuffer( LPDIRECTSOUND* pDS,
  23. LPCTSTR strName );
  24. //-----------------------------------------------------------------------------
  25. // Name: DSUtil_ReloadSoundBuffer()
  26. // Desc: Reloads an IDirectSoundBuffer from a Win32 resource in the current
  27. // application. normally used to handle a DSERR_BUFFERLOST error.
  28. //-----------------------------------------------------------------------------
  29. HRESULT DSUtil_ReloadSoundBuffer( LPDIRECTSOUNDBUFFER pDSB, LPCTSTR strName );
  30. //-----------------------------------------------------------------------------
  31. // Name: DSUtil_GetWaveResource()
  32. // Desc: Finds a WAV resource in a Win32 module.
  33. //-----------------------------------------------------------------------------
  34. HRESULT DSUtil_GetWaveResource( HMODULE hModule, LPCTSTR strName,
  35. WAVEFORMATEX** ppWaveHeader, BYTE** ppbWaveData,
  36. DWORD* pdwWaveSize );
  37. //-----------------------------------------------------------------------------
  38. // Name: struct SoundObject
  39. // Desc: Used to manage individual sounds which need to be played multiple
  40. // times concurrently. A SoundObject represents a queue of
  41. // IDirectSoundBuffer objects which all refer to the same buffer memory.
  42. //-----------------------------------------------------------------------------
  43. struct SoundObject
  44. {
  45. BYTE* pbWaveData; // Ptr into wave resource (for restore)
  46. DWORD cbWaveSize; // Size of wave data (for restore)
  47. DWORD dwNumBuffers; // Number of sound buffers.
  48. DWORD dwCurrent; // Current sound buffer
  49. LPDIRECTSOUNDBUFFER* pdsbBuffers; // List of sound buffers
  50. };
  51. //-----------------------------------------------------------------------------
  52. // Name: DSUtil_CreateSound()
  53. // Desc: Loads a SoundObject from a Win32 resource in the current application.
  54. //-----------------------------------------------------------------------------
  55. SoundObject* DSUtil_CreateSound( LPDIRECTSOUND pDS, LPCTSTR strName,
  56. DWORD dwNumConcurrentBuffers );
  57. //-----------------------------------------------------------------------------
  58. // Name: DSUtil_DestroySound()
  59. // Desc: Frees a SoundObject and releases all of its buffers.
  60. //-----------------------------------------------------------------------------
  61. VOID DSUtil_DestroySound( SoundObject* pSound );
  62. //-----------------------------------------------------------------------------
  63. // Name: DSUtil_PlayPannedSound()
  64. // Desc: Play a sound, but first set the panning according to where the
  65. // object is on the screen. fScreenXPos is between -1.0f (left) and
  66. // 1.0f (right).
  67. //-----------------------------------------------------------------------------
  68. VOID DSUtil_PlayPannedSound( SoundObject* pSound, FLOAT fScreenXPos );
  69. //-----------------------------------------------------------------------------
  70. // Name: DSUtil_PlaySound()
  71. // Desc: Plays a buffer in a SoundObject.
  72. //-----------------------------------------------------------------------------
  73. HRESULT DSUtil_PlaySound( SoundObject* pSound, DWORD dwPlayFlags );
  74. //-----------------------------------------------------------------------------
  75. // Name: DSUtil_StopSound()
  76. // Desc: Stops one or more buffers in a SoundObject.
  77. //-----------------------------------------------------------------------------
  78. HRESULT DSUtil_StopSound( SoundObject* pSound );
  79. //-----------------------------------------------------------------------------
  80. // Name: DSUtil_GetFreeSoundBuffer()
  81. // Desc: Returns one of the cloned buffers that is not currently playing
  82. //-----------------------------------------------------------------------------
  83. LPDIRECTSOUNDBUFFER DSUtil_GetFreeSoundBuffer( SoundObject* pSound );
  84. #endif // DSUTIL_H