I’ve been pulling audio files out of a downloaded zip file. I’m now also bundling some of the audio files as a zip file in BinaryData.
To pull the zip file from BinaryData I’m doing:
// Load from binary data
MemoryBlock mb (BinaryData::freewordaudio_zip, BinaryData::freewordaudio_zipSize);
MemoryInputStream inputStream (mb, true);
audioZipFile = std::make_unique<ZipFile> (&inputStream, true);
(audioZipFile is now a std::unique_ptr class member`)
and after some checks I’m then reading a single file in with:
auto audioFileName = word[Word::Ids::fileName].toString() + ".mp3";
auto* zipEntry = audioZipFile->getEntry (audioFileName, false);
jassert (zipEntry != nullptr);
if (zipEntry == nullptr)
return false;
audioZipFile->createStreamForEntry (*zipEntry)->readIntoMemoryBlock (wordAudioData);
This second part is fine when loading from an actual zip file (not from BinaryData). When loading from BinaryData, it crashes in createStreamForEntry at
stream = new ZipInputStream (*this, *zei);
where, at the time of the crash, this seems to be NULL. So it looks like something going out of scope. But I can’t work out what…
