mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
Add the notion of samples rates to audio buffers.
This commit is contained in:
+11
-4
@@ -9335,6 +9335,7 @@ typedef struct
|
|||||||
ma_data_source_base ds;
|
ma_data_source_base ds;
|
||||||
ma_format format;
|
ma_format format;
|
||||||
ma_uint32 channels;
|
ma_uint32 channels;
|
||||||
|
ma_uint32 sampleRate;
|
||||||
ma_uint64 cursor;
|
ma_uint64 cursor;
|
||||||
ma_uint64 sizeInFrames;
|
ma_uint64 sizeInFrames;
|
||||||
const void* pData;
|
const void* pData;
|
||||||
@@ -9358,6 +9359,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
ma_format format;
|
ma_format format;
|
||||||
ma_uint32 channels;
|
ma_uint32 channels;
|
||||||
|
ma_uint32 sampleRate;
|
||||||
ma_uint64 sizeInFrames;
|
ma_uint64 sizeInFrames;
|
||||||
const void* pData; /* If set to NULL, will allocate a block of memory for you. */
|
const void* pData; /* If set to NULL, will allocate a block of memory for you. */
|
||||||
ma_allocation_callbacks allocationCallbacks;
|
ma_allocation_callbacks allocationCallbacks;
|
||||||
@@ -55200,7 +55202,7 @@ static ma_result ma_audio_buffer_ref__data_source_on_get_data_format(ma_data_sou
|
|||||||
|
|
||||||
*pFormat = pAudioBufferRef->format;
|
*pFormat = pAudioBufferRef->format;
|
||||||
*pChannels = pAudioBufferRef->channels;
|
*pChannels = pAudioBufferRef->channels;
|
||||||
*pSampleRate = 0; /* There is no notion of a sample rate with audio buffers. */
|
*pSampleRate = pAudioBufferRef->sampleRate;
|
||||||
ma_channel_map_init_standard(ma_standard_channel_map_default, pChannelMap, channelMapCap, pAudioBufferRef->channels);
|
ma_channel_map_init_standard(ma_standard_channel_map_default, pChannelMap, channelMapCap, pAudioBufferRef->channels);
|
||||||
|
|
||||||
return MA_SUCCESS;
|
return MA_SUCCESS;
|
||||||
@@ -55256,6 +55258,7 @@ MA_API ma_result ma_audio_buffer_ref_init(ma_format format, ma_uint32 channels,
|
|||||||
|
|
||||||
pAudioBufferRef->format = format;
|
pAudioBufferRef->format = format;
|
||||||
pAudioBufferRef->channels = channels;
|
pAudioBufferRef->channels = channels;
|
||||||
|
pAudioBufferRef->sampleRate = 0; /* TODO: Version 0.12. Set this to sampleRate. */
|
||||||
pAudioBufferRef->cursor = 0;
|
pAudioBufferRef->cursor = 0;
|
||||||
pAudioBufferRef->sizeInFrames = sizeInFrames;
|
pAudioBufferRef->sizeInFrames = sizeInFrames;
|
||||||
pAudioBufferRef->pData = pData;
|
pAudioBufferRef->pData = pData;
|
||||||
@@ -55466,10 +55469,11 @@ MA_API ma_audio_buffer_config ma_audio_buffer_config_init(ma_format format, ma_u
|
|||||||
ma_audio_buffer_config config;
|
ma_audio_buffer_config config;
|
||||||
|
|
||||||
MA_ZERO_OBJECT(&config);
|
MA_ZERO_OBJECT(&config);
|
||||||
config.format = format;
|
config.format = format;
|
||||||
config.channels = channels;
|
config.channels = channels;
|
||||||
|
config.sampleRate = 0; /* TODO: Version 0.12. Set this to sampleRate. */
|
||||||
config.sizeInFrames = sizeInFrames;
|
config.sizeInFrames = sizeInFrames;
|
||||||
config.pData = pData;
|
config.pData = pData;
|
||||||
ma_allocation_callbacks_init_copy(&config.allocationCallbacks, pAllocationCallbacks);
|
ma_allocation_callbacks_init_copy(&config.allocationCallbacks, pAllocationCallbacks);
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
@@ -55498,6 +55502,9 @@ static ma_result ma_audio_buffer_init_ex(const ma_audio_buffer_config* pConfig,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: Version 0.12. Set this in ma_audio_buffer_ref_init() instead of here. */
|
||||||
|
pAudioBuffer->ref.sampleRate = pConfig->sampleRate;
|
||||||
|
|
||||||
ma_allocation_callbacks_init_copy(&pAudioBuffer->allocationCallbacks, &pConfig->allocationCallbacks);
|
ma_allocation_callbacks_init_copy(&pAudioBuffer->allocationCallbacks, &pConfig->allocationCallbacks);
|
||||||
|
|
||||||
if (doCopy) {
|
if (doCopy) {
|
||||||
|
|||||||
Reference in New Issue
Block a user