alsa: Do not buffer more than 500ms.
authorAndre Noll <maan@systemlinux.org>
Wed, 13 Jun 2012 15:53:07 +0000 (17:53 +0200)
committerAndre Noll <maan@systemlinux.org>
Sun, 17 Jun 2012 09:42:04 +0000 (11:42 +0200)
In alsa_init() we set the buffer time to the maximum value supported
by the device. However, on some systems this time is more than 10
seconds, which is much too high.

This patch changes alsa_init() to use a buffer time of at most
0.5 seconds.

alsa_write.c

index a4863a59a5bc3a426a08e6a69d333bded736d780..a211985ab94bb71406d7729793387bbabc5fc452 100644 (file)
@@ -113,6 +113,8 @@ static int alsa_init(struct private_alsa_write_data *pad,
                NULL);
        if (ret < 0 || buffer_time == 0)
                goto fail;
                NULL);
        if (ret < 0 || buffer_time == 0)
                goto fail;
+       /* buffer at most 500 milliseconds */
+       buffer_time = PARA_MIN(buffer_time, 500U * 1000U);
        msg = "could not set buffer time";
        ret = snd_pcm_hw_params_set_buffer_time_near(pad->handle, hwparams,
                &buffer_time, NULL);
        msg = "could not set buffer time";
        ret = snd_pcm_hw_params_set_buffer_time_near(pad->handle, hwparams,
                &buffer_time, NULL);