299 |
uint Fragments = ((DeviceCreationParameterInt*)Parameters["FRAGMENTS"])->ValueAsInt(); |
uint Fragments = ((DeviceCreationParameterInt*)Parameters["FRAGMENTS"])->ValueAsInt(); |
300 |
String Card = ((DeviceCreationParameterString*)Parameters["CARD"])->ValueAsString(); |
String Card = ((DeviceCreationParameterString*)Parameters["CARD"])->ValueAsString(); |
301 |
|
|
302 |
dmsg(1,("Checking if hw parameters supported...\n")); |
dmsg(2,("Checking if hw parameters supported...\n")); |
303 |
if (HardwareParametersSupported(Card, uiAlsaChannels, uiSamplerate, Fragments, FragmentSize)) { |
if (HardwareParametersSupported(Card, uiAlsaChannels, uiSamplerate, Fragments, FragmentSize)) { |
304 |
pcm_name = "hw:" + Card; |
pcm_name = "hw:" + Card; |
305 |
} |
} |
306 |
else { |
else { |
307 |
printf("Warning: your soundcard doesn't support chosen hardware parameters; "); |
fprintf(stderr, "Warning: your soundcard doesn't support chosen hardware parameters; "); |
308 |
printf("trying to compensate support lack with plughw..."); |
fprintf(stderr, "trying to compensate support lack with plughw..."); |
309 |
fflush(stdout); |
fflush(stdout); |
310 |
pcm_name = "plughw:" + Card; |
pcm_name = "plughw:" + Card; |
311 |
} |
} |
312 |
dmsg(1,("HW check completed.\n")); |
dmsg(2,("HW check completed.\n")); |
313 |
|
|
314 |
int err; |
int err; |
315 |
|
|
322 |
/* PCM device will return immediately. If SND_PCM_ASYNC is */ |
/* PCM device will return immediately. If SND_PCM_ASYNC is */ |
323 |
/* specified, SIGIO will be emitted whenever a period has */ |
/* specified, SIGIO will be emitted whenever a period has */ |
324 |
/* been completely processed by the soundcard. */ |
/* been completely processed by the soundcard. */ |
325 |
if ((err = snd_pcm_open(&pcm_handle, pcm_name.c_str(), stream, 0)) < 0) { |
if ((err = snd_pcm_open(&pcm_handle, pcm_name.c_str(), stream, SND_PCM_NONBLOCK)) < 0) { |
326 |
throw AudioOutputException(String("Error opening PCM device ") + pcm_name + ": " + snd_strerror(err)); |
throw AudioOutputException(String("Error opening PCM device ") + pcm_name + ": " + snd_strerror(err)); |
327 |
} |
} |
328 |
|
|
435 |
bool AudioOutputDeviceAlsa::HardwareParametersSupported(String card, uint channels, int samplerate, uint numfragments, uint fragmentsize) throw (AudioOutputException) { |
bool AudioOutputDeviceAlsa::HardwareParametersSupported(String card, uint channels, int samplerate, uint numfragments, uint fragmentsize) throw (AudioOutputException) { |
436 |
pcm_name = "hw:" + card; |
pcm_name = "hw:" + card; |
437 |
int err; |
int err; |
438 |
if ((err = snd_pcm_open(&pcm_handle, pcm_name.c_str(), stream, 0)) < 0) { |
if ((err = snd_pcm_open(&pcm_handle, pcm_name.c_str(), stream, SND_PCM_NONBLOCK)) < 0) { |
439 |
throw AudioOutputException(String("Error opening PCM device ") + pcm_name + ": " + snd_strerror(err)); |
throw AudioOutputException(String("Error opening PCM device ") + pcm_name + ": " + snd_strerror(err)); |
440 |
} |
} |
441 |
snd_pcm_hw_params_alloca(&hwparams); |
snd_pcm_hw_params_alloca(&hwparams); |
516 |
} |
} |
517 |
|
|
518 |
String AudioOutputDeviceAlsa::Version() { |
String AudioOutputDeviceAlsa::Version() { |
519 |
String s = "$Revision: 1.18 $"; |
String s = "$Revision: 1.19 $"; |
520 |
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 |
521 |
} |
} |
522 |
|
|