ma_formatformat;/* Sample format. If set to ma_format_unknown, all sample formats are supported. */
ma_uint32channels;/* If set to 0, all channels are supported. */
ma_uint32sampleRate;/* If set to 0, all sample rates are supported. */
ma_uint32flags;
}nativeDataFormats[64];
ma_uint32flags;/* A combination of MA_DATA_FORMAT_FLAG_* flags. */
}nativeDataFormats[/*ma_format_count * ma_standard_sample_rate_count * MA_MAX_CHANNELS*/64];/* Not sure how big to make this. There can be *many* permutations for virtual devices which can support anything. */
}ma_device_info;
structma_device_config
...
...
@@ -2027,12 +2043,13 @@ If the backend requires absolute flexibility with it's data delivery, it can opt
which will allow it to implement the logic that will run on the audio thread. This is much more advanced and is completely optional.
The audio thread should run data delivery logic in a loop while `ma_device_get_state() == MA_STATE_STARTED` and no errors have been
encounted. Do not start or stop the device here. That will be handled from outside the `onDeviceAudioThread()` callback.
encounted. Do not start or stop the device here. That will be handled from outside the `onDeviceDataLoop()` callback.
The invocation of the `onDeviceAudioThread()` callback will be handled by miniaudio. When you start the device, miniaudio will fire this
The invocation of the `onDeviceDataLoop()` callback will be handled by miniaudio. When you start the device, miniaudio will fire this
callback. When the device is stopped, the `ma_device_get_state() == MA_STATE_STARTED` condition will fail and the loop will be terminated
which will then fall through to the part that stops the device. For an example on how to implement the `onDeviceAudioThread()` callback,
look at `ma_device_audio_thread__default_read_write()`.
which will then fall through to the part that stops the device. For an example on how to implement the `onDeviceDataLoop()` callback,
look at `ma_device_audio_thread__default_read_write()`. Implement the `onDeviceDataLoopWakeup()` callback if you need a mechanism to
/* WASAPI specific structure for some commands which must run on a common thread due to bugs in WASAPI. */
typedefstruct
{
intcode;
ma_event*pEvent;/* This will be signalled when the event is complete. */
union
{
struct
{
int_unused;
}quit;
struct
{
ma_device_typedeviceType;
void*pAudioClient;
void**ppAudioClientService;
ma_resultresult;/* The result from creating the audio client service. */
}createAudioClient;
struct
{
ma_device*pDevice;
ma_device_typedeviceType;
}releaseAudioClient;
}data;
}ma_context_command__wasapi;
structma_context
{
ma_backend_callbackscallbacks;
...
...
@@ -2096,23 +2140,18 @@ struct ma_context
ma_uint32playbackDeviceInfoCount;
ma_uint32captureDeviceInfoCount;
ma_device_info*pDeviceInfos;/* Playback devices first, then capture. */
ma_bool8isBackendAsynchronous;/* Set when the context is initialized. Set to 1 for asynchronous backends such as Core Audio and JACK. Do not modify. */
ma_result(*onUninit)(ma_context*pContext);
ma_result(*onEnumDevices)(ma_context*pContext,ma_enum_devices_callback_proccallback,void*pUserData);/* Return false from the callback to stop enumeration. */
ma_bool32noAudioSessionDeactivate;/* For tracking whether or not the iOS audio session should be explicitly deactivated. Set from the config in ma_context_init__coreaudio(). */
}coreaudio;
#endif
...
...
@@ -2491,15 +2535,12 @@ struct ma_device
ma_device_callback_proconData;/* Set once at initialization time and should not be changed after. */
ma_stop_proconStop;/* Set once at initialization time and should not be changed after. */
void*pUserData;/* Application defined data. */
ma_mutexlock;
ma_mutexstartStopLock;
ma_eventwakeupEvent;
ma_eventstartEvent;
ma_eventstopEvent;
ma_threadthread;
ma_resultworkResult;/* This is set by the worker thread after it's finished doing a job. */
ma_bool8usingDefaultSampleRate;
ma_bool8usingDefaultBufferSize;
ma_bool8usingDefaultPeriods;
ma_bool8isOwnerOfContext;/* When set to true, uninitializing the device will also uninitialize the context. Set to true when NULL is passed into ma_device_init(). */
ma_bool8noPreZeroedOutputBuffer;
ma_bool8noClip;
...
...
@@ -2533,9 +2574,6 @@ struct ma_device
ma_uint32internalPeriods;
ma_channel_mix_modechannelMixMode;
ma_data_converterconverter;
ma_bool8usingDefaultFormat;
ma_bool8usingDefaultChannels;
ma_bool8usingDefaultChannelMap;
}playback;
struct
{
...
...
@@ -2553,9 +2591,6 @@ struct ma_device
ma_uint32internalPeriods;
ma_channel_mix_modechannelMixMode;
ma_data_converterconverter;
ma_bool8usingDefaultFormat;
ma_bool8usingDefaultChannels;
ma_bool8usingDefaultChannelMap;
}capture;
union
...
...
@@ -2579,15 +2614,15 @@ struct ma_device
ma_performance_profileoriginalPerformanceProfile;
ma_uint32periodSizeInFramesPlayback;
ma_uint32periodSizeInFramesCapture;
MA_ATOMICma_bool8hasDefaultPlaybackDeviceChanged;/* Can be read and written simultaneously across different threads. Must be used atomically. */
MA_ATOMICma_bool8hasDefaultCaptureDeviceChanged;/* Can be read and written simultaneously across different threads. Must be used atomically. */
MA_ATOMICma_bool8isStartedCapture;/* Can be read and written simultaneously across different threads. Must be used atomically. */
MA_ATOMICma_bool8isStartedPlayback;/* Can be read and written simultaneously across different threads. Must be used atomically. */
MA_ATOMICma_bool32isStartedCapture;/* Can be read and written simultaneously across different threads. Must be used atomically, and must be 32-bit. */
MA_ATOMICma_bool32isStartedPlayback;/* Can be read and written simultaneously across different threads. Must be used atomically, and must be 32-bit. */
ma_bool8noAutoConvertSRC;/* When set to true, disables the use of AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM. */
ma_bool8noDefaultQualitySRC;/* When set to true, disables the use of AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY. */
ma_bool8noHardwareOffloading;
ma_bool8allowCaptureAutoStreamRouting;
ma_bool8allowPlaybackAutoStreamRouting;
ma_bool8isDetachedPlayback;
ma_bool8isDetachedCapture;
}wasapi;
#endif
#ifdef MA_SUPPORT_DSOUND
...
...
@@ -2633,7 +2668,6 @@ struct ma_device
{
/*pa_stream**/ma_ptrpStreamPlayback;
/*pa_stream**/ma_ptrpStreamCapture;
ma_pcm_rbduplexRB;
}pulse;
#endif
#ifdef MA_SUPPORT_JACK
...
...
@@ -2659,11 +2693,11 @@ struct ma_device
ma_uint32originalPeriodSizeInFrames;
ma_uint32originalPeriodSizeInMilliseconds;
ma_uint32originalPeriods;
ma_performance_profileoriginalPerformanceProfile;
ma_bool32isDefaultPlaybackDevice;
ma_bool32isDefaultCaptureDevice;
ma_bool32isSwitchingPlaybackDevice;/* <-- Set to true when the default device has changed and miniaudio is in the process of switching. */
ma_bool32isSwitchingCaptureDevice;/* <-- Set to true when the default device has changed and miniaudio is in the process of switching. */
ma_pcm_rbduplexRB;
void*pRouteChangeHandler;/* Only used on mobile platforms. Obj-C object for handling route changes. */
}coreaudio;
#endif
...
...
@@ -2695,7 +2729,6 @@ struct ma_device
{
/*AAudioStream**/ma_ptrpStreamPlayback;
/*AAudioStream**/ma_ptrpStreamCapture;
ma_pcm_rbduplexRB;
}aaudio;
#endif
#ifdef MA_SUPPORT_OPENSL
...
...
@@ -2715,7 +2748,6 @@ struct ma_device
ma_uint32currentBufferIndexCapture;
ma_uint8*pBufferPlayback;/* This is malloc()'d and is used for storing audio data. Typed as ma_uint8 for easy offsetting. */
ma_uint8*pBufferCapture;
ma_pcm_rbduplexRB;
}opensl;
#endif
#ifdef MA_SUPPORT_WEBAUDIO
...
...
@@ -2740,7 +2772,7 @@ struct ma_device
ma_uint32currentPeriodFramesRemainingCapture;
ma_uint64lastProcessedFramePlayback;
ma_uint64lastProcessedFrameCapture;
MA_ATOMICma_bool8isStarted;/* Read and written by multiple threads. Must be used atomically. */
MA_ATOMICma_bool32isStarted;/* Read and written by multiple threads. Must be used atomically, and must be 32-bit for compiler compatibility. */
}null_device;
#endif
};
...
...
@@ -3615,7 +3647,7 @@ pDevice (in)
Return Value
------------
MA_SUCCESS if successful; any other error code otherwise.