alhelpers.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef ALHELPERS_H
  2. #define ALHELPERS_H
  3. #ifndef _WIN32
  4. #include <unistd.h>
  5. #define Sleep(x) usleep((x)*1000)
  6. #else
  7. #define WIN32_LEAN_AND_MEAN
  8. #include <windows.h>
  9. #endif
  10. #include "AL/alc.h"
  11. #include "AL/al.h"
  12. #include "AL/alext.h"
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif /* __cplusplus */
  16. /* Some helper functions to get the name from the channel and type enums. */
  17. const char *ChannelsName(ALenum chans);
  18. const char *TypeName(ALenum type);
  19. /* Helpers to convert frame counts and byte lengths. */
  20. ALsizei FramesToBytes(ALsizei size, ALenum channels, ALenum type);
  21. ALsizei BytesToFrames(ALsizei size, ALenum channels, ALenum type);
  22. /* Retrieves a compatible buffer format given the channel configuration and
  23. * sample type. If an alIsBufferFormatSupportedSOFT-compatible function is
  24. * provided, it will be called to find the closest-matching format from
  25. * AL_SOFT_buffer_samples. Returns AL_NONE (0) if no supported format can be
  26. * found. */
  27. ALenum GetFormat(ALenum channels, ALenum type, LPALISBUFFERFORMATSUPPORTEDSOFT palIsBufferFormatSupportedSOFT);
  28. /* Loads samples into a buffer using the standard alBufferData call, but with a
  29. * LPALBUFFERSAMPLESSOFT-compatible prototype. Assumes internalformat is valid
  30. * for alBufferData, and that channels and type match it. */
  31. void AL_APIENTRY wrap_BufferSamples(ALuint buffer, ALuint samplerate,
  32. ALenum internalformat, ALsizei samples,
  33. ALenum channels, ALenum type,
  34. const ALvoid *data);
  35. /* Easy device init/deinit functions. InitAL returns 0 on success. */
  36. int InitAL(void);
  37. void CloseAL(void);
  38. #ifdef __cplusplus
  39. }
  40. #endif /* __cplusplus */
  41. #endif /* ALHELPERS_H */