250 |
|
|
251 |
optional<int> AudioOutputDeviceAlsa::ParameterChannels::RangeMaxAsInt(std::map<String,String> Parameters) { |
optional<int> AudioOutputDeviceAlsa::ParameterChannels::RangeMaxAsInt(std::map<String,String> Parameters) { |
252 |
uint channels = 100; |
uint channels = 100; |
253 |
if (!Parameters.count("CARD")) return channels; |
if (!Parameters.count("CARD")) return optional<int>::nothing; |
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 channels; |
if (snd_pcm_open(&pcm_handle, pcm_name.c_str(), SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK) < 0) |
259 |
|
return optional<int>::nothing; |
260 |
snd_pcm_hw_params_t* hwparams; |
snd_pcm_hw_params_t* hwparams; |
261 |
snd_pcm_hw_params_alloca(&hwparams); |
snd_pcm_hw_params_alloca(&hwparams); |
262 |
if (snd_pcm_hw_params_any(pcm_handle, hwparams) < 0) { |
if (snd_pcm_hw_params_any(pcm_handle, hwparams) < 0) { |
263 |
snd_pcm_close(pcm_handle); |
snd_pcm_close(pcm_handle); |
264 |
return channels; |
return optional<int>::nothing; |
265 |
} |
} |
266 |
|
|
267 |
if (snd_pcm_hw_params_get_channels_max(hwparams, &channels) < 0) { |
if (snd_pcm_hw_params_get_channels_max(hwparams, &channels) < 0) { |
268 |
snd_pcm_close(pcm_handle); |
snd_pcm_close(pcm_handle); |
269 |
return channels; |
return optional<int>::nothing; |
270 |
} |
} |
271 |
snd_pcm_close(pcm_handle); |
snd_pcm_close(pcm_handle); |
272 |
return channels; |
return channels; |
736 |
} |
} |
737 |
|
|
738 |
String AudioOutputDeviceAlsa::Version() { |
String AudioOutputDeviceAlsa::Version() { |
739 |
String s = "$Revision: 1.24 $"; |
String s = "$Revision: 1.25 $"; |
740 |
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 |
741 |
} |
} |
742 |
|
|