1 |
/*************************************************************************** |
/*************************************************************************** |
2 |
* * |
* * |
3 |
* Copyright (C) 2005, 2006 Christian Schoenebeck * |
* Copyright (C) 2005 - 2012 Christian Schoenebeck * |
4 |
* * |
* * |
5 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
6 |
* 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 * |
89 |
} lockedChannels; |
} lockedChannels; |
90 |
|
|
91 |
Mutex EngineChannelFactory::LockedChannelsMutex; |
Mutex EngineChannelFactory::LockedChannelsMutex; |
92 |
|
Mutex EngineChannelFactory::EngineChannelsMutex; |
93 |
|
|
94 |
void EngineChannelFactory::SetDeleteEnabled(const EngineChannel* pEngineChannel, bool enable) { |
void EngineChannelFactory::SetDeleteEnabled(const EngineChannel* pEngineChannel, bool enable) { |
95 |
LockedChannelsMutex.Lock(); |
LockedChannelsMutex.Lock(); |
109 |
static std::set<LinuxSampler::EngineChannel*> engineChannels; |
static std::set<LinuxSampler::EngineChannel*> engineChannels; |
110 |
|
|
111 |
LinuxSampler::EngineChannel* EngineChannelFactory::Create(String EngineType) throw (Exception) { |
LinuxSampler::EngineChannel* EngineChannelFactory::Create(String EngineType) throw (Exception) { |
112 |
|
LinuxSampler::EngineChannel* pEngineChannel; |
113 |
if (!strcasecmp(EngineType.c_str(),"GigEngine") || !strcasecmp(EngineType.c_str(),"gig")) { |
if (!strcasecmp(EngineType.c_str(),"GigEngine") || !strcasecmp(EngineType.c_str(),"gig")) { |
114 |
LinuxSampler::EngineChannel* pEngineChannel = new gig::EngineChannel; |
pEngineChannel = new gig::EngineChannel; |
|
engineChannels.insert(pEngineChannel); |
|
|
return pEngineChannel; |
|
115 |
} else if (!strcasecmp(EngineType.c_str(),"sf2")) { |
} else if (!strcasecmp(EngineType.c_str(),"sf2")) { |
116 |
#if HAVE_SF2 |
#if HAVE_SF2 |
117 |
LinuxSampler::EngineChannel* pEngineChannel = new sf2::EngineChannel; |
pEngineChannel = new sf2::EngineChannel; |
|
engineChannels.insert(pEngineChannel); |
|
|
return pEngineChannel; |
|
118 |
#else |
#else |
119 |
throw Exception("LinuxSampler is not compiled with SF2 support"); |
throw Exception("LinuxSampler is not compiled with SF2 support"); |
120 |
#endif |
#endif |
121 |
} else if (!strcasecmp(EngineType.c_str(),"sfz")) { |
} else if (!strcasecmp(EngineType.c_str(),"sfz")) { |
122 |
LinuxSampler::EngineChannel* pEngineChannel = new sfz::EngineChannel; |
pEngineChannel = new sfz::EngineChannel; |
123 |
engineChannels.insert(pEngineChannel); |
} else { |
124 |
return pEngineChannel; |
throw Exception("Unknown engine type"); |
125 |
} |
} |
126 |
throw Exception("Unknown engine type"); |
EngineChannelsMutex.Lock(); |
127 |
|
engineChannels.insert(pEngineChannel); |
128 |
|
EngineChannelsMutex.Unlock(); |
129 |
|
return pEngineChannel; |
130 |
} |
} |
131 |
|
|
132 |
void EngineChannelFactory::Destroy(LinuxSampler::EngineChannel* pEngineChannel) { |
void EngineChannelFactory::Destroy(LinuxSampler::EngineChannel* pEngineChannel) { |
133 |
pEngineChannel->RemoveAllFxSendCountListeners(); |
pEngineChannel->RemoveAllFxSendCountListeners(); |
134 |
|
EngineChannelsMutex.Lock(); |
135 |
engineChannels.erase(pEngineChannel); |
engineChannels.erase(pEngineChannel); |
136 |
|
EngineChannelsMutex.Unlock(); |
137 |
|
|
138 |
// Postpone the deletion of the specified EngineChannel if needed (bug #113) |
// Postpone the deletion of the specified EngineChannel if needed (bug #113) |
139 |
LockedChannelsMutex.Lock(); |
LockedChannelsMutex.Lock(); |