I partially answered my own question.
I currently have an implementation that behaves as follows on the various platforms:
[list] - Mac: Success. Sound plays.
iOS: Works, but requires the modification commented below. But, sound plays.
Android OS 4.1: Works for the first audio playback, but crashes the app on the second
(Difficult to debug the JNI output, but it appears to be: “JUCE Assertion failure in juce_File.cpp:149”)
Windows 8: Fails to play sound, but otherwise works with no apparent errors.
Linux: Not tested yet.[/list]
I am using JUCE v2.0.40.
Please look at this code and show me some of the mistakes that keep it from working on Android and Windows.
Call this init function from the Component constructor:
audioFormatManager = new AudioFormatManager();
audioTransportSource = nullptr; // new AudioTransportSource();
audioSourcePlayer = new AudioSourcePlayer();
audioDeviceManager = nullptr; // new AudioDeviceManager();
And, call this release function in the destructor:
audioDeviceManager = nullptr;
audioSourcePlayer = nullptr;
audioTransportSource = nullptr;
audioFormatReaderSource = nullptr;
audioFormatReader = nullptr;
audioFormatManager = nullptr;
And finally, the player code:
MemoryInputStream *mis = new MemoryInputStream (BinaryData::cello_wav, BinaryData::cello_wavSize, false);
audioFormatReader = wavFormat.createReaderFor(mis, true);
audioFormatReaderSource = new AudioFormatReaderSource(audioFormatReader, true);
// Note: Mac OS X allows reuse of the audioTransportSource object,
// but iOS forces creating a 'new' on every time the sound is played.
if(audioTransportSource != nullptr)
audioTransportSource = new AudioTransportSource();
audioTransportSource->setSource(audioFormatReaderSource, 0, nullptr, 44100.0, 2);
if(audioDeviceManager != nullptr)
audioDeviceManager = new AudioDeviceManager();
audioDeviceManager->initialise(2, 2, 0, true);