API CHANGE: Update ma_get_standard_channel_map().

This adds a capacity parameter for added safety. It also changes the
order of parameters to make it a bit more consistent.
This commit is contained in:
David Reid
2021-07-04 19:46:00 +10:00
parent 3fad6cad86
commit 33aae652fe
5 changed files with 625 additions and 627 deletions
+1 -1
View File
@@ -415,7 +415,7 @@ static ma_result ma_device_init_internal__sdl(ma_device_ex* pDeviceEx, const ma_
pDescriptor->format = ma_format_from_sdl(obtainedSpec.format);
pDescriptor->channels = obtainedSpec.channels;
pDescriptor->sampleRate = (ma_uint32)obtainedSpec.freq;
ma_get_standard_channel_map(ma_standard_channel_map_default, pDescriptor->channels, pDescriptor->channelMap);
ma_get_standard_channel_map(ma_standard_channel_map_default, pDescriptor->channelMap, ma_countof(pDescriptor->channelMap), pDescriptor->channels);
pDescriptor->periodSizeInFrames = obtainedSpec.samples;
pDescriptor->periodCount = 1; /* SDL doesn't use the notion of period counts, so just set to 1. */
+1 -1
View File
@@ -403,7 +403,7 @@ MA_API ma_result ma_libopus_get_data_format(ma_libopus* pOpus, ma_format* pForma
}
if (pChannelMap != NULL) {
ma_get_standard_channel_map(ma_standard_channel_map_vorbis, (ma_uint32)ma_min(channels, channelMapCap), pChannelMap);
ma_get_standard_channel_map(ma_standard_channel_map_vorbis, pChannelMap, channelMapCap, channels);
}
return MA_SUCCESS;
+1 -1
View File
@@ -416,7 +416,7 @@ MA_API ma_result ma_libvorbis_get_data_format(ma_libvorbis* pVorbis, ma_format*
}
if (pChannelMap != NULL) {
ma_get_standard_channel_map(ma_standard_channel_map_vorbis, (ma_uint32)ma_min((size_t)pInfo->channels, channelMapCap), pChannelMap);
ma_get_standard_channel_map(ma_standard_channel_map_vorbis, pChannelMap, channelMapCap, pInfo->channels);
}
return MA_SUCCESS;
+608 -610
View File
File diff suppressed because it is too large Load Diff
+7 -7
View File
@@ -2544,7 +2544,7 @@ static ma_result ma_paged_audio_buffer__data_source_on_get_data_format(ma_data_s
*pFormat = pPagedAudioBuffer->pData->format;
*pChannels = pPagedAudioBuffer->pData->channels;
*pSampleRate = 0; /* There is no notion of a sample rate with audio buffers. */
ma_get_standard_channel_map(ma_standard_channel_map_default, (ma_uint32)ma_min(channelMapCap, pPagedAudioBuffer->pData->channels), pChannelMap);
ma_get_standard_channel_map(ma_standard_channel_map_default, pChannelMap, channelMapCap, pPagedAudioBuffer->pData->channels);
return MA_SUCCESS;
}
@@ -8642,7 +8642,7 @@ MA_API ma_result ma_resource_manager_data_buffer_get_data_format(ma_resource_man
*pFormat = pDataBuffer->pNode->data.decoded.format;
*pChannels = pDataBuffer->pNode->data.decoded.channels;
*pSampleRate = pDataBuffer->pNode->data.decoded.sampleRate;
ma_get_standard_channel_map(ma_standard_channel_map_default, (ma_uint32)ma_min(channelMapCap, pDataBuffer->pNode->data.decoded.channels), pChannelMap);
ma_get_standard_channel_map(ma_standard_channel_map_default, pChannelMap, channelMapCap, pDataBuffer->pNode->data.decoded.channels);
return MA_SUCCESS;
};
@@ -8651,7 +8651,7 @@ MA_API ma_result ma_resource_manager_data_buffer_get_data_format(ma_resource_man
*pFormat = pDataBuffer->pNode->data.decodedPaged.data.format;
*pChannels = pDataBuffer->pNode->data.decodedPaged.data.channels;
*pSampleRate = pDataBuffer->pNode->data.decodedPaged.sampleRate;
ma_get_standard_channel_map(ma_standard_channel_map_default, (ma_uint32)ma_min(channelMapCap, pDataBuffer->pNode->data.decoded.channels), pChannelMap);
ma_get_standard_channel_map(ma_standard_channel_map_default, pChannelMap, channelMapCap, pDataBuffer->pNode->data.decoded.channels);
return MA_SUCCESS;
};
@@ -10971,7 +10971,7 @@ static float ma_doppler_pitch(ma_vec3f relativePosition, ma_vec3f sourceVelocity
}
static void ma_get_default_channel_map_for_spatializer(ma_uint32 channelCount, ma_channel* pChannelMap)
static void ma_get_default_channel_map_for_spatializer(ma_channel* pChannelMap, size_t channelMapCap, ma_uint32 channelCount)
{
/*
Special case for stereo. Want to default the left and right speakers to side left and side
@@ -10984,7 +10984,7 @@ static void ma_get_default_channel_map_for_spatializer(ma_uint32 channelCount, m
pChannelMap[0] = MA_CHANNEL_SIDE_LEFT;
pChannelMap[1] = MA_CHANNEL_SIDE_RIGHT;
} else {
ma_get_standard_channel_map(ma_standard_channel_map_default, channelCount, pChannelMap);
ma_get_standard_channel_map(ma_standard_channel_map_default, pChannelMap, channelMapCap, channelCount);
}
}
@@ -11091,7 +11091,7 @@ MA_API ma_result ma_spatializer_listener_init_preallocated(const ma_spatializer_
/* Use a slightly different default channel map for stereo. */
if (pConfig->pChannelMapOut == NULL) {
ma_get_default_channel_map_for_spatializer(pConfig->channelsOut, pListener->config.pChannelMapOut);
ma_get_default_channel_map_for_spatializer(pListener->config.pChannelMapOut, pConfig->channelsOut, pConfig->channelsOut);
} else {
ma_channel_map_copy_or_default(pListener->config.pChannelMapOut, pConfig->pChannelMapOut, pConfig->channelsOut);
}
@@ -14286,7 +14286,7 @@ MA_API ma_result ma_sound_get_data_format(ma_sound* pSound, ma_format* pFormat,
}
if (pChannelMap != NULL) {
ma_get_standard_channel_map(ma_standard_channel_map_default, (ma_uint32)ma_min(channels, channelMapCap), pChannelMap);
ma_get_standard_channel_map(ma_standard_channel_map_default, pChannelMap, channelMapCap, channels);
}
return MA_SUCCESS;