Commit 1051ab9a authored by David Reid's avatar David Reid

Fix errors with incorrectly reported frame counts from data conversion.

parent 39d44ae2
...@@ -17343,6 +17343,10 @@ mal_uint64 mal_format_converter_read(mal_format_converter* pConverter, mal_uint6 ...@@ -17343,6 +17343,10 @@ mal_uint64 mal_format_converter_read(mal_format_converter* pConverter, mal_uint6
totalFramesRead += framesJustRead; totalFramesRead += framesJustRead;
pNextFramesOut += framesJustRead * frameSizeOut; pNextFramesOut += framesJustRead * frameSizeOut;
if (framesJustRead < framesToReadRightNow) {
break;
}
} }
} else { } else {
// Conversion required. // Conversion required.
...@@ -17367,6 +17371,10 @@ mal_uint64 mal_format_converter_read(mal_format_converter* pConverter, mal_uint6 ...@@ -17367,6 +17371,10 @@ mal_uint64 mal_format_converter_read(mal_format_converter* pConverter, mal_uint6
totalFramesRead += framesJustRead; totalFramesRead += framesJustRead;
pNextFramesOut += framesJustRead * frameSizeOut; pNextFramesOut += framesJustRead * frameSizeOut;
if (framesJustRead < framesToReadRightNow) {
break;
}
} }
} }
} else { } else {
...@@ -17421,6 +17429,10 @@ mal_uint64 mal_format_converter_read(mal_format_converter* pConverter, mal_uint6 ...@@ -17421,6 +17429,10 @@ mal_uint64 mal_format_converter_read(mal_format_converter* pConverter, mal_uint6
totalFramesRead += framesJustRead; totalFramesRead += framesJustRead;
pNextFramesOut += framesJustRead * frameSizeOut; pNextFramesOut += framesJustRead * frameSizeOut;
if (framesJustRead < framesToReadRightNow) {
break;
}
} }
} }
...@@ -17480,6 +17492,10 @@ mal_uint64 mal_format_converter_read_deinterleaved(mal_format_converter* pConver ...@@ -17480,6 +17492,10 @@ mal_uint64 mal_format_converter_read_deinterleaved(mal_format_converter* pConver
for (mal_uint32 iChannel = 0; iChannel < pConverter->config.channels; ++iChannel) { for (mal_uint32 iChannel = 0; iChannel < pConverter->config.channels; ++iChannel) {
ppNextSamplesOut[iChannel] += framesJustRead * sampleSizeOut; ppNextSamplesOut[iChannel] += framesJustRead * sampleSizeOut;
} }
if (framesJustRead < framesToReadRightNow) {
break;
}
} }
} else { } else {
// Input data is deinterleaved. // Input data is deinterleaved.
...@@ -17501,6 +17517,10 @@ mal_uint64 mal_format_converter_read_deinterleaved(mal_format_converter* pConver ...@@ -17501,6 +17517,10 @@ mal_uint64 mal_format_converter_read_deinterleaved(mal_format_converter* pConver
for (mal_uint32 iChannel = 0; iChannel < pConverter->config.channels; ++iChannel) { for (mal_uint32 iChannel = 0; iChannel < pConverter->config.channels; ++iChannel) {
ppNextSamplesOut[iChannel] += framesJustRead * sampleSizeOut; ppNextSamplesOut[iChannel] += framesJustRead * sampleSizeOut;
} }
if (framesJustRead < framesToReadRightNow) {
break;
}
} }
} else { } else {
// Conversion required. // Conversion required.
...@@ -17531,6 +17551,10 @@ mal_uint64 mal_format_converter_read_deinterleaved(mal_format_converter* pConver ...@@ -17531,6 +17551,10 @@ mal_uint64 mal_format_converter_read_deinterleaved(mal_format_converter* pConver
} }
totalFramesRead += framesJustRead; totalFramesRead += framesJustRead;
if (framesJustRead < framesToReadRightNow) {
break;
}
} }
} }
} }
...@@ -18114,6 +18138,10 @@ mal_uint64 mal_channel_router_read_deinterleaved(mal_channel_router* pRouter, ma ...@@ -18114,6 +18138,10 @@ mal_uint64 mal_channel_router_read_deinterleaved(mal_channel_router* pRouter, ma
for (mal_uint32 iChannel = 0; iChannel < pRouter->config.channelsOut; ++iChannel) { for (mal_uint32 iChannel = 0; iChannel < pRouter->config.channelsOut; ++iChannel) {
ppNextSamplesOut[iChannel] += framesJustRead; ppNextSamplesOut[iChannel] += framesJustRead;
} }
if (framesJustRead < framesToReadRightNow) {
break;
}
} }
} }
} }
...@@ -18152,6 +18180,10 @@ mal_uint64 mal_channel_router_read_deinterleaved(mal_channel_router* pRouter, ma ...@@ -18152,6 +18180,10 @@ mal_uint64 mal_channel_router_read_deinterleaved(mal_channel_router* pRouter, ma
ppNextSamplesOut[iChannel] += framesJustRead; ppNextSamplesOut[iChannel] += framesJustRead;
} }
} }
if (framesJustRead < framesToReadRightNow) {
break;
}
} }
return totalFramesRead; return totalFramesRead;
...@@ -18303,14 +18335,18 @@ mal_uint64 mal_src_read_deinterleaved__passthrough(mal_src* pSRC, mal_uint64 fra ...@@ -18303,14 +18335,18 @@ mal_uint64 mal_src_read_deinterleaved__passthrough(mal_src* pSRC, mal_uint64 fra
framesToReadRightNow = 0xFFFFFFFF; framesToReadRightNow = 0xFFFFFFFF;
} }
mal_uint32 framesRead = (mal_uint32)pSRC->config.onReadDeinterleaved(pSRC, (mal_uint32)framesToReadRightNow, (void**)ppNextSamplesOut, pUserData); mal_uint32 framesJustRead = (mal_uint32)pSRC->config.onReadDeinterleaved(pSRC, (mal_uint32)framesToReadRightNow, (void**)ppNextSamplesOut, pUserData);
if (framesRead == 0) { if (framesJustRead == 0) {
break; break;
} }
totalFramesRead += framesRead; totalFramesRead += framesJustRead;
for (mal_uint32 iChannel = 0; iChannel < pSRC->config.channels; ++iChannel) { for (mal_uint32 iChannel = 0; iChannel < pSRC->config.channels; ++iChannel) {
ppNextSamplesOut[iChannel] += framesRead; ppNextSamplesOut[iChannel] += framesJustRead;
}
if (framesJustRead < framesToReadRightNow) {
break;
} }
} }
......
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