/[svn]/linuxsampler/trunk/src/drivers/audio/AudioOutputDevice.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/drivers/audio/AudioOutputDevice.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 272 by schoenebeck, Fri Oct 8 21:03:32 2004 UTC revision 1305 by iliev, Mon Aug 27 07:51:28 2007 UTC
# Line 3  Line 3 
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, 2006 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  *
# Line 55  namespace LinuxSampler { Line 56  namespace LinuxSampler {
56          return true;          return true;
57      }      }
58    
59      void AudioOutputDevice::ParameterActive::OnSetValue(bool b) throw (LinuxSamplerException) {      void AudioOutputDevice::ParameterActive::OnSetValue(bool b) throw (Exception) {
60          if (b) ((AudioOutputDevice*)pDevice)->Play();          if (b) ((AudioOutputDevice*)pDevice)->Play();
61          else ((AudioOutputDevice*)pDevice)->Stop();          else ((AudioOutputDevice*)pDevice)->Stop();
62      }      }
# Line 108  namespace LinuxSampler { Line 109  namespace LinuxSampler {
109          return std::vector<int>();          return std::vector<int>();
110      }      }
111    
112      void AudioOutputDevice::ParameterSampleRate::OnSetValue(int i) throw (LinuxSamplerException) {      void AudioOutputDevice::ParameterSampleRate::OnSetValue(int i) throw (Exception) {
113          /* cannot happen, as parameter is fix */          /* cannot happen, as parameter is fix */
114      }      }
115    
# Line 149  namespace LinuxSampler { Line 150  namespace LinuxSampler {
150      }      }
151    
152      optional<int> AudioOutputDevice::ParameterChannels::RangeMinAsInt(std::map<String,String> Parameters) {      optional<int> AudioOutputDevice::ParameterChannels::RangeMinAsInt(std::map<String,String> Parameters) {
153          return optional<int>::nothing;          return 1;
154      }      }
155    
156      optional<int> AudioOutputDevice::ParameterChannels::RangeMaxAsInt(std::map<String,String> Parameters) {      optional<int> AudioOutputDevice::ParameterChannels::RangeMaxAsInt(std::map<String,String> Parameters) {
157          return optional<int>::nothing;          return 100;
158      }      }
159    
160      std::vector<int> AudioOutputDevice::ParameterChannels::PossibilitiesAsInt(std::map<String,String> Parameters) {      std::vector<int> AudioOutputDevice::ParameterChannels::PossibilitiesAsInt(std::map<String,String> Parameters) {
161          return std::vector<int>();          return std::vector<int>();
162      }      }
163    
164      void AudioOutputDevice::ParameterChannels::OnSetValue(int i) throw (LinuxSamplerException) {      void AudioOutputDevice::ParameterChannels::OnSetValue(int i) throw (Exception) {
165          ((AudioOutputDevice*)pDevice)->AcquireChannels(i);          ((AudioOutputDevice*)pDevice)->AcquireChannels(i);
166      }      }
167    
# Line 173  namespace LinuxSampler { Line 174  namespace LinuxSampler {
174  // *************** AudioOutputDevice ***************  // *************** AudioOutputDevice ***************
175  // *  // *
176    
177      AudioOutputDevice::AudioOutputDevice(std::map<String,DeviceCreationParameter*> DriverParameters) {      AudioOutputDevice::AudioOutputDevice(std::map<String,DeviceCreationParameter*> DriverParameters)
178            : EnginesReader(Engines) {
179          this->Parameters = DriverParameters;          this->Parameters = DriverParameters;
180      }      }
181    
# Line 182  namespace LinuxSampler { Line 184  namespace LinuxSampler {
184          {          {
185              std::vector<AudioChannel*>::iterator iter = Channels.begin();              std::vector<AudioChannel*>::iterator iter = Channels.begin();
186              while (iter != Channels.end()) {              while (iter != Channels.end()) {
                 Channels.erase(iter);  
187                  delete *iter;                  delete *iter;
188                  iter++;                  iter++;
189              }              }
190                Channels.clear();
191          }          }
192    
193          // delete all device parameters          // delete all device parameters
194          {          {
195              std::map<String,DeviceCreationParameter*>::iterator iter = Parameters.begin();              std::map<String,DeviceCreationParameter*>::iterator iter = Parameters.begin();
196              while (iter != Parameters.end()) {              while (iter != Parameters.end()) {
                 Parameters.erase(iter);  
197                  delete iter->second;                  delete iter->second;
198                  iter++;                  iter++;
199              }              }
200                Parameters.clear();
201          }          }
202      }      }
203    
204      void AudioOutputDevice::Connect(Engine* pEngine) {      void AudioOutputDevice::Connect(Engine* pEngine) {
205          if (Engines.find(pEngine) == Engines.end()) {          std::set<Engine*>& engines = Engines.GetConfigForUpdate();
206              pEngine->Connect(this);          if (engines.find(pEngine) == engines.end()) {
207              Engines.insert(pEngine);              engines.insert(pEngine);
208                Engines.SwitchConfig().insert(pEngine);
209                // make sure the engine knows about the connection
210                //pEngine->Connect(this);
211          }          }
212      }      }
213    
214      void AudioOutputDevice::Disconnect(Engine* pEngine) {      void AudioOutputDevice::Disconnect(Engine* pEngine) {
215          if (Engines.find(pEngine) != Engines.end()) { // if clause to prevent disconnect loop          std::set<Engine*>& engines = Engines.GetConfigForUpdate();
216              Engines.erase(pEngine);          if (engines.find(pEngine) != engines.end()) { // if clause to prevent disconnect loop
217              pEngine->DisconnectAudioOutputDevice();              engines.erase(pEngine);
218                Engines.SwitchConfig().erase(pEngine);
219                // make sure the engine knows about the disconnection
220                //pEngine->DisconnectAudioOutputDevice();
221          }          }
222      }      }
223    
# Line 226  namespace LinuxSampler { Line 233  namespace LinuxSampler {
233          }          }
234      }      }
235    
236        uint AudioOutputDevice::ChannelCount() {
237            return Channels.size();
238        }
239    
240      std::map<String,DeviceCreationParameter*> AudioOutputDevice::DeviceParameters() {      std::map<String,DeviceCreationParameter*> AudioOutputDevice::DeviceParameters() {
241          return Parameters;          return Parameters;
242      }      }
# Line 244  namespace LinuxSampler { Line 255  namespace LinuxSampler {
255          int result = 0;          int result = 0;
256    
257          // let all connected engines render audio for the current audio fragment cycle          // let all connected engines render audio for the current audio fragment cycle
258          #if USE_EXCEPTIONS          const std::set<Engine*>& engines = EnginesReader.Lock();
259            #if CONFIG_RT_EXCEPTIONS
260          try          try
261          #endif // USE_EXCEPTIONS          #endif // CONFIG_RT_EXCEPTIONS
262          {          {
263              std::set<Engine*>::iterator iterEngine = Engines.begin();              std::set<Engine*>::iterator iterEngine = engines.begin();
264              std::set<Engine*>::iterator end        = Engines.end();              std::set<Engine*>::iterator end        = engines.end();
265              for (; iterEngine != end; iterEngine++) {              for (; iterEngine != end; iterEngine++) {
266                  int res = (*iterEngine)->RenderAudio(Samples);                  int res = (*iterEngine)->RenderAudio(Samples);
267                  if (res != 0) result = res;                  if (res != 0) result = res;
268              }              }
269          }          }
270          #if USE_EXCEPTIONS          #if CONFIG_RT_EXCEPTIONS
271          catch (std::runtime_error se) {          catch (std::runtime_error se) {
272              std::cerr << "std::runtime_error: " << se.what() << std::endl << std::flush;              std::cerr << "std::runtime_error: " << se.what() << std::endl << std::flush;
273              exit(EXIT_FAILURE);              exit(EXIT_FAILURE);
274          }          }
275          #endif // USE_EXCEPTIONS          #endif // CONFIG_RT_EXCEPTIONS
276    
277            EnginesReader.Unlock();
278          return result;          return result;
279      }      }
280    

Legend:
Removed from v.272  
changed lines
  Added in v.1305

  ViewVC Help
Powered by ViewVC