48 |
|
|
49 |
SamplerChannel::~SamplerChannel() { |
SamplerChannel::~SamplerChannel() { |
50 |
if (pEngineChannel) { |
if (pEngineChannel) { |
51 |
|
Engine* engine = pEngineChannel->GetEngine(); |
52 |
|
if (pAudioOutputDevice) pAudioOutputDevice->Disconnect(engine); |
53 |
|
|
54 |
MidiInputPort* pMidiInputPort = (pEngineChannel) ? pEngineChannel->GetMidiInputPort() : __GetMidiInputDevicePort(GetMidiInputChannel()); |
MidiInputPort* pMidiInputPort = (pEngineChannel) ? pEngineChannel->GetMidiInputPort() : __GetMidiInputDevicePort(GetMidiInputChannel()); |
55 |
if (pMidiInputPort) pMidiInputPort->Disconnect(pEngineChannel); |
if (pMidiInputPort) pMidiInputPort->Disconnect(pEngineChannel); |
56 |
if (pEngineChannel) { |
if (pEngineChannel) { |
57 |
if (pAudioOutputDevice) pEngineChannel->DisconnectAudioOutputDevice(); |
if (pAudioOutputDevice) pEngineChannel->DisconnectAudioOutputDevice(); |
58 |
EngineChannelFactory::Destroy(pEngineChannel); |
EngineChannelFactory::Destroy(pEngineChannel); |
59 |
|
|
60 |
|
// reconnect engine if it still exists |
61 |
|
const std::set<Engine*>& engines = EngineFactory::EngineInstances(); |
62 |
|
if (engines.find(engine) != engines.end()) pAudioOutputDevice->Connect(engine); |
63 |
} |
} |
64 |
} |
} |
65 |
} |
} |
78 |
MidiInputPort* pMidiInputPort = __GetMidiInputDevicePort(GetMidiInputPort()); |
MidiInputPort* pMidiInputPort = __GetMidiInputDevicePort(GetMidiInputPort()); |
79 |
// disconnect old engine channel |
// disconnect old engine channel |
80 |
if (pEngineChannel) { |
if (pEngineChannel) { |
81 |
|
Engine* engine = pEngineChannel->GetEngine(); |
82 |
|
if (pAudioOutputDevice) pAudioOutputDevice->Disconnect(engine); |
83 |
|
|
84 |
if (pMidiInputPort) pMidiInputPort->Disconnect(pEngineChannel); |
if (pMidiInputPort) pMidiInputPort->Disconnect(pEngineChannel); |
85 |
if (pAudioOutputDevice) pEngineChannel->DisconnectAudioOutputDevice(); |
if (pAudioOutputDevice) pEngineChannel->DisconnectAudioOutputDevice(); |
86 |
EngineChannelFactory::Destroy(pEngineChannel); |
EngineChannelFactory::Destroy(pEngineChannel); |
87 |
|
|
88 |
|
// reconnect engine if it still exists |
89 |
|
const std::set<Engine*>& engines = EngineFactory::EngineInstances(); |
90 |
|
if (engines.find(engine) != engines.end()) pAudioOutputDevice->Connect(engine); |
91 |
} |
} |
92 |
|
|
93 |
// connect new engine channel |
// connect new engine channel |
109 |
|
|
110 |
void SamplerChannel::SetAudioOutputDevice(AudioOutputDevice* pDevice) { |
void SamplerChannel::SetAudioOutputDevice(AudioOutputDevice* pDevice) { |
111 |
// disconnect old device |
// disconnect old device |
112 |
if (pAudioOutputDevice && pEngineChannel) pEngineChannel->DisconnectAudioOutputDevice(); |
if (pAudioOutputDevice && pEngineChannel) { |
113 |
|
Engine* engine = pEngineChannel->GetEngine(); |
114 |
|
pAudioOutputDevice->Disconnect(engine); |
115 |
|
|
116 |
|
pEngineChannel->DisconnectAudioOutputDevice(); |
117 |
|
|
118 |
|
// reconnect engine if it still exists |
119 |
|
const std::set<Engine*>& engines = EngineFactory::EngineInstances(); |
120 |
|
if (engines.find(engine) != engines.end()) pAudioOutputDevice->Connect(engine); |
121 |
|
} |
122 |
|
|
123 |
// connect new device |
// connect new device |
124 |
pAudioOutputDevice = pDevice; |
pAudioOutputDevice = pDevice; |
125 |
if (pEngineChannel) { |
if (pEngineChannel) { |
331 |
// disable device |
// disable device |
332 |
pDevice->Stop(); |
pDevice->Stop(); |
333 |
|
|
334 |
|
// remove device from the device list |
335 |
|
mAudioOutputDevices.erase(iter); |
336 |
|
|
337 |
// destroy and free device from memory |
// destroy and free device from memory |
338 |
delete pDevice; |
delete pDevice; |
339 |
|
|
340 |
|
break; |
341 |
} |
} |
342 |
} |
} |
|
// remove devices from the device list |
|
|
mAudioOutputDevices.clear(); |
|
343 |
} |
} |
344 |
|
|
345 |
void Sampler::DestroyMidiInputDevice(MidiInputDevice* pDevice) throw (LinuxSamplerException) { |
void Sampler::DestroyMidiInputDevice(MidiInputDevice* pDevice) throw (LinuxSamplerException) { |
353 |
// disable device |
// disable device |
354 |
pDevice->StopListen(); |
pDevice->StopListen(); |
355 |
|
|
356 |
|
// remove device from the device list |
357 |
|
mMidiInputDevices.erase(iter); |
358 |
|
|
359 |
// destroy and free device from memory |
// destroy and free device from memory |
360 |
delete pDevice; |
delete pDevice; |
361 |
|
|
362 |
|
break; |
363 |
} |
} |
364 |
} |
} |
|
// remove devices from the device list |
|
|
mMidiInputDevices.clear(); |
|
365 |
} |
} |
366 |
|
|
367 |
MidiInputDevice* Sampler::CreateMidiInputDevice(String MidiDriver, std::map<String,String> Parameters) throw (LinuxSamplerException) { |
MidiInputDevice* Sampler::CreateMidiInputDevice(String MidiDriver, std::map<String,String> Parameters) throw (LinuxSamplerException) { |