mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
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:
@@ -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->format = ma_format_from_sdl(obtainedSpec.format);
|
||||||
pDescriptor->channels = obtainedSpec.channels;
|
pDescriptor->channels = obtainedSpec.channels;
|
||||||
pDescriptor->sampleRate = (ma_uint32)obtainedSpec.freq;
|
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->periodSizeInFrames = obtainedSpec.samples;
|
||||||
pDescriptor->periodCount = 1; /* SDL doesn't use the notion of period counts, so just set to 1. */
|
pDescriptor->periodCount = 1; /* SDL doesn't use the notion of period counts, so just set to 1. */
|
||||||
|
|
||||||
|
|||||||
@@ -403,7 +403,7 @@ MA_API ma_result ma_libopus_get_data_format(ma_libopus* pOpus, ma_format* pForma
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pChannelMap != NULL) {
|
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;
|
return MA_SUCCESS;
|
||||||
|
|||||||
@@ -416,7 +416,7 @@ MA_API ma_result ma_libvorbis_get_data_format(ma_libvorbis* pVorbis, ma_format*
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pChannelMap != NULL) {
|
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;
|
return MA_SUCCESS;
|
||||||
|
|||||||
+608
-610
File diff suppressed because it is too large
Load Diff
@@ -2544,7 +2544,7 @@ static ma_result ma_paged_audio_buffer__data_source_on_get_data_format(ma_data_s
|
|||||||
*pFormat = pPagedAudioBuffer->pData->format;
|
*pFormat = pPagedAudioBuffer->pData->format;
|
||||||
*pChannels = pPagedAudioBuffer->pData->channels;
|
*pChannels = pPagedAudioBuffer->pData->channels;
|
||||||
*pSampleRate = 0; /* There is no notion of a sample rate with audio buffers. */
|
*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;
|
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;
|
*pFormat = pDataBuffer->pNode->data.decoded.format;
|
||||||
*pChannels = pDataBuffer->pNode->data.decoded.channels;
|
*pChannels = pDataBuffer->pNode->data.decoded.channels;
|
||||||
*pSampleRate = pDataBuffer->pNode->data.decoded.sampleRate;
|
*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;
|
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;
|
*pFormat = pDataBuffer->pNode->data.decodedPaged.data.format;
|
||||||
*pChannels = pDataBuffer->pNode->data.decodedPaged.data.channels;
|
*pChannels = pDataBuffer->pNode->data.decodedPaged.data.channels;
|
||||||
*pSampleRate = pDataBuffer->pNode->data.decodedPaged.sampleRate;
|
*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;
|
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
|
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[0] = MA_CHANNEL_SIDE_LEFT;
|
||||||
pChannelMap[1] = MA_CHANNEL_SIDE_RIGHT;
|
pChannelMap[1] = MA_CHANNEL_SIDE_RIGHT;
|
||||||
} else {
|
} 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. */
|
/* Use a slightly different default channel map for stereo. */
|
||||||
if (pConfig->pChannelMapOut == NULL) {
|
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 {
|
} else {
|
||||||
ma_channel_map_copy_or_default(pListener->config.pChannelMapOut, pConfig->pChannelMapOut, pConfig->channelsOut);
|
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) {
|
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;
|
return MA_SUCCESS;
|
||||||
|
|||||||
Reference in New Issue
Block a user