mirror of
https://github.com/mackron/miniaudio.git
synced 2026-07-22 12:52:43 +02:00
Update dr_wav.
This commit is contained in:
+39
-14
@@ -80482,6 +80482,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);
|
||||||
@@ -81597,6 +81605,9 @@ MA_PRIVATE ma_bool32 ma_dr_wav_init__internal(ma_dr_wav* pWav, ma_dr_wav_chunk_p
|
|||||||
((pWav->container == ma_dr_wav_container_w64) && ma_dr_wav_guid_equal(header.id.guid, ma_dr_wavGUID_W64_FACT))) {
|
((pWav->container == ma_dr_wav_container_w64) && ma_dr_wav_guid_equal(header.id.guid, ma_dr_wavGUID_W64_FACT))) {
|
||||||
if (pWav->container == ma_dr_wav_container_riff || pWav->container == ma_dr_wav_container_rifx) {
|
if (pWav->container == ma_dr_wav_container_riff || pWav->container == ma_dr_wav_container_rifx) {
|
||||||
ma_uint8 sampleCount[4];
|
ma_uint8 sampleCount[4];
|
||||||
|
if (chunkSize < 4) {
|
||||||
|
return MA_FALSE;
|
||||||
|
}
|
||||||
if (ma_dr_wav__on_read(pWav->onRead, pWav->pUserData, &sampleCount, 4, &cursor) != 4) {
|
if (ma_dr_wav__on_read(pWav->onRead, pWav->pUserData, &sampleCount, 4, &cursor) != 4) {
|
||||||
return MA_FALSE;
|
return MA_FALSE;
|
||||||
}
|
}
|
||||||
@@ -81607,6 +81618,9 @@ MA_PRIVATE ma_bool32 ma_dr_wav_init__internal(ma_dr_wav* pWav, ma_dr_wav_chunk_p
|
|||||||
sampleCountFromFactChunk = 0;
|
sampleCountFromFactChunk = 0;
|
||||||
}
|
}
|
||||||
} else if (pWav->container == ma_dr_wav_container_w64) {
|
} else if (pWav->container == ma_dr_wav_container_w64) {
|
||||||
|
if (chunkSize < 8) {
|
||||||
|
return MA_FALSE;
|
||||||
|
}
|
||||||
if (ma_dr_wav__on_read(pWav->onRead, pWav->pUserData, &sampleCountFromFactChunk, 8, &cursor) != 8) {
|
if (ma_dr_wav__on_read(pWav->onRead, pWav->pUserData, &sampleCountFromFactChunk, 8, &cursor) != 8) {
|
||||||
return MA_FALSE;
|
return MA_FALSE;
|
||||||
}
|
}
|
||||||
@@ -82858,24 +82872,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);
|
||||||
@@ -82906,7 +82914,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;
|
||||||
}
|
}
|
||||||
@@ -83169,6 +83186,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)
|
||||||
@@ -88845,7 +88870,7 @@ static ma_bool32 ma_dr_flac__read_and_decode_metadata(ma_dr_flac_read_proc onRea
|
|||||||
if (onTell(pUserData, &fileSize)) {
|
if (onTell(pUserData, &fileSize)) {
|
||||||
hasKnownFileSize = MA_TRUE;
|
hasKnownFileSize = MA_TRUE;
|
||||||
}
|
}
|
||||||
onSeek(pUserData, runningFilePos, MA_DR_FLAC_SEEK_SET);
|
onSeek(pUserData, (int)runningFilePos, MA_DR_FLAC_SEEK_SET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|||||||
Reference in New Issue
Block a user