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) { |