--- linuxsampler/trunk/src/Sampler.cpp 2004/07/18 00:29:39 209 +++ linuxsampler/trunk/src/Sampler.cpp 2004/07/28 14:17:29 212 @@ -160,6 +160,8 @@ return pMidiInputPort; } + + // ****************************************************************** // * Sampler @@ -167,31 +169,7 @@ } Sampler::~Sampler() { - // delete sampler channels - { - SamplerChannelMap::iterator iter = mSamplerChannels.begin(); - for (; iter != mSamplerChannels.end(); iter++) delete iter->second; - } - - // delete midi input devices - { - MidiInputDeviceMap::iterator iter = mMidiInputDevices.begin(); - for (; iter != mMidiInputDevices.end(); iter++) { - MidiInputDevice* pDevice = iter->second; - pDevice->StopListen(); - delete pDevice; - } - } - - // delete audio output devices - { - AudioOutputDeviceMap::iterator iter = mAudioOutputDevices.begin(); - for (; iter != mAudioOutputDevices.end(); iter++) { - AudioOutputDevice* pDevice = iter->second; - pDevice->Stop(); - delete pDevice; - } - } + Reset(); } uint Sampler::SamplerChannels() { @@ -343,4 +321,42 @@ return pDevice; } + void Sampler::Reset() { + // delete sampler channels + try { + SamplerChannelMap::iterator iter = mSamplerChannels.begin(); + for (; iter != mSamplerChannels.end(); iter++) { + RemoveSamplerChannel(iter->second); + } + } + catch(...) { + std::cerr << "Sampler::Reset(): Exception occured while trying to delete all sampler channels, exiting.\n" << std::flush; + exit(EXIT_FAILURE); + } + + // delete midi input devices + try { + MidiInputDeviceMap::iterator iter = mMidiInputDevices.begin(); + for (; iter != mMidiInputDevices.end(); iter++) { + DestroyMidiInputDevice(iter->second); + } + } + catch(...) { + std::cerr << "Sampler::Reset(): Exception occured while trying to delete all MIDI input devices, exiting.\n" << std::flush; + exit(EXIT_FAILURE); + } + + // delete audio output devices + try { + AudioOutputDeviceMap::iterator iter = mAudioOutputDevices.begin(); + for (; iter != mAudioOutputDevices.end(); iter++) { + DestroyAudioOutputDevice(iter->second); + } + } + catch(...) { + std::cerr << "Sampler::Reset(): Exception occured while trying to delete all audio output devices, exiting.\n" << std::flush; + exit(EXIT_FAILURE); + } + } + } // namespace LinuxSampler