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

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

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

revision 1304 by schoenebeck, Wed Feb 28 06:53:42 2007 UTC revision 1305 by iliev, Mon Aug 27 07:51:28 2007 UTC
# Line 225  namespace LinuxSampler { Line 225  namespace LinuxSampler {
225      }      }
226    
227      optional<int> AudioOutputDeviceAlsa::ParameterChannels::RangeMinAsInt(std::map<String,String> Parameters) {      optional<int> AudioOutputDeviceAlsa::ParameterChannels::RangeMinAsInt(std::map<String,String> Parameters) {
228          if (!Parameters.count("CARD")) return optional<int>::nothing;          uint channels = 1;
229            if (!Parameters.count("CARD")) return channels;
230    
231          // obtain information from given sound card          // obtain information from given sound card
232          ParameterCard card(Parameters["CARD"]);          ParameterCard card(Parameters["CARD"]);
233          String pcm_name = "hw:" + card.ValueAsString();          String pcm_name = "hw:" + card.ValueAsString();
234          snd_pcm_t* pcm_handle = NULL;          snd_pcm_t* pcm_handle = NULL;
235          if (snd_pcm_open(&pcm_handle, pcm_name.c_str(), SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK) < 0) return optional<int>::nothing;          if (snd_pcm_open(&pcm_handle, pcm_name.c_str(), SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK) < 0) return channels;
236          snd_pcm_hw_params_t* hwparams;          snd_pcm_hw_params_t* hwparams;
237          snd_pcm_hw_params_alloca(&hwparams);          snd_pcm_hw_params_alloca(&hwparams);
238          if (snd_pcm_hw_params_any(pcm_handle, hwparams) < 0) {          if (snd_pcm_hw_params_any(pcm_handle, hwparams) < 0) {
239              snd_pcm_close(pcm_handle);              snd_pcm_close(pcm_handle);
240              return optional<int>::nothing;              return channels;
241          }          }
242          uint channels;  
243          if (snd_pcm_hw_params_get_channels_min(hwparams, &channels) < 0) {          if (snd_pcm_hw_params_get_channels_min(hwparams, &channels) < 0) {
244              snd_pcm_close(pcm_handle);              snd_pcm_close(pcm_handle);
245              return optional<int>::nothing;              return channels;
246          }          }
247          snd_pcm_close(pcm_handle);          snd_pcm_close(pcm_handle);
248          return channels;          return channels;
249      }      }
250    
251      optional<int> AudioOutputDeviceAlsa::ParameterChannels::RangeMaxAsInt(std::map<String,String> Parameters) {      optional<int> AudioOutputDeviceAlsa::ParameterChannels::RangeMaxAsInt(std::map<String,String> Parameters) {
252          if (!Parameters.count("CARD")) return optional<int>::nothing;          uint channels = 100;
253            if (!Parameters.count("CARD")) return channels;
254    
255          // obtain information from given sound card          // obtain information from given sound card
256          String pcm_name       = "hw:" + Parameters["CARD"];          String pcm_name       = "hw:" + Parameters["CARD"];
257          snd_pcm_t* pcm_handle = NULL;          snd_pcm_t* pcm_handle = NULL;
258          if (snd_pcm_open(&pcm_handle, pcm_name.c_str(), SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK) < 0) return optional<int>::nothing;          if (snd_pcm_open(&pcm_handle, pcm_name.c_str(), SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK) < 0) return channels;
259          snd_pcm_hw_params_t* hwparams;          snd_pcm_hw_params_t* hwparams;
260          snd_pcm_hw_params_alloca(&hwparams);          snd_pcm_hw_params_alloca(&hwparams);
261          if (snd_pcm_hw_params_any(pcm_handle, hwparams) < 0) {          if (snd_pcm_hw_params_any(pcm_handle, hwparams) < 0) {
262              snd_pcm_close(pcm_handle);              snd_pcm_close(pcm_handle);
263              return optional<int>::nothing;              return channels;
264          }          }
265          uint channels;  
266          if (snd_pcm_hw_params_get_channels_max(hwparams, &channels) < 0) {          if (snd_pcm_hw_params_get_channels_max(hwparams, &channels) < 0) {
267              snd_pcm_close(pcm_handle);              snd_pcm_close(pcm_handle);
268              return optional<int>::nothing;              return channels;
269          }          }
270          snd_pcm_close(pcm_handle);          snd_pcm_close(pcm_handle);
271          return channels;          return channels;
# Line 635  namespace LinuxSampler { Line 637  namespace LinuxSampler {
637          //StopThread();  //FIXME: commented out due to a bug in thread.cpp (StopThread() doesn't return at all)          //StopThread();  //FIXME: commented out due to a bug in thread.cpp (StopThread() doesn't return at all)
638          //dmsg(0,("OK\n"));          //dmsg(0,("OK\n"));
639    
640          //FIXME: currently commented out due to segfault          snd_pcm_close(pcm_handle);
         //snd_pcm_close(pcm_handle);  
641    
642          if (pAlsaOutputBuffer) {          if (pAlsaOutputBuffer) {
643              //FIXME: currently commented out due to segfault              //FIXME: currently commented out due to segfault
# Line 734  namespace LinuxSampler { Line 735  namespace LinuxSampler {
735      }      }
736    
737      String AudioOutputDeviceAlsa::Version() {      String AudioOutputDeviceAlsa::Version() {
738         String s = "$Revision: 1.22 $";         String s = "$Revision: 1.23 $";
739         return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword         return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword
740      }      }
741    

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

  ViewVC Help
Powered by ViewVC