alsa: disable rewinds when using ALSA plugins
authorPierre-Louis Bossart <pierre-louis.bossart@intel.com>
Tue, 13 Jul 2010 20:27:40 +0000 (15:27 -0500)
committerColin Guthrie <cguthrie@mandriva.org>
Tue, 13 Jul 2010 21:10:39 +0000 (22:10 +0100)
This is required to when playing on a52: device, rewind is broken
in those plugins.
Credits to Michael Rans <mcarans@yahoo.co.uk> for finding this
workaround, and Tanu Kaskinen <tanuk@iki.fi> for providing
valuable feedback.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@intel.com>
src/modules/alsa/alsa-sink.c

index 2995c3c..2e54dbe 100644 (file)
@@ -953,7 +953,12 @@ static int update_sw_params(struct userdata *u) {
     }
 
     pa_sink_set_max_request_within_thread(u->sink, u->hwbuf_size - u->hwbuf_unused);
-    pa_sink_set_max_rewind_within_thread(u->sink, u->hwbuf_size);
+     if (pa_alsa_pcm_is_hw(u->pcm_handle))
+         pa_sink_set_max_rewind_within_thread(u->sink, u->hwbuf_size);
+    else {
+        pa_log_info("Disabling rewind_within_thread for device %s", u->device_name);
+        pa_sink_set_max_rewind_within_thread(u->sink, 0);
+    }
 
     return 0;
 }
@@ -1906,7 +1911,12 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
                 (double) pa_bytes_to_usec(u->hwbuf_size, &ss) / PA_USEC_PER_MSEC);
 
     pa_sink_set_max_request(u->sink, u->hwbuf_size);
-    pa_sink_set_max_rewind(u->sink, u->hwbuf_size);
+    if (pa_alsa_pcm_is_hw(u->pcm_handle))
+        pa_sink_set_max_rewind(u->sink, u->hwbuf_size);
+    else {
+        pa_log_info("Disabling rewind for device %s", u->device_name);
+        pa_sink_set_max_rewind(u->sink, 0);
+    }
 
     if (u->use_tsched) {
         u->tsched_watermark = pa_usec_to_bytes_round_up(pa_bytes_to_usec_round_up(tsched_watermark, &requested_ss), &u->sink->sample_spec);