alhelpers.h 1.6 KB

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