Fixed crash in MIDI to wave writer

This commit is contained in:
alexey.lysiuk 2018-03-08 11:38:02 +02:00
parent 6ab58e56ad
commit 7f17121df8
3 changed files with 10 additions and 5 deletions

View file

@ -198,7 +198,7 @@ protected:
class MIDIWaveWriter : public SoftSynthMIDIDevice
{
public:
MIDIWaveWriter(const char *filename, MIDIDevice *devtouse);
MIDIWaveWriter(const char *filename, SoftSynthMIDIDevice *devtouse);
~MIDIWaveWriter();
int Resume();
int Open(MidiCallback cb, void *userdata)

View file

@ -87,11 +87,11 @@ struct FmtChunk
//
//==========================================================================
MIDIWaveWriter::MIDIWaveWriter(const char *filename, MIDIDevice *playdevice)
: SoftSynthMIDIDevice(playDevice->GetSampleRate())
MIDIWaveWriter::MIDIWaveWriter(const char *filename, SoftSynthMIDIDevice *playdevice)
: SoftSynthMIDIDevice(playdevice->GetSampleRate())
{
File = FileWriter::Open(filename);
playDevice = (SoftSynthMIDIDevice*) playdevice;
playDevice = playdevice;
if (File != nullptr)
{ // Write wave header
uint32_t work[3];

View file

@ -319,8 +319,13 @@ bool MIDIStreamer::DumpWave(const char *filename, int subsong, int samplerate)
assert(MIDI == NULL);
auto devtype = SelectMIDIDevice(DeviceType);
if (devtype == MDEV_MMAPI)
{
Printf("MMAPI device is not supported");
return false;
}
MIDI = CreateMIDIDevice(devtype, samplerate);
MIDI = new MIDIWaveWriter(filename, MIDI);
MIDI = new MIDIWaveWriter(filename, reinterpret_cast<SoftSynthMIDIDevice *>(MIDI));
return InitPlayback();
}