wchar_t wasapi[64]; /* WASAPI uses a wchar_t string for identification. */
wchar_t wasapi[64]; /* WASAPI uses a wchar_t string for identification. */
...
@@ -2493,12 +2499,6 @@ typedef struct
...
@@ -2493,12 +2499,6 @@ typedef struct
ma_uint32 maxSampleRate;
ma_uint32 maxSampleRate;
} ma_device_info;
} ma_device_info;
typedef union
{
ma_int64 counter;
double counterD;
} ma_timer;
typedef struct
typedef struct
{
{
ma_device_type deviceType;
ma_device_type deviceType;
...
@@ -3879,6 +3879,67 @@ ALSA Specific: When initializing the default device, requesting shared mode will
...
@@ -3879,6 +3879,67 @@ ALSA Specific: When initializing the default device, requesting shared mode will
If these fail it will try falling back to the "hw" device.
If these fail it will try falling back to the "hw" device.
Example 1 - Simple Initialization
---------------------------------
This example shows how to initialize a simple playback default using a standard configuration. If you are just needing to do simple playback from the default
ma_result result = ma_device_init(NULL, &config, &device);
if (result != MA_SUCCESS) {
// Error
}
```
Example 2 - Advanced Initialization
-----------------------------------
This example show how you might do some more advanced initialization. In this hypothetical example we want to control the latency by setting the buffer size
and period count. We also want to allow the user to be able to choose which device to output from which means we need a context so we can perform device
enumeration.
```c
ma_context context;
ma_result result = ma_context_init(NULL, 0, NULL, &context);
if (result != MA_SUCCESS) {
// Error
}
ma_device_info* pPlaybackDeviceInfos;
ma_uint32 playbackDeviceCount;
result = ma_context_get_devices(&context, &pPlaybackDeviceInfos, &playbackDeviceCount, NULL, NULL);
if (result != MA_SUCCESS) {
// Error
}
// ... choose a device from pPlaybackDeviceInfos ...
config.playback.pDeviceID = pMyChosenDeviceID; // <-- Get this from the `id` member of one of the `ma_device_info` objects returned by ma_context_get_devices().
config.playback.format = ma_format_f32;
config.playback.channels = 2;
config.sampleRate = 48000;
config.dataCallback = ma_data_callback;
config.pUserData = pMyUserData;
config.bufferSizeInMilliseconds = 30;
config.periods = 3;
ma_device device;
result = ma_device_init(&context, &config, &device);