@@ -29309,7 +29380,7 @@ static ma_result ma_device__post_init_setup(ma_device* pDevice, ma_device_type d
...
@@ -29309,7 +29380,7 @@ static ma_result ma_device__post_init_setup(ma_device* pDevice, ma_device_type d
pDevice->playback.inputCacheConsumed = 0;
pDevice->playback.inputCacheConsumed = 0;
pDevice->playback.inputCacheRemaining = 0;
pDevice->playback.inputCacheRemaining = 0;
if ((pDevice->type == ma_device_type_duplex && ma_context_is_backend_asynchronous(pDevice->pContext)) || /* Duplex with asynchronous backend. */
if (pDevice->type == ma_device_type_duplex || /* Duplex. backend may decide to use ma_device_handle_backend_data_callback() which will require this cache. */
ma_data_converter_get_required_input_frame_count(&pDevice->playback.converter, 1, &unused) != MA_SUCCESS) /* Data conversion required input frame calculation not supported. */
ma_data_converter_get_required_input_frame_count(&pDevice->playback.converter, 1, &unused) != MA_SUCCESS) /* Data conversion required input frame calculation not supported. */
{
{
/* We need a heap allocated cache. We want to size this based on the period size. */
/* We need a heap allocated cache. We want to size this based on the period size. */
ma_channel defaultStereoChannelMap[2] = {MA_CHANNEL_SIDE_LEFT, MA_CHANNEL_SIDE_RIGHT}; /* <-- Consistent with the default channel map of a stereo listener. Means channel conversion can run on a fast path. */
ma_channel defaultStereoChannelMap[2] = {MA_CHANNEL_SIDE_LEFT, MA_CHANNEL_SIDE_RIGHT}; /* <-- Consistent with the default channel map of a stereo listener. Means channel conversion can run on a fast path. */
@@ -62659,6 +62781,7 @@ MA_API ma_result ma_engine_node_init_preallocated(const ma_engine_node_config* p
...
@@ -62659,6 +62781,7 @@ MA_API ma_result ma_engine_node_init_preallocated(const ma_engine_node_config* p
ma_fader_config faderConfig;
ma_fader_config faderConfig;
ma_spatializer_config spatializerConfig;
ma_spatializer_config spatializerConfig;
ma_panner_config pannerConfig;
ma_panner_config pannerConfig;
ma_gainer_config gainerConfig;
ma_uint32 channelsIn;
ma_uint32 channelsIn;
ma_uint32 channelsOut;
ma_uint32 channelsOut;
ma_channel defaultStereoChannelMap[2] = {MA_CHANNEL_SIDE_LEFT, MA_CHANNEL_SIDE_RIGHT}; /* <-- Consistent with the default channel map of a stereo listener. Means channel conversion can run on a fast path. */
ma_channel defaultStereoChannelMap[2] = {MA_CHANNEL_SIDE_LEFT, MA_CHANNEL_SIDE_RIGHT}; /* <-- Consistent with the default channel map of a stereo listener. Means channel conversion can run on a fast path. */
...
@@ -62681,15 +62804,17 @@ MA_API ma_result ma_engine_node_init_preallocated(const ma_engine_node_config* p
...
@@ -62681,15 +62804,17 @@ MA_API ma_result ma_engine_node_init_preallocated(const ma_engine_node_config* p
@@ -62769,6 +62894,18 @@ MA_API ma_result ma_engine_node_init_preallocated(const ma_engine_node_config* p
...
@@ -62769,6 +62894,18 @@ MA_API ma_result ma_engine_node_init_preallocated(const ma_engine_node_config* p
goto error3;
goto error3;
}
}
/* We'll need a gainer for smoothing out volume changes if we have a non-zero smooth time. We apply this before converting to the output channel count. */
ma_uint32sampleRate;/* Only used when the type is set to ma_engine_node_type_sound. */
ma_uint32sampleRate;/* Only used when the type is set to ma_engine_node_type_sound. */
ma_uint32volumeSmoothTimeInPCMFrames;/* The number of frames to smooth over volume changes. Defaults to 0 in which case no smoothing is used. */
ma_mono_expansion_modemonoExpansionMode;
ma_mono_expansion_modemonoExpansionMode;
ma_bool8isPitchDisabled;/* Pitching can be explicitly disabled with MA_SOUND_FLAG_NO_PITCH to optimize processing. */
ma_bool8isPitchDisabled;/* Pitching can be explicitly disabled with MA_SOUND_FLAG_NO_PITCH to optimize processing. */
ma_bool8isSpatializationDisabled;/* Spatialization can be explicitly disabled with MA_SOUND_FLAG_NO_SPATIALIZATION. */
ma_bool8isSpatializationDisabled;/* Spatialization can be explicitly disabled with MA_SOUND_FLAG_NO_SPATIALIZATION. */
...
@@ -7317,11 +7318,14 @@ typedef struct
...
@@ -7317,11 +7318,14 @@ typedef struct
ma_node_basebaseNode;/* Must be the first member for compatiblity with the ma_node API. */
ma_node_basebaseNode;/* Must be the first member for compatiblity with the ma_node API. */
ma_engine*pEngine;/* A pointer to the engine. Set based on the value from the config. */
ma_engine*pEngine;/* A pointer to the engine. Set based on the value from the config. */
ma_uint32sampleRate;/* The sample rate of the input data. For sounds backed by a data source, this will be the data source's sample rate. Otherwise it'll be the engine's sample rate. */
ma_uint32sampleRate;/* The sample rate of the input data. For sounds backed by a data source, this will be the data source's sample rate. Otherwise it'll be the engine's sample rate. */
ma_uint32volumeSmoothTimeInPCMFrames;
ma_mono_expansion_modemonoExpansionMode;
ma_mono_expansion_modemonoExpansionMode;
ma_faderfader;
ma_faderfader;
ma_linear_resamplerresampler;/* For pitch shift. */
ma_linear_resamplerresampler;/* For pitch shift. */
ma_spatializerspatializer;
ma_spatializerspatializer;
ma_pannerpanner;
ma_pannerpanner;
ma_gainervolumeGainer;/* This will only be used if volumeSmoothTimeInPCMFrames is > 0. */
ma_atomic_floatvolume;/* Defaults to 1. */
MA_ATOMIC(4,float)pitch;
MA_ATOMIC(4,float)pitch;
floatoldPitch;/* For determining whether or not the resampler needs to be updated to reflect the new pitch. The resampler will be updated on the mixing thread. */
floatoldPitch;/* For determining whether or not the resampler needs to be updated to reflect the new pitch. The resampler will be updated on the mixing thread. */
floatoldDopplerPitch;/* For determining whether or not the resampler needs to be updated to take a new doppler pitch into account. */
floatoldDopplerPitch;/* For determining whether or not the resampler needs to be updated to take a new doppler pitch into account. */
...
@@ -7356,6 +7360,7 @@ typedef struct
...
@@ -7356,6 +7360,7 @@ typedef struct
ma_uint32channelsOut;/* Set this to 0 (default) to use the engine's channel count. Set to MA_SOUND_SOURCE_CHANNEL_COUNT to use the data source's channel count (only used if using a data source as input). */
ma_uint32channelsOut;/* Set this to 0 (default) to use the engine's channel count. Set to MA_SOUND_SOURCE_CHANNEL_COUNT to use the data source's channel count (only used if using a data source as input). */
ma_mono_expansion_modemonoExpansionMode;/* Controls how the mono channel should be expanded to other channels when spatialization is disabled on a sound. */
ma_mono_expansion_modemonoExpansionMode;/* Controls how the mono channel should be expanded to other channels when spatialization is disabled on a sound. */
ma_uint32flags;/* A combination of MA_SOUND_FLAG_* flags. */
ma_uint32flags;/* A combination of MA_SOUND_FLAG_* flags. */
ma_uint32volumeSmoothTimeInPCMFrames;/* The number of frames to smooth over volume changes. Defaults to 0 in which case no smoothing is used. */
ma_uint64initialSeekPointInPCMFrames;/* Initializes the sound such that it's seeked to this location by default. */
ma_uint64initialSeekPointInPCMFrames;/* Initializes the sound such that it's seeked to this location by default. */
ma_resource_manager*pResourceManager;/* Can be null in which case a resource manager will be created for you. */
ma_resource_manager*pResourceManager;/* Can be null in which case a resource manager will be created for you. */
#endif
#endif
#if !defined(MA_NO_DEVICE_IO)
#if !defined(MA_NO_DEVICE_IO)
ma_context*pContext;
ma_context*pContext;
ma_device*pDevice;/* If set, the caller is responsible for calling ma_engine_data_callback() in the device's data callback. */
ma_device*pDevice;/* If set, the caller is responsible for calling ma_engine_data_callback() in the device's data callback. */
ma_device_id*pPlaybackDeviceID;/* The ID of the playback device to use with the default listener. */
ma_device_id*pPlaybackDeviceID;/* The ID of the playback device to use with the default listener. */
ma_device_notification_procnotificationCallback;
ma_device_notification_procnotificationCallback;
#endif
#endif
ma_log*pLog;/* When set to NULL, will use the context's log. */
ma_log*pLog;/* When set to NULL, will use the context's log. */
ma_uint32listenerCount;/* Must be between 1 and MA_ENGINE_MAX_LISTENERS. */
ma_uint32listenerCount;/* Must be between 1 and MA_ENGINE_MAX_LISTENERS. */
ma_uint32channels;/* The number of channels to use when mixing and spatializing. When set to 0, will use the native channel count of the device. */
ma_uint32channels;/* The number of channels to use when mixing and spatializing. When set to 0, will use the native channel count of the device. */
ma_uint32sampleRate;/* The sample rate. When set to 0 will use the native channel count of the device. */
ma_uint32sampleRate;/* The sample rate. When set to 0 will use the native channel count of the device. */
ma_uint32periodSizeInFrames;/* If set to something other than 0, updates will always be exactly this size. The underlying device may be a different size, but from the perspective of the mixer that won't matter.*/
ma_uint32periodSizeInFrames;/* If set to something other than 0, updates will always be exactly this size. The underlying device may be a different size, but from the perspective of the mixer that won't matter.*/
ma_uint32periodSizeInMilliseconds;/* Used if periodSizeInFrames is unset. */
ma_uint32periodSizeInMilliseconds;/* Used if periodSizeInFrames is unset. */
ma_uint32gainSmoothTimeInFrames;/* The number of frames to interpolate the gain of spatialized sounds across. If set to 0, will use gainSmoothTimeInMilliseconds. */
ma_uint32gainSmoothTimeInFrames;/* The number of frames to interpolate the gain of spatialized sounds across. If set to 0, will use gainSmoothTimeInMilliseconds. */
ma_uint32gainSmoothTimeInMilliseconds;/* When set to 0, gainSmoothTimeInFrames will be used. If both are set to 0, a default value will be used. */
ma_uint32gainSmoothTimeInMilliseconds;/* When set to 0, gainSmoothTimeInFrames will be used. If both are set to 0, a default value will be used. */
ma_uint32defaultVolumeSmoothTimeInPCMFrames;/* Defaults to 0. Controls the default amount of smoothing to apply to volume changes to sounds. High values means more smoothing at the expense of high latency (will take longer to reach the new volume). */
ma_allocation_callbacksallocationCallbacks;
ma_allocation_callbacksallocationCallbacks;
ma_bool32noAutoStart;/* When set to true, requires an explicit call to ma_engine_start(). This is false by default, meaning the engine will be started automatically in ma_engine_init(). */
ma_bool32noAutoStart;/* When set to true, requires an explicit call to ma_engine_start(). This is false by default, meaning the engine will be started automatically in ma_engine_init(). */
ma_bool32noDevice;/* When set to true, don't create a default device. ma_engine_read_pcm_frames() can be called manually to read data. */
ma_bool32noDevice;/* When set to true, don't create a default device. ma_engine_read_pcm_frames() can be called manually to read data. */
ma_mono_expansion_modemonoExpansionMode;/* Controls how the mono channel should be expanded to other channels when spatialization is disabled on a sound. */
ma_mono_expansion_modemonoExpansionMode;/* Controls how the mono channel should be expanded to other channels when spatialization is disabled on a sound. */
ma_vfs*pResourceManagerVFS;/* A pointer to a pre-allocated VFS object to use with the resource manager. This is ignored if pResourceManager is not NULL. */
ma_vfs*pResourceManagerVFS;/* A pointer to a pre-allocated VFS object to use with the resource manager. This is ignored if pResourceManager is not NULL. */