Commit bfe8358d authored by David Reid's avatar David Reid

Add ma_decoder_get_data_format().

With this change, ma_decoder should now be fully consistent with other
data sources.
parent 3ec737d8
...@@ -6244,6 +6244,11 @@ This is not thread safe without your own synchronization. ...@@ -6244,6 +6244,11 @@ This is not thread safe without your own synchronization.
*/ */
MA_API ma_result ma_decoder_seek_to_pcm_frame(ma_decoder* pDecoder, ma_uint64 frameIndex); MA_API ma_result ma_decoder_seek_to_pcm_frame(ma_decoder* pDecoder, ma_uint64 frameIndex);
/*
Retrieves the decoder's output data format.
*/
MA_API ma_result ma_decoder_get_data_format(ma_decoder* pDecoder, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap);
/* /*
Retrieves the current position of the read cursor in PCM frames. Retrieves the current position of the read cursor in PCM frames.
*/ */
...@@ -49593,13 +49598,7 @@ static ma_result ma_decoder__data_source_on_seek(ma_data_source* pDataSource, ma ...@@ -49593,13 +49598,7 @@ static ma_result ma_decoder__data_source_on_seek(ma_data_source* pDataSource, ma
static ma_result ma_decoder__data_source_on_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate) static ma_result ma_decoder__data_source_on_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate)
{ {
ma_decoder* pDecoder = (ma_decoder*)pDataSource; return ma_decoder_get_data_format((ma_decoder*)pDataSource, pFormat, pChannels, pSampleRate, NULL, 0);
*pFormat = pDecoder->outputFormat;
*pChannels = pDecoder->outputChannels;
*pSampleRate = pDecoder->outputSampleRate;
return MA_SUCCESS;
} }
static ma_result ma_decoder__data_source_on_get_cursor(ma_data_source* pDataSource, ma_uint64* pCursor) static ma_result ma_decoder__data_source_on_get_cursor(ma_data_source* pDataSource, ma_uint64* pCursor)
...@@ -50513,6 +50512,31 @@ MA_API ma_result ma_decoder_seek_to_pcm_frame(ma_decoder* pDecoder, ma_uint64 fr ...@@ -50513,6 +50512,31 @@ MA_API ma_result ma_decoder_seek_to_pcm_frame(ma_decoder* pDecoder, ma_uint64 fr
return MA_INVALID_ARGS; return MA_INVALID_ARGS;
} }
MA_API ma_result ma_decoder_get_data_format(ma_decoder* pDecoder, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap)
{
if (pDecoder == NULL) {
return MA_INVALID_ARGS;
}
if (pFormat != NULL) {
*pFormat = pDecoder->outputFormat;
}
if (pChannels != NULL) {
*pChannels = pDecoder->outputChannels;
}
if (pSampleRate != NULL) {
*pSampleRate = pDecoder->outputSampleRate;
}
if (pChannelMap != NULL) {
ma_channel_map_copy_or_default(pChannelMap, pDecoder->outputChannelMap, (ma_uint32)ma_min(channelMapCap, pDecoder->outputChannels));
}
return MA_SUCCESS;
}
MA_API ma_result ma_decoder_get_cursor_in_pcm_frames(ma_decoder* pDecoder, ma_uint64* pCursor) MA_API ma_result ma_decoder_get_cursor_in_pcm_frames(ma_decoder* pDecoder, ma_uint64* pCursor)
{ {
if (pCursor == NULL) { if (pCursor == NULL) {
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment