Fix a couple comment typos, and a minor cleanup
[openal-soft.git] / examples / alhelpers.h
blobeda8925e8833bc9d8f0c2fb49d30b28acc78ec51
1 #ifndef ALHELPERS_H
2 #define ALHELPERS_H
4 #ifndef _WIN32
5 #include <unistd.h>
6 #define Sleep(x) usleep((x)*1000)
7 #else
8 #define WIN32_LEAN_AND_MEAN
9 #include <windows.h>
10 #endif
12 #ifdef __cplusplus
13 extern "C" {
14 #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);
20 /* Helpers to convert frame counts and byte lengths. */
21 ALsizei FramesToBytes(ALsizei size, ALenum channels, ALenum type);
22 ALsizei BytesToFrames(ALsizei size, ALenum channels, ALenum type);
24 /* Retrieves a compatible buffer format given the channel configuration and
25 * sample type. If an alIsBufferFormatSupportedSOFT-compatible function is
26 * provided, it will be called to find the closest-matching format from
27 * AL_SOFT_buffer_samples. Returns AL_NONE (0) if no supported format can be
28 * found. */
29 ALenum GetFormat(ALenum channels, ALenum type, LPALISBUFFERFORMATSUPPORTEDSOFT palIsBufferFormatSupportedSOFT);
31 /* Loads samples into a buffer using the standard alBufferData call, but with a
32 * LPALBUFFERSAMPLESSOFT-compatible prototype. Assumes internalformat is valid
33 * for alBufferData, and that channels and type match it. */
34 void AL_APIENTRY wrap_BufferSamples(ALuint buffer, ALuint samplerate,
35 ALenum internalformat, ALsizei samples,
36 ALenum channels, ALenum type,
37 const ALvoid *data);
39 /* Easy device init/deinit functions. InitAL returns 0 on success. */
40 int InitAL(void);
41 void CloseAL(void);
43 #ifdef __cplusplus
45 #endif /* __cplusplus */
47 #endif /* ALHELPERS_H */