[pulseaudio-commits] r1844 - /branches/lennart/src/modules/module-alsa-sink.c
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Mon Sep 17 10:00:51 PDT 2007
Author: lennart
Date: Mon Sep 17 19:00:50 2007
New Revision: 1844
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1844&root=pulseaudio&view=rev
Log:
fall back to plughw: if hw: doesn't work
Modified:
branches/lennart/src/modules/module-alsa-sink.c
Modified: branches/lennart/src/modules/module-alsa-sink.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/module-alsa-sink.c?rev=1844&root=pulseaudio&r1=1843&r2=1844&view=diff
==============================================================================
--- branches/lennart/src/modules/module-alsa-sink.c (original)
+++ branches/lennart/src/modules/module-alsa-sink.c Mon Sep 17 19:00:50 2007
@@ -678,7 +678,7 @@
pa_modargs *ma = NULL;
struct userdata *u = NULL;
- const char *dev;
+ char *dev;
pa_sample_spec ss;
pa_channel_map map;
uint32_t nfrags, frag_size;
@@ -737,24 +737,39 @@
pa_rtpoll_item_new_asyncmsgq(u->rtpoll, PA_RTPOLL_EARLY, u->thread_mq.inq);
snd_config_update_free_global();
- if ((err = snd_pcm_open(&u->pcm_handle, dev = pa_modargs_get_value(ma, "device", DEFAULT_DEVICE), SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)) < 0) {
- pa_log("Error opening PCM device %s: %s", dev, snd_strerror(err));
- goto fail;
- }
-
- u->device_name = pa_xstrdup(dev);
-
- if ((err = snd_pcm_info(u->pcm_handle, pcm_info)) < 0) {
- pa_log("Error fetching PCM info: %s", snd_strerror(err));
- goto fail;
- }
-
- b = use_mmap;
- if ((err = pa_alsa_set_hw_params(u->pcm_handle, &ss, &nfrags, &period_size, &b)) < 0) {
- pa_log("Failed to set hardware parameters: %s", snd_strerror(err));
- goto fail;
- }
-
+
+ dev = pa_xstrdup(pa_modargs_get_value(ma, "device", DEFAULT_DEVICE));
+
+ for (;;) {
+
+ if ((err = snd_pcm_open(&u->pcm_handle, dev, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)) < 0) {
+ pa_log("Error opening PCM device %s: %s", dev, snd_strerror(err));
+ pa_xfree(dev);
+ goto fail;
+ }
+
+ b = use_mmap;
+ if ((err = pa_alsa_set_hw_params(u->pcm_handle, &ss, &nfrags, &period_size, &b)) < 0) {
+
+ if (err == -EPERM) {
+ /* Hmm, some hw is very exotic, so we retry with plughw, if hw didn't work */
+
+ if (pa_startswith(dev, "hw:")) {
+ char *d = pa_sprintf_malloc("plughw:%s", dev+3);
+ pa_xfree(dev);
+ dev = d;
+ continue;
+ }
+ }
+
+ pa_log("Failed to set hardware parameters: %s", snd_strerror(err));
+ pa_xfree(dev);
+ goto fail;
+ }
+
+ break;
+ }
+
if (use_mmap && !b) {
pa_log_info("Device doesn't support mmap(), falling back to UNIX read/write mode.");
u->use_mmap = use_mmap = b;
@@ -763,6 +778,13 @@
if (u->use_mmap)
pa_log_info("Successfully enabled mmap() mode.");
+ if ((err = snd_pcm_info(u->pcm_handle, pcm_info)) < 0) {
+ pa_log("Error fetching PCM info: %s", snd_strerror(err));
+ goto fail;
+ }
+
+ u->device_name = dev;
+
if ((err = pa_alsa_set_sw_params(u->pcm_handle)) < 0) {
pa_log("Failed to set software parameters: %s", snd_strerror(err));
goto fail;
More information about the pulseaudio-commits
mailing list