Hello, Juceys. Back in Brooklyn again.
I have a reliable user who’s reporting an error saving that amounts to the fact that AudioFormatWriter::writeFromAudioSource is returning false. This feature has been reliable in testing on Mac/PC. Unfortunately, there’s no way to get any other sort of information from Juce other than it failed…
The code is fairly simple and I have pasted some of it below. I essentially create a new FileOutputStream for the file, use it to create an AudioFormatWriter, and then starting writing to it. It seems to me that that it must be the case that the virtual function
virtual bool AudioFormatWriter::write (const int** samplesToWrite,
int numSamples) = 0; most be returning false, but since this is at a client I’m sort of stymied.
Question:
Could the filename be somehow invalid (it looks valid in the logs but…)? If the file were somehow impossible to write to, would I not get an error before this point, when I created the FileOutputStream or the AudioFormatWriter?
Here’s some of the code:[code]
ptr fos(new FileOutputStream(f));
ptr writer(fmt->createWriterFor(fos.transfer(), sampleRate,
channels, 16,
StringPairArray(),
quality));
[…]
for (SampleTime toCopy = length_;
!threadShouldExit() && toCopy > 0; toCopy -= COPY_UPDATE_SIZE) {
if (writer->writeFromAudioSource(*source_,
std::min(COPY_UPDATE_SIZE, toCopy.toInt()),
COPY_BLOCK_SIZE)) {
setProgress(1.0 - toCopy / (1.0 * length_));
} else {
writer.reset();
file_.deleteFile();
String error = String::formatted(FILE_SAVE_FAILED_FULL,
c_str(file_.getFileName()));
AlertWindow::showMessageBox(AlertWindow::InfoIcon, FILE_SAVE_FAILED,
error, OK);
return false;
}
}
return true;[/code]
