I have a question about calculation of stream length in CocosDenshion (win8 port), in CocosDenshion/win8_metro/MediaStreamer.cpp. Now it’s rounded up to the nearest four bytes. Why four?
My app crashes on next mp3-file (when trying to play it):
* avg bytes per sec: 88200
* samples per sec: 44100
* block align: 2
* channels: 1
* bits per sample: 16
* duration: 1.0186666 seconds
m_maxStreamLengthInBytes is 89848 at the end of MediaStreamer::Initialize. As I understand, there are 44924 samples in my file. But Foobar2000 says that there are 44928 samples. Bad m_maxStreamLengthInBytes value causes sampleBufferLength > maxBufferSize in MediaStreamer::GetNextBuffer (first and the only one useful call of this function, second is EOF), so no copy and crash when trying to play it.
I have two solutions. I calculate that foobar2000 rounds up the number of samples to the nearest 8 bytes on files like above, so I can round up the buffer size to the nearest 16 bytes when load this files. Or I can copy only the part of file that fits in the buffer. I think that the second solution is better. The question is why you round up to the nearest 4 bytes?