/* TODO: Remove the pCallbacks parameter when we move all backends to the new callbacks system, at which time we can just reference the context directly. */
return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "ma_device_init() called with an invalid config. Device type is invalid. Make sure the device type has been set in the config.", MA_INVALID_DEVICE_CONFIG);
}
if (config.deviceType == ma_device_type_capture || config.deviceType == ma_device_type_duplex) {
if (config.capture.channels > MA_MAX_CHANNELS) {
if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
if (pConfig->capture.channels > MA_MAX_CHANNELS) {
return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "ma_device_init() called with an invalid config. Capture channel count cannot exceed 32.", MA_INVALID_DEVICE_CONFIG);
}
if (!ma__is_channel_map_valid(config.capture.channelMap, config.capture.channels)) {
if (!ma__is_channel_map_valid(pConfig->capture.channelMap, pConfig->capture.channels)) {
return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "ma_device_init() called with invalid config. Capture channel map is invalid.", MA_INVALID_DEVICE_CONFIG);
if (pConfig->playback.channels > MA_MAX_CHANNELS) {
return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "ma_device_init() called with an invalid config. Playback channel count cannot exceed 32.", MA_INVALID_DEVICE_CONFIG);
}
if (!ma__is_channel_map_valid(config.playback.channelMap, config.playback.channels)) {
if (!ma__is_channel_map_valid(pConfig->playback.channelMap, pConfig->playback.channels)) {
return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "ma_device_init() called with invalid config. Playback channel map is invalid.", MA_INVALID_DEVICE_CONFIG);
Must have at least 3 periods for full-duplex mode. The idea is that the playback and capture positions hang out in the middle period, with the surrounding
periods acting as a buffer in case the capture and playback devices get's slightly out of sync.
*/
if (config.deviceType == ma_device_type_duplex && config.periods < 3) {
config.periods = 3;
}
/* Default buffer size. */
if (config.periodSizeInMilliseconds == 0 && config.periodSizeInFrames == 0) {