Add ma_decode_from_vfs().

This commit is contained in:
David Reid
2020-06-13 09:15:47 +10:00
parent d65d714802
commit 373234255a
2 changed files with 18 additions and 52 deletions
+13 -9
View File
@@ -5571,6 +5571,7 @@ MA_API ma_result ma_decoder_seek_to_pcm_frame(ma_decoder* pDecoder, ma_uint64 fr
Helper for opening and decoding a file into a heap allocated block of memory. Free the returned pointer with ma_free(). On input,
pConfig should be set to what you want. On output it will be set to what you got.
*/
MA_API ma_result ma_decode_from_vfs(ma_vfs* pVFS, const char* pFilePath, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut);
MA_API ma_result ma_decode_file(const char* pFilePath, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut);
MA_API ma_result ma_decode_memory(const void* pData, size_t dataSize, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut);
@@ -43308,11 +43309,11 @@ static ma_result ma_decoder__full_decode_and_uninit(ma_decoder* pDecoder, ma_dec
return MA_SUCCESS;
}
MA_API ma_result ma_decode_file(const char* pFilePath, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut)
MA_API ma_result ma_decode_from_vfs(ma_vfs* pVFS, const char* pFilePath, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut)
{
ma_result result;
ma_decoder_config config;
ma_decoder decoder;
ma_result result;
if (pFrameCountOut != NULL) {
*pFrameCountOut = 0;
@@ -43321,18 +43322,21 @@ MA_API ma_result ma_decode_file(const char* pFilePath, ma_decoder_config* pConfi
*ppPCMFramesOut = NULL;
}
if (pFilePath == NULL) {
return MA_INVALID_ARGS;
}
config = ma_decoder_config_init_copy(pConfig);
result = ma_decoder_init_file(pFilePath, &config, &decoder);
result = ma_decoder_init_vfs(pVFS, pFilePath, &config, &decoder);
if (result != MA_SUCCESS) {
return result;
}
return ma_decoder__full_decode_and_uninit(&decoder, pConfig, pFrameCountOut, ppPCMFramesOut);
result = ma_decoder__full_decode_and_uninit(&decoder, pConfig, pFrameCountOut, ppPCMFramesOut);
return result;
}
MA_API ma_result ma_decode_file(const char* pFilePath, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut)
{
return ma_decode_from_vfs(NULL, pFilePath, pConfig, pFrameCountOut, ppPCMFramesOut);
}
MA_API ma_result ma_decode_memory(const void* pData, size_t dataSize, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut)