mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-24 09:14:04 +02:00
Fix an error when loading WAV files.
The sample format of a WAV file is not always being set which results in get_data_format() returning ma_format_unknown.
This commit is contained in:
+55
-30
@@ -61092,33 +61092,8 @@ static ma_result ma_wav_init_internal(const ma_decoding_backend_config* pConfig,
|
||||
return MA_SUCCESS;
|
||||
}
|
||||
|
||||
MA_API ma_result ma_wav_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_proc onTell, void* pReadSeekTellUserData, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_wav* pWav)
|
||||
static ma_result ma_wav_post_init(ma_wav* pWav)
|
||||
{
|
||||
ma_result result;
|
||||
|
||||
result = ma_wav_init_internal(pConfig, pWav);
|
||||
if (result != MA_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (onRead == NULL || onSeek == NULL) {
|
||||
return MA_INVALID_ARGS; /* onRead and onSeek are mandatory. */
|
||||
}
|
||||
|
||||
pWav->onRead = onRead;
|
||||
pWav->onSeek = onSeek;
|
||||
pWav->onTell = onTell;
|
||||
pWav->pReadSeekTellUserData = pReadSeekTellUserData;
|
||||
|
||||
#if !defined(MA_NO_WAV)
|
||||
{
|
||||
ma_bool32 wavResult;
|
||||
|
||||
wavResult = ma_dr_wav_init(&pWav->dr, ma_wav_dr_callback__read, ma_wav_dr_callback__seek, pWav, pAllocationCallbacks);
|
||||
if (wavResult != MA_TRUE) {
|
||||
return MA_INVALID_FILE;
|
||||
}
|
||||
|
||||
/*
|
||||
If an explicit format was not specified, try picking the closest match based on the internal
|
||||
format. The format needs to be supported by miniaudio.
|
||||
@@ -61157,6 +61132,38 @@ MA_API ma_result ma_wav_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_p
|
||||
|
||||
return MA_SUCCESS;
|
||||
}
|
||||
|
||||
MA_API ma_result ma_wav_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_proc onTell, void* pReadSeekTellUserData, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_wav* pWav)
|
||||
{
|
||||
ma_result result;
|
||||
|
||||
result = ma_wav_init_internal(pConfig, pWav);
|
||||
if (result != MA_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (onRead == NULL || onSeek == NULL) {
|
||||
return MA_INVALID_ARGS; /* onRead and onSeek are mandatory. */
|
||||
}
|
||||
|
||||
pWav->onRead = onRead;
|
||||
pWav->onSeek = onSeek;
|
||||
pWav->onTell = onTell;
|
||||
pWav->pReadSeekTellUserData = pReadSeekTellUserData;
|
||||
|
||||
#if !defined(MA_NO_WAV)
|
||||
{
|
||||
ma_bool32 wavResult;
|
||||
|
||||
wavResult = ma_dr_wav_init(&pWav->dr, ma_wav_dr_callback__read, ma_wav_dr_callback__seek, pWav, pAllocationCallbacks);
|
||||
if (wavResult != MA_TRUE) {
|
||||
return MA_INVALID_FILE;
|
||||
}
|
||||
|
||||
ma_wav_post_init(pWav);
|
||||
|
||||
return MA_SUCCESS;
|
||||
}
|
||||
#else
|
||||
{
|
||||
/* wav is disabled. */
|
||||
@@ -61184,6 +61191,8 @@ MA_API ma_result ma_wav_init_file(const char* pFilePath, const ma_decoding_backe
|
||||
return MA_INVALID_FILE;
|
||||
}
|
||||
|
||||
ma_wav_post_init(pWav);
|
||||
|
||||
return MA_SUCCESS;
|
||||
}
|
||||
#else
|
||||
@@ -61214,6 +61223,8 @@ MA_API ma_result ma_wav_init_file_w(const wchar_t* pFilePath, const ma_decoding_
|
||||
return MA_INVALID_FILE;
|
||||
}
|
||||
|
||||
ma_wav_post_init(pWav);
|
||||
|
||||
return MA_SUCCESS;
|
||||
}
|
||||
#else
|
||||
@@ -61244,6 +61255,8 @@ MA_API ma_result ma_wav_init_memory(const void* pData, size_t dataSize, const ma
|
||||
return MA_INVALID_FILE;
|
||||
}
|
||||
|
||||
ma_wav_post_init(pWav);
|
||||
|
||||
return MA_SUCCESS;
|
||||
}
|
||||
#else
|
||||
@@ -62422,6 +62435,18 @@ static ma_result ma_mp3_generate_seek_table(ma_mp3* pMP3, const ma_decoding_back
|
||||
return MA_SUCCESS;
|
||||
}
|
||||
|
||||
static ma_result ma_mp3_post_init(ma_mp3* pMP3, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks)
|
||||
{
|
||||
ma_result result;
|
||||
|
||||
result = ma_mp3_generate_seek_table(pMP3, pConfig, pAllocationCallbacks);
|
||||
if (result != MA_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return MA_SUCCESS;
|
||||
}
|
||||
|
||||
MA_API ma_result ma_mp3_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_proc onTell, void* pReadSeekTellUserData, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_mp3* pMP3)
|
||||
{
|
||||
ma_result result;
|
||||
@@ -62449,7 +62474,7 @@ MA_API ma_result ma_mp3_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_p
|
||||
return MA_INVALID_FILE;
|
||||
}
|
||||
|
||||
ma_mp3_generate_seek_table(pMP3, pConfig, pAllocationCallbacks);
|
||||
ma_mp3_post_init(pMP3, pConfig, pAllocationCallbacks);
|
||||
|
||||
return MA_SUCCESS;
|
||||
}
|
||||
@@ -62480,7 +62505,7 @@ MA_API ma_result ma_mp3_init_file(const char* pFilePath, const ma_decoding_backe
|
||||
return MA_INVALID_FILE;
|
||||
}
|
||||
|
||||
ma_mp3_generate_seek_table(pMP3, pConfig, pAllocationCallbacks);
|
||||
ma_mp3_post_init(pMP3, pConfig, pAllocationCallbacks);
|
||||
|
||||
return MA_SUCCESS;
|
||||
}
|
||||
@@ -62512,7 +62537,7 @@ MA_API ma_result ma_mp3_init_file_w(const wchar_t* pFilePath, const ma_decoding_
|
||||
return MA_INVALID_FILE;
|
||||
}
|
||||
|
||||
ma_mp3_generate_seek_table(pMP3, pConfig, pAllocationCallbacks);
|
||||
ma_mp3_post_init(pMP3, pConfig, pAllocationCallbacks);
|
||||
|
||||
return MA_SUCCESS;
|
||||
}
|
||||
@@ -62544,7 +62569,7 @@ MA_API ma_result ma_mp3_init_memory(const void* pData, size_t dataSize, const ma
|
||||
return MA_INVALID_FILE;
|
||||
}
|
||||
|
||||
ma_mp3_generate_seek_table(pMP3, pConfig, pAllocationCallbacks);
|
||||
ma_mp3_post_init(pMP3, pConfig, pAllocationCallbacks);
|
||||
|
||||
return MA_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user