If anyone is a bit bored and wants to investigate, I currently lack the time.
Windows 10
SFML master
Tested with: VS 2015, MinGW Builds GCC 5.3.0
Used code:
#include <SFML/Audio.hpp>
#include <iostream>
int main()
{
sf::SoundBuffer buf;
buf.loadFromFile("ff.ogg");
std::vector<sf::Int16> samples(buf.getSampleCount());
std::cout << "Memory allocated\n";
for(std::size_t i = 0; i < buf.getSampleCount(); i++)
{
samples[i] = buf.getSamples()[i];
}
sf::SoundBuffer buff;
buff.loadFromSamples(samples.data(), buf.getSampleCount(), buf.getChannelCount(), buf.getSampleRate());
std::cout << "Loading new buffer.\n";
buff.saveToFile("ff-test.ogg");
std::cout << "Data written\n";
}
Call stack (from VS 2015):
SupportVS.exe!_chkstk() Line 99
SupportVS.exe!_vorbis_analysis_wrote()
SupportVS.exe!sf::priv::SoundFileWriterOgg::write(const short * samples, unsigned __int64 count) Line 144
SupportVS.exe!sf::OutputSoundFile::write(const short * samples, unsigned __int64 count) Line 76
SupportVS.exe!sf::SoundBuffer::saveToFile(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & filename) Line 153
SupportVS.exe!main() Line 22
Used sound file: ff.ogg (https://my-gate.net/pub/sfml/random/ff.ogg) [1.25 MiB]
Have fun debugging. ;)
////////////////////////////////////////////////////////////
void SoundFileWriterOgg::write(const Int16* samples, Uint64 count)
{
// Vorbis has issues with buffers that are too large, so we ask for 64K
const static int bufferSize = 65536;
// A frame contains a sample from each channel
int frameCount = static_cast<int>(count / m_channelCount);
while(frameCount > 0)
{
// Prepare a buffer to hold our samples
float** buffer = vorbis_analysis_buffer(&m_state, bufferSize);
assert(buffer);
// Write the samples to the buffer, converted to float
for(int i = 0; i < std::min(frameCount, bufferSize); ++i)
for(unsigned int j = 0; j < m_channelCount; ++j)
buffer[j][i] = *samples++ / 32767.0f;
// Tell the library how many samples we've written
vorbis_analysis_wrote(&m_state, std::min(frameCount, bufferSize));
frameCount -= bufferSize;
// Flush any produced block
flushBlocks();
}
}
Make a PR... I'm preoccupied with... "stuff"...