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; |
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 |
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 |
|
|