mirror of
https://github.com/mackron/miniaudio.git
synced 2026-06-29 17:42:42 +02:00
Update dr_wav.
This commit is contained in:
+32
-13
@@ -89794,6 +89794,14 @@ MA_PRIVATE unsigned int ma_dr_wav__chunk_padding_size_w64(ma_uint64 chunkSize)
|
|||||||
{
|
{
|
||||||
return (unsigned int)(chunkSize % 8);
|
return (unsigned int)(chunkSize % 8);
|
||||||
}
|
}
|
||||||
|
MA_PRIVATE unsigned int ma_dr_wav_calculate_padding_size(ma_dr_wav_container container, ma_uint64 chunkSize)
|
||||||
|
{
|
||||||
|
if (container == ma_dr_wav_container_riff || container == ma_dr_wav_container_rf64) {
|
||||||
|
return ma_dr_wav__chunk_padding_size_riff(chunkSize);
|
||||||
|
} else {
|
||||||
|
return ma_dr_wav__chunk_padding_size_w64(chunkSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s16__msadpcm(ma_dr_wav* pWav, ma_uint64 samplesToRead, ma_int16* pBufferOut);
|
MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s16__msadpcm(ma_dr_wav* pWav, ma_uint64 samplesToRead, ma_int16* pBufferOut);
|
||||||
MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s16__ima(ma_dr_wav* pWav, ma_uint64 samplesToRead, ma_int16* pBufferOut);
|
MA_PRIVATE ma_uint64 ma_dr_wav_read_pcm_frames_s16__ima(ma_dr_wav* pWav, ma_uint64 samplesToRead, ma_int16* pBufferOut);
|
||||||
MA_PRIVATE ma_bool32 ma_dr_wav_init_write__internal(ma_dr_wav* pWav, const ma_dr_wav_data_format* pFormat, ma_uint64 totalSampleCount);
|
MA_PRIVATE ma_bool32 ma_dr_wav_init_write__internal(ma_dr_wav* pWav, const ma_dr_wav_data_format* pFormat, ma_uint64 totalSampleCount);
|
||||||
@@ -92170,24 +92178,18 @@ MA_API ma_bool32 ma_dr_wav_init_memory_write_sequential_pcm_frames(ma_dr_wav* pW
|
|||||||
}
|
}
|
||||||
return ma_dr_wav_init_memory_write_sequential(pWav, ppData, pDataSize, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks);
|
return ma_dr_wav_init_memory_write_sequential(pWav, ppData, pDataSize, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks);
|
||||||
}
|
}
|
||||||
MA_API ma_result ma_dr_wav_uninit(ma_dr_wav* pWav)
|
MA_PRIVATE ma_uint32 ma_dr_wav_write_padding(ma_dr_wav* pWav)
|
||||||
{
|
{
|
||||||
ma_result result = MA_SUCCESS;
|
ma_uint32 paddingSize = ma_dr_wav_calculate_padding_size(pWav->container, pWav->dataChunkDataSize);
|
||||||
if (pWav == NULL) {
|
|
||||||
return MA_INVALID_ARGS;
|
|
||||||
}
|
|
||||||
if (pWav->onWrite != NULL) {
|
|
||||||
ma_uint32 paddingSize = 0;
|
|
||||||
if (pWav->container == ma_dr_wav_container_riff || pWav->container == ma_dr_wav_container_rf64) {
|
|
||||||
paddingSize = ma_dr_wav__chunk_padding_size_riff(pWav->dataChunkDataSize);
|
|
||||||
} else {
|
|
||||||
paddingSize = ma_dr_wav__chunk_padding_size_w64(pWav->dataChunkDataSize);
|
|
||||||
}
|
|
||||||
if (paddingSize > 0) {
|
if (paddingSize > 0) {
|
||||||
ma_uint64 paddingData = 0;
|
ma_uint64 paddingData = 0;
|
||||||
ma_dr_wav__write(pWav, &paddingData, paddingSize);
|
ma_dr_wav__write(pWav, &paddingData, paddingSize);
|
||||||
}
|
}
|
||||||
if (pWav->onSeek && !pWav->isSequentialWrite) {
|
return paddingSize;
|
||||||
|
}
|
||||||
|
MA_PRIVATE void ma_dr_wav_write_chunk_sizes(ma_dr_wav* pWav)
|
||||||
|
{
|
||||||
|
if (pWav->onSeek != NULL && !pWav->isSequentialWrite) {
|
||||||
if (pWav->container == ma_dr_wav_container_riff) {
|
if (pWav->container == ma_dr_wav_container_riff) {
|
||||||
if (pWav->onSeek(pWav->pUserData, 4, MA_DR_WAV_SEEK_SET)) {
|
if (pWav->onSeek(pWav->pUserData, 4, MA_DR_WAV_SEEK_SET)) {
|
||||||
ma_uint32 riffChunkSize = ma_dr_wav__riff_chunk_size_riff(pWav->dataChunkDataSize, pWav->pMetadata, pWav->metadataCount);
|
ma_uint32 riffChunkSize = ma_dr_wav__riff_chunk_size_riff(pWav->dataChunkDataSize, pWav->pMetadata, pWav->metadataCount);
|
||||||
@@ -92218,7 +92220,16 @@ MA_API ma_result ma_dr_wav_uninit(ma_dr_wav* pWav)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
MA_API ma_result ma_dr_wav_uninit(ma_dr_wav* pWav)
|
||||||
|
{
|
||||||
|
ma_result result = MA_SUCCESS;
|
||||||
|
if (pWav == NULL) {
|
||||||
|
return MA_INVALID_ARGS;
|
||||||
|
}
|
||||||
|
if (pWav->onWrite != NULL) {
|
||||||
if (pWav->isSequentialWrite) {
|
if (pWav->isSequentialWrite) {
|
||||||
|
ma_dr_wav_write_padding(pWav);
|
||||||
if (pWav->dataChunkDataSize != pWav->dataChunkDataSizeTargetWrite) {
|
if (pWav->dataChunkDataSize != pWav->dataChunkDataSizeTargetWrite) {
|
||||||
result = MA_INVALID_FILE;
|
result = MA_INVALID_FILE;
|
||||||
}
|
}
|
||||||
@@ -92481,6 +92492,14 @@ MA_API size_t ma_dr_wav_write_raw(ma_dr_wav* pWav, size_t bytesToWrite, const vo
|
|||||||
}
|
}
|
||||||
bytesWritten = pWav->onWrite(pWav->pUserData, pData, bytesToWrite);
|
bytesWritten = pWav->onWrite(pWav->pUserData, pData, bytesToWrite);
|
||||||
pWav->dataChunkDataSize += bytesWritten;
|
pWav->dataChunkDataSize += bytesWritten;
|
||||||
|
if (!pWav->isSequentialWrite) {
|
||||||
|
ma_uint32 padding;
|
||||||
|
padding = ma_dr_wav_write_padding(pWav);
|
||||||
|
ma_dr_wav_write_chunk_sizes(pWav);
|
||||||
|
if (pWav->onSeek != NULL) {
|
||||||
|
pWav->onSeek(pWav->pUserData, -(int)padding, MA_DR_WAV_SEEK_END);
|
||||||
|
}
|
||||||
|
}
|
||||||
return bytesWritten;
|
return bytesWritten;
|
||||||
}
|
}
|
||||||
MA_API ma_uint64 ma_dr_wav_write_pcm_frames_le(ma_dr_wav* pWav, ma_uint64 framesToWrite, const void* pData)
|
MA_API ma_uint64 ma_dr_wav_write_pcm_frames_le(ma_dr_wav* pWav, ma_uint64 framesToWrite, const void* pData)
|
||||||
|
|||||||
Reference in New Issue
Block a user