3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
|
* Copyright (C) 2005 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
9 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
183 |
{ |
{ |
184 |
std::vector<AudioChannel*>::iterator iter = Channels.begin(); |
std::vector<AudioChannel*>::iterator iter = Channels.begin(); |
185 |
while (iter != Channels.end()) { |
while (iter != Channels.end()) { |
|
Channels.erase(iter); |
|
186 |
delete *iter; |
delete *iter; |
187 |
iter++; |
iter++; |
188 |
} |
} |
189 |
|
Channels.clear(); |
190 |
} |
} |
191 |
|
|
192 |
// delete all device parameters |
// delete all device parameters |
193 |
{ |
{ |
194 |
std::map<String,DeviceCreationParameter*>::iterator iter = Parameters.begin(); |
std::map<String,DeviceCreationParameter*>::iterator iter = Parameters.begin(); |
195 |
while (iter != Parameters.end()) { |
while (iter != Parameters.end()) { |
|
Parameters.erase(iter); |
|
196 |
delete iter->second; |
delete iter->second; |
197 |
iter++; |
iter++; |
198 |
} |
} |
199 |
|
Parameters.clear(); |
200 |
} |
} |
201 |
} |
} |
202 |
|
|
203 |
void AudioOutputDevice::Connect(Engine* pEngine) { |
void AudioOutputDevice::Connect(Engine* pEngine) { |
204 |
if (Engines.find(pEngine) == Engines.end()) { |
if (Engines.find(pEngine) == Engines.end()) { |
|
pEngine->Connect(this); |
|
205 |
Engines.insert(pEngine); |
Engines.insert(pEngine); |
206 |
|
// make sure the engine knows about the connection |
207 |
|
//pEngine->Connect(this); |
208 |
} |
} |
209 |
} |
} |
210 |
|
|
211 |
void AudioOutputDevice::Disconnect(Engine* pEngine) { |
void AudioOutputDevice::Disconnect(Engine* pEngine) { |
212 |
if (Engines.find(pEngine) != Engines.end()) { // if clause to prevent disconnect loop |
if (Engines.find(pEngine) != Engines.end()) { // if clause to prevent disconnect loop |
213 |
Engines.erase(pEngine); |
Engines.erase(pEngine); |
214 |
pEngine->DisconnectAudioOutputDevice(); |
// make sure the engine knows about the disconnection |
215 |
|
//pEngine->DisconnectAudioOutputDevice(); |
216 |
} |
} |
217 |
} |
} |
218 |
|
|
246 |
int result = 0; |
int result = 0; |
247 |
|
|
248 |
// let all connected engines render audio for the current audio fragment cycle |
// let all connected engines render audio for the current audio fragment cycle |
249 |
|
#if CONFIG_RT_EXCEPTIONS |
250 |
|
try |
251 |
|
#endif // CONFIG_RT_EXCEPTIONS |
252 |
{ |
{ |
253 |
std::set<Engine*>::iterator iterEngine = Engines.begin(); |
std::set<Engine*>::iterator iterEngine = Engines.begin(); |
254 |
std::set<Engine*>::iterator end = Engines.end(); |
std::set<Engine*>::iterator end = Engines.end(); |
257 |
if (res != 0) result = res; |
if (res != 0) result = res; |
258 |
} |
} |
259 |
} |
} |
260 |
|
#if CONFIG_RT_EXCEPTIONS |
261 |
|
catch (std::runtime_error se) { |
262 |
|
std::cerr << "std::runtime_error: " << se.what() << std::endl << std::flush; |
263 |
|
exit(EXIT_FAILURE); |
264 |
|
} |
265 |
|
#endif // CONFIG_RT_EXCEPTIONS |
266 |
|
|
267 |
return result; |
return result; |
268 |
} |
} |